//Variables for the screen size
Xdiff  =15;
Ydiff  =30;
screenWidth = screen.availWidth-Xdiff;
screenHeight= screen.availHeight-Ydiff;
if ((screenHeight<=0) || (screenHeight<=0))
{
    screenWidth = 640;
    screenHeight= 480;
}

//Following functions are to create popup based on the URL
popupURLWindow	= 0
popupURLWidth	= 640
popupURLHeight	= 480
function popupURL(url)
{
	if ( popupURLWindow && !popupURLWindow.closed )
		popupURLWindow.close()
	popupURLWindow = window.open(url,"popupURLWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-popupURLWidth)+",top=0,height="+popupURLHeight+",width="+popupURLWidth)
}

popupQuickTourWindow= 0
popupQuickTourWidth	= 690
popupQuickTourHeight= 490
function popupQuickTour(url)
{
	if ( popupQuickTourWindow && !popupQuickTourWindow.closed )
		popupQuickTourWindow.close()
	popupQuickTourWindow = window.open(url,"popupQuickTourWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+((screenWidth-popupQuickTourWidth)/2)+",top="+((screenHeight-popupQuickTourHeight)/2)+",height="+popupQuickTourHeight+",width="+popupQuickTourWidth)
}
popupTipWindow	= 0
popupTipWidth	= 480
popupTipHeight	= 250
function popupTip(url)
{
	if ( popupTipWindow && !popupTipWindow.closed )
		popupTipWindow.close()
	popupTipWindow = window.open(url,"popupTipWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-popupTipWidth)+",top=0,height="+popupTipHeight+",width="+popupTipWidth)
}

popupHelpURLWindow	= 0
popupHelpURLWidth	= 640
popupHelpURLHeight	= 500
function popupHelpURL(url)
{
	if ( popupHelpURLWindow && !popupHelpURLWindow.closed )
		popupHelpURLWindow.close()
	popupHelpURLWindow = window.open(url,"popupHelpURLWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-popupHelpURLWidth)+",top=0,height="+popupHelpURLHeight+",width="+popupHelpURLWidth)
}
spotHelpWindow= 0
spotHelpWidth = 640
spotHelpHeight= 480
function spotHelp(url)
{
    if ( spotHelpWindow && !spotHelpWindow.closed )
        spotHelpWindow.close()
	spotHelpWindow = window.open(url,"spotHelpWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-spotHelpWidth)+",top=0,height="+spotHelpHeight+",width="+spotHelpWidth)
}

popupRawWindow= 0
popupRawWidth = 640
popupRawHeight= 480
function popupRaw(url)
{
    if ( popupRawWindow && !popupRawWindow.closed )
        popupRawWindow.close()
	popupRawWindow = window.open(url,"popupRawWindow","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,left="+(screenWidth-popupRawWidth)+",top="+(screenHeight-popupRawHeight-30)+",height="+popupRawHeight+",width="+popupRawWidth)
}
popupAggregateWindow= 0
popupAggregateWidth = 640
popupAggregateHeight= 480
function popupAggregate(url)
{
    if ( popupAggregateWindow && !popupAggregateWindow.closed )
        popupAggregateWindow.close()
	popupAggregateWindow = window.open(url,"popupAggregateWindow","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,left="+(screenWidth-popupAggregateWidth)+",top="+(screenHeight-popupAggregateHeight-30)+",height="+popupAggregateHeight+",width="+popupAggregateWidth)
}
popupUrlmappingWindow= 0
popupUrlmappingWidth = 750
popupUrlmappingHeight= 300
function popupUrlmapping(url)
{
    if ( popupUrlmappingWindow && !popupUrlmappingWindow.closed )
        popupUrlmappingWindow.close()
	popupUrlmappingWindow = window.open(url,"popupUrlmappingWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+((screenWidth-popupUrlmappingWidth)/2)+",top="+((screenHeight-popupUrlmappingHeight)/2)+",height="+popupUrlmappingHeight+",width="+popupUrlmappingWidth)
}

popupSupportWindow= 0
popupSupportWidth = 640
popupSupportHeight= 480
function supportHelp()
{
    if ( popupSupportWindow && !popupSupportWindow.closed )
        popupSupportWindow.close()
	popupSupportWindow = window.open("http://www.keynote.com/support/index.html","popupSupportWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-popupSupportWidth)+",top=,height="+popupSupportHeight+",width="+popupSupportWidth)
}
SNMPWindow= 0
SNMPWidth = 790
SNMPHeight= 420
function popupSNMP(url)
{
    if ( SNMPWindow && !SNMPWindow.closed )
        SNMPWindow.close()
	SNMPWindow = window.open(url,"SNMPWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left="+(screenWidth-SNMPWidth)+",top=0,height="+SNMPHeight+",width="+SNMPWidth)
}
KSCWindow= 0
KSCWidth = 800
KSCHeight= 600
function popupKSC(url)
{
    if ( KSCWindow && !KSCWindow.closed )
       {
		KSCWindow.focus()
	}
    else
	{
      		KSCWindow = window.open(url,"KSCWindow","toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,left="+(screenWidth-KSCWidth)+",top=0,height="+KSCHeight+",width="+KSCWidth)
		KSCWindow.focus()	
	}
}
function decodequotes(val2)
{
	character2 = ".";
	character3 = ".";
	var val3 = new String(val2);

	//This code fixes the problem with the ' character
	idx = val3.indexOf(character2);
	while(idx > -1)
	{
		var val3 = new String(val3.substring(0,idx) + "'" + val3.substring(idx+1));
		idx = val3.indexOf(character2);
	}

        //This code fixes the problem with the " character
	idx = val3.indexOf(character3);
	while(idx > -1)
	{
		var val3 = new String(val3.substring(0,idx) + "\\\"" + val3.substring(idx+1));
		idx = val3.indexOf(character3);
	}
	return val3;
}

function htmldecodequotes(val2)
{
	character2 = ".";
	character3 = ".";
	var val3 = new String(val2);

	//This code fixes the problem with the ' character
	idx = val3.indexOf(character2);
	while(idx > -1)
	{
		var val3 = new String(val3.substring(0,idx) + "'" + val3.substring(idx+1));
		idx = val3.indexOf(character2);
	}

        //This code fixes the problem with the " character
	idx = val3.indexOf(character3);
	while(idx > -1)
	{
		var val3 = new String(val3.substring(0,idx) + "&quot;" + val3.substring(idx+1));
		idx = val3.indexOf(character3);
	}
	return val3;
}

function replacebr(val4)
{
	var val5 = new String(val4);

	//This code fixes the problem with the <BR> tag
	idx = val5.indexOf("<BR>");
	while(idx > -1)
	{
		var val5 = new String(val5.substring(0,idx) + "," + val5.substring(idx+4));
		idx = val5.indexOf("<BR>");
	}

	return val5;
}
function start()
{
}
function windowStatus(val)
{
	var val1 = new String(val)
	q = "\"";
	cmd = "window.status=" + q + replacebr(decodequotes(val1)) + q;
	setTimeout(cmd,10);
}


/******************************************************************************/
// Embedded Popups
var hideSwitch=0;
function showpopbox(sName,offsetX,offsetY,sLink) {
if (hideSwitch==0) {
	// fix burn through
	//fixBurnThru(true);
	// get the position of the associated link
	if ((sLink == null) || (sLink == "")) { sLink = sName+'_link'; }
	if (document.getElementById(sLink) != null) {
		var xPos = findPos(document.getElementById(sLink),'x');
		var yPos = findPos(document.getElementById(sLink),'y');
		// pad the position so the link will not be covered
		xPos = xPos-112;
		yPos = yPos + 13;

	} else {
		// if there's no link to attach to, put the popup under the nav
		var xPos = 100;
		var yPos = 150;
	}
	// move elements if needed
	if (!isNaN(offsetX)) { xPos = xPos + offsetX; }
	if (!isNaN(offsetY)) { yPos = yPos + offsetY; }
	// open the embedded popup
	document.getElementById(sName).style.display = 'block';
	document.getElementById(sName).style.left = xPos + "px";
	document.getElementById(sName).style.top = yPos + "px";
	hideSwitch=1;
	return;
}
else { hidepopbox(sName);return;}
}

function showinlinepopbox(sName) {
	// fix burn through
    fixBurnThru(true);
	// opens the inline popups
	document.getElementById(sName).style.display = 'block';
	return;
}

function hidepopbox(sName) {
	// Closes the popups
	document.getElementById(sName).style.display = 'none';
	// fix burn through
    fixBurnThru(false);
	hideSwitch=0;
	return;
}

// finds the position of the click to place the popup

function findPos(obj,axis) {
	var cur = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			if (axis == 'x') { cur += obj.offsetLeft }
			else { cur += obj.offsetTop }
			obj = obj.offsetParent;
		}
	} else {
		if ((axis == 'x') && (obj.x)) { cur += obj.x; }
		if ((axis == 'y') && (obj.y)) { cur += obj.y; }
	}
	return cur;
}

// fix the burnthrough on select elements in IE, ns6 and 7 do not have burn-through

// this script is duplicated in menu_settings.js as "fixBurn" for external sites (RNT, Unopi, etc)

function fixBurnThru(isHidden) {
	if (document.all) {
		var rows = document.getElementsByTagName('select');
		for( var i = 0, row; row = rows[i]; i++ ) {
			if (isHidden) {
				row.style.visibility = "hidden";
			} else {
				row.style.visibility = "visible";
			}
		}
	}
	return;
}

// Embedded Popups
/******************************************************************************/

function swapImg(el,i,h) {
var cImg= document.getElementById(el);
if (h==0) {
	cImg.src="images/"+i+"_on.gif"; 
	return; }
else { 
	cImg.src="images/"+i+"_off.gif"; 
	return; }
}

function signin() {
	var type = document.login.username.value;
	if(type == "client") {
		document.location.href = "client/client_console.html";
	} else if(type == "admin") {
		document.location.href = "admin/admin_console.html";
	} else {
		document.location.href = "agent/agent_console.html";
	}
	return;
}

	function formatDate(date){ 	 	
 		var month=0;
 		var MONTH_NAMES=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 		
 		var dates = date.split("-"); 		
 		for (var i=0; MONTH_NAMES.length > i ; i++)
 		{ 			
			var month_name=MONTH_NAMES[i];						
			if (dates[1].toLowerCase()==month_name.toLowerCase()) 
			{					
			  month=i+1;
			  if (month>12) { month -= 12;}				
	                  break;
			}
		}
		if ((month < 1)||(month > 12)){			
			month= 0;
		}		

 		var newDate = new Date();
 		newDate.setDate(dates[0]);
 		newDate.setMonth(month-1);
 		newDate.setYear("20"+dates[2]);
 		return newDate;
 	}