function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function jump(fe){
	var opt_key = fe.selectedIndex;
	var url_val = fe.options[opt_key].value;
	window.open(url_val,'_top');
	return true;
 	}

function popWin(url) {
remote = window.open(url,"netnowhelpwin","width=650,height=420,resizable=1,menubar=0,status=0,scrollbars=1");
remote.opener.name = "netnoswhelp";
}

function popUp(url) {     //function for VeriSign Seal PopUp
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=650,height=480');
self.name = "mainWin";
}

function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }

function _CF_checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Bret's mod.
	return _CF_checknumber(object_value);
    }

function _CF_checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Bret's modification to disallow leading "."
	if (check_char < 5)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
                     //Brets mod - add.
                        decimal = true;
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks
		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }

function  _CF_checkitem_qty(_CF_this)
    {
    if  (!_CF_checkinteger(_CF_this.Quantity.value))

        {
        if  (!_CF_onError(_CF_this, _CF_this.Quantity, _CF_this.Quantity.value, "Quantity must be a number greater than zero (no decimals or alphabet characters)."))
            {
            return false; 
            }
        }
    return true;
    }


function check_model(modelID)  
  {  
  var selected_model = modelID.value;  
  if(selected_model=="dummy")  
   {
   alert("Please first select a phone model from the drop-down list, and then click the 'Go' button");
     return false; 
   }     
  }
  
  //Used to check discount code validity on coPay.cfm
  function check_code(DiscountCode, MinimumMet)  
  {  
  var discount_code = DiscountCode.value;
  var minmet = MinimumMet.value;    
  if(discount_code!="CPSAVE10" && discount_code!="CRCSAVE10")  
   {
   alert("The Discount Code you have entered is not valid.  Please check that you have entered the code correctly. Codes are case sensitive.");
     return false; 
   } 
  else {
     if(discount_code=="GIVEMOBILE"  || discount_code=="CPSAVE10")
 	{
	  alert("The Discount Code you have entered has expired and is no longer valid.");
		return false;
    }     
	   }
   if(minmet=="no")
    {
   alert("Discount code only valid on orders of $40 or more.");
     return false; 
   } 
  }