/*
 * Derek Clayton
 *   www.DerekClayton.com
 * September 2009
 * (c) Copyright Derek Clayton 2008-2010
 * asapCMS Copyright 2008-2010 Derek Clayton and DerekClayton.com, All rights Reserved.
 * Use of this code, in whole or in part, is expressly forbidden without the prior written permission of DerekClayton.com.
 */
// ------------------------
//Detect if the user is using IE on Windows.
//var isIE=0;
//if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) { isIE=1; }

function findObj( obj ) {
	var theObj = "";
	if ( document.getElementById ) {
		theObj = document.getElementById( obj );
	} else if ( document.layers ) {
		theObj = document.layers[ obj ];
	} else if ( document.all ) {
		theObj = document.all.item( obj );
	}
	return theObj;
}

function findLeft( obj ) {
	var curLeft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curLeft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curLeft += obj.x;
	}
	return curLeft;// - 160;
}

function findTop( obj ) {
	var curTop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
		 	curTop += obj.offsetTop;
		 	obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curTop += obj.y;
	}
	return curTop; // - 190;
}

function hideDates( ) {
	thePopUp = findObj( "popup" );
	thePopUp.innerHTML = "";
	if ( ! thePopUp.style ) {
		thePopUp.visibility = "hidden";
		thePopUp.top = "-10px";
		thePopUp.left = "-10px";
	} else {
		thePopUp.style.visibility = "hidden";
		thePopUp.style.top = "-10px";
		thePopUp.style.left = "-10px";
	}
}

function showDates( vardate, varhours, varid, vartext ) {
	var theCall = "";
	var cellOffset = Math.round(cellWidth/5*4);
	theCall = findObj( varid );
	var thePopUp = "";
	thePopUp = findObj( "popup" );
	theText = "<b>" + vardate + "</b><br/>";
	if (vartext!="") { theText = theText + "<div class='calholiday'>"+ vartext +"</div>"; }
	theText = theText + varhours;
	thePopUp.innerHTML = theText;
	if ( !thePopUp.style ) {
		thePopUp.visibility = "visible";
		thePopUp.top = findTop(theCall) + cellOffset + "px";
		thePopUp.left = FindLeft(theCall) + cellOffset + "px";
	} else {
		thePopUp.style.visibility = "visible";
		thePopUp.style.top = findTop(theCall) + cellOffset + "px";
		thePopUp.style.left = findLeft(theCall) + cellOffset + "px";
	}
}

function showHide(id) {
	var currentState = document.getElementById(id).style.visibility;
	if (currentState=="visible") {
		document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.visibility = "visible";
		document.getElementById(id).style.display = "block";
	}
}