    /*----------------------------------------------------------------
    Description   :- function to open a new window
    Programmer    :- ASW
    Last Modified :- 15/JAN/2007
    -------------------------------------------------------------------*/
   	function OpenWindow(url)
	{
       nw = open(url,'new','height=450,width=550,scrollbars=yes,resizable=1');
	   nw.focus();
	}

function select_country(oldstate,oldcountry){
	var x = document.getElementById('sel_country').value;
	if( x == "other" ){
		if( oldstate !='' ||  oldcountry !=''  ){
			
			var url = "user_state.php?country="+x+"&oldcountry="+oldcountry;
			var url_new="user_state.php?country="+x+"&flag=1&oldstate="+oldstate;
		}else{
			
			var url = "user_state.php?country="+x;
			var url_new="user_state.php?country="+x+"&flag=1";
		}
		
		document.getElementById('h_country').value="other";
		ajaxpage(url,'TD_country');
		ajaxpage(url_new,'TD_state');
	} 
	
	
}
function submit_userform(){
	var zip= document.getElementById('txt_zip').value ;  
	if(zip.length ==5) {
 		var url	=	"signupvalidate.php";  
		document.frm_signup.action=url;//"signupvalidate.php?newstate="+state+"&txt_country="+country;
		document.frm_signup.submit();
		
    	}else{
		alert("Zip code must be 5 digits");
		document.frm_signup.txt_zip.focus();
		return false;
	}
}
/*********************************************************************************************
	functions for calculator
**********************************************************************************************/
	/*function addtrade() {
		if (document.forms.loanCalc.trade.selectedIndex == 1) {
			document.getElementById("test").style.display = 'block';
		} else {
			document.getElementById("test").style.display = 'none';
		}
	}*/
	function display_div(){
		if(document.frm_loan.sel_trade.selectedIndex == 1)
			document.getElementById('div_trade').style.display = "block";
		else
			document.getElementById('div_trade').style.display = "none";
	}
	function checkNumber(input, min, max, msg) {       
	  msg = msg + " field has invalid data: " + input.value;         
	  var str = input.value;        
	   for (var i = 0; i < str.length; i++) {           
			var ch = str.substring(i, i + 1)            
			if ((ch < "0" || "9" < ch) && ch != '.') {                
				alert(msg);                
			  return false;             
			}        
		}        
		var num = 0 + str         
		if (num < min || max < num) {            
			 alert(msg + " not in range [" + min + ".." + max + "]");            
			 return false;         
		}         
		input.value = str;         
		return true;     
	}      
	function computeField(input) {   
		if (input.value != null && input.value.length != 0)             
			input.value = "" + eval(input.value);         
			computeForm(input.form);    
	 }     
	  function computeForm(form) {         
			if (form.txt_downpay.value == null || form.txt_downpay.value.length == 0)             
				form.txt_downpay.value = 0;        
			 if (form.txt_owed.value == null || form.txt_owed.value.length == 0)             
				form.txt_owed.value = 0;         
			if (form.txt_tradevalue.value == null || form.txt_tradevalue.value.length == 0)             
				form.txt_tradevalue.value = 0;        
			 if ((form.sel_term.value == null || form.sel_term.value.length == 0) || (form.txt_rate.value == null || form.txt_rate.value.length == 0) || (form.txt_price.value == null || form.txt_price.value.length == 0)) {         
				 return;         
			}         
			if (!checkNumber(form.sel_term, 1, 480, "# of payments") || !checkNumber(form.txt_rate, .001, 99, "Interest") ||             !checkNumber(form.txt_price, 100, 10000000, "Price") || !checkNumber(form.txt_owed, 0, 10000000, "Owed on Trade") ||             !checkNumber(form.txt_tradevalue, 0, 10000000, "Trade Value") || !checkNumber(form.txt_downpay, 0, form.txt_price.value, "Down payment")) {            
					 form.txt_loan.value = "Invalid";            
					 return;         
			}         
			 var i = form.txt_rate.value;                 
			 if (i > .001) {            
				i = i / 100.0;            // form.interest.value = i;       
			  }       
				i /= 12;          
				var pow = 1;         
				for (var j = 0; j < form.sel_term.value; j++)            
					 pow = pow * (1 + i);         
				form.txt_loan.value = Math.ceil(((form.txt_price.value - form.txt_downpay.value - (form.txt_tradevalue.value - form.txt_owed.value)) * pow * i) / (pow - 1))     
		}      

   	function OpenPrintWindow(url)
	{
       nw = open(url,'new','height=570,width=550,scrollbars=yes,resizable=1');
	   nw.focus();
	}
//to submit the form
	function submit_form(selval){
		var act = selval.selectedIndex;
		if(act == 1)
			window.location = "ford.php?process=showpage&id=25";
		else if(act == 2)
			window.location = "ford.php?process=showpage&id=24";
	}

//for updateing the status of the record
function updatestatusconfirm(page,name,id,status,pageno,flag){
	 
	if(confirm("Are sure  to modify the status "+ status + "of this "+ name + "?" ))
		window.location = page + "?name="+name + "&id="+id+"&status="+status+"&page="+pageno+"&flag="+flag;
}
//function to delete record
function deleterecord(page,name,id,mode){
	
	x	= confirm("Are really wantto delete this selected "+name + " ?\n if ok  all the information associated with the selected "+name +" will be removed from the system . \n You cannot undo this Process." );
	if(x){
		window.location = page + "?id="+id + "&name="+name+"&mode="+mode;
 	}
  
}
//function is for ajax paging
function ajaxpaging(categoryid,subcategoryid,page){
	var url	= "product_listing_products.php?ajax=ajax&categoryId="+categoryid+"&subCategoryId="+subcategoryid+"&page="+page;
	 
		ajaxpage(url,'product_list');
}

	function numbersonly(e)
	{
		var key;
		var keychar;
		
		if (window.event)
		key = window.event.keyCode;
		else if (e)
		key = e.which;
		else
		return true;
		
		keychar = String.fromCharCode(key);
		keychar = keychar.toLowerCase();
		if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;
		else if ((("0123456789").indexOf(keychar) > -1))
		return true;
		else
		return false;
	}
//for user login
function checkout_login(){
 	var url	=	"loginvalidate.php?checkout_option=1";  
  	document.frm_checkoutLogin.action=url;//"signupvalidate.php?newstate="+state+"&txt_country="+country;
	document.frm_checkoutLogin.submit();
}

 
 function jsutshopping(){ 
 	var url	=	"justshopping.php";  
	window.location=url;
 }
 
 //gift card section
 function giftcard(){ 
 	var url	=	"index.php?process=giftcard";  
	window.location=url;
 }

 //gift card section
 function gift_addtocart(){ 
 	var url	=	"Giftcard_validate.php?action=giftsubmit";  
  	document.frm_giftcard.action=url;
	document.frm_giftcard.submit();
 }
 
 function gift_checkout(){ 
 	var url	=	"Giftcard_validate.php?action=giftsubmit&checkoutflag=1";  
  	document.frm_giftcard.action=url;//"signupvalidate.php?newstate="+state+"&txt_country="+country;
	document.frm_giftcard.submit();
 }
 
 function gift_addtocart1(){ 
 	var url	=	"Giftcard_validate1.php?action=giftsubmit";  
  	document.frm_giftcard.action=url;
	document.frm_giftcard.submit();
 }
 
 function gift_checkout1(){ 
 	var url	=	"Giftcard_validate1.php?action=giftsubmit&checkoutflag=1";  
  	document.frm_giftcard.action=url;//"signupvalidate.php?newstate="+state+"&txt_country="+country;
	document.frm_giftcard.submit();
 }

//function to check the value is numeric 
function checknumeric(){
	if(isNaN(document.frm_signup.txt_zip.value) )
	{			
		alert("Zip code must be 5 digits ");
		document.frm_signup.txt_zip.value.focus();
		return false;
	}else return true;

}

//function for return to home
function returntohome(domain,sessId){
	window.location = domain+"index.php?sessId="+sessId;
}

 
function Registernow(domain,sessId){ 
	//window.location="index.php?process=signup";
	window.location=domain+"usersignup.php?sessid="+sessId;
}

function clear_amt()
{
	if(document.frm_giftcard.service.value!='')
	{
		document.frm_giftcard.amount.value='';
		document.getElementById('amount').style.backgroundColor='#cccccc';
		updateDesc(document.frm_giftcard.service.value);
		return true;
	}
}



function change_color()
{
	document.getElementById('amount').style.backgroundColor='#ffffff';
	document.frm_giftcard.service.value='';
}

//function to display the email div for gift card
function display_email(){
	document.getElementById('div_email').style.display = "block";
}

function display_email1(){
	document.getElementById('div_ship').style.display = "none";
	document.getElementById('div_email').style.display = "block";
}
function display_ship(){
	document.getElementById('div_ship').style.display = "block";
	document.getElementById('div_email').style.display = "none";
}
//function to hide the email div for gift card
function hide_email(){
	document.getElementById('div_email').style.display = "none";
}
//function to display the billing div
function check_billing(){
	//document.getElementById('rdo_billing').value = 1;
	document.getElementById('div_bill').style.display = "block";
	document.getElementById('div_same').style.display = "none";
}
//function to display the shipping div
function check_shipping(flag){
	if(flag == 1){
		document.getElementById('txt_sfname').value 	= "";
		document.getElementById('txt_slname').value 	= "";
		document.getElementById('txt_saddress').value 	= "";
		document.getElementById('txt_saddress1').value 	= "";
		document.getElementById('txt_scity').value 		= "";
		document.getElementById('txt_sstate').value 	= "";
		document.getElementById('txt_szip').value 		= "";	
	}
	//document.getElementById('rdo_shipping').value = 1;
	document.getElementById('div_ship').style.display = "block";
}
//function to hide the shipping form
function hide_shipping(){
	document.getElementById('div_ship').style.display = "none";
}
//function to hide the billing form
function hide_billing(){
	document.getElementById('div_same').style.display = "block";
	document.getElementById('div_bill').style.display = "none";
}

//function to cancel user registeration process
function cancelregisteration(url){ //alert(url);
	window.location=url;	
}