// JavaScript Document
var i;
var imageObj;
var images = new Array();

images[0] = "/uscellular/images/topnav_ps_on.gif";
images[1] = "/uscellular/images/topnav_so_on.gif";
images[2] = "/uscellular/images/topnav_bs_on.gif";
images[3] = "/uscellular/images/topnav_au_on.gif";
images[4] = "/uscellular/images/topnav_cs_on.gif";
images[5] = "/uscellular/images/topnav_ma_on.gif";

for (i = 0; i < images.length; i++)
{
	imageObj = new Image();
	imageObj.src = images[i];
}

function overGraphic(iStr)
{
	document.getElementById(iStr).src = "/uscellular/images/topnav_" + iStr + "_on.gif";
}
function outGraphic(iStr)
{
	document.getElementById(iStr).src = "/uscellular/images/topnav_" + iStr + "_off.gif";
}
function openMenu(iStr)
{
	document.getElementById(iStr).style.display = "block";
}
function closeMenu(iStr)
{
	document.getElementById(iStr).style.display = "none";
}
function popWindow(windowURL,windowName,windowWidth,windowHeight)
{
  	window.name = 'flash';
  	newWindow = window.open(windowURL, windowName, 'width=' + windowWidth + ', height=' + windowHeight + ', toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=0, resizable=0');
  	newWindow.focus();
}
function openWindow(windowURL,windowName,windowWidth,windowHeight)
{
  	window.name = 'parentWnd';
  	newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
}

// Function Name: showWait
// Purpose: Positions and displays a hidden <DIV> element that "pops" on the screen
// Input: none
// Output: none
function showWait()
{
	var iDivWidth = 300;	// Hard-coded width of the pleaseWait <DIV>
	var iDivHeight = 100;	// Hard-coded height of the pleaseWait <DIV>
	var iDivPosX = 0;		// The eventual x-coordinate of the top-left corner of the pleaseWait <DIV>
	var iDivPosY = 0;		// The eventual y-coordinate of the top-left corner of the pleaseWait <DIV>
	
	// There are serious compatibility issues in deriving the vertical and horizontal middle of the browser
	// The innerWidth property is valid only for FF and the like, while IE has its own version called clientWidth
	// Further complicating matters is an IE6/7 difference which requires the definition of the iebody variable
	var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
	
	if (window.innerWidth)
	{
		iDivPosX = window.pageXOffset + (window.innerWidth / 2) - (iDivWidth / 2);
		iDivPosY = window.pageYOffset + (window.innerHeight / 2) - (iDivHeight / 2);
	}
	else
	{
		iDivPosX = iebody.scrollLeft + (iebody.clientWidth / 2) - (iDivWidth / 2);
		iDivPosY = iebody.scrollTop + (iebody.clientHeight / 2) - (iDivHeight / 2);
	}
	
	if (document.getElementById('pleaseWait') != null)
	{
		document.getElementById('pleaseWait').style.left = iDivPosX + 'px';
		document.getElementById('pleaseWait').style.top = iDivPosY + 'px';
		
		// For the zip code page, we only show the Please Wait graphic for the Phones version (call=3)
		if (location.href.indexOf('zipCode') > 0)
		{
		   	   
			if (!checkRequired(document.forms[0].elements["S14_"], "Zip Code")) return false;
			if (!checkNumeric(document.forms[0].elements["S14_"], "Zip Code", 5)) return false;
			
			if (location.href.indexOf('type=phones') > 0)
			{
				document.getElementById('pleaseWait').style.display = 'block';
			}
		}
		else
		{
			// For the state/city page, we only show the Please Wait graphic for the Phones version (call=3)
			if (location.href.indexOf('stateAndCity') > 0)
			{
				if (!checkSelect(document.forms[0].elements["S13_"], "State")) return false;
				
				if (location.href.indexOf('type=phones') > 0)
				{	
					if (document.getElementById('locationCityList').style.display == 'inline')
					{
						return false;
					}
					else
					{
						document.getElementById('pleaseWait').style.display = 'block';	
					}
				}
			}
			else
			{
				// For the b_opt page, only display the Please Wait graphic when the Add Lines button is clicked for a Family Plan
				if (location.href.indexOf('b_opt') > 0)
				{
					if (location.href.indexOf('covType=5') > 0)
					{
						document.getElementById('pleaseWait').style.display = 'block';	
					}
				}
				else
				{
					if (location.href.indexOf('b_checkout') > 0)
					{
						if (document.getElementById('confirmContent').style.display != 'block')
						{
							return false;
						}
						else
						{
							document.getElementById('pleaseWait').style.display = 'block';
						}
					}
					else
					{
						document.getElementById('pleaseWait').style.display = 'block';
					}
				}
			}
		}
	}
	return true;
}


function openWindow(windowURL,windowName,windowWidth,windowHeight)
{
	
  	window.name = 'parentWnd';
  	newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=1,status=0,menuBar=0,scrollBars=1,resizable=0');
  	newWindow.focus(); 
  	
}
