function verifyPassword(value){
	if (document.getElementById('txtPass_reg').value != ""){
		pass = document.getElementById('txtPass_reg').value;
		if (pass != value){
			document.getElementById('txtEmailE').innerHTML = "Your password does not match the password you typed in the verify field.";
			document.getElementById('txtPass_reg').value = "";
			document.getElementById('txtPassCon').value = "";
			document.getElementById('txtPass_reg').focus();
		} else {
			document.getElementById('txtEmailE').innerHTML = "";		
		}
	}
}
function validateEmail(elem){
	var str = elem;
    str = str.toLowerCase( );
    if (str.indexOf("@") > 1) {
        var addr = str.substring(0, str.indexOf("@"));
        var domain = str.substring(str.indexOf("@") + 1, str.length);
        // at least one top level domain required
        if (domain.indexOf(".") == -1) {
            document.getElementById('txtEmailE').innerHTML = "Verify the domain portion of the email address" //alert("Verify the domain portion of the email address.");
            return false;
        }
		else{
			document.getElementById('txtEmailE').innerHTML = ""
			return true;
		}
        // parse address portion first, character by character
        for (var i = 0; i < addr.length; i++) {
            oneChar = addr.charAt(i).charCodeAt(0);
            // dot or hyphen not allowed in first position; dot in last
            if ((i == 0 && (oneChar == 45 || oneChar == 46))  || 
                (i == addr.length - 1 && oneChar == 46)) {
                document.getElementById('txtEmailE').innerHTML = "Verify the user name portion of the email address" //alert("Verify the user name portion of the email address.");
                return false;
            }
			else{
				document.getElementById('txtEmailE').innerHTML = "";
				return true;
			}
            // acceptable characters (- . _ 0-9 a-z)
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                 document.getElementById('txtEmailE').innerHTML = "Verify the user name portion of the email address";  //alert("Verify the user name portion of the email address.");
                return false;
            }
        }
        for (i = 0; i < domain.length; i++) {
            oneChar = domain.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46)) || 
                ((i == domain.length - 1  || i == domain.length - 2) && oneChar == 46)) {
                document.getElementById('txtEmailE').innerHTML = "Verify the domain portion of the email address";//alert("Verify the domain portion of the email address.");
                return false;
            }
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                document.getElementById('txtEmailE').innerHTML = "Verify the domain portion of the email address"; //alert("Verify the domain portion of the email address.");
                return false;
            }
        }
        return true;
    }
    document.getElementById('txtEmailE').innerHTML = "The email address may not be formatted correctly. Please verify";//alert("The email address may not be formatted correctly. Please verify.");
    return false;
}

function mainValidation(){
	sw = 0;
	if (document.getElementById('txtName').value == ""){
		alert ("Please enter your name");
		document.getElementById('txtName').focus();
		return false;
	}	
	if (document.getElementById('txtEmail').value == ""){
		alert ("Your email is required");
		document.getElementById('txtEmail').focus();
		return false;
	}
	else{
		if (!(validateEmail(document.getElementById('txtEmail').value))){
			alert ("The email address may not be formatted correctly. Please verify");
			document.getElementById('txtEmail').focus();
			return false;
		}		
	}
	if (document.getElementById('txtPass').value == ""){
		alert ("Password is required");
		document.getElementById('txtPass').focus();
		return false;
	}
	else{
		pass = document.getElementById('txtPass').value;
		value = document.getElementById('txtPassCon').value;;
		if (pass != value){
			alert ("Your password does not match the password you typed in the verify field.");
			document.getElementById('txtPassCon').focus();
			return false;
		}
	}
	if (document.getElementById('security_code').value == ""){
		alert ("Image Verification is required");
		document.getElementById('security_code').focus();
		return false;	
	}
	return true;	
}

function mainValidation2(){
	sw = 0;
	if (document.getElementById('txtName').value == ""){
		alert ("Please enter your name");
		document.getElementById('txtName').focus();
		return false;
	}	
	if (document.getElementById('txtEmail').value == ""){
		alert ("Your email is required");
		document.getElementById('txtEmail').focus();
		return false;
	}
	else{
		if (!(validateEmail(document.getElementById('txtEmail').value))){
			alert ("The email address may not be formatted correctly. Please verify");
			document.getElementById('txtEmail').focus();
			return false;
		}		
	}
	if (document.getElementById('security_code').value == ""){
		alert ("Image Verification is required");
		document.getElementById('security_code').focus();
		return false;	
	}
	return true;	
}

function mainValidation3(){
	if (document.getElementById('txtPass').value == ""){
		alert ("Password is required");
		document.getElementById('txtPass').focus();
		return false;
	}
	else{
		pass = document.getElementById('txtPass').value;
		value = document.getElementById('txtPassCon').value;;
		if (pass != value){
			alert ("Your password does not match the password you typed in the verify field.");
			document.getElementById('txtPassCon').focus();
			return false;
		}
	}
	return true;	
}



function showtr(val){
var browser=navigator.appName
	for(i=1;i<=val;i++)
	{
		tj = 't'+i;
		bj = 'b'+i;
		if (browser=="Microsoft Internet Explorer"){
			document.getElementById(tj).style.display = "block";
		}else{
			document.getElementById(tj).style.display = "table-row";
		}
		document.getElementById(bj).style.display = "none";		
	}
	val = val+1;
	if(val<10){
	if (browser=="Microsoft Internet Explorer"){
		document.getElementById('b'+val).style.display = "block";
	}else{
		document.getElementById('b'+val).style.display = "table-row";
	}
	}
}
function dosub()
{

	if(document.getElementById('loginreg_state').value == 'reg' || document.getElementById('loginreg_state').value == 'log'){

		if(document.getElementById('loginreg_state').value == 'reg'){
			if(document.getElementById('email').value == ''){
				document.getElementById('email').focus();
				document.getElementById('email1').style.visibility = "visible";
				return false;
			}
			else{
				document.getElementById('email1').style.visibility = "hidden";
			}
			
			if(document.getElementById('txtPass_reg').value == ''){
				document.getElementById('txtPass_reg').focus();
				document.getElementById('txtPass_reg1').style.visibility = "visible";
				return false;
			}
			else{
				document.getElementById('txtPass_reg1').style.visibility = "hidden";
			}
			
			if(document.getElementById('txtPassCon').value == ''){
				document.getElementById('txtPassCon').focus();
				document.getElementById('txtPassCon1').style.visibility = "visible";
				return false;
			}
			else{
				document.getElementById('txtPassCon1').style.visibility = "hidden";
			}		
			
		}
		
		if(document.getElementById('loginreg_state').value == 'log'){
			if(document.getElementById('txtUserN').value == ''){
				document.getElementById('txtUserN').focus();
				document.getElementById('txtUserN1').style.visibility = "visible";
				return false;
			}
			else{
				document.getElementById('txtUserN1').style.visibility = "hidden";
			}
			
			if(document.getElementById('txtPass').value == ''){
				document.getElementById('txtPass').focus();
				document.getElementById('txtPass1').style.visibility = "visible";
				return false;
			}
			else{
				document.getElementById('txtPass1').style.visibility = "hidden";
			}	
		}
	
	}
	if(document.getElementById('security_code').value == ''){
		document.getElementById('security_code').focus();
		document.getElementById('security_code1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('security_code1').style.visibility = "hidden";
	}

	if(document.getElementById('firstname').value == ''){
		document.getElementById('firstname').focus();
		document.getElementById('firstname1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('firstname1').style.visibility = "hidden";
	}
	if(document.getElementById('lastname').value == ''){
		document.getElementById('lastname').focus();
		document.getElementById('lastname1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('lastname1').style.visibility = "hidden";
	}
	if(document.getElementById('txtUserN').value == ''){
		if(!validateEmail(document.getElementById('email').value)){		
			return false;
		}
	}

	if(document.getElementById('address').value == ''){
		document.getElementById('address').focus();
		document.getElementById('address1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('address1').style.visibility = "hidden";
	}
	if(document.getElementById('city').value == ''){
		document.getElementById('city').focus();
		document.getElementById('city1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('city1').style.visibility = "hidden";
	}
	if(document.getElementById('state').value == ''){
		document.getElementById('state').focus();
		document.getElementById('state1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('state1').style.visibility = "hidden";
	}
	if(document.getElementById('zipcode').value == ''){
		document.getElementById('zipcode').focus();
		document.getElementById('zipcode1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('zipcode1').style.visibility = "hidden";
	}
	if(document.getElementById('country').value == ''){
		document.getElementById('country').focus();
		document.getElementById('country1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('country1').style.visibility = "hidden";
	}
	if(document.getElementById('phonno').value == ''){
		document.getElementById('phonno').focus();
		document.getElementById('phonno1').style.visibility = "visible";		
		return false;
	}
	else{
		document.getElementById('phonno1').style.visibility = "hidden";		
	}
	if(document.getElementById('ccnumber').value == ''){
		document.getElementById('ccnumber').focus();
		document.getElementById('ccnumber1').style.visibility = "visible";
		return false;
	}	
	else{
		document.getElementById('ccnumber1').style.visibility = "hidden";
	}
	if(document.getElementById('cccode').value == ''){
		document.getElementById('cccode').focus();
		document.getElementById('cccode1').style.visibility = "visible";
		return false;
	}
	else{
		document.getElementById('cccode1').style.visibility = "hidden";
	}	
	
	if(document.getElementById('creditCardType').value == 'Amex'){		
		if (document.getElementById('ccnumber').value.indexOf("3")!= 0){
			document.getElementById('ccnumber').focus();
			document.getElementById('ccnumber1').style.visibility = "visible";
			return false;
		}
		else{
			document.getElementById('ccnumber1').style.visibility = "hidden";
		}
	}	
	else if(document.getElementById('creditCardType').value == 'Visa'){		
		if (document.getElementById('ccnumber').value.indexOf("4") != 0){
			document.getElementById('ccnumber').focus();
			document.getElementById('ccnumber1').style.visibility = "visible";
			return false;
		}
		else{
			document.getElementById('ccnumber1').style.visibility = "hidden";
		}
	}
	else if(document.getElementById('creditCardType').value == 'MasterCard'){		
		if (document.getElementById('ccnumber').value.indexOf("5") != 0){
			document.getElementById('ccnumber').focus();
			document.getElementById('ccnumber1').style.visibility = "visible";
			return false;
		} 
		else{
			document.getElementById('ccnumber1').style.visibility = "hidden";
		}
	}	
	else if(document.getElementById('creditCardType').value == 'Discover'){		
		if (document.getElementById('ccnumber').value.indexOf("6") != 0){
			document.getElementById('ccnumber').focus();
			document.getElementById('ccnumber1').style.visibility = "visible";
			return false;
		} 
		else{
			document.getElementById('ccnumber1').style.visibility = "hidden";
		}
	}	
	return true;
}
function isdigit(keyCode){
		if(keyCode == 37)return true;
		if(keyCode == 39) return true; 
		if(keyCode == 46) return true; 
		if(keyCode == 109) return true; 
		if(keyCode == 110) return true; 
		if(keyCode == 189) return true; 
		if(keyCode == 9) return true; 
		if(keyCode == 8) return true;
		if(keyCode == 190) return true;
		if(keyCode > 95 && keyCode < 106) return true; 
		if(keyCode < 48 || keyCode > 57) return false;	
}
function changestate(val){
	url = "<?php echo $SITE_NAME; ?>/statecombo.php?cid="+val;
	obj = new Ajax(url,'GET','state')
}
function Ajax(url,method,eleid) {
	var xmlhttp = false;
 	if (window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
  	}
  	else if (window.ActiveXObject){
    	try{
      		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
      	try{
        	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      	} catch (E) {
	        xmlhttp=false;
 	    }
  	  }
  	}
  	if(xmlhttp){
	  	xmlhttp.onreadystatechange=function(){
		if(xmlhttp && xmlhttp.readyState==4){
			if (xmlhttp.status==200){ 
				document.getElementById(eleid).innerHTML = "";
				document.getElementById(eleid).innerHTML = xmlhttp.responseText;
			}
		}
	}
		xmlhttp.open(method,url,true);
  		xmlhttp.send(null);
  }
  else{
		alert("Unable to creat Ajax Object for this browser");
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function idProduct(id){
	document.getElementById('amount').value = id;	
}
function ValidationUpdate(){
	sw = 0;
	if (document.getElementById('txtName').value == ""){
		alert ("Please enter your name");
		document.getElementById('txtName').focus();
		return false;
	}	
	if (document.getElementById('txtEmail').value == ""){
		alert ("Your email is required");
		document.getElementById('txtEmail').focus();
		return false;
	}
	else{
		if (!(validateEmail(document.getElementById('txtEmail').value))){
			alert ("The email address may not be formatted correctly. Please verify");
			document.getElementById('txtEmail').focus();
			return false;
		}		
	}
	/*if (document.getElementById('txtPass').value == ""){
		alert ("The Password it's requiered");
		document.getElementById('txtPass').focus();
		return false;
	}
	else{
		pass = document.getElementById('txtPass').value;
		value = document.getElementById('txtPassCon').value;;
		if (pass != value){
			alert ("The Password it's incorrect");
			document.getElementById('txtPassCon').focus();
			return false;
		}
	}
	if (document.getElementById('security_code').value == ""){
		alert ("The Image Verification it's requiered");
		document.getElementById('security_code').focus();
		return false;	
	}*/	
	return true;	
}

function ValidationDemoCreate(){
	sw = 0;
	if (document.getElementById('txtName').value == ""){
		alert ("Please enter your name");
		document.getElementById('txtName').focus();
		return false;
	}	
	if (document.getElementById('txtEmail').value == ""){
		alert ("Your email is required");
		document.getElementById('txtEmail').focus();
		return false;
	}
	else{
		if (!(validateEmail(document.getElementById('txtEmail').value))){
			alert ("The email address may not be formatted correctly. Please verify");
			document.getElementById('txtEmail').focus();
			return false;
		}		
	}
	if (document.getElementById('txtPass_reg').value == ""){
		alert ("The Password it's requiered");
		document.getElementById('txtPass_reg').focus();
		return false;
	}
	else{
		pass = document.getElementById('txtPass_reg').value;
		value = document.getElementById('txtPassCon').value;;
		if (pass != value){
			alert ("The Password it's incorrect");
			document.getElementById('txtPassCon').focus();
			return false;
		}
	}

	return true;	
}

