var navlinkCount = 16;
var buylinkCount = 4;
var imageMapCount = 10;
var planlinkCount = 10;
var pageLocation = window.location.toString();

//Remove 3rd party banner flag
repText = pageLocation;
pageLocation = repText.replace(/((\?)|(\&))3ptb/gi,"");

var queryStart = pageLocation.indexOf('?');
var equalStart = pageLocation.indexOf('=');
var pathPrefix = "/mobilebroadband";

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function open_email() {
	var win = window.open(pathPrefix+'/email.html','email','width=250,height=325,scrollbars=0,addressbar=0,resizable=no'); 
}

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
queryAddition = (queryStart != -1)?pageLocation.substring(queryStart, pageLocation.length):"";
menu1[0]='<a href="'+pathPrefix+'/casestudies/cspc.html'+queryAddition+'">Case Studies &amp; Podcasts</a>'
//menu1[1]='<a href="'+pathPrefix+'/plans/coverage.html'+queryAddition+'">Coverage</a>'

var menu2=new Array()
queryAddition = (queryStart != -1)?pageLocation.substring(queryStart, pageLocation.length):"";
//menu2[0]='<a href="'+pathPrefix+'/devices/index_network.html'+queryAddition+'">Network Devices</a>'
//menu2[1]='<a href="'+pathPrefix+'/devices/index_smart.html'+queryAddition+'">Smart Devices</a>'
//menu2[2]='<a href="'+pathPrefix+'/devices/index_notebooks.html'+queryAddition+'">Notebooks</a>'
//menu2[3]='<a href="'+pathPrefix+'/devices/index_phones.html'+queryAddition+'">Multimedia Phones</a>'

var menu3=new Array()
queryAddition = (queryStart != -1)?pageLocation.substring(queryStart, pageLocation.length):"";
menu3[0]='<a href="'+pathPrefix+'/plans/notebook_plans.html'+queryAddition+'">Network Devices or Notebook Plans</a>'
menu3[1]='<a href="'+pathPrefix+'/plans/blackberry_plans.html'+queryAddition+'">BlackBerry Plans</a>'
menu3[2]='<a href="'+pathPrefix+'/plans/multimedia_plans.html'+queryAddition+'">Multimedia Phone Plans</a>'
menu3[3]='<a href="'+pathPrefix+'/plans/other_plans.html'+queryAddition+'">Other Smart Device Plans</a>'

var menuwidth='251px' //default menu width
var menubgcolor='lightgray'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6) document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6) {
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	}
	
	if (menuwidth!="") {
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
		obj.visibility=visible
	} else if (e.type=="click") {
		obj.visibility=hidden
	}
}

function showhideContent(obj, e, visible, hidden){
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
		obj.visibility=visible
	} else if (e.type=="click") {
		obj.visibility=hidden
	}
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) {
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
		}
	} else {
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

function populatemenu(what) {
	if (ie4||ns6) {
		dropmenuobj.innerHTML=what.join("")
	}
}


function dropdownmenu(obj, e, menucontents, menuwidth){
	if (window.event) {
		event.cancelBubble=true
	}	else if (e.stopPropagation) { 
		e.stopPropagation()
	}
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)
	
	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		var safariHack = 0;
		if (navigator.userAgent.search("Safari") != -1) {
			safariHack = 5;
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+safariHack+"px"
	}
	
	

	return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) {
		return false
	} else {
		return true
	}
}

function contains_ns6(a, b) {
	while (b.parentNode) {
		if ((b = b.parentNode) == a) {
			return true;
		}
	}
	return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined") {
		if (ie4||ns6) {
			dropmenuobj.style.visibility="hidden"
		}
	}
}

function delayhidemenu() {
	if (ie4||ns6) {
		delayhide=setTimeout("hidemenu()",disappeardelay)
	}
}

function clearhidemenu(){
	if (typeof delayhide!="undefined") {
		clearTimeout(delayhide)
	}
}

if (hidemenu_onclick=="yes") {
	document.onclick=hidemenu
}

/********************************************************
** Code for roll over DHTML layer on product page      **
********************************************************/
var delayHideLayer = null;

function getFile(filename)
{ oxmlhttp = null;
    try
      { oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/html");
      }
    catch(e)
      { try
          { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch(e)
          { return null;
          }
      }
    if(!oxmlhttp) return null;
    try
      { oxmlhttp.open("GET",filename,false);
        oxmlhttp.send(null);
      }
    catch(e)
      { return null;
      }
    return oxmlhttp.responseText;
}

function delayHideFlashLayer(parentLayer, layerName) {
	var myFunc = "alt_destroyFlashLayer('"+parentLayer+"', '"+layerName+"')";
	delayHideLayer=setTimeout(myFunc,100);
}

function clearHideFlashLayer(){
	if (typeof delayHideLayer!="undefined") {
		clearTimeout(delayHideLayer)
	}
}

function alt_makeLayer(parentLayer, layerName,flashW,flashH,flashVars,flashPath,pageName,docLang){
	
	if(!d.getElementById(layerName)){
		
		/* Tracking addition */
		if (queryStart != -1) {
			pageName += pageLocation.substring(queryStart, pageLocation.length);
		}
		
		var newLayerContent = getFile(flashPath);
		if(newLayerContent == null) newLayerContent = MSG_UNAVAIL;
		newLayer = d.createElement('DIV');
		newLayer.id = layerName;
		newLayer.className = "floatingWindow hidden";
		
		newLayerGuts = '	<div class="popOver" onMouseover="clearHideFlashLayer()" onMouseout="delayHideFlashLayer(\''+parentLayer+'\',\''+layerName+'\')">';
		newLayerGuts += '			<a href="'+pageName+'"><div class="popOverContent">';
		newLayerGuts += newLayerContent;
		newLayerGuts += '				<b>&gt; Click for more info</b>';
		newLayerGuts += '			</div></a>';
		newLayerGuts += '	</div>';
		
		newLayer.innerHTML = newLayerGuts;
		try {
			d.getElementById(parentLayer).appendChild(newLayer);
		} catch(e) {
		
		}
	}
}
	
function alt_destroyFlashLayer(parentLayer, layerName){
	var theLayer = d.getElementById(layerName);
	d.getElementById(parentLayer).removeChild(theLayer);
	lastWindow = "";
}

var lastWindow;

function sprint_slide(slideWhat,startFrom,dir,offsetX,offsetY,winX,winY,winW,winH){
	theBox = d.getElementById(slideWhat);
	if(slideWhat != lastWindow && theBox.className.indexOf('show') == "-1"){
		//if(!startFrom.nodeName) startFrom = d.getElementById(startFrom);
		//imgs = startFrom.getElementsByTagName('img'); // firefox bug with anchors/images
		//if(imgs.length >="1")startFrom = imgs[0];
		if(lastWindow){
			hideLayer(lastWindow);
		}
		
		if(winW >= "1") theBox.style.width = winW+"px";
		if(winH >= "1") theBox.style.height = winH+"px";
		
		newLeft = findPosX(startFrom)+offsetX;
		if(!isNaN(winX))newLeft = winY+offsetX;
		if(winX == "left")newLeft = findPosX(startFrom)+offsetX;
		if(winX == "right")newLeft = findPosX(startFrom)+startFrom.offsetWidth+offsetX;

		newTop = findPosY(startFrom)-106+offsetY; // -106 to compensate for being in the bodyArea
		if(!isNaN(winY))newTop = winX-106+offsetY;
		if(winY == "top")newTop = findPosY(startFrom)-106+offsetY;
		if(winY == "bot")newTop = findPosY(startFrom)-106+startFrom.offsetHeight+offsetY;

		sprint_addClass(slideWhat,"seen"); // show layer
		
		if(dir == "left"){
			linkW = startFrom.offsetWidth;
			theW = theBox.offsetWidth;
			newLeft = newLeft-theW;
		}
		
		theBox.style.top = newTop+"px";
		theBox.style.left = newLeft+"px";
		
		if(dir == "right"){
			sprint_slideRight(theBox.id, 30, 30, 0, 0);
		}
		if(dir == "left"){
			sprint_slideLeft(theBox.id, 30, 30, theW, 0);
		}
		if(dir == "down"){
			sprint_slideDown(theBox.id, 0, 30, 0, 0);
		}
		lastWindow = slideWhat;
	}
}

function sprint_slideRight(layerName, xInt, yInt, xClip, yClip){
	var theLayer = d.getElementById(layerName);
	if (xClip < theLayer.offsetWidth || yClip < theLayer.offsetHeight){
		xClip += xInt;
		yClip += yInt;
		theLayer.style.clip = "rect(auto, "+xClip+"px, "+yClip+"px, auto)";
		slideagain = setTimeout("sprint_slideRight('"+layerName+"', "+xInt+", "+yInt+", "+xClip+", "+yClip+");", 0);
	}
}

function sprint_slideLeft(layerName, xInt, yInt, xClip, yClip){
	var theLayer = d.getElementById(layerName);
	if (xClip > 0 || yClip < theLayer.offsetHeight){
		xClip -= xInt;
		yClip += yInt;
		theLayer.style.clip = "rect(auto, "+theLayer.offsetWidth+"px, "+yClip+"px, "+xClip+"px)";
		slideagain = setTimeout("sprint_slideLeft('"+layerName+"', "+xInt+", "+yInt+", "+xClip+", "+yClip+");", 0);
	}
}

function sprint_slideDown(layerName, xInt, yInt, xClip, yClip){
	var theLayer = d.getElementById(layerName);
	if (yClip < theLayer.offsetHeight){
		yClip += yInt;
		theLayer.style.clip = "rect(auto, "+theLayer.offsetWidth+"px, "+yClip+"px, "+xClip+"px)";
		slideagain = setTimeout("sprint_slideDown('"+layerName+"', "+xInt+", "+yInt+", "+xClip+", "+yClip+");", 0);
	}
}

function sprint_slideClose(layerName){
	var theLayer = d.getElementById(layerName);
	hideLayer(layerName);
	lastWindow = "";
}

/* Open/Close Drawer behavior */
function openClose(parentDiv,imageName,fileName) {
	var contentArea = null;
	var leftContent = null;
	if (navigator.appName.search("Microsoft") != -1) {
		firstChild = parentDiv.childNodes[0];
		secondChild = parentDiv.childNodes[1];
	} else {
		//Mozilla 5.0 reads tabs as a text object.
		firstChild = secondChild = null;
		for (i = 0; i < parentDiv.childNodes.length; i++) {
			if ( parentDiv.childNodes[i].nodeName == "DIV" ) {
				if (firstChild == null) {
					firstChild = parentDiv.childNodes[i];
				} else {
					secondChild = parentDiv.childNodes[i];
					secondChild.style.width = parentDiv.offsetWidth + "px";
				}
			} 
		}	
		
		contentArea = findObj("contentArea");
		leftContent = findObj("leftContent");

	}
	
	
	heightValue = firstChild.offsetHeight + secondChild.offsetHeight + "px";
	if (parentDiv.style.height != heightValue) {
		parentDiv.style.height = heightValue;
		secondChild.style.visibility = "visible";
		if (leftContent) {
			leftContent.style.height = leftContent.offsetHeight + secondChild.offsetHeight + "px";
			contentArea.style.height = contentArea.offsetHeight + secondChild.offsetHeight + "px";
		}
	} else {
		parentDiv.style.height = firstChild.offsetHeight + "px";
		if (leftContent) {
			leftContent.style.height = leftContent.offsetHeight - secondChild.offsetHeight - 10 + "px";
			contentArea.style.height = contentArea.offsetHeight - secondChild.offsetHeight - 60 + "px";
		}
		secondChild.style.visibility = "hidden";
	}
		//alert(leftContent.offsetHeight + " | " + secondChild.offsetHeight);

	// Plan Selector Option Header Rollover Code
	if (secondChild.style.visibility != "hidden") {
		swapImage(imageName,'','../images/'+fileName+'_on.gif',1)
	} else {
		swapImage(imageName,'','../images/'+fileName+'_off.gif',1)
	}
}

/* Open/Close Drawer behavior */
function openClose2(parentDiv2) {
	var contentArea2 = null;
	var leftContent2 = null;
	if (navigator.appName.search("Microsoft") != -1) {
		firstChild2 = parentDiv2.childNodes[0];
		secondChild2 = parentDiv2.childNodes[1];
	} else {
		//Mozilla 5.0 reads tabs as a text object.
		firstChild2 = secondChild2 = null;
		for (i = 0; i < parentDiv2.childNodes.length; i++) {
			if ( parentDiv2.childNodes[i].nodeName == "DIV" ) {
				if (firstChild2 == null) {
					firstChild2 = parentDiv2.childNodes[i];
				} else {
					secondChild2 = parentDiv2.childNodes[i];
					secondChild2.style.width = parentDiv2.offsetWidth + "px";
				}
			} 
		}	
		
		contentArea2 = findObj("contentArea");
		leftContent2 = findObj("leftContent");

	}
	
	
	heightValue2 = firstChild2.offsetHeight + secondChild2.offsetHeight + "px";
	if (parentDiv2.style.height != heightValue2) {
		parentDiv2.style.height = heightValue2;
		secondChild2.style.visibility = "visible";
		if (leftContent2) {
			leftContent2.style.height = leftContent2.offsetHeight + secondChild2.offsetHeight + "px";
			contentArea2.style.height = contentArea2.offsetHeight + secondChild2.offsetHeight + "px";
		}
	} else {
		parentDiv2.style.height = firstChild2.offsetHeight + "px";
		if (leftContent2) {
			leftContent2.style.height = leftContent2.offsetHeight - secondChild2.offsetHeight - 10 + "px";
			contentArea2.style.height = contentArea2.offsetHeight - secondChild2.offsetHeight - 60 + "px";
		}
		secondChild2.style.visibility = "hidden";
	}
		//alert(leftContent2.offsetHeight + " | " + secondChild2.offsetHeight);
		
}

function resetPaths() {
 
	var docUrl = document.location.toString();
	
	//Record all arguments in an associative array
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for (var i=0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname]=unescape(value);
	}


	// if there is no tracking var in the incoming query string - don't do anything
	if(args['id9'] == null && args['id12'] == null && args['PCode'] == null && args['ATR_ExtraOne'] == null) {return;}

	var isInternal = (docUrl.indexOf('id12=') != -1)?true:false;//Is true if window url contains id12
	
	//Reset Omniture Vars
	if (isInternal) {
		s_eVar1=args['id12']; //Set custom commerce evar
	} else {
		s_campaign=args['id9']; //Set campaign var
	}
	
	var linksArray = document.links;
	for (z = 0; z < linksArray.length; z++) {
			
			var theLink = linksArray[z];	
			var notJS = (theLink.href.indexOf('javascript:') != -1)?false:true;//Is true if window url contains id12
			if(notJS) {

					var urlString = theLink.href.substring(0, theLink.href.lastIndexOf("?"));
					if (urlString == "") {
						var urlString = theLink.href;
					} 
					var newQString = '?';
					
					var isNextLink = ((theLink.href.indexOf('nextel') != -1) || (theLink.href.indexOf('nxt') != -1))?true:false; // Is true if link contains sprintpcs.com 
					if (isNextLink) { //Is Nextel Link
						if (isInternal) {
							ThirdPartyURL = "id12";						
						} else {
							ThirdPartyURL = "id9";												
						}
					} else {
						if (isInternal) {
							ThirdPartyURL = "ATR_ExtraOne";
						} else {
							ThirdPartyURL = "PCode"
						}				
					}
					
					//Record all arguments in an associative array
					var pgArgs = new Object();
					var pgQuery = theLink.href.substring(1);
					var pgPairs = pgQuery.split("&");
					for (var i=0; i < pgPairs.length; i++) {
						var pgPos = pgPairs[i].indexOf('=');
						if (pgPos == -1) continue;
						var pgArgname = pgPairs[i].substring(0,pgPos);
						if (pgArgname.indexOf('?') > 0) { // trim off leading characters before the ? i.e. html?
							pgArgname = pgArgname.substring(pgArgname.lastIndexOf('?')+1, pgArgname.length);
						}
						var pgValue = pgPairs[i].substring(pgPos+1);
						if (pgArgname != 'PCode') {
							pgArgs[pgArgname]=unescape(pgValue);
							newQString += pgArgname + "=" + pgValue;
							if(pgPairs.length-1 != i){newQString += "&";}//don't add & to the last value
						}
					}
					
					if (args['PCode'] != null) {
						qsValue = "&PCode=" + args['PCode'];
					} else if (args['ATR_ExtraOne'] != null) {
						qsValue = "&ATR_ExtraOne=" + args['ATR_ExtraOne'];
					} else {
						if (isInternal) {
							qsValue = "&" + ThirdPartyURL + "=" + args['id12'];
						} else {
							qsValue = "&" + ThirdPartyURL + "=" + args['id9'];
						}
					}
					
					urlString += newQString + qsValue;
					
					if (urlString.indexOf('?&') != -1) {
						var str1 = urlString.substring(0,urlString.indexOf('&'));
						var str2 = urlString.substring(urlString.indexOf('&')+1, urlString.length);
						urlString = str1+str2;
					}
					
					if (urlString.indexOf('&&') != -1) {
						var str1 = urlString.substring(0,urlString.indexOf('&'));
						var str2 = urlString.substring(urlString.indexOf('&&')+1, urlString.length);
						urlString = str1+str2;
					}
					
					theLink.href = urlString;
					
			}
	}
			
}

function resetPathsOld() {

	//Record all arguments in an associative array
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for (var i=0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname]=unescape(value);
	}

	var docUrl = document.location.toString();
	var isInternal = (docUrl.indexOf('id12=') != -1)?true:false;//Is true if window url contains id12
	//Reset Omniture Vars
	if (isInternal) {
		s_eVar1=args['id12']; //Set custom commerce evar
	} else {
		s_campaign=args['id9']; //Set campaign var
	}
	
	if (queryStart != -1) {
		for (i = 0; i < navlinkCount; i++) {
			if (document.getElementById('navLink'+i)) {
				var nlink = document.getElementById('navLink'+i);
				if (nlink.href.indexOf('?') != -1) {
					nlink.href = nlink.href.substring(0, nlink.href.indexOf('=')) + pageLocation.substring(equalStart, pageLocation.length);
				} else {
					nlink.href += pageLocation.substring(queryStart, pageLocation.length);
				}
			}
		}
		//for (i = 0; i < crosslinkCount; i++) {
			//if (document.getElementById('crossLink'+i)) {
				//var clink = document.getElementById('crossLink'+i);
				//if (clink.href.indexOf('?') != -1) {
					//save the current href, minus its query
					//var currentClinkHref = clink.href.substring(0, clink.href.indexOf('?'));
					//save the current query, minus the initial '?':
					//var currentClinkQuery = clink.href.substring(clink.href.indexOf('?') + 1);
					//clink.href = currentClinkHref + "?" + currentClinkQuery + "&" + locationQueryString;
				//} else {
					//clink.href += pageLocation.substring(queryStart, pageLocation.length);
				//}
			//}
		//}
		for (i = 0; i < buylinkCount; i++) {
			if (document.getElementById('buyLink'+i)) {
				var blink = document.getElementById('buyLink'+i);
				var isSprintLink = (blink.href.indexOf('sprintpcs.com') != -1)?true:false; // Is true if link contains sprintpcs.com 
				var ThirdPartyURL = '';
				var LegacyURL = '';
				//Check if the buy link goes to Sprint or Nextel
				if (isSprintLink) {
					if (isInternal) {
						ThirdPartyURL = "ATR_ExtraOne";
					} else {
						ThirdPartyURL = "pCode"
					}
				} else { //Is Nextel Link
					if (isInternal) {
						ThirdPartyURL = "id12";						
					} else {
						ThirdPartyURL = "id9";												
					}
				}
				//Rewrite URL
				if ((docUrl.indexOf('id12=') >= 0) || (docUrl.indexOf('id9=') >= 0))
				{
					if (blink.href.indexOf('&') != -1){
						//set & url, appending url string
						blink.href = blink.href.substring(0, blink.href.indexOf('&')) + "&" + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
					} else {
						//set no & url, appending url string
						blink.href += "&" + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
					}
				}
			}
		}

		for (i = 0; i < planlinkCount; i++) {
			if (document.getElementById('planLink'+i)) {
				var plink = document.getElementById('planLink'+i);
				var isSprintLink = (plink.href.indexOf('sprintpcs.com') != -1)?true:false; // Is true if link contains sprintpcs.com 
				var ThirdPartyURL = '';
				var LegacyURL = '';
				//Check if the buy link goes to Sprint or Nextel
				if (isSprintLink) {
					if (isInternal) {
						ThirdPartyURL = "ATR_ExtraOne";
					} else {
						ThirdPartyURL = "pCode"
					}
				} else { //Is Nextel Link
					if (isInternal) {
						ThirdPartyURL = "id12";						
					} else {
						ThirdPartyURL = "id9";												
					}
				}
				//Rewrite URL
					if ((docUrl.indexOf('id12=') >= 0) || (docUrl.indexOf('id9=') >= 0))
					{						
						if (plink.href.indexOf('&') != -1){
							//set & url, appending url string
							plink.href = plink.href.substring(0, plink.href.indexOf('&')) + "&" + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
						} else {
							//set no & url, appending url string
							plink.href = plink.href.substring(0, plink.href.indexOf('?')+1) + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
						}
					}
			}
		}
	}
}
/*
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
*/
function resetMaps() {
	var docUrl = document.location.toString();
	var isInternal = (docUrl.indexOf('id12=') != -1)?true:false;//Is true if window url contains id12
	
	if (queryStart != -1) {
		for (var i = 0; i < imageMapCount; i++) {
			if (document.getElementById("Map"+i)) {
				myMap = document.getElementById("Map"+i);
				for (var nodes = 0; nodes < myMap.childNodes.length; nodes++) {
					mlink = myMap.childNodes[nodes];
					if(mlink.href) {
	
						var isSprintLink = (mlink.href.indexOf('sprintpcs.com') != -1)?true:false; // Is true if link contains sprintpcs.com 
						var ThirdPartyURL = '';
						var LegacyURL = '';
						//Check if the buy link goes to Sprint or Nextel
						if (isSprintLink) {
							if (isInternal) {
								ThirdPartyURL = "ATR_ExtraOne";
							} else {
								ThirdPartyURL = "pCode"
							}
						} else { //Is Nextel Link
							if (isInternal) {
								ThirdPartyURL = "id12";						
							} else {
								ThirdPartyURL = "id9";												
							}
						}
						//Rewrite URL
						if ((docUrl.indexOf('id12=') >= 0) || (docUrl.indexOf('id9=') >= 0))
						{
							if (mlink.href.indexOf('&') != -1){
								//set & url, appending url string
								mlink.href = mlink.href.substring(0, mlink.href.indexOf('&')) + "&" + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
							} else {
								//set no & url, appending url string
								mlink.href = mlink.href.substring(0, mlink.href.indexOf('?')+1) + ThirdPartyURL + pageLocation.substring(equalStart, pageLocation.length);
							}
						}
					}
				}
			}
		}
	}
}




function randomBanner(path_to_images){
  var i=0;
  banners = new Array();
  banners[0] = '<img src="' + path_to_images + 'MBB_Banner_Carpe.jpg" />';
  banners[1] = '<img src="' + path_to_images + 'MBB_Banner_Now_Available.jpg" />';
  banners[2] = '<img src="' + path_to_images + 'MBB_Banner_SlowBusiness.jpg" />';
  today = new Date();
  i=today.getSeconds();
  n=banners.length;
  return banners[i-Math.round((i-1)/n)*n];
}
