//<!---krishan edit-------------Function to change the On and Off text of show hide requesting attempts-->
function change(obj){
	var temp = document.getElementById(obj);
	temp.innerHTML = ((temp.innerHTML == "On") ? "Off":"On");
}
//------------------------------------------------------------------------>

function hide(obj1){
	var temp = document.getElementById(obj1).style;
	temp.display = "none";
}
function show(oba,obb,obc,obd,obe,obf){
	document.getElementById(oba).style.display = "block";
	document.getElementById(obb).style.display = "none";
	document.getElementById(obc).style.display = "none";
	document.getElementById(obd).style.display = "none";
	document.getElementById(obe).style.display = "none";
	document.getElementById(obf).style.display = "none";
}

//<!-------------------Function to display and hide objects
function display(obj1,obj2){
	var temp = document.getElementById(obj1).style;
	temp.display = ((temp.display == "none") ? "block" : "none");
	change(obj2);
}
function display(obj1){
	var temp = document.getElementById(obj1).style;
	temp.display = ((temp.display == "none") ? "block" : "none");
	
}
function bgchange(obj1,obj2){
	document.getElementById(obj1).style.background = obj2;
}

function display2(ob1,ob2,ob3){
	var temp =  document.getElementById(ob1).style;
	var temp2 = document.getElementById(ob2).style;
	
	temp.display =  "block";
	temp2.display = "none";
	for(i=1;i<=5;i++){
		var tp = 'tb'+i;
		if(i == ob3)
			document.getElementById(tp).style.background = '#c10100';
		else
			document.getElementById(tp).style.background = '#ffffff';
	}
}

function display3(oj1,oj2,oj3,oj4){
	var temp = document.getElementById(oj1).style;
	var temp2 = document.getElementById(oj2).style;
	var temp3 = document.getElementById(oj3).style;
	
	temp.display = "block";
	temp2.display = "none";
	temp3.display = "none";

	for(i=1;i<=5;i++){
		var tp = 'tb'+i;
		if(i == oj4)
			document.getElementById(tp).style.background = '#c10100';
		else
			document.getElementById(tp).style.background = '#ffffff';
	}
	
}

//<!------------------Function to disable and enable readonly properties of objects -->
function edit(obj1,obj2) {
	var temp = document.getElementById(obj1);
	
	if(temp.readOnly || !temp.readOnly)
		temp.readOnly = !temp.readOnly;

	change(obj2);
}

function openWindow(url){
	popupWin = window.open(url, 'remote',
'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, dependent, width=430, height=230, left=50, top=50')
}

function openWindow1(url){
	var width=283;
	var height=300;
	var y=screen.height/2-height/2;
	var x=screen.width/2-width/2;


	popupWin = window.open(url, 'remote',
'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=yes, dependent, width="width", height="height", left="x", top="y"')
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkFldVal(frm)
{
	if(!IsEmpty(eval(frm.keyword),"Please type search keyword."))
	{
		frm.keyword.focus();
		return false;
	 }

	 return true;

}
//-->

function orderPagePaymentOptions(obj){
	var v1 = document.getElementById('year');
	var v2 = document.getElementById('month');
	var v3 = document.getElementById('CCVNo');
	var v4 = document.getElementById('cardnumber');
	var v5 = document.getElementById('holdername');
	var v6 = document.getElementById('cardPay');
	var v7 = document.getElementById('paypalCheckout');
	var v8 = document.getElementById('creditCardCheckout');
	var v9 = document.getElementById('billingInfo1');
	var v10 = document.getElementById('billingInfo2');
	
	if(obj == '1'){
		v1.disabled = false;
		v2.disabled = false;
		v3.disabled = false;
		v4.disabled = false;
		v5.disabled = false;
		v6.style.opacity = '1'
		v7.style.display = 'none';
		v8.style.display = 'block';
		v9.style.opacity = '1';
		v10.style.opacity = '1';
	}else{
		v1.disabled = true;
		v2.disabled = true;
		v3.disabled = true;
		v4.disabled = true;
		v5.disabled = true;
		v6.style.opacity = '.1'
		v7.style.display = 'block';
		v8.style.display = 'none';
		v9.style.opacity = '.1';
		v10.style.opacity = '.1';
		
	
		
	}
}
//-------------stop edit------------------------------------------------------------>


//function to Check Empty
  function IsEmpty(fld,mesg)
  {
	reg = / /g;
  	str = fld.value;
  	res = str.replace(reg,"");
	//res = str.replace("'","'''");
	reg = /\s/g;
	res = res.replace(reg,"");
  	if(res == "")
  	{
  		alert(mesg);
  		fld.value="";
  		fld.focus();
  		return false;
  	}
	return true;
  }

//function to Check Empty but no alert message & return bool value
  function IsEmptyNoMsg(fld)
  {
  	reg = / /g;
  	str = fld.value;
  	res = str.replace(reg,"");
	reg = /\s/g;
	res = res.replace(reg,"");
  	if(res == "")
  	{
  		return true;
  	}		
  	return false;
  }
  
//function to Check email
// opt value 0 if mandatory and 1 if not
function CheckEmail(fld,msg,opt)
{
	if(opt=="0" || fld.value!="")
	{
	
	var emailStr=fld.value;
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	var emailPat=/^(.+)@(.+)$/;

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	var validChars="\[^\\s" + specialChars + "\]";

	var quotedUser="(\"[^\"]*\")";

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	var word="(" + atom + "|" + quotedUser + ")";

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null)
	{
		fld.focus();
		fld.select();
		alert(msg);
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	   }
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

	// user is not valid
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	   }
	}
	return true;
	}


	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	   }
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	}

	if (len<2) {
	fld.focus();
	fld.select();
	alert(msg);
	return false;
	}
	return true;
}
return true;
}

//function to Check Phone
function CheckPhone(fld1,fld2,fld3)
{
	if(fld1.value=='')
    {
		alert('Telephone number should be in xxx-xxx-xxxx format only.');
		fld1.focus();
		return false;
	}
    if(isNaN(fld1.value)==true)
    {
		alert('Telephone number could contain numeric values only.');
		fld1.focus();
		return false;
    }
    if(fld1.value.length!=3)
    {
		alert('Telephone number should be in xxx-xxx-xxxx format only.');
		fld1.focus();
		return false;
    }
    if(isNaN(fld2.value)==true)
    {
		alert('Telephone number could contain numeric values only.');
		fld2.focus();
		return false;
    }
	if(fld2.value.length!=3)
	{
		alert('Telephone number should be in xxx-xxx-xxxx format only.');
		fld2.focus();
		return false;
	}
	if(isNaN(fld3.value)==true)
	{
		alert('Telephone number could contain numeric values only.');
		fld3.focus();
		return false;
	}
	if(fld3.value.length!=4)
	{
		alert('Telephone number should be in xxx-xxx-xxxx format only.');
		fld3.focus();
		return false;
	}
	return true;
}

function checkjs()
{
	var js="yes";
	return js;
}


function UserValidation(FRMName)
{

//	alert(FRMName.ftitle.value)

	if(!IsEmpty(FRMName.ffirstname,"Please type your 'First Name' in the space provided"))
	{
		return false;
	}
	if(!IsEmpty(FRMName.flastname,"Please type your 'Last name' in the space provided"))
	{
		return false;
	}
	if(!CheckEmail(FRMName.femail,"Please type a valid 'Email address' in the space provided",0))
	{
		return false;
	}
	if(!IsEmpty(FRMName.fpassword,"Please type your 'Password' in the space provided."))
	{
		return false;
	}
	if(!IsEmpty(FRMName.fconfirm,"Please confirm your password in the space provided."))
	{
		return false;
	}

	if(FRMName.fpassword.value != FRMName.fconfirm.value)
	{
		alert("The password entered in the 'Confirm Password' field does \nnot match your password; if necessary, please re-type \nyour password and confirm in the spaces provided.")

		return false;
	}
	if(!IsEmpty(FRMName.freminder,"Please type your 'Password Reminder' in the space provided."))
	{
		return false;
	}

	if(!IsEmpty(FRMName.fjob,"Please type your 'Job title' in the space provided'"))
	{
		return false;
	}
	if(!IsEmpty(FRMName.forganisation,"Please type your 'Organisation' in the space provided"))
	{
		return false;
	}
	if(!IsEmpty(FRMName.ftel,"Please type your 'Telephone Number' in the space provided"))
	{
		return false;
	}
}

function userLoginValidate(FRMName)
{

	if(!IsEmpty(FRMName.femail,"Please enter your 'username' in the space provided."))
	{
		return false;
	}

	if(!CheckEmail(FRMName.femail,"Please type a valid 'Email address' in the space provided",0))
	{
		return false;
	}

	if(!IsEmpty(FRMName.fpassword,"Please enter your 'Password' in the space provided."))
	{
		return false;
	}

}

function CheckUrl(fld,mesg)
{
 	if(fld.value.indexOf("http://")==-1 || fld.value.indexOf(".")==-1)
 	{
		alert(mesg);
		fld.focus();
		fld.select();
 		return false;
	}
	return true;
}    


// validFileFormat=/(.gif|.GIF|.jpg|.JPG|.jpeg|.JPEG|.png|.PNG)$/;
function IsValidFileFormat(fld, validFileFormat, mesg)
{
	if(!validFileFormat.test(fld.value))
	{
		alert(mesg);
		fld.focus();
		fld.select();
		return false;
	}

	return true;
} 



function TestFileType(fileName,fileTypes)
	{


   if (!fileName) return;
   dots = fileName.split(".")

   //get the part AFTER the LAST period.

   fileType = "." + dots[dots.length-1];
    return (fileTypes.join(".").indexOf(fileType) != -1) ?true: alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
   return false;   
}

//onSubmit validation for Number
function IsNumber(fld,mesg)
{
	reg = / /g;
	str = fld.value;
	res = str.replace(reg,"");
	reg = /\s/g;
	res = res.replace(reg,"");
	
	if(res == "" || isNaN(res))
	{
		alert(mesg);
		fld.select();
		fld.focus();
		return false;
	}		
	return true;
}

//onSubmit validation for Albhabet
function IsAlbhabet(fld,mesg)
{
	var teststring=/[a-zA-Z\s]+$/; 
	str = fld.value;

	if (str.search(teststring)==-1)
	{
		alert(mesg);
		return false;
	}
	else
		return true;
	
}




function IsFldValChanged(frm)
{
	frm.haschanged.value=1;
}



	//-------------------------------------//
	//  keycode		=	key				   //
	//-------------------------------------//
	//	'13'		=	'Enter Key Press'  //
	//	'40'		=	'('                // 
	//	'41'		=	')'                //
	//	'45'		=	'-'                //
	//	'46'		=	'.'                //
	//	'48'		=	'0'                //
	//	'57'		=	'9'                //
	//	'65'		=	'A'                //
	//	'90'		=	'Z'                //
	//	'97'		=	'a'                //
	//	'122'		=	'z'                //
	//-------------------------------------//



// allow only numberic key
function undoNonNumValue(fld)
{
	var key;
	key	= event.keyCode;
	
	if(key==13 || key==46)
	{}
	else if(key < 48 || key > 57)
	{
		window.event.returnValue=false;
	}	
}

// allow only albhabet key
function undoNumValue(fld)
{
	var key;
	key	= event.keyCode;
	
	if(key==13 || key==46)	// action on 'enter key' and 'dot' key
	{}
	else if(key < 65 || key > 90 )
	{	
		if(key < 97 || key > 122)
			window.event.returnValue=false;
	}	
}

function formatAmt(fld)
{
	reg	= / /g;
	amt	= fld.value;
	amt	= amt.replace(reg, "");
	if(amt != "")
	{
		if(amt.indexOf(".")== -1)
		{
			fld.value = amt+".00";
		}
		else
		{
			arr = amt.split(".")
			str = arr[1];
			if(str == "")
			{
				fld.value = amt+"00";
			}
			else
			{
				switch(str.length)
				{
					case 0:
						fld.value = amt+".00";
						break;
					case 1:
						fld.value = amt+"0";
						break;
				}
			}
		}
	}
}

function LimitTextArea(fld, len)
{
	str = fld.value;
	if(str.length >= len)
	{
		alert("Can not be added more words");
		window.event.returnValue=false;
	}
}

function DelConfirm()
{
 var where_to= confirm("Are you sure you wanted to delete this?");
 if (where_to== true)
 {
   return true
 }
 else
 {
  return false;
  }
}


// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-"+" "+".";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
	return returnString;
}

//function checkInternationalPhone(strPhone){
//s=stripCharsInBag(strPhone,validWorldPhoneChars);
//return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
//}

function checkInternationalPhone(objElement)
{
	// non-digit characters which are allowed in phone numbers
	 var phoneNumberDelimiters1 = "-";
	 var phoneNumberDelimiters2 = ".";
	 var phoneNumberDelimiters3 = " ";
	 // Minimum no of digits in an international phone no.
	var minDigitsInIPhoneNumber = 10;
 	var strValue = objElement;
    
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters1 + "+";
	s=stripCharsInBag(strValue,validWorldPhoneChars);

	var validWorldPhoneChars = phoneNumberDelimiters2 + "+";
	s=stripCharsInBag(s,validWorldPhoneChars);

	var validWorldPhoneChars = phoneNumberDelimiters3 + "+";
	s=stripCharsInBag(s,validWorldPhoneChars);

 return (ValidateInteger(s) && s.length >= minDigitsInIPhoneNumber);
 }




function ValidateInteger(objElement)

// check for valid numeric strings 

{

var strString = objElement;

var strValidChars = "0123456789";

var strChar;

var blnResult = true;
// test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
	blnResult = false;
}
}

return blnResult;

}





function billingShippingAddressValidation()
{
	FRM = document.confirmed;
	if(document.confirmed.BillingAddType[1].checked)
	{
		if(!IsEmpty(FRM.Billing_FirstName_Inter,"Please enter your First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_LastName_Inter,"Please enter your Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_StreetAddress_Inter,"Please enter your Street Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_CityVal_Inter,"Please enter your City"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_CountryName_Inter,"Please enter your Country"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_Zipcode_Inter,"Please enter your Zip Code"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_DayTimePhone_Inter,"Please enter your Day Phone"))
		{
			return false;
		}
		if(!(FRM.Billing_DayTimePhone_Inter.value))
		{
			alert("Invalid Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
		
		if(FRM.Billing_DayTimePhone_Inter.value != "")
		{
			if(!checkInternationalPhone(FRM.Billing_DayTimePhone_Inter.value))
			{
				alert("Invalid Phone, Please enter Daytime Phone in \"123-555-6789\" format");
				return false;
			}
		}
		

	}
	
	if(document.confirmed.BillingAddType[0].checked)
	{
		if(!IsEmpty(FRM.Billing_FirstName_USACanada,"Please enter your First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_LastName_USACanada,"Please enter your Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_StreetAddress_USACanada,"Please enter your Street Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_City_USACanada,"Please enter your City"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_StateName_USACanada,"Please enter your State of Territory / Canadian Province"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_Zipcode_USACanada,"Please enter your Zip Code"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_DayTimePhone_USACanada,"Please enter your Day Phone"))
		{
			return false;
		}
		if(!checkInternationalPhone(FRM.Billing_DayTimePhone_USACanada.value))
		{
			alert("Invalid Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
				
		if(FRM.Billing_DayTimePhone_USACanada.value != "")
		{
			if(!checkInternationalPhone(FRM.Billing_DayTimePhone_USACanada.value))
			{
				alert("Invalid Phone, Please enter Daytime Phone in \"123-555-6789\" format");
				return false;
			}
		}
		

		if(FRM.verifyf){
			if(!IsEmpty(FRM.Billing_Email_USACanada,"Please enter your billing email.(very important)"))
				return false;
			if(!CheckEmail(FRM.Billing_Email_USACanada,"Please enter your correct billing email!","0"))
				return false;
		}
		
	}
	if(document.confirmed.BillingAddType[2].checked)
	{
		if(!IsEmpty(FRM.Billing_FirstName_Military,"Please enter your First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_LastName_Military,"Please enter your Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_MilitaryAddress_1_Military,"Please enter your Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_MilitaryCity_Military,"Please enter your City"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_StateName_Military,"Please enter your State"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_Zipcode_Military,"Please enter your Zip Code"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Billing_DayTimePhone_Military,"Please enter your Day Phone"))
		{
			return false;
		}
		if(!checkInternationalPhone(FRM.Billing_DayTimePhone_Military.value))
		{
			alert("Invalid Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
		
		if(FRM.Billing_DayTimePhone_Military.value != "")
		{
			if(!checkInternationalPhone(FRM.Billing_DayTimePhone_Military.value))
			{
				alert("Invalid Phone, Please enter DayTime Phone in \"123-555-6789\" format");
				return false;
			}
		}
		if(FRM.verifyf){
			if(!IsEmpty(FRM.Billing_Email_Military,"Please enter your billing email.(very important)"))
				return false;
			if(!CheckEmail(FRM.Billing_Email_Military,"Please enter your correct billing email!","0"))
				return false;
		}
	}
	
	
		if(document.confirmed.ShippingAddType[1].checked)
	{
		if(!IsEmpty(FRM.Shipping_FirstName_Inter,"Please enter your Shipping First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_LastName_Inter,"Please enter your Shipping Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_StreetAddress_Inter,"Please enter your Shipping Street Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_Zipcode_Inter,"Please enter your Shipping ZipCode"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_CityVal_Inter,"Please enter your Shipping City"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_CountryName_Inter,"Please enter your Shipping Country"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_DayTimePhone_Inter,"Please enter your Shipping Day Phone"))
		{
			return false;
		}
		if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_Inter.value))
		{
			alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
		
		if(FRM.Shipping_DayTimePhone_Inter.value != "")
		{
			if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_Inter.value))
			{
				alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
				return false;
			}
		}
		

	}
	
	
	if(document.confirmed.ShipTo.value == "2")
	{
	if(document.confirmed.ShippingAddType[0].checked)
	{
		if(!IsEmpty(FRM.Shipping_FirstName_USACanada,"Please enter your Shipping First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_LastName_USACanada,"Please enter your Shipping Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_StreetAddress_USACanada,"Please enter your Shipping Street Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_City_USACanada,"Please enter your Shipping International Province / Territory"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_StateName_USACanada,"Please enter your Shipping State"))
		{
			return false;
		}
		
		if(!IsEmpty(FRM.Shipping_Zipcode_USACanada,"Please enter your Shipping Zip Code"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_DayTimePhone_USACanada,"Please enter your Shipping Day Phone"))
		{
			return false;
		}
		if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_USACanada.value))
		{
			alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
		
		if(FRM.Shipping_DayTimePhone_USACanada.value != "")
		{
			if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_USACanada.value))
			{
				alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
				return false;
			}
		}

		if(FRM.verifyf){
			if(!IsEmpty(FRM.Shipping_Email_USACanada,"Please enter your shipping email.(very important)"))
				return false;
			if(!CheckEmail(FRM.Shipping_Email_USACanada,"Please enter your correct shipping email!","0"))
				return false;
		}
		
	}
	if(document.confirmed.ShippingAddType[2].checked)
	{
		if(!IsEmpty(FRM.Shipping_FirstName_Military,"Please enter your Shipping First Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_LastName_Military,"Please enter your Shipping Last Name"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_MilitaryAddress_1_Military,"Please enter your Shipping Address"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_MilitaryCity_Military,"Please enter your Shipping City"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_StateName_Military,"Please enter your Shipping State"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_Zipcode_Military,"Please enter your Shipping Zip Code"))
		{
			return false;
		}
		if(!IsEmpty(FRM.Shipping_DayTimePhone_Military,"Please enter your Shipping Day Phone"))
		{
			return false;
		}
		if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_Military.value))
		{
			alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
			return false;
		}
		
		if(FRM.Shipping_DayTimePhone_Military.value != "")
		{
			if(!checkInternationalPhone(FRM.Shipping_DayTimePhone_Military.value))
			{
				alert("Invalid Shipping Phone, Please enter in \"123-555-6789\" format");
				return false;
			}
		}
		if(FRM.verifyf){
			if(!IsEmpty(FRM.Shipping_Email_Military,"Please enter your shipping email.(very important)"))
				return false;
			if(!CheckEmail(FRM.Shipping_Email_Military,"Please enter your correct shipping email!","0"))
				return false;
		}
	  }
	}
}

function Validate(frm){	
	var val=0;
	var i=0;
	var len=frm.length;
	for(i=0; i<=len; i++)
		  {
   	    	 if(frm.elements[i].type=='checkbox')
			        if(frm.elements[i].checked)
		              val=val+1;    
		   }

   

}




 function AddtoCartAll()
{

  var el = document.getElementsByName('productcompare[]');
  var x = 0;

  for(i=0;i<el.length;i++)
  {
    if(el[i].checked)
	 {
	   x = x + 1;
	 }

  }

  if(x <2)
   alert("Please check at least 2 products to add into the cart.");
  else
   {
	document.forms['productdisplayform'].action = "additem.php?all=true";
	document.forms['productdisplayform'].submit();
   }
}

function ShortbyPrice()
{
	document.forms['productdisplayform'].action = "productdisplay.php?ord=price";
	document.forms['productdisplayform'].submit();

}



function CheckAll()
{
	var con = 'false';
	var el = document.getElementsByName('productcompare[]');

  for(i=0;i<el.length;i++)
  {
    el[i].checked = true;
  }

}

function CheckAll2()
{
	var con = 'false';
	var el = document.getElementsByName('productcompare[]');
  for(i=0;i<el.length;i++)
  {
    el[i].checked = !el[i].checked;
  }

}


function UnCheckAll()
{
	var con = 'false';
	var el = document.getElementsByName('productcompare[]');

  for(i=0;i<el.length;i++)
  {
    el[i].checked = false;

  }

}

function modify_boxes(to_be_checked,total_boxes){
  	for ( i=0 ; i < total_boxes ; i++ ){
  	  	if (to_be_checked){
  	document.productdisplayform.productcompare[i].checked=true;
}
  	  	else{
  	  	
	document.productdisplayform.productcompare[i].checked=false;
  	  	}
  	} 	 
}


function CompareCheck()
{
	//var con = 'false';
	var el = document.getElementsByName('productcompare[]');
	var x = 0;
	msg = "Please check atleast two phone to compare.";
	if(document.productbrandform.ProductForCompare.value >= 1)
	{
		msg = "Please check one more phone to compare.";
		var x = 1;
	}
	

  for(i=0;i<el.length;i++)
  {
    if(el[i].checked)
	 {
	   x = x + 1;
	 }

  }

  if(x <2)
   alert(msg);
  else
   {
	//document.forms['##%%FORM_NAME1%%##'].action = "product_compare.php";
	//document.forms['##%%FORM_NAME1%%##'].submit();
	MM_openBrWindow('product_comparevalue.php?ProdToCompare='+document.productbrandform.ProductForCompare.value,'','status=yes, scrollbars=yes,resizable=yes,width=680,height=500');

   }


}

function validatecreditcardform(frm)
	{


//creditcardtype  creditcardnumber monthselect  yearselect

	//alert(frm.CTR_Email.value);
				 if(IsEmptyNoMsg(eval(frm.creditholdername)))
				{
					  alert("Please enter the credit card holder's name.");
					  frm.creditholdername.focus();
					  return false;
				}


			  

			 if(IsEmptyNoMsg(eval(frm.creditcardnumber)))
				{

					  alert("Please enter the credit card number.");
					  frm.creditcardnumber.focus();
					  return false;
				}
				if(IsEmptyNoMsg(eval(frm.CreditCCVNo)))
				{

					  alert("Please enter the credit card CCV.");
					  frm.CreditCCVNo.focus();
					  return false;
				}

				if(!frm.terms.checked){
				alert("You need to agree to all terms and conditions!");
				return false;
				}
				return true;

	}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CompareCheck_new()
{

	var el = document.getElementsByName('productcompare[]');
	var x = 0;

  for(i=0;i<el.length;i++)
  {
    if(el[i].checked)
	 {
	   x = x + 1;
	 }

  }

  if(x <2)
   alert("Please check at least 2 options to compare.");
  else
   {
//	document.forms['productdisplayform'].action = "product_compare.php";
//	document.forms['productdisplayform'].submit();

	MM_openBrWindow('product_comparevalue.php','','status=yes, scrollbars=yes,resizable=yes,width=680,height=500');

   }

}