function $(id) { return document.getElementById(id); }

window.onload = function()
{
	if(document.getElementById('content')){
		var oFCKeditor = new FCKeditor( 'content' ) ;
		//oFCKeditor.Config["CustomConfigurationsPath"] = "../myconfig.js";
		oFCKeditor.ToolbarSet = 'Content' ;
		oFCKeditor.BasePath = "fckeditor/" ;
		oFCKeditor.Height = '512' ;
		oFCKeditor.Width = '675' ; 
		oFCKeditor.ReplaceTextarea() ;
	}
	if(document.getElementById('header')){
		var oFCKeditor = new FCKeditor( 'header' ) ;
		oFCKeditor.ToolbarSet = 'Basic' ;
		oFCKeditor.BasePath = "fckeditor/" ;
		oFCKeditor.Height = '180' ; 
		oFCKeditor.Width = '675' ; 
		oFCKeditor.ReplaceTextarea() ;
	}
	if(document.getElementById('notice')){
		var oFCKeditor = new FCKeditor( 'notice' ) ;
		oFCKeditor.ToolbarSet = 'Basic' ;
		oFCKeditor.BasePath = "fckeditor/" ;
		oFCKeditor.Width = '675' ; 
		oFCKeditor.Height = '128' ; 
		oFCKeditor.ReplaceTextarea() ;
	}
	if(document.getElementById('impressum')){
		var oFCKeditor = new FCKeditor( 'impressum' ) ;
		oFCKeditor.ToolbarSet = 'Basic' ;
		oFCKeditor.BasePath = "fckeditor/" ;
		oFCKeditor.Width = '675' ; 
		oFCKeditor.Height = '200' ; 
		oFCKeditor.ReplaceTextarea() ;
	}
}

function update_position() {
	var nrOfItems = document.getElementById('changedPosition').title;
	var changedPositionValue = "";
	for(var i = 1; i < nrOfItems; i++){
		var item = document.getElementById('item_'+i);
		var position = parseInt( item.parentNode.getAttribute('position') );
		var oldposition = parseInt(item.getAttribute('position'));
		if(position != oldposition){
			changedPositionValue += (item.getAttribute("theid") + "x" + position + "_");
		}
	}
	
	document.getElementById("changedPosition").value = changedPositionValue;
}

function moveup(item){
	var id = item.parentNode.getAttribute("id").replace(/line_/,"");
	if(id > 1)
		move(item,'up');
}

function movedown(item){
	var nrOfItems = parseInt( document.getElementById('changedPosition').title );
	var id = parseInt( item.parentNode.getAttribute("id").replace(/line_/,"") );
	if(id < nrOfItems-1)
		move(item,'down');
}

function move(item,mode){
	var line = item.parentNode;
	var fixedid = parseInt( line.getAttribute("id").replace(/line_/,"") );
	mode = mode == 'up' ? (--fixedid) : (++fixedid);//up or down
	var targetLine = document.getElementById('line_' + mode);
	var temp;
	
	/*temp = line.title;
	line.title = targetLine.title;
	targetLine.title = temp;*/
	
	temp = line.innerHTML;
	line.innerHTML = targetLine.innerHTML;
	targetLine.innerHTML = temp;
	update_position();
}

function selectField(field) {
    field.focus();
    field.select();
}

function del(url){
	var del = window.confirm('Wollen Sie wirklich diesen Eintrag löschen?');
	if(del)
		window.location = url;
	else
		return;
}

function showcategory(id){
	document.getElementById('submenu').innerHTML = document.getElementById("cat_"+id).innerHTML;
}

function showvietinfo(){
	document.getElementById('submenu').innerHTML = document.getElementById("vietinfo").innerHTML;
}
