// ***************************** MOTOROLA VALIDATION BEGINS HERE *********************************
function selectManu(type){
	for(var s=0;s<document.pdfForm.manufacturer.length;s++)
		if(document.pdfForm.manufacturer[s].value == type)
		document.pdfForm.manufacturer[s].selected = true ;
}
function selectModel(type){
	for(var s=0;s<document.pdfForm.model.length;s++)
		if(document.pdfForm.model[s].value == type)
		document.pdfForm.model[s].selected = true ; 
}
function selectState(type){
	for(var s=0;s<document.pdfForm.selState.length;s++)
		if(document.pdfForm.selState[s].value == type)
		document.pdfForm.selState[s].selected = true ; 
}
function selectCountry(type){
	for(var s=0;s<document.pdfForm.selCountry.length;s++)
		if(document.pdfForm.selCountry[s].value == type)
		document.pdfForm.selCountry[s].selected = true ; 
}
function ValidateCustDetails(){
var strErrorMsg;
strErrorMsg = '';
	if (document.pdfForm.txtFName.value == ''){
	strErrorMsg = strErrorMsg + "Please Enter First Name."
		alert(strErrorMsg);
		document.pdfForm.txtFName.focus();
		return false ;
	}
	if (document.pdfForm.txtLName.value == ''){
	strErrorMsg = strErrorMsg + "Please Enter Last Name."
		alert(strErrorMsg);
		document.pdfForm.txtLName.focus();
		return false ;
	}
	if (document.pdfForm.txtAdd1.value == ''){
		alert("Please Enter Address.");
		document.pdfForm.txtAdd1.focus();
		return false ;
	}
	if (document.pdfForm.txtCity.value == ''){
		alert("Please Enter City.");
		document.pdfForm.txtCity.focus();
		return false ;
	}
	if (document.pdfForm.selState.value == ''){
		alert("Please Select State.");
		document.pdfForm.selState.focus();
		return false ;
	}
	if (document.pdfForm.txtZip.value == ''){
		alert("Please Enter Zip Code.");
		document.pdfForm.txtZip.focus();
		return false ;
	}
	if (document.pdfForm.selCountry.value == ''){
		alert("Please Select Country.");
		document.pdfForm.selCountry.focus();
		return false ;
	}
	if (document.pdfForm.txtPhone.value == ''){
		alert("Please Enter Phone.");
		document.pdfForm.txtPhone.focus();
		return false ;
	}
	if ((document.pdfForm.txtPhone.value != '') && (!isPhoneOK(document.pdfForm.txtPhone.value))){
		alert("Please check the Phone Number");
		document.pdfForm.txtPhone.focus();
		return false ;
	}
	if (document.pdfForm.txtEmail.value == ''){
		alert("Please Enter E-Mail Address.");
		document.pdfForm.txtEmail.focus();
		return false ;
	}
	if ((document.pdfForm.txtEmail.value != '') && (!isEmailOK(document.pdfForm.txtEmail.value))){
		alert("Please check the Email Address");
		document.pdfForm.txtEmail.focus();
		return false ;
	}
	if (document.pdfForm.year.value == ''){
		alert("Please Enter Your Date of Birth.");
		document.pdfForm.txtAge.focus();
		return false ;
		}
return true ;
	
	
}
function isEmailOK(usrInput){
	var rXP = new RegExp("^\\w+([-.]\\w+)?[@]\\w+([-.]\\w+)*([.][a-zA-Z]+)$")
	if(rXP.test(usrInput))
		{return true}
	else
		{return false}
}
function isPhoneOK(usrInput){
	var rXP = new RegExp("\\(?\\d{3,5}\\)?\\s?[-\\/]\\s?(\\d{4,7})$")
	if(rXP.test(usrInput))
		{return true}
	else
		{return false}
}
function formatPhoneNumber(txtObj){
	var txtVal ;
	txtVal = txtObj.value ;
	if (txtVal.length == 3){ txtObj.value = txtVal + '-' } ;
	if (txtVal.length == 7){ txtObj.value = txtVal + '-' } ;
}

// ***************************** Motorola VALIDATION ENDS HERE  ********************************* 

  // ***************************** Virgin Mobile VALIDATION ENDS HERE  ********************************* 
  
var msgtop=190 // Set the top position of the div
var msgleft=380 // Set the left position of the div 
var tborder="0"
var cspace="0"
var cpad="0"
var tabheight=20 // Set the height of table
var tabwidth=350 // Set the width of table
var td1height=20
var td2height=100
var boxt=""
function Domsg(flag)
{
hidebox() // Hide the box after clicking on text link in box
if(flag=="Yes")
{
document.location="http://www.virginmobileusa.com";
}
else
{
document.location="http://www.virginmobileusa.com";
}
}


function y2k(number) { return (number < 1900) ? number + 1900 : number; }


    function isDate(day,month,year) {
    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
    (month == test.getMonth()) &&
    (day == test.getDate()) )
    return true;
    else
    return false;
}

function getMonthLength(month,year,julianFlag)


    {
    var ml;
    if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10||month==12)


        {ml = 31;}


            else {


                if(month==2) {
                ml = 28;
                if(!(year%4) && (julianFlag==1 || year%100 || !(year%400)))
                ml++;
            }
            else


                {ml = 30;}
            }
            return ml; 
        }


        function CheckAge(pdfForm)


            {
            var myLimit = 13;
            
            // Get Current Date
            Today=new Date();
            var yd = Today.getYear();
            var md = Today.getMonth();
            var dd = Today.getDate();
            
            //check for year on case netscape browser
            
            	if (yd < 1900) 


                	{
                	yd = yd + 1900;
            }
            // Get Date from the form
            //var birthDate = document.pdfForm.txtAge.value;
            //birthDate.substring(0,2)
            var mb = document.pdfForm.month.options[document.pdfForm.month.selectedIndex].value; //birthDate.substring(0,2); 
            var db =document.pdfForm.date.options[document.pdfForm.date.selectedIndex].value; //birthDate.substring(3,5); 
            var yb =document.pdfForm.year.options[document.pdfForm.year.selectedIndex].value; // birthDate.substring(6,10)
           MNames=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
            "Oct","Nov","Dec");
            
            
            if((db == 0) || 
            (mb == 0) || 
            (yb == 0))


                {
                alert("You must enter a valid date.");
                document.pdfForm.month.focus();
                return false;
            }
            else
            {
                		if (isDate(db,mb,yb)==false) 
                             {
                    		 alert("You must enter a valid date");
                    		 document.pdfForm.txtAge.focus();
                    		 return false;
                    		 }
                }
                // Month length 0->use calendar length
                var mLength = 0;
                // 0 if Gregorian, 1 is Julian
                var isJulian = 1;
                var ma=0;
                var ya=0;
                var da = dd-db;
                // This is the all-important day borrowi
                //     ng code.
                if(da<0)

 {
                    md--;
                    // Borrow months from the year if necess
                    //     sary.
                    if(md<1)
                    {
                        	 yd--;
                        	 // Determine no. of months in year
                        	 if(mLength)
                        	 {md=md+parseInt(365/mLength);}
                        	 else
                        	 {md=md+12;}
                    }
                    if(mLength==0) // Use real month length if no fixed


                        { // length is indicated - note that we add a leap day if necessary.
                        ml=getMonthLength(md,yd,isJulian);
                        	 da=da+ml;
                    } 
                    // For this case, everything works like 
                    //     it did in elementary school.
                    else
                    	 {da+=mLength;} // Use fixed month length
 }
                ma = md - mb;
                // Month borrowing code - borrows months
                //     from years.
                if(ma<0)
                {
                    yd--;
                    if(mLength!=0)
                    	 {ma=ma+parseInt(365/mLength);}
                    else
                    	 {ma=ma+12;}
                }
                ya = yd - yb;
                // Find if you are over AgeLimit.
                if(ya>=myLimit)
                {
                return true;
                }
                else
                { 
//var theString;
//theString="<h1>Hello</h1>" 
//if (document.layers) // Netscape 4.0+
//{
//document.formbox.document.write(theString)
//document.formbox.document.close()
//document.formbox.left=msgleft
//document.formbox.top=msgtop+40
//document.formbox.visibility="show"
//}
//else
//{
var conn = confirm("Sorry, but registration cannot be accepted for customers under 13 years of age.\nYou may still print a shipping label and recycle your phone anonymously.\nClick OK to print your shipping label now.");
if (conn==true)
{
document.pdfForm.txtFName.value="";
document.pdfForm.txtLName.value="";
document.pdfForm.txtAdd1.value="";
document.pdfForm.txtAdd2.value="";
document.pdfForm.txtCity.value="";
document.pdfForm.txtZip.value="";
document.pdfForm.selState.value="";
document.pdfForm.selCountry.value="";
document.pdfForm.txtEmail.value="";
document.pdfForm.month.value="";
document.pdfForm.date.value="";
document.pdfForm.year.value="";
document.location="index.asp?actionMode=SaveAnonymous";
}
else
{
document.pdfForm.txtFName.value="";
document.pdfForm.txtLName.value="";
document.pdfForm.txtAdd1.value="";
document.pdfForm.txtAdd2.value="";
document.pdfForm.txtCity.value="";
document.pdfForm.txtZip.value="";
document.pdfForm.selState.value="";
document.pdfForm.selCountry.value="";
document.pdfForm.txtEmail.value="";
document.pdfForm.month.value="";
document.pdfForm.date.value="";
document.pdfForm.year.value="";
document.location="http://www.virginmobileusa.com";
}
return false;
}
}
//}  
            

function hidebox()
{
if (document.layers) // Netscape 4.0+
{
document.pdfForm.visibility="hidden"
}
if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
{
document.getElementById("pdfForm").style.visibility="hidden"
}
}      
                  
            



