function qsrf(name)
{
name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
var regexS = "[\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}

function showLess( link )
{
	location.href = location.href.replace(/f_mode=1/,"f_mode=0");
	return false;
}

function showAll( link )
{
	var loc = location.href;
	loc = loc.replace(/\&f_mode=0/,"");
	loc = loc + "&f_mode=1";
	location.href = loc;
	return false;
}


function setCM(q) {
	if ( document.getElementById('promo') )
	{
		var a = document.getElementById('promo').parentNode;
		if ( a.tagName.toLowerCase() == 'a' )
		{
			var promotion_name = document.getElementById('promo').alt;
			a.href += (a.href.indexOf('?') >=0 ? '&' : '?') + 'cm_re=' + encodeURI(q) + '-_-' + encodeURI(promotion_name) + '-_-abc';
		}
	}
}

function submitCompare(){
	document.phoneoverview.action.value = 'viewPhoneCompare';
	document.phoneoverview.submit();
}

function verifyForm(selectedphoneid) {
	var tag = document.phoneoverview.elements["phoneId"];
	var selectedTag = document.getElementById('phoneid' + selectedphoneid);
	var total = 0;

	for (var i=0; i < tag.length ; i++)
	{
		if (tag[i].checked)
		{
			total++;
		}
	}

	if (total > 3)
	{
		for (var i=tag.length-1; i >= 0 ; i--)
		{
			if ((tag[i].checked) && (tag[i].value == selectedTag.value))
			{
				tag[i].checked = 0;
				i = -1;
			}
		}
		document.getElementById("error").style.visibility = "visible";
		document.getElementById("error").style.position = "relative";
	}

	return false;
}


function adjustBrand(Obj)
{
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = Obj.toLowerCase();

	strLen = tmpStr.length;
	if (strLen > 0)  
	{

		for (index = 0; index < strLen; index++) 
		{
			if (index == 0)
			{
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}else{
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	
		if (tmpStr == "Blackberry")
		{
			tmpStr = "BlackBerry&reg;";
		}
		else if (tmpStr == "Palm")
		{
			tmpStr = "Palm&reg;";
		}
		else if (tmpStr == "Lg")
		{
			tmpStr = "LG";
		}
		
	document.write(tmpStr);
	}
}


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+ ";domain=verizonwireless.com";
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function checkCookie()
{
	ZIPCODE=getCookie('ZIPCODE');
	if (document.info)
	{
	document.info.zipcode.value = ZIPCODE;
	}
}

function resetCookie()
{
	ZIPCODE=getCookie('ZIPCODE');
	newZip = document.info.zipcode.value;
	if (ZIPCODE != newZip)
	{
		setCookie('ZIPCODE',newZip,365);
	}
	else
	{
		setCookie('ZIPCODE',ZIPCODE,365);
	}
}

function footNote()
{
    if(typeof(footnote) != "undefined"){ document.getElementById('footnoteDIV').innerHTML = footnote; }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function png_init() {

	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 

	{
	   for(var i=0; i<document.images.length; i++)
	   {
			  var img = document.images[i]
			  var imgName = img.src.toUpperCase()
			  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			  {
					 var imgID = (img.id) ? "id='" + img.id + "' " : ""
					 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
					 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
					 var imgStyle = "display:inline-block" + img.style.cssText 
					 if (img.align == "left") imgStyle = "float:left;" + imgStyle
					 if (img.align == "right") imgStyle = "float:right;" + imgStyle
					 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
					 var strNewHTML = "<span " + imgID + imgClass + imgTitle
					 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
					 img.outerHTML = strNewHTML
					 i = i-1
			  }
	   }
	}
}


