﻿//Javascript goes here

function panelSwap(tblUserId, tblPassId)
{
    if (document.getElementById(tblUserId).style.visibility == 'hidden')
    {
        document.getElementById(tblUserId).style.display = 'inline';
        document.getElementById(tblUserId).style.visibility = 'visible';
        
        document.getElementById(tblPassId).style.display = 'none';
        document.getElementById(tblPassId).style.visibility = 'hidden';
    }
    
    else
    {

        document.getElementById(tblUserId).style.display = 'none';
        document.getElementById(tblUserId).style.visibility = 'hidden';
        
        document.getElementById(tblPassId).style.display = 'inline';
        document.getElementById(tblPassId).style.visibility = 'visible';
       
    }
    
}

function closeWindow() 
{ 
    //Firefox 
    if (navigator.appName == 'Netscape') 
    { 
        window.open('', '_self', ''); 
        window.close(); 
    } 
    else //Internet Explorer 
        setTimeout("WB.ExecWB(45,2)",0); 
} 


function fncUpdateTextAndColor(arrRows, selectedIndex, hiddenFieldID, questionID)
{
    var i = 0;
    for (i = 0; i < arrRows.length; i++)
    {
        if (selectedIndex == i)
        {
            document.getElementById(arrRows[i]).style.backgroundColor = '#41345F';
        }
        else
        {
            document.getElementById(arrRows[i]).style.backgroundColor = 'white';            
        }
    }
    document.getElementById(hiddenFieldID).value = questionID;
}


function fncUpdateTextAndColorOverload(arrRows, selectedIndex, hiddenFieldID, hiddenFieldID2, memberID, itemID)
{
    var i = 0;
    for (i = 0; i < arrRows.length; i++)
    {
        if (selectedIndex == i)
        {
            document.getElementById(arrRows[i]).style.backgroundColor = '#41345F';
        }
        else
        {
            document.getElementById(arrRows[i]).style.backgroundColor = 'white';            
        }
    }
    document.getElementById(hiddenFieldID).value = memberID;
    document.getElementById(hiddenFieldID2).value = itemID;
}


function fncUpdateTextBox(id, index, tdRow)
{
    document.getElementById(id).value = index;
    document.getElementById(tdRow).style.backgroundColor = '#41345F';
}

function fncCopyFields(arrSource, arrDestination)
{
    if (arrSource.length != arrDestination.length)
    {
        alert('Source and Destination do not match');
    }
    else
    {
        var i = 0;
        for (i = 0; i < arrSource.length; i ++)
        {
            //Get Access to the item
            var oItem = document.getElementById(arrSource[i]);
            
            //Check to make sure it's a text box
            document.getElementById(arrDestination[i]).value = oItem.value;
        }
    }
}

//open the popup window...
function fncGL_PopWin(strPage, strName) 
{
	//window.name = "a name for the current window...";
	var windowprops = "height=600,width=760,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes";
	var myPopup = window.open(strPage, strName, windowprops);
	
    if (!myPopup.opener) 
		myPopup.opener = window.self; 
		
}

//open the popup window for delivery charges...
function fncGL_PopWinDeliveryCharges(strPage, strName) 
{
	//window.name = "a name for the current window...";
	var windowprops = "height=600,width=500,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no";
	var myPopup = window.open(strPage, strName, windowprops);
	
    if (!myPopup.opener) 
		myPopup.opener = window.self; 
		
}

function fncBuyClick(strButtonClientId,strClientId,strItemCode)
{

    fnc_FormElm(strClientId).value = strItemCode;
    fnc_FormElm(strButtonClientId).click();
}

function fnc_FormElm(strName) {
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		//Opera and MSIE both work as per W3C DOM...
		//note: Opera also comes out as == "Microsoft Internet Explorer"
		return document.all(strName);
	} else {
		//I hate Netscape
		var icFrm = window.document.forms.length;
		var icElm = 0;
		for (iFrm = 0; iFrm < icFrm; iFrm++) {
			icElm = window.document.forms[iFrm].elements.length;
			for (iElm = 0; iElm < icElm; iElm++) {
				if (window.document.forms[iFrm].elements[iElm].id == strName) {
					return window.document.forms[iFrm].elements[iElm];
				};
			};
		};
		return window.document.getElementById(strName);
	};
}


function fnc_FormElmSHOP(strName) {
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		//Opera and MSIE both work as per W3C DOM...
		//note: Opera also comes out as == "Microsoft Internet Explorer"
		return document.all("ctl00_cphBody_" & strName);
	} else {
		//I hate Netscape
		var icFrm = window.document.forms.length;
		var icElm = 0;
		for (iFrm = 0; iFrm < icFrm; iFrm++) {
			icElm = window.document.forms[iFrm].elements.length;
			for (iElm = 0; iElm < icElm; iElm++) {
				if (window.document.forms[iFrm].elements[iElm].id == strName) {
					return window.document.forms[iFrm].elements[iElm];
				};
			};
		};
		return window.document.getElementById("ctl00_cphBody_" & strName);
	};
}

function fnc_FormElmSHOPButt(strName) {
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		//Opera and MSIE both work as per W3C DOM...
		//note: Opera also comes out as == "Microsoft Internet Explorer"
		return document.all(strName);
	} else {
		//I hate Netscape
		var icFrm = window.document.forms.length;
		var icElm = 0;
		for (iFrm = 0; iFrm < icFrm; iFrm++) {
			icElm = window.document.forms[iFrm].elements.length;
			for (iElm = 0; iElm < icElm; iElm++) {
				if (window.document.forms[iFrm].elements[iElm].id == strName) {
					return window.document.forms[iFrm].elements[iElm];
				};
			};
		};
		return window.document.getElementById(strName);
	};
}

//To submit a button with a value asp work around for
function btnSubmitLSHOP(strName, strIndex) {
    
	fnc_FormElmSHOP("txt" + strName + "Click").value = strIndex;
	fnc_FormElmSHOPButt("ctl00$cphBody$btn" + strName + "Click").click();
    		
	window.event.returnValue = false;
	return false;
}

//Do a button click for the SSL entry
function btnClick(btnDoClick)
{
    document.getElementById(btnDoClick).click();
    return false;
}