//***************************************
//
//  DHTML and JavaScript Functions
//  Jonathan Naumann
//  Toenda Software Company
//  toendaCMS
//  Version: 0.0.8
//
//


/************************************************
*
* JAVASCRIPT CLASSES
*
* - show(id, top, left)             -> show box on place top and left
* - show_easy(id)                   -> show box without setting place
* - hide(id)                        -> hide menu (little box)
*
* - wxlBgCol(id, farbe)             -> change bgcolor of id if mouse over
*
* - save()                          -> send first form on page
* - save_id(id)                     -> send form by id
* - accept(id)                      -> accept an form by id
* - checkinputs()                   -> check inputs of an form
* - submitXML(id, action, newvalue) -> change value of "action" to "newvalue", then submit "id"
*
* - win_open(img, param)            -> opens an window with image or other inside
*
* - setImage(img, id)			    -> accept image for openers ID field
*
* - showImage()                     -> random images   ---> TODO: take images as function parameter
*
*/



//***************************************
// SHOW MENU
//***************************************
function show(id, top, left){
	document.getElementById(id).style.visibility='visible';
	document.getElementById(id).style.top=top;
	document.getElementById(id).style.left=left;
}
function show_easy(id){
	document.getElementById(id).style.visibility='visible';
}

function hide(id){
	document.getElementById(id).style.visibility='hidden';
}










//***************************************
// Backgroundcolor Changer
//***************************************

function wxlBgCol(id,farbe) {
	if (document.all){
		document.all[id].style.backgroundColor=farbe;
	}
	else{
		if (document.getElementById){
			document.getElementById(id).style.backgroundColor=farbe;
		}
		else{
			if (document.layers){
				document.layers[id].bgColor=farbe;
			}
		}
	}
}










//***************************************
// SAVE FORM VALUE
//***************************************
function save(){
	document.forms[0].submit();
}

function save_id(id){
	//document.forms[id].submit();
	document.getElementById(id).submit();
}

function accept(id){
	document.getElementById(id).submit();
}

function checkinputs(){
	sendOK = true;
	
	if (sendOK) { document.forms[0].submit(); }
}

function submitXML(id, action, newvalue){
	document.getElementById(action).value = newvalue;
	document.getElementById(id).submit();
}














//***************************************
// OPEN WINDOW FOR IMAGES
//***************************************
function win_open(img, param){
	var path;
	
	if(param == 'media'){ path = '../../data/images/upload/'; }
	else{ path = ''; }
	
	win = window.open(path+img, 'Window', 'width=600,height=400,scrollbars=1,resizable=1');
	if(win != null){
		if(win.opener == null){
			mpic.opener = self;
		}
		/*win.location.href = img;*/
	}
}














/*************************************
* ACCEPT IMAGE TO CONTENT
*/
function setImage(img, id){
	window.opener.document.getElementById(id).value = window.opener.document.getElementById(id).value + '{tcms_img_upload/' + img + '_end}';
	self.close();
}














//***************************************
// ROTATE IMAGES
//***************************************
function showImage(){
	var theImages = new Array();
	
	theImages[0] = 'theme/main/img/rotate/logo1.gif';
	theImages[1] = 'theme/main/img/rotate/logo2.gif';
	theImages[2] = 'theme/main/img/rotate/logo3.gif';
	theImages[3] = 'theme/main/img/rotate/logo4.gif';
	theImages[4] = 'theme/main/img/rotate/logo5.gif';
	theImages[5] = 'theme/main/img/rotate/logo6.gif';
	
	var j = 0
	var p = theImages.length;
	var preBuffer = new Array()
	for (i = 0; i < p; i++){
		preBuffer[i] = new Image()
		preBuffer[i].src = theImages[i]
	}
	
	var whichImage = Math.round(Math.random()*(p-1));
	function showImage2(){
		document.write('<img border="0" width="112" height="111" alt="Top Banner" src="'+theImages[whichImage]+'">');
	}
}

