var ISOProvince = new Array(); 

document.write('<script language="javascript" src="js/state.js"></script>');

var PreFix=new Array("Mr","Ms","Mrs","Dr","Prof","Sir","Lady","Pastor");
var SufFix=new Array("Sr","Jr","I","II","III","IV","V","VI");

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function add_country(condition){
	for(s=0;s<(Country.length-1);s++){
		S_Country=Country[s].split("+");
		if(S_Country[1]==""){
			document.forms[0].Country.options[s]=new Option('--------------------------------------------------','', false, false);
		}else{
			document.forms[0].Country.options[s]=new Option(S_Country[1], S_Country[1], false, false);
		}
		if(condition=='bill'){
			if(S_Country[1]==""){
				document.forms[0].BillingCountry.options[s]=new Option('--------------------------------------------------','', false, false);
			}else{
				document.forms[0].BillingCountry.options[s]=new Option(S_Country[1], S_Country[1], false, false);
			}
		}
		if(S_Country[1]=="United States of America"){
			document.forms[0].Country.options[s].selected=true;
			if(condition=='bill'){
				document.forms[0].BillingCountry.options[s].selected=true;
			}
		}
	}
	select_country(document.forms[0].Country.value);
	if(condition=='bill'){
		select_country_bill(document.forms[0].BillingCountry.value);
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function select_country(country){// for ship address
	for(s=0;s<(Country.length-1);s++){
		S_Country=Country[s].split("+");
		if(S_Country[1]==country){
			for(x=document.forms[0].State.options.length;x>-1;x--){
				document.forms[0].State.options[x] = null;
			}
			Province=ISOProvince[S_Country[0]].split('+');
			countProvince=Province.length-1;
			if(countProvince!=0){
				for(i=0;i<countProvince;i++){
					document.forms[0].State.options[i]=new Option(Province[i], Province[i], false, false);	
				}
			}else{
					document.forms[0].State.options[0]=new Option('Other', '', false, false);
			}
			document.forms[0].OtherProvince.disabled=true;
		}
	}
}

function select_country_bill(country){// for bill address
	for(s=0;s<(Country.length-1);s++){
		S_Country=Country[s].split("+");
		if(S_Country[1]==country){
			for(x=document.forms[0].BillingState.options.length;x>-1;x--){
				document.forms[0].BillingState.options[x] = null;
			}
			Province=ISOProvince[S_Country[0]].split('+');
			countProvince=Province.length-1;
			if(countProvince!=0){
				for(i=0;i<countProvince;i++){
					document.forms[0].BillingState.options[i]=new Option(Province[i], Province[i], false, false);	
				}
			}else{
					document.forms[0].BillingState.options[0]=new Option('Other', '', false, false);
			}
			document.forms[0].BillingOtherProvince.disabled=true;
		}
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function get_value_cookie(){
	var realname_Array=new Array();
	var realaddress_Array=new Array();
	var phones_Array=new Array();
	email=GetValue("email");
	realname=GetValue("realname");
	realaddress=GetValue("realaddress");
	if(email!=null){
		document.Inquiry.Email.value=email;
	}
	if (realname != null){
		realname_Array=realname.split("|");
		all_fname=realname_Array[0].split(" ");
		all_lname=realname_Array[1].split(" ");
		Nun_array=0;
		for(q=0;q<PreFix.length;q++){//[ PreFix ]  this array from country.js
			if(PreFix[q]==all_fname[0]){
				document.Inquiry.Prefix.options[q+1].selected = true;
				Nun_array=1;
			}
		}
		if(all_fname[(0+Nun_array)]){
			document.Inquiry.FirstName.value=all_fname[(0+Nun_array)];
		}
		if(all_fname[(1+Nun_array)]){
			document.Inquiry.MiddleName.value=all_fname[(1+Nun_array)];
		}

		if(all_lname[0]){
			document.Inquiry.LastName.value=all_lname[0];
		}
		for(qq=0;qq<SufFix.length;qq++){//[ SufFix ]  this array from country.js
			if(SufFix[qq]==all_lname[1]){
				document.Inquiry.Suffix.options[qq+1].selected = true;
			}
		}
	}
	if (realaddress != null){
		realaddress_Array=realaddress.split("|");
		document.Inquiry.PhoneDay.value=realaddress_Array[5];
		document.Inquiry.PhoneEvening.value=realaddress_Array[6];		
		document.Inquiry.PhoneMobile.value=realaddress_Array[7];
		document.Inquiry.Fax.value=realaddress_Array[8];
		document.Inquiry.Address.value=realaddress_Array[0];
		document.Inquiry.City.value=realaddress_Array[1];
		document.Inquiry.State.value=realaddress_Array[2];
		document.Inquiry.ZipCode.value=realaddress_Array[4];
		for (i=0; i<document.Inquiry.Country.options.length; i++){
			if (document.Inquiry.Country.options[i].value == realaddress_Array[3]){
				document.Inquiry.Country.options[i].selected = true;
			}
		}
		select_country(realaddress_Array[3]);
		for (ii=0; ii<document.Inquiry.State.options.length; ii++){
			if (document.Inquiry.State.options[ii].value == realaddress_Array[2]){
				document.Inquiry.State.options[ii].selected = true;
				var select_state=1;
			}
		}
		if(select_state!=1){
			option_no=document.Inquiry.State.options.length-1;
			document.Inquiry.State.options[option_no].selected = true;
			document.Inquiry.OtherProvince.disabled=false;
			document.Inquiry.OtherProvince.value=realaddress_Array[2];
		}
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++