var ajax; ajax = new AjaxRequest();

var permlink = window.location.href;

function setPermlink (newperm){
	permlink = newperm;
	if(document.getElementById){
		var perma = document.getElementById('permlink');
		if(perma != null){
			perma.href = permlink;
		}
	}
}

function addToPermlink(appendix){
		var re = new RegExp(/\?/);
		if(permlink.match(re)){//we have a ?
			permlink += '&' + appendix;
		}
		else{
			permlink = 'index.php?' + appendix;
		}
		setPermlink(permlink);
}

function goToPermlink(){
	window.location = permlink;
}

	function updatelang(){//change the langugage of the session
		addToPermlink('lang=' + this.options[this.selectedIndex].value);
		goToPermlink();
	}



function getContent(e){
	prevent(e);
	var arr = new Array('id', this.params[0]);//id=1
	setPermlink('index.php?id=' + this.params[0]);
	if(document.getElementById){
		ajax.start('content.php', arr, updateContent, 'body_text');//hostfunct, params, callback_func, loader_obj
		var arrB = new Array('banner', this.params[0]);//id=1
		var newAja = new AjaxRequest();
		newAja.start('content.php', arrB, updateBanner, 'banner');//hostfunct, params, callback_func, loader_obj
	}
	else{//dann hat ajax sowieso keinen sinn.
		goToPermlink();
	}
}

function updateContent(req){
	if(document.getElementById){		var ele = document.getElementById('body_text');		try{
			ele.innerHTML = req.responseText;
			traverseTags(ele);
		}
		catch(Error){
			goToPermlink();
		}	}	else{		goToPermlink();	}
}

function updateBanner(req){
	if(document.getElementById){		var ele = document.getElementById('banner');		try{
			ele.innerHTML = req.responseText;
			//traverseTags(ele);
		}
		catch(Error){
			goToPermlink();
		}	}	else{		goToPermlink();	}
}
