//Browser Detection

var bType;
function BDetect () {
	if (document.layers) {
	bType = "ns4";
	}
	else if (document.getElementById) {
	bType = "dom"
	}
	else if (document.all && !document.getElementById) {
	bType = "ie4";
	}
	else {
	bType = "other";
	}
}
BDetect();

//Mac ?
isMac = 0;
if (navigator.appVersion.indexOf("Mac") > -1)	{
	isMac	= 1;
	//alert("isMac");
}

function setElementProperty(elm, property, value){
	var thisElm = null;
	if(typeof(elm) == "object"){
		thisElm = elm;
	} else {
		thisElm = document.getElementById(elm);
	}
	if((thisElm != null) && (thisElm.style != null)){
		thisElm = thisElm.style;
		thisElm[property] = value;
	}
}

function showTip(layerName) {
	//alert("executing showTip");
	if (isMac == 1)	{
		captureMousePos();
		//alert("isMac");
	}
	thisLeft = xMousePos + 15;
	thisTop = yMousePos;
	//alert(thisLeft + ", " + yMousePos);
	setElementProperty(layerName, 'left', thisLeft)
	setElementProperty(layerName, 'top', thisTop)
	setElementProperty(layerName, 'visibility', 'visible')
}

function hideTip(layerName){	
	setElementProperty(layerName, 'visibility', 'hidden')
}

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePos;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePos;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePos;
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePos(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.clientX+document.body.scrollLeft;
        yMousePos = window.event.clientY+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

// Ad Randomizer
function adRotate(thisAd)	{
	thisCount = thisAd.length;
	rndNumber = Math.floor(Math.random()*thisCount)
	alert(thisAd[rndNumber]);
}

// Business Image Array
var adBusiness = new Array();
	adBusiness[0] = "img 0"
	adBusiness[1] = "img 1 "
	adBusiness[2] = "img 2"
	adBusiness[3] = "img 3"
	adBusiness[4] = "img 4"
	adBusiness[5] = "img 5"
	adBusiness[6] = "img 6"
	adBusiness[7] = "img 7"
	
// Popup Window
function popWin(url,wd,ht,scroll){
	useScroll = 0;
	if (scroll == 1)	{
		useScroll = 1;
	}
	height = ht;
	width = wd;
	thisURL = url;
	popupWin=window.open(thisURL,"","width=" + width + ",height=" + height + ", scrollbars=" + useScroll)
}


function launchSBS(phoneID)	{
	
	thisURL = "/stepbystep/index.jsp?id=" + phoneID;
	//alert(thisURL)
	popWin(thisURL,736,515);
}

function changeLocation(url){
	window.location=url
}


function swapChars(processString, removeStr, replaceStr) {
	var outputString = processString
	while (outputString.indexOf(removeStr) > -1) 
	{
		pos				= outputString.indexOf(removeStr)
		outputString 	= outputString.substring(0, pos) 
		outputString 	= outputString + replaceStr 
		outputString 	=outputString +  processString.substring((pos + removeStr.length), processString.length);
	}
	return outputString
}

function changeLayer(thisLayer)	{
	setElementProperty(currentLayer, 'visibility', 'hidden')
	setElementProperty(thisLayer, 'visibility', 'visible')
	currentLayer = thisLayer
}

function nothing()
{
	return
}

function submitData()
{
	var zipcode = document.dataForm.zipCode.value;
	ModalPopup_showPopup(self, 'http://www.alltel.com/estore/wireless/products/greater/ValidateZipCode.jsp?zipCode=' + zipcode, 530, 620, '');
}

var ModalPopup_popupWindow;
var ModalPopup_creatingPopup = false;
var ModalPopup_sourceWindow;

function ModalPopup_showPopup( sourceWindow, url, popupWidth, popupHeight, windowAttributes ) 
{
	if(ModalPopup_popupWindow != null && !ModalPopup_popupWindow.closed)
	{
		ModalPopup_closePopup();
	}
	ModalPopup_creatingPopup = true;
	if( windowAttributes.length > 0 )
	{
        	windowAttributes = ',' + windowAttributes;
        }
	ModalPopup_popupWindow = window.open(url,'popup', 'resizable=yes,scrollbars=yes,dependent=yes,' +
		'screenX='+(screen.availWidth-popupWidth)/2+',screenY='+(screen.availHeight-popupHeight-30)/2 +
		',left='+(screen.availWidth-popupWidth)/2+',top='+(screen.availHeight-popupHeight-30)/2+
		',width=' +popupWidth + ',height=' + popupHeight + windowAttributes);

    	ModalPopup_sourceWindow = sourceWindow;
	ModalPopup_creatingPopup = false;
}
function ModalPopup_getSourceWindow() 
{
    	return ModalPopup_sourceWindow;
}
function ModalPopup_focusPopup() 
{
    	if(!ModalPopup_creatingPopup && ModalPopup_popupWindow != null && !ModalPopup_popupWindow.closed ) {
		if( typeof(ModalPopup_popupWindow.onError) != 'unknown' ) 
		{
			ModalPopup_popupWindow.focus();
		}
	}
}
function ModalPopup_closePopup() 
{
    	if(!ModalPopup_creatingPopup && ModalPopup_popupWindow != null && !ModalPopup_popupWindow.closed && ModalPopup_popupWindow.close )
	{
		ModalPopup_popupWindow.close();
	}
    	if(!ModalPopup_creatingPopup)
    	{
		ModalPopup_popupWindow = null;
	}
}

function changeParent(url)	{
	window.opener.location = url;
	self.close()
}

if (navigator.appName == "Netscape") {			
	layerRef="document.getElementById(";
	styleSwitch=").style";
	} else {
		layerRef="document.all";
		styleSwitch=".style";
}

currentDiv = "";

function hideDiv(layerName){	
	if (currentDiv != "") {
		setElementProperty(currentDiv, 'visibility', 'hidden');
		currentDiv="";
		}
}

function showDiv(layerName) {
	hideDiv(currentDiv);
	setElementProperty(layerName, 'visibility', 'visible');
	currentDiv=layerName;
}

currentImg = "why_get";

currentLockImg = "why_get";
function lockImg(imgName)	{
	currentLockImg = imgName;
}

function unLockImg(imgName)	{
	if(currentLockImg != "")	{
		if (navigator.appName == "Netscape") {	
			DefaultImage = eval(imgName + "_default.src");		
			document[imgName].src =DefaultImage;
			}
		else{
			if(document.readyState == "complete"){	
				DefaultImage = eval(imgName + "_default.src");		
				document[imgName].src =DefaultImage;
			}			
		}
	}
}
		
//Image on
function image_on(imgName) {
	if (navigator.appName == "Netscape") {			
		ActiveImage = eval(imgName + "_active.src");
		document[imgName].src = ActiveImage;		
		}
	else{
		if(document.readyState == "complete"){	
			ActiveImage = eval(imgName + "_active.src");
			document[imgName].src = ActiveImage;		
			}
		}	
	currentImg = imgName;
	}
	
	//Image off
	function image_off(imgName) {	
	if (imgName != currentLockImg)	{
		if (navigator.appName == "Netscape") {	
			DefaultImage = eval(imgName + "_default.src");		
			document[imgName].src =DefaultImage;
			}
		else{
			if(document.readyState == "complete"){	
				DefaultImage = eval(imgName + "_default.src");		
				document[imgName].src =DefaultImage;
				}			
		}
	}	
	}

if (document.images){		
	why_get_active = new Image;                             
	why_get_active.src = "images/subnav_why_i_should_get_it_on.gif";                     
	why_get_default = new Image;                            
	why_get_default.src = "images/subnav_why_i_should_get_it.gif";          

	avail_active = new Image;                             
	avail_active.src = "images/subnav_whats_available_on.gif";                     
	avail_default = new Image;                            
	avail_default.src = "images/subnav_whats_available.gif";                   

	how_does_active = new Image;                             
	how_does_active.src = "images/subnav_how_does_it_work_on.gif";                     
	how_does_default = new Image;                            
	how_does_default.src = "images/subnav_how_does_it_work.gif";                   

	how_much_active = new Image;                             
	how_much_active.src = "images/subnav_how_much_does_it_cost_on.gif";                     
	how_much_default = new Image;                            
	how_much_default.src = "images/subnav_how_much_does_it_cost.gif";

	what_do_active = new Image;                             
	what_do_active.src = "images/subnav_what_do_i_need_on.gif";                     
	what_do_default = new Image;                            
	what_do_default.src = "images/subnav_what_do_i_need.gif";          
	}