// Preload images
//if (document.images) 
//{
//   loadingImage = new Image();
//   loadingImage.src = "";
//   //setTimeout('loadingImage', 200); 
//}

// Call function to show div before submitting form. This is used for the updating cart message...
function showMessageAndSubmitForm(frm,divID,frmID) {
	/*document.getElementById(divID).style.display = "block";
	// If browser is IE, don't show animated gif due to bug
	if (navigator.userAgent.indexOf("MSIE")!=-1) {
		document.getElementById(divID).innerHTML = "Updating cart...";
	} else {
		document.getElementById(divID).innerHTML = "Updating cart...";
		//document.getElementById(divID).innerHTML = "<img src='img/loading/dkBlueCircle2.gif' border='0' style='margin-bottom:-10px'>&nbsp;&nbsp;&nbsp;Updating cart...";
	}*/
	document.getElementById(frmID).submit();
}

// preload images on home page for image switch
//
function homepage_preloader() {
	 image0 = new Image();
	 image0.src = "images/choose-a-rate-plan-on.gif";
	 image1 = new Image();
	 image1.src = "images/choose-a-phone-on.gif";
}

// Jump menu for http request on pull down menu selection
function jumpMenu(targ,selObj,restore){
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

// New function for anchor tags to submit form for validation and submittal
function validateAndSubmitForm(formID){
	var formObj = document.getElementById(formID);
	if(doCheck(formObj)){
		document.getElementById(formID).submit();
	}
}


// simple image switcher
//
function Switcher(imgID,whichimg) {
	if (document.images){
			document.images[imgID].src=whichimg;
		}
}

// function to pop up new window
// 
function OpenWindow(linkpage,thewidth,theheight){

	therest = 'toolbar=no, location=no, scrollbars=auto, resizable=no,width='+thewidth+',height='+theheight;

	window.open(linkpage,'detail', therest)

}

// function to pop up new window - full screen
// 
function OpenPopUpFullScreen(linkpage,screenTitle) {

    var thewidth = 780;
    var theheight = 750;
    if (screen) {
        thewidth = screen.width;
        theheight = screen.height;
    }
    therest = 'toolbar=no, location=no, scrollbars=auto, resizable=no,top=0,left=0,width=' + thewidth + ',height=' + theheight;

    window.open(linkpage, screenTitle, therest)

}

// This function to open browser window gives you more control over how the window looks from the view page. 
// <a href="#" onclick="openBrWindow('file.html','nameOfFile','toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=200, height=200');return false">Link</a>
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


// function to close window
// 
function CloseWindow(){
window.close();
}







// function to propagate address info from top input fields to bottom
// 
function propagate(){

if (document.forms['bottomform'].elements['sameAddressInfo'].checked){

	if (document.forms['topform'].elements['the_name'].value){
document.forms['bottomform'].elements['the_name'].value=document.forms['topform'].elements['the_name'].value;
	}

	if (document.forms['topform'].elements['address'].value){ 
document.forms['bottomform'].elements['address'].value=document.forms['topform'].elements['address'].value; 
	}

	if (document.forms['topform'].elements['city'].value){ 
document.forms['bottomform'].elements['city'].value=document.forms['topform'].elements['city'].value; 
	}

	theState=document.forms.topform.state.options[document.forms.topform.state.selectedIndex].value;

	thelength=document.forms.bottomform.state.options.length;

	for(i=0;i<thelength;i++){

		if (document.forms.bottomform.elements['state'].options[i].value == theState)
			{
			document.forms.bottomform.elements['state'].options[i].selected = true;
			}
	}


	if (document.forms['topform'].elements['zipcode'].value){ 
document.forms['bottomform'].elements['zipcode'].value=document.forms['topform'].elements['zipcode'].value; 
	}	
}
}

