
// Function to preload images  - the buttons for the onmouseover effect 

function preloadButtons(){

	imgIDs   = new Array("imgNea",      "imgDrast",               "imgEkdoseis",      "imgSemin",          "imgGallery",      "imgLinks",      "imgFiloi",      "imgHome",         "imgForum",         "imgSyllogos",      "imgContact");
	imgPlain = new Array("nea.gif",     "drastiriotites.gif",     "ekdoseis.gif",     "seminaria.gif",     "gallery.gif",     "links.gif",     "filoi.gif",     "home_02.gif",     "forum_02.gif",     "sillogos.gif",     "contact.gif");
	imgOver  = new Array("nea_over.gif","drastiriotites_over.gif","ekdoseis_over.gif","seminaria_over.gif","gallery_over.gif","links_over.gif","filoi_over.gif","home_over_02.gif","forum_over_02.gif","sillogos_over.gif","contact_over.gif");

	for(i=0; i<imgIDs.length; i++){
		preloadOneButton(imgIDs[i],imgPlain[i],imgOver[i]);
	}
	
}


function preloadOneButton(imgid,imgplain,imgover){

	//alert('called with:'+imgid+imgplain+imgover);
	z = document.getElementById(imgid);
	z.src = "../media/siteimages/" + imgover;
	z.src = "../media/siteimages/" + imgplain;
}


// For the onmouseover and onmouseout events of the section buttons ('ekdoseis', klp)
function changeImage(thisImg,file,state){
	//	out = document.getElementById('mainLayer');
	//	out.innerHTML = out.innerHTML+'<br>--changeImage function called, with:'+thisImg+', '+ file +', '+state;

	z = document.getElementById(thisImg);
	z.src=file;
	z.state = state; // state is a custom property field that follows the 'onmouseover' / 'onmouseout' state of the button
}

// Debugging routine, not used right now.
function report(message){
	//z = document.getElementById('mainLayer');
	//z.innerHTML = z.innerHTML+ '<Br>'+message;
}


// Function to show or hide a section's sub menu
function subMenu(thisSubBox,onoff){
	//out = document.getElementById('mainLayer');
	//out.innerHTML = out.innerHTML+'<br>--subMenu function called, with:'+thisSubBox+', '+ onoff ;
	
	// Watch out, this custom keepOrKill property is set to avoid hiding the submenu when we still want it
	thisSection = document.getElementById(thisSubBox)
	if ( (thisSection.keepOrKill == 'keep') && (onoff == "none") ){
		return;
	}
	thisSection.style.display = onoff;
}

// This sets the keepOrKill custom property to make sure the submenu doesn't disappear when mouse moves from the submenu back to the
// section button.
function keepMe(thisSubBox){
	//out = document.getElementById('mainLayer');
	//out.innerHTML = out.innerHTML+'<br>--keepMe function called, with:'+thisSubBox;
	thisSection = document.getElementById(thisSubBox)
	thisSection.keepOrKill = 'keep';
	//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;'+thisSubBox+' status now:'+thisSection.keepOrKill ;
}

// This checks whether a submenu is to be hidden or not (it may be 'protected' by the custom 'lStatus' property of a link element),
// and if we must, hide it.
function killMe(thisSubBox,thisImg){
	//out = document.getElementById('mainLayer');
	//out.innerHTML = out.innerHTML+'<br>--killMe function called, with:'+thisSubBox+', '+thisImg;

	thisSection = document.getElementById(thisSubBox);
	//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;persistance (link) status of section is: ['+thisSection.lStatus+']';
	if (thisSection.lStatus == "linkActive"){
		//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;hey, active link! dont kill!!!';
		return;
	}	
	thisSection.keepOrKill = '';
	//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;now unset (will be killed first chance). Check:<br>';
	sectionButton = document.getElementById(thisImg);
	if (sectionButton.state == 'off'){
		//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;its button off! Killing it...';
		thisSection.style.display = 'none';
	}else{
		//out.innerHTML = out.innerHTML+'<br>&nbsp;&nbsp;its button on! Spare it...';
	}
}

// This function sets the 'lStatus' custom property of a link element (item of a submenu). At the moment, it's either 'linkActive'
// (a value that 'protects' the submenu from becoming accidentally hidden), or nothing (so the submenu is candidate for hiding).
// The 'p' in the name 'pStatus' stands for 'persistance', because we in a way help the element persist (stay visible in attempts
// to hide it).
function pStatus(thisSubBox,newStatus){
	thisSection = document.getElementById(thisSubBox);
	thisSection.lStatus = newStatus;

	//out = document.getElementById('mainLayer');
	//out.innerHTML = out.innerHTML+'<br>--pStatus function here, just set:'+thisSubBox+' status to ['+newStatus+']';

}

// Classic popupup opener function
function openWindow(theUrl,theName,theOptions){
	//alert('1:'+theUrl+', 2:'+theName+', 3:'+theOptions);
	window.open(theUrl,theName,theOptions);
	return false;
}



