//
// glb_func.js
//


function NewWindow(sLocation, sName, iWidth, iHeight) {
	if (iWidth == null || iWidth == "") {iWidth = '591'}
	if (iHeight == null || iHeight == "") {iHeight = '400'}
	if (sName == null) {sName = 'popup'}
	var oWin = window.open(sLocation, sName, "top=32,left=32,scrollbars,width=" + iWidth + ",height=" + iHeight);
	oWin.focus();

}

function KeepSessionState() {
	for (i=0 ; i < document.links.length ; i++) {
		if (document.links[i].protocol != "mailto:" && document.links[i].hash == "" && document.links[i].target != "new") {
			var iPos = 0;
			var iPos1 = 0;
			var iPos2 = 0;
			iPos1 = document.links[i].href.indexOf(".asp");
			iPos2 = document.links[i].href.indexOf(".htm");
			
			if (iPos1 > 0) {iPos = iPos1}
			if (iPos2 > 0) {iPos = iPos2}
			
			if (iPos > 0) {
				var sLast = document.links[i].href.substring(iPos + 4, document.links[i].href.length);
				if (sLast.indexOf("?") != -1) {sLast = sLast.substring(1, sLast.length)}
				var sQuery = location.search;
				if (sQuery == "" || sQuery == null) {sQuery = "?"}
				if (sLast != "") {
					if (sQuery.length > 1) {sQuery += "&"}
					document.links[i].href = document.links[i].href.substring(0, iPos + 4) + sQuery + sLast; 
				} else {
					document.links[i].href = document.links[i].href.substring(0, iPos + 4) + sQuery; 
				}
			} else {
				if (document.links[i].protocol != "javascript:") {
					document.links[i].href += sQuery;	
				}
			}
		}
	}
}

function fnAddSessionState(sSID) {
	for (i=0 ; i < document.links.length ; i++) {
		if (document.links[i].protocol != "mailto:" && document.links[i].hash == "" && document.links[i].target != "new") {
			var iPos = 0;
			var iPos1 = 0;
			var iPos2 = 0;
			iPos1 = document.links[i].href.indexOf(".asp");
			iPos2 = document.links[i].href.indexOf(".htm");
			
			if (iPos1 > 0) {iPos = iPos1}
			if (iPos2 > 0) {iPos = iPos2}
			
			if (iPos > 0) {
				var sLast = document.links[i].href.substring(iPos + 4, document.links[i].href.length);
				if (sLast.indexOf("?") != -1) {sLast = sLast.substring(1, sLast.length)}
				if (sLast != "") {
					document.links[i].href = document.links[i].href.substring(0, iPos + 4) + "?sid=" + sSID + "&" + sLast; 
				} else {
					document.links[i].href = document.links[i].href.substring(0, iPos + 4) + "?sid=" + sSID; 
				}
			} else {
				if (document.links[i].protocol != "javascript:") {
					document.links[i].href += "?sid=" + sSID;	
				}
			}
		}
	}
}

function Redirect() {
	var sMsg1 = "Based on your selection, we are transferring you to the ";  
	var sMsg2 = " section of our site to better address your needs.";
	var sLocation = "";
	var bOn = false;
	 
	if (document.forms[0].survey[0].checked == true) {
		sHref = "../../RetailAccounts/Wireless/";
		sLocation = "Wireless";
		bOn = true;
	}
	
	if (document.forms[0].survey[1].checked == true) {
		sHref = "../../RetailAccounts/RetailStorefronts/";
		sLocation = "Retail";
		bOn = true;
	}
	
	if (document.forms[0].survey[2].checked == true) {
		sHref = "../../MOTOAccounts/";
		sLocation = "Internet, Mail Order, Telephone Order";
		bOn = true;
	}
	
	if (document.forms[0].survey[3].checked == true) {
		sHref = "../../MOTOAccounts/";
		sLocation = "Internet, Mail Order, Telephone Order";
		bOn = true;
	}
	
	if (bOn == true) {
		if (confirm(sMsg1 + "\n" + sLocation + sMsg2) == true) {
			location.href = sHref;
		}
	} else {
		alert("Please select an option to continue.");
	}
}

function fnOpenFlashIntro() {
	var oWin = window.open("flash_intro.htm", "flash_intro", "width=640,height=480");
	oWin.focus();
}

