	var oDetailsWindow = null;
	var oEditEventWindow = null;
	var oPrintWindow = null;
	var oExportWindow = null;
	function openPrint() 
    {	
		winleft = (screen.width - 500) / 2; wintop = (screen.height - 500) / 2; 
		oPrintWindow = window.open('PrintCalendar.aspx', '', 'resizable=yes,scrollbars=yes');
		return false;
    }
    function openExport()
    {	
		window.location.href = 'ExportEvents.aspx';
		return;
    }
    
     function openSearch()
    {	
		window.location.href = 'Search.aspx';
		return;
    }
    
     function goBack(Num) 
    {	
		window.history.go(Num);
		return false;
    }
	function openEventDetails(pathtoroot, data) 
    {	
		winleft = (screen.width - 500) / 2; wintop = (screen.height - 500) / 2; 
		oDetailsWindow = window.open(pathtoroot + 'EventDetails.aspx?' + data, '', 'resizable=yes,scrollbars=yes,width=500,height=500,top=' + wintop + ',left=' + winleft );
		return false;
    }
    
    function openEditEvent(pathtoroot, data) 
    { 
		winleft = (screen.width - 500) / 2; wintop = (screen.height - 500) / 2; 
		oDetailsWindow = window.open(pathtoroot + 'AddEvent.aspx?' + data, '', 'resizable=yes,scrollbars=yes,width=800,height=600,top=' + wintop + ',left=' + winleft );
		return false;
	}
    
    function openEditSpecialEvent(pathtoroot, data) 
    { 
		winleft = (screen.width - 500) / 2; wintop = (screen.height - 500) / 2; 
		oEditEventWindow = window.open(pathtoroot + 'CalendarManagement.aspx?' + data, '', 'resizable=yes,scrollbars=yes,width=800,height=600,top=' + wintop + ',left=' + winleft );
		return false;
    }
    
    var oHelpItemWindow = null;
	function openHelpTextWindow(pathToRoot, h, t, p, l)
	{
		oHelpItemWindow = window.open(pathToRoot + 'EditHelpText.aspx?h=' + h + '&t=' + t + '&p=' + p + '&l=' + l , 'HelpWindow',  'resizable=yes,scrollbars=yes,width=700,height=700');	
		oHelpItemWindow.focus();
	}
	
	var oReminderWindow = null;
	function OpenReminderWindow(pathToRoot, data)
	{	
		winleft = (screen.width - 400) / 2; wintop = (screen.height - 400) / 2; 
		oReminderWindow = window.open(pathToRoot + 'EventReminder.aspx?' + data, 'ReminderWindow',  'resizable=yes,scrollbars=yes,width=420,height=155,top=' + wintop + ',left=' + winleft );	
		oReminderWindow.focus();
	}
	
	var oLargeImageWindow = null;
	function OpenImageWindow(eventid)
	{	
		winleft = (screen.width - 400) / 2; wintop = (screen.height - 400) / 2; 
		oLargeImageWindow = window.open('ShowImage.aspx?L=1&EID=' + eventid, 'ImageWindow',  'resizable=yes,scrollbars=yes,width=400,height=400,top=' + wintop + ',left=' + winleft );	
		oLargeImageWindow.focus();
	}
	function cascadedstyle(el, cssproperty, csspropertyNS){
		if (el.currentStyle)
		return el.currentStyle[cssproperty]
		else if (window.getComputedStyle){
		var elstyle=window.getComputedStyle(el, "")
		return convertRGB(elstyle.getPropertyValue(csspropertyNS))
		}
		return "";
	}

	function setTabBGColor() {
		var Primary=document.getElementById("PrimaryBgColor");
		var Secondary=document.getElementById("SecondaryBgColor");
		document.getElementById("ucCalendarTabs_hdnPrimaryBGColor").value = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_hdnSecondaryBGColor").value = cascadedstyle(Secondary,"backgroundColor", "background-color");
		
		
		document.getElementById("ucCalendarTabs_tdDay").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_tdWeek").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_tdMonth").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_tdYear").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_rightedge1").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_rightedge2").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_rightedge3").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("ucCalendarTabs_rightedge4").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
	} 
	function hightab(what,e,edge){
		if (document.getElementById){ 
		var sPrimaryBGColor = document.getElementById("ucCalendarTabs_hdnPrimaryBGColor").value;
		var sSecondaryBGColor = document.getElementById("ucCalendarTabs_hdnSecondaryBGColor").value;
		
		color=(e.type.toLowerCase()=="mouseover")? sSecondaryBGColor : sPrimaryBGColor 
		what.bgColor=document.getElementById("ucCalendarTabs_rightedge"+edge).bgColor=color
		}
	}
	
	function setTabBGColorForSubmit() {
		var Primary=document.getElementById("PrimaryBgColor");
		var Secondary=document.getElementById("SecondaryBgColor");
		document.getElementById("hdnPrimaryBGColor").value = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("hdnSecondaryBGColor").value = cascadedstyle(Secondary,"backgroundColor", "background-color");
		
		
		document.getElementById("tdCustom").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("tdEmails").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("rightedge1").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
		document.getElementById("rightedge2").bgColor = cascadedstyle(Primary,"backgroundColor", "background-color");
	} 
	
	function ChangeTab(Type) {
		
		if (document.getElementById){ 
			var Primary = document.getElementById("hdnPrimaryBGColor").value;
			var Secondary = document.getElementById("hdnSecondaryBGColor").value;
			var PrimaryFont = document.getElementById("hdnPrimaryFontColor").value;
			var SecondaryFont = document.getElementById("hdnSecondaryFontColor").value;
			
			if(Type == 1) {
					document.getElementById("tdCustom").style.backgroundColor= Secondary;
					document.getElementById("rightedge1").style.backgroundColor= Secondary;
					document.getElementById("lkbtnCustom").style.color = SecondaryFont;
					
					document.getElementById("tdEmails").style.backgroundColor= Primary;
					document.getElementById("rightedge2").style.backgroundColor= Primary;
					document.getElementById("lkbtnEmails").style.color = PrimaryFont;
					
					document.getElementById("divCustom").style.display = 'inline';
					document.getElementById("divEmails").style.display = 'none';
			} else { 
					document.getElementById("tdCustom").style.backgroundColor = Primary;
					document.getElementById("rightedge1").style.backgroundColor = Primary;
					document.getElementById("lkbtnEmails").style.color = SecondaryFont;
					
					document.getElementById("tdEmails").style.backgroundColor = Secondary;
					document.getElementById("rightedge2").style.backgroundColor = Secondary;
					document.getElementById("lkbtnCustom").style.color = PrimaryFont;
					
					document.getElementById("divCustom").style.display = 'none';
					document.getElementById("divEmails").style.display = 'inline';
					
					
				}
			return false;
		} 
	} 
	
	function convertRGB(z)
	{
	var newfcS = "", splitter = "";
	splitter = z.split(",");
	splitter[0] = parseInt(splitter[0].substring(4, splitter[0].length));
	splitter[1] = parseInt(splitter[1]);
	splitter[2] = parseInt(splitter[2].substring(0, splitter[2].length-1));
	for (var q = 0; q < 3; q++)
	{
		splitter[q] = splitter[q].toString(16);
		if (splitter[q].length == 1) splitter[q] = "0" + splitter[q];
		newfcS += splitter[q];
	}
	return newfcS;
	}

	function hideShowTable(parentId)
	{
		var oRow = document.getElementById("row" + parentId);
		var isMac = false;
		
		if(navigator.userAgent.indexOf("MSIE") > 0 && navigator.userAgent.indexOf("Mac") > 0)
			isMac = true;
			
		if(oRow.style.display == "none")
		{
			if(!isMac)
			{
				oRow.style.display = "inline";
				oRow.style.visibility = "visible"
			}
			else
			{
				oRow.style.display = "block";
				oRow.style.visibility = "visible";
			}
		}
		else
		{
			oRow.style.display = "none";
			oRow.style.visibility = "hidden";
		}
		return;
	}
	
	function setEvent(e)
		{
			if(document.all) return;
			
			window.event = e
			window.event.fromElement = e.target
			window.event.toElement = e.target
			window.event.srcElement = e.target
			window.event.x = e.x
			window.event.y = e.y
			return;
		}
		
	function toggleOptions()
	{
		var oRow = document.getElementById("advancedRow");
		var oButton = document.getElementById("btnOptions");
		var oAdvanced = document.getElementById("advancedVisible");
		if(oRow)
		{
			if(oRow.className == "hide")
			{
				oRow.className = "show";
				oButton.value = "Simple View";
				oAdvanced.value = "1";
			}
			else
			{
				oRow.className = "hide";
				oButton.value = "Advanced View";
				oAdvanced.value = "0";
				document.getElementById("tbEventName").value = "";
				document.getElementById("tbLocation").value = "";
				document.forms[0].submit();
			}
		}
		return;
	}
	
	function returnCheck()
	{
		setEvent(event);
		var pressed = window.event.which;
		if(!pressed) {
			pressed = window.event.keyCode;
		}
		if(pressed == 13 || document.getElementById("hdnSubmit").value == "1")
		{
			document.getElementById("hdnSubmit").value = "";
			document.forms[0].submit();
			return false;	
		}
		else
			return true;
			
	}
	
	//Checks whole numbers only
	function numberMask(event)
	{
		setEvent(event);
		var pressed = window.event.which;
		
		if(pressed)
			return checkKey(pressed)
		else
			pressed = window.event.keyCode;
		
			return checkKey(pressed);
	}

	//check whole numbers only
	function checkKey(key)
	{
		if(isNumberKey(key) || isNavKey(key))
			return true
		else
			return false;
	}
	
	function isNumberKey(key)
{
//47 - 58 => numbers 0-9

	if(key > 47 && key < 58)
		return true;
	else 
		return false;
}

	function isNavKey(key)
	{
		/*
		37 => left arrow
		39 => right arrow
		8 => backspace
		46 => delete
		36 => home
		35 => end
		*/
		if(key == 37 || key == 39 || key == 8 || key == 36 || key == 35)
			return true;
		else 
			return false;
		
	}

	function trim(inputString) 
	{
        if (typeof inputString != "string") { return inputString; }
        var retValue = inputString;
        var ch = retValue.substring(0, 1);
        while (ch == ' ') { // Check for spaces at the beginning of the string
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
        }
        ch = retValue.substring(retValue.length-1, retValue.length);
        while (ch == ' ') { // Check for spaces at the end of the string
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
        }
        while (retValue.indexOf('  ') != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
			retValue = retValue.substring(0, retValue.indexOf('  ')) + retValue.substring(retValue.indexOf('  ')+1, retValue.length); // Again, there are two spaces in each of the strings
        }
        return retValue; // Return the trimmed string back to the user
	}