var clickedHeader = '';
var oldHeader = '';
//Set global variable
function setHeaderName(name)
{
	oldHeader = clickedHeader;
	clickedHeader = name;	
}

var a_Icon = new Array();
var a_Text = new Array();
var a_URL = new Array();
var ie;
var n;

var browserName = navigator.appName;
if ( browserName.indexOf( "Explorer" ) != -1 ) 
{
	ie=true;
	n=false;
} 
else if ( browserName.indexOf( "Netscape" ) != -1 ) 
{     
	ie=false;
	n=true;
}


//Menu Buttons
function buttonOver(table)
{
	table.style.borderRight = 'black 1px outset ';
	table.style.borderTop = '#ebecf6 1px outset ';
	table.style.borderLeft = '#ebecf6 1px outset ';
	table.style.borderButtom = 'black 1px outset ';
	table.style.color ='#FFFF00'
}
function buttonOut(table)
{
	table.style.borderRight = '#300063 1px solid';
	table.style.borderTop = '#300063 1px solid';
	table.style.borderLeft = '#300063 1px solid';
	table.style.borderButtom = '#300063 1px solid';
	table.style.color ='#9798CB'
}
function buttonDown(table)
{
	table.style.borderRight = '#ebecf6 1px inset';
	table.style.borderTop = 'black 1px inset';
	table.style.borderLeft = 'black 1px inset';
	table.style.borderButtom = '#ebecf6 1px inset';
	table.style.color ='#FFFF00'
}
function mainOut(table)
{
	table.style.borderRight = '#300063 1px solid';
	table.style.borderTop = '#300063 1px solid';
	table.style.borderLeft = '#300063 1px solid';
	table.style.borderButtom = '#300063 1px solid';
	table.style.color ='#FFFF00'
}

//Data buttons

function dataButtonOver(table)
{
	table.style.borderRight = '#C7BCA8 1px outset ';
	table.style.borderTop = '#EDE7DC 1px outset ';
	table.style.borderLeft = '#EDE7DC 1px outset ';
	table.style.borderButtom = '#C7BCA8 1px outset ';
	table.style.color ='#FFFF00'
}
function dataButtonOut(table)
{
	table.style.borderRight = '#DACEB8 1px solid';
	table.style.borderTop = '#DACEB8 1px solid';
	table.style.borderLeft = '#DACEB8 1px solid';
	table.style.borderButtom = '#DACEB8 1px solid';
	if (table.innerText != clickedHeader)
		table.style.color ='#666666';
	else
		table.style.color ='#F00000'
}
function dataButtonDown(table)
{
	table.style.borderRight = '#EDE7DB 1px inset';
	table.style.borderTop = '#9B9283 1px inset';
	table.style.borderLeft = '#9B9283 1px inset';
	table.style.borderButtom = '#EDE7DB 1px inset';
	table.style.color ='#F00000'
}


function init() {
		
		if (n) 
		{
			poptool = document.getElementById('poptooldiv');
			popview = document.getElementById('popviewdiv');			
			popMain = document.getElementById('popmaindiv');
			popReport = document.getElementById('popreportdiv');
			popReportCustomer = document.getElementById('popreport_customerdiv');
			popReportStation = document.getElementById('popreport_stationdiv');
			popReportIn = document.getElementById('popreport_indiv');
			popReportOut = document.getElementById('popreport_outdiv');			
			popTable = document.getElementById('poptablediv');
			reportbox = document.getElementById('popreportdiv')
			reportboxCustomer = document.getElementById('popreport_customerdiv')
			reportboxStation = document.getElementById('popreport_stationdiv')
			viewby = document.getElementById('viewby');
			popFavorites = document.getElementById('popfavoritesdiv');
			toolbox = document.getElementById('toolbox');	
			mainbox = document.getElementById('mainbox');	
			tablebox = document.getElementById('poptablediv');
			favoritesbox = document.getElementById('favoritesbox');				
		}
        if (ie) 
        {
			poptool = poptooldiv;		
			popview = popviewdiv;	
			popMain = popmaindiv;
			popTable = poptablediv;
			popFavorites = popfavoritesdiv
			popReport = popreportdiv;
			popReportCustomer = popreport_customerdiv
			popReportStation = popreport_stationdiv
			popReportIn = popreport_indiv
			popReportOut = popreport_outdiv
		}
		poptool.style.left = toolbox.offsetLeft - 1;
		popview.style.left = viewby.offsetLeft;
		popMain.style.left =  mainbox.offsetLeft;
		popReport.style.left = toolbox.offsetLeft - 85;
		popReportCustomer.style.left = reportbox.offsetLeft - 85;
		popReportStation.style.left = reportbox.offsetLeft - 85;
		popReportIn.style.left = reportbox.offsetLeft - 85;
		popReportOut.style.left = reportbox.offsetLeft - 85;
		popTable.style.left = mainbox.offsetLeft + 70;
		popTable.style.width = tablebox.offsetWidth;
		popFavorites.style.left = mainbox.offsetLeft + 70;
		if (n) 
		{
			popview.style.width = viewby.offsetWidth - 10;
			poptool.style.width = toolbox.offsetWidth - 10;
			popMain.style.width = mainbox.offsetWidth - 10;
			popReport.style.width = toolbox.offsetWidth - 20;
			popReportCustomer.style.width = reportbox.offsetWidth - 10;
			popReportStation.style.width = reportbox.offsetWidth - 10;			
			popview.style.top = viewby.offsetTop + viewby.offsetHeight;
			poptool.style.top = toolbox.offsetTop + toolbox.offsetHeight;
			popMain.style.top = mainbox.offsetTop + mainbox.offsetHeight;
			popTable.style.top = document.getElementById('tablebox').offsetTop + document.getElementById('tablebox').offsetHeight + 72;
			popFavorites.style.top = document.getElementById('favoritesbox').offsetTop + document.getElementById('favoritesbox').offsetHeight + 72;
			popReport.style.top = document.getElementById('reportbox').offsetTop + document.getElementById('reportbox').offsetHeight + 72;
			popReport.style.width = 110;
			popReportCustomer.style.top = document.getElementById('reportboxCustomer').offsetTop + document.getElementById('reportboxCustomer').offsetHeight + 75;
			popReportCustomer.style.width = toolbox.offsetWidth + 30;			
			popReportCustomer.style.left = toolbox.offsetLeft - 200;			
			popReportStation.style.top = document.getElementById('reportboxStation').offsetTop + document.getElementById('reportboxStation').offsetHeight + 75;
			popReportStation.style.width = toolbox.offsetWidth + 30;
			popReportStation.style.left = toolbox.offsetLeft - 200;
			popReportIn.style.top = document.getElementById('reportboxIn').offsetTop + document.getElementById('reportboxIn').offsetHeight + 75;
			popReportOut.style.top = document.getElementById('reportboxOut').offsetTop + document.getElementById('reportboxOut').offsetHeight + 75;
		}
		if (ie)
		{
			popview.style.width = viewby.offsetWidth;
			//poptool.style.width = toolbox.offsetWidth;
			popMain.style.width = mainbox.offsetWidth;
			popTable.style.top = document.getElementById('tablebox').offsetTop + document.getElementById('tablebox').offsetHeight + 65;
			popFavorites.style.top = document.getElementById('favoritesbox').offsetTop + document.getElementById('favoritesbox').offsetHeight + 65;
			popReport.style.width = toolbox.offsetWidth;
			popReport.style.top = document.getElementById('reportbox').offsetTop + document.getElementById('reportbox').offsetHeight + 65;			
			popReportCustomer.style.width = toolbox.offsetWidth + 30;			
			popReportCustomer.style.left = toolbox.offsetLeft - 200;
			popReportCustomer.style.top = document.getElementById('reportboxCustomer').offsetTop + document.getElementById('reportboxCustomer').offsetHeight + 75;									
			popReportStation.style.width = toolbox.offsetWidth + 30;
			popReportStation.style.left = toolbox.offsetLeft - 200;
			popReportStation.style.top = document.getElementById('reportboxStation').offsetTop + document.getElementById('reportboxStation').offsetHeight + 75;
			popReportIn.style.left = toolbox.offsetLeft - 200;
			popReportIn.style.top = document.getElementById('reportboxIn').offsetTop + document.getElementById('reportboxIn').offsetHeight + 75;
			popReportOut.style.left = toolbox.offsetLeft - 200;
			popReportOut.style.top = document.getElementById('reportboxOut').offsetTop + document.getElementById('reportboxOut').offsetHeight + 75;
		}
		hideReport(0);
}


//Hide-Show Layer

function hidetool(toolShow) 
{
	if (toolShow == 0) 
	{
		if (typeof(poptool) == "object")
			poptool.style.visibility = "hidden";
		if (typeof(popview) == "object")
			popview.style.visibility = "hidden";	
        	if (typeof(popMain) == "object")
			popMain.style.visibility = "hidden";
        toolShow = 1;
        return;
	}           
    if (toolShow == 1) 
    {
		if (typeof(poptool) == "object")
			poptool.style.visibility = "visible";
		if (typeof(popview) == "object")	
			popview.style.visibility = "hidden";
	    	if (typeof(popMain) == "object")
			popMain.style.visibility = "hidden";
	    toolShow = 0;
	    return;
	}
}


function hideview(viewShow)
{
	if (viewShow == 0)
	{
		if (typeof(popview) == "object")
			popview.style.visibility = "hidden";
		if (typeof(poptool) == "object")
			poptool.style.visibility = "hidden";
		if (typeof(popReport) == "object")
			popReport.style.visibility = "hidden";
		if (typeof(popMain) == "object")
			popMain.style.visibility = "hidden";
		if (typeof(popTable) == "object")
			popTable.style.visibility = "hidden";
        viewShow = 1;
        return;
	}
    if (viewShow == 1)
    {
	    	if (typeof(poptool) == "object")
			poptool.style.visibility = "hidden";
		if (typeof(popReport) == "object")
			popReport.style.visibility = "hidden";
		if (typeof(popview) == "object")
			popview.style.visibility = "visible";
		if (typeof(popMain) == "object")
			popMain.style.visibility = "hidden";
		if (typeof(popTable) == "object")
			popTable.style.visibility = "hidden";  
        viewShow = 0;
        return;
	}
}

function hideMain(mainShow) 
{
	if (mainShow == 0)
	{          
        	if (typeof(popview) == "object")
			popview.style.visibility = "hidden";
		if (typeof(popReport) == "object")
			popReport.style.visibility = "hidden";
        	if (typeof(poptool) == "object")	
			poptool.style.visibility = "hidden";
        	if (typeof(popMain) == "object")
			popMain.style.visibility = "hidden";
		if (typeof(popTable) == "object")
			popTable.style.visibility = "hidden";
        mainShow = 1;
        return;
	}           
    if (mainShow == 1) 
    {
	    if (typeof(popview) == "object")
			popview.style.visibility = "hidden";
	    if (typeof(popReport) == "object")
			popReport.style.visibility = "hidden";
	    if (typeof(poptool) == "object")	
			poptool.style.visibility = "hidden";
	    if (typeof(popTable) == "object")
			popTable.style.visibility = "hidden";
	    if (typeof(popMain) == "object")
			popMain.style.visibility = "visible";
        mainShow = 0;
        return;
	}
}

function hideReport(reportShow) 
{
	if (reportShow == 0)
	{
		if (typeof(popReport) == "object")
			popReport.style.visibility = "hidden";
        reportShow = 1;
        return;
	}          
    if (reportShow == 1) 
    {	   
		if (typeof(popReport) == "object")
			popReport.style.visibility = "visible";
        reportShow = 0;
        return;
	}
}

function hideReportCustomer(reportShow) 
{
	if (reportShow == 0)
	{
		if (typeof(popReportCustomer) == "object")
			popReportCustomer.style.visibility = "hidden";
        reportShow = 1;
        return;
	}          
    if (reportShow == 1) 
    {	   
		if (typeof(popReportCustomer) == "object")
		{
			popReportCustomer.style.visibility = "visible";
        }
        reportShow = 0;
        return;
	}
}

function hideReportStation(reportShow) 
{
	if (reportShow == 0)
	{
		if (typeof(popReportStation) == "object")
			popReportStation.style.visibility = "hidden";
        reportShow = 1;
        return;
	}          
    if (reportShow == 1) 
    {	   
		if (typeof(popReportStation) == "object")
			popReportStation.style.visibility = "visible";
        reportShow = 0;
        return;
	}
}

function hideReportIn(reportShow) 
{
	if (reportShow == 0)
	{
		if (typeof(popReportIn) == "object")
			popReportIn.style.visibility = "hidden";
        reportShow = 1;
        return;
	}          
    if (reportShow == 1) 
    {	   
		if (typeof(popReportIn) == "object")
					popReportIn.style.visibility = "visible";
        reportShow = 0;
        return;
	}
}

function hideReportOut(reportShow) 
{
	if (reportShow == 0)
	{
		if (typeof(popReportOut) == "object")
			popReportOut.style.visibility = "hidden";
        reportShow = 1;
        return;
	}          
    if (reportShow == 1) 
    {	   
		if (typeof(popReportOut) == "object")
			popReportOut.style.visibility = "visible";
        reportShow = 0;
        return;
	}
}

function hideTable(tableShow) 
{
	if (tableShow == 0)
	{
		if (typeof(popTable) == "object")
			popTable.style.visibility = "hidden";
        tableShow = 1;
        return;
	}          
    if (tableShow == 1) 
    {	   
		if (typeof(popTable) == "object")
			popTable.style.visibility = "visible";
        tableShow = 0;
        return;
	}
}

function hideFavorites(favoritesShow) 
{
	if (favoritesShow == 0)
	{
		if (typeof(popFavorites) == "object")
			popFavorites.style.visibility = "hidden";
        favoritesShow = 1;
        return;
	}          
    if (favoritesShow == 1) 
    {	   
		if (typeof(popTable) == "object")
			popFavorites.style.visibility = "visible";
        favoritesShow = 0;
        return;
	}
}

function webChat(chatType)
{
	if(chatType == 'im')
	{
		//document.frmChat.action = 'http://chat.abxglobal.com/cbim.asp';
		document.frmChat.action = '/GlobalChat/cbim.asp';
		document.frmChat.target = '_blank';		
	}
	else
	{
		//document.frmChat.action = 'http://chat.abxglobal.com/cbdirect.asp';
		document.frmChat.action = '/GlobalChat/cbdirect.asp';
	}
	document.frmChat.submit();
}

function smartReferenceWindow(url)
{
	openSmartFrame(url, 800, 600, 'status=yes, resizable=yes, scrollbars=yes, toolbar=no');
}

function smartFavoritesWindow(url)
{
	window.open(url, 'FavoritesWindow', 'status=1,resizable=1,scrollbars=1,toolbar=no,width=414,height=300');
}

function disablePopup(status, url) 
{
	var today = new Date();
	var value = name;
	var expires = new Date();
	expires.setTime(today.getTime() + 1000*60*60*24*365);
	setCookie("DisableAlerts", status, expires);
	document.location.href=url;
}

function isInt (field) 
{
var str = field.value;
var i = parseInt (str);
	if (isNaN (i)) {
		alert(str + ' is not a number.  Please enter a numeric value.');
		field.focus();
		field.select();
        return false;
    }
	/*(i= i . toString ();
	if (i != str) {
        alert(str + ' is not a number.  Please enter a numeric value.');
		field.focus();
		field.select();
        return false;
    }  */ 
return true;
}

function ignoreSpaces(string) 
{
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
	return temp;


}

function isEmpty( field, message ) 
{
	var str = field.value;
	str = ignoreSpaces(str);
    if( str == '' ) 
	{
       alert( message );
       //field.select();
       field.focus();
       return false;
	}  
    return true;  
}

function isZero( field, message ) 
{
	var str = field.value;
	str = ignoreSpaces(str);
    if( str == 0 ) 
	{
       alert( message );
       //field.select();
       field.focus();
       return false;
	}  
    return true;  
}
