/* calendar.js

*/
var DetailTarget = "";
var origclass;
function hover(divname) {
    if (document.all && document.getElementById) {
       thisdiv = document.getElementById(divname);
		currentname = thisdiv.className;
		origclass=currentname;
        thisdiv.className=currentname+"_over";
		if(origclass=="eventbox_over") {
			origclass = "eventbox";
			//alert("hover: "+origclass);
		}
    }
}

function clearhover(divname) {
    if (document.all && document.getElementById) {
		thisdiv = document.getElementById(divname);
		//thisdiv.className=thisdiv.className.replace("_over","");
		thisdiv.className=origclass;
		
	}
 
}

function loadcontentdetail(contentID) {
	//alert ("load: "+DetailTarget + " " + contentID);			
	var thistarget = "evb_"+contentID;
	var targetcontent = "ev_"+contentID;
	DetailTarget = targetcontent;
	//clearcontentdiv(contentID);
	//updatetitle("evb_"+contentID,"Click for details...");

	xmlDoc = "";
	//alert("loadcontentdetail: "+contentID);
	//alert ("load: "+DetailTarget);	

	//eval(DetailTarget+".innerHTML = \"<p>It works!</p>\"");
	filldiv("both",targetcontent,contentID);
	updateclickfunction(contentID,"open");
}

function clearcall () {
	contentID = this.id.substr(4);
	clearcontentdiv(contentID);return true;
}
function loadcall () {
	contentID = this.id.substr(4);
	loadcontentdetail(contentID);return true;
}

function updateclickfunction(contentID,whichway) {
	whichtarget = "evb_"+contentID;
	//alert("updateclick: "+contentID);
	var targetdiv = document.getElementById(whichtarget);
	if(!targetdiv) {
		alert("error: updateclickfunction - "+whichtarget+" not found.");
		return;
	}
	if(whichway == "open") {
		//targetdiv.onclick = "alert('clicked');clearcontentdetail('"+contentID+"');return true;";
		targetdiv.onclick = clearcall;

		//alert("updateclickfunction: "+targetdiv.id+" targetdiv.onclick="+targetdiv.onclick);
		updatetitle(whichtarget,"Click to close...");
		return;
	}
	if(whichway == "close") {
		//targetdiv.onclick = "javascript:loadcontentdetail('"+contentID+"');return true;"
		targetdiv.onclick = loadcall;

		updatetitle(whichtarget,"Click to open...");

		return;	
	}
	
}

function updatetitle(whichtarget,whichcontent) {

	var contentdiv = document.getElementById(whichtarget);
	if(contentdiv) {
		contentdiv.title = whichcontent;
	}

}

function clearcontentdiv(contentID) {
	var thistarget = "evb_"+contentID;
	var targetcontent = "ev_"+contentID;	
	//alert ("clear: "+DetailTarget);	
	//alert ("clearcontentdiv: "+contentID);
	var contentdiv = document.getElementById(targetcontent);
	if(contentdiv) {
		contentdiv.innerHTML = "";
	}
	updateclickfunction(contentID,"close");
}
function opendetailwindow(myurl,windowname) {
	//alert("opendetailwindow("+myurl+","+windowname+")");
	window.open(myurl,windowname,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=600");
}
