function in_array (needle, haystack, argStrict) {    var key = '', strict = !!argStrict;     if (strict) {        for (key in haystack) {            if (haystack[key] === needle) {                return true;            				}        }    } else {        for (key in haystack) {            if (haystack[key] == needle) {                			return true;            }        }    }     return false;}jQuery(window).load(function(){if(document.getElementById("response_div")) {/*var arr = jQuery("input");var sliced_array = '';for(var i=0;i<arr.length;i++){sliced_array = sliced_array+"<br />arr["+i+"] is =>"+arr[i].value;}alert(sliced_array);*/if (jQuery("#response_div input").slice(1,2).attr('type')=='text'){ //check to see whether it is a validation box and sizing needs to be donevar windowwidth;var content_width = jQuery('#add_1').parents('form:first').css('width');//alert(content_width);if (content_width == 0) {var sUserAgent = navigator.userAgent;if(sUserAgent.indexOf("MSIE") > -1) {windowwidth = document.getElementsByTagName("html")[0].clientWidth;} else {windowwidth = document.getElementsByTagName("html")[0].innerWidth;if (!windowwidth){windowwidth = document.getElementsByTagName("html")[0].clientWidth;}}} else {if (content_width.indexOf('px')>0) { windowwidth = content_width.replace("px",""); } else { windowwidth = content_width; }}//alert(windowwidth);//alert(jQuery(".txtError input").slice(1,2).val());if (windowwidth<700) {  //these work in sync with items in address_validation.php5if (jQuery("#response_div input").slice(1,2).val().length>24) {var address_width = windowwidth * .50; var city_width = windowwidth * .30; var state_width = windowwidth * .25; var zip_width = windowwidth * .25; var country_width = windowwidth * .30; } else {var address_width = windowwidth * .38; var city_width = windowwidth * .20; var state_width = windowwidth * .20; var zip_width = windowwidth * .38; var country_width = windowwidth * .20; }} else {var address_width = windowwidth * .25; var city_width = windowwidth * .14; var state_width = windowwidth * .10; var zip_width = windowwidth * .12; var country_width = windowwidth * .16; }       jQuery("#response_div input").slice(1,2).css('width',Math.round(address_width)+'px');	   jQuery("#response_div input").slice(2,3).css('width',Math.round(city_width)+'px');	   jQuery("#response_div input").slice(3,4).css('width',Math.round(state_width)+'px');	   jQuery("#response_div input").slice(4,5).css('width',Math.round(zip_width)+'px');       jQuery("#response_div input").slice(5,6).css('width',Math.round(country_width)+'px'); //jQuery("#loader").hide ("blind", { direction: "vertical" }, 1200);  //jQuery("#response_div").show ("blind", { direction: "vertical" }, 1200); //show this later so they don't have to see the width updates//no ie support    jQuery('#loader').css('filter', 'alpha(opacity=40)'); //no ie support    jQuery('#loader').fadeOut(500);//no ie support    jQuery("#response_div").css('filter', 'alpha(opacity=40)');//no ie support    jQuery('#response_div').fadeIn(500);/*jQuery("#loader").show().html().slideUp().hide(function(){	    jQuery(this).html(data).hide();	});jQuery("#response_div").hide().html().slideDown().show(function(){jQuery(this).html(data).show();	});*///no ie support    jQuery("#loader").slideUp();//no ie support    jQuery("#response_div").slideDown();       //no ie support    jQuery("#loader").hide();//no ie support    jQuery("#response_div").show(); //show this later so they don't have to see the width updates//jQuery("#loader").css("display","none");//jQuery("#response_div").css("display","");} //#response_div input is presentjQuery("#loader").slideUp('slow');	setTimeout('jQuery("#response_div").slideDown("slow");',1000);		//this must go right here so it applies for both successful and unsuccessful results	var sUserAgent = navigator.userAgent;var textErrorTargetWidth;if(sUserAgent.indexOf("MSIE") > -1) {textErrorTargetWidth = document.getElementsByClassName("txtError")[0].clientWidth-40;} else {textErrorTargetWidth = document.getElementsByClassName("txtError")[0].innerWidth-40;if (!textErrorTargetWidth){textErrorTargetWidth = document.getElementsByClassName("txtError")[0].clientWidth-40;}}setTimeout('jQuery(".txtError").css("width",'+textErrorTargetWidth+');',1500); //prevents expansion of the div on slideUp by giving it an actual style width element based on the clientWidth of the txtError div      if (jQuery("#address_checkbox").is(":checked")) {	   var parent_form = jQuery('#add_1').parents('form:first').attr('name');	   if (parent_form!='orderBuilder') { //admin or not	   var addvalue = jQuery(".txtError input").slice(6,7).val();       jQuery("#add_1").val(addvalue);	   var addvalue2 = jQuery(".txtError input").slice(7,8).val();       jQuery("#add_2").val(addvalue2);       var townvalue = jQuery(".txtError input").slice(2,3).val().substring(-1);       jQuery("#town").val(townvalue);     	   var countryvalue = jQuery(".txtError input").slice(5,6).val();        if (parent_form=='registerForm') {	   var countrylist = document.getElementsByName("country")[0];	   } else {	          var countrylist = document.getElementById("country");       }	   	   for (i=0;i<countrylist.options.length;i++) {	   if (countrylist.options[i].text == countryvalue) { countrylist.options[i].selected = true; }       }	          updateCounty(document.forms[parent_form]);        var countyvalue = jQuery(".txtError input").slice(3,4).val();              var countylist = document.getElementById("county_sel");       	   for (i=0;i<countylist.options.length;i++) {	   if (countylist.options[i].text == countyvalue) { countylist.options[i].selected = true; }       }	          jQuery("#county").val(countyvalue);       var postcodevalue = jQuery(".txtError input").slice(4,5).val();       jQuery("#postcode").val(postcodevalue);       } 	   }}});jQuery(window).load(function(){     if (jQuery("input[name='address_not_shipping_check']").is(":checked")) {     jQuery("input[name='address_not_shipping']").val('true');     } else { jQuery("input[name='address_not_shipping']").val('false'); }    });jQuery(window).load(function(){     if (jQuery("input[name='address_validated_check']").is(":checked")) {     jQuery("input[name='address_validated']").val('true');     } else { jQuery("input[name='address_validated']").val('false'); }});jQuery(window).load(function(){     if (jQuery("input[name='address_not_validated_check']").is(":checked")) {     jQuery("input[name='address_not_validated']").val('true');     } else { jQuery("input[name='address_not_validated']").val('false'); }});jQuery(function() {    jQuery(".address_checkbox").click(function()  {      if (jQuery("#address_checkbox").is(":checked")) { 	  var parent_form = jQuery('#add_1').parents('form:first').attr('name');      /*var arr = jQuery("input");var sliced_array = '';for(var i=0;i<arr.length;i++){sliced_array = sliced_array+"<br />arr["+i+"] is =>"+arr[i].value;}alert(sliced_array);*/	   if (document.location.search.indexOf('orderBuilder')<0) { //admin or not	   var addvalue = jQuery(".txtError input").slice(6,7).val();          jQuery("#add_1").val(addvalue);	   var addvalue2 = jQuery(".txtError input").slice(7,8).val();       jQuery("#add_2").val(addvalue2);       var townvalue = jQuery(".txtError input").slice(2,3).val().substring(-1);       jQuery("#town").val(townvalue);       var countryvalue = jQuery(".txtError input").slice(5,6).val();       if (parent_form=='registerForm') {	   var countrylist = document.getElementsByName("country")[0];	   } else {	          var countrylist = document.getElementById("country");       }	   	   for (i=0;i<countrylist.options.length;i++) {	   if (countrylist.options[i].text == countryvalue) { countrylist.options[i].selected = true; }       }	          updateCounty(document.forms[parent_form]);       var countyvalue = jQuery(".txtError input").slice(3,4).val();       var countylist = document.getElementById("county_sel");       	   for (i=0;i<countylist.options.length;i++) {	   if (countylist.options[i].text == countyvalue) { countylist.options[i].selected = true; }       }	          jQuery("#county").val(countyvalue);       var postcodevalue = jQuery(".txtError input").slice(4,5).val();       jQuery("#postcode").val(postcodevalue);	       } else { //admin or not	   var addvalue = jQuery("#response_div input").slice(6,7).val();       jQuery("#add_1_d").val(addvalue);	   var addvalue2 = jQuery("#response_div input").slice(7,8).val();       jQuery("#add_2_d").val(addvalue2);       var townvalue = jQuery("#response_div input").slice(2,3).val().substring(-1);       jQuery("#town_d").val(townvalue);     	   var countryvalue = jQuery("#response_div input").slice(5,6).val();    	   jQuery("#country_d").val(countryvalue);       var countyvalue = jQuery("#response_div input").slice(3,4).val();       jQuery("#county_d").val(countyvalue);       var postcodevalue = jQuery("#response_div input").slice(4,5).val();       jQuery("#postcode_d").val(postcodevalue);       } //end admin or not	          	   }});    jQuery(".f6_Group1").click(function()  {     jQuery(".f6_Group1").attr('checked',false);      jQuery("input[name='address_validated']").val('false');      jQuery("input[name='address_not_validated']").val('false');      jQuery("input[name='address_not_shipping']").val('false');      jQuery(this).attr('checked',true);});    jQuery(".address_checkbox").click(function()  {        if (jQuery(this).is(":checked")) {	 /* when you use .submit() it adds an object to your form called submit because submit is not a function. So if you have an input named submitted then the form will not submit and furthermore any code that relies on isset($_POST['submit']) will not function. So we add a variable called formsubmitted and make it 	 if ((isset($_POST['submit'])||isset($_POST['formsubmitted']))	 We tried changing the name, type and value of submit but type cannot be changed so we append formsubmitted instead	 */	 	 jQuery('input').each(function(){	 if (jQuery(this).attr('name')=='submit') {jQuery(this).attr('name',''); jQuery(this).after('<input type="hidden" name="formsubmitted" value="1"/>'); }	 });     jQuery("input[name='address_validated']").val('true');	 if (document.location.search.indexOf('orderBuilder')<0) { //admin or not	 var parent_form = jQuery(this).parents('form:first').attr('name'); //error box must be inside form for this to work	 setTimeout("submitDoc('"+parent_form+"')",1500);	 jQuery(".txtError").slideUp('slow');	 } else {	 var parent_form = 'orderBuilder';	 setTimeout("submitDoc('"+parent_form+"')",1500);	 }          } else { jQuery("input[name='address_validated']").val('false'); }});    jQuery(".address_not_validated").click(function()  {     if (jQuery(this).is(":checked")) {	 jQuery('input').each(function(){	 if (jQuery(this).attr('name')=='submit') {jQuery(this).attr('name',''); jQuery(this).after('<input type="hidden" name="formsubmitted" value="1"/>'); }	 });     jQuery("input[name='address_validated']").val('true');     	 if (jQuery('#add_1').parents('form:first').attr('name')!='orderBuilder') {	 var parent_form = jQuery(this).parents('form:first').attr('name'); //error box must be inside form for this to work	 setTimeout("submitDoc('"+parent_form+"')",1500);	 jQuery(".txtError").slideUp('slow');	 } else {	 var parent_form = 'orderBuilder';	 setTimeout("submitDoc('"+parent_form+"')",1500);	 jQuery(this).parents('table:first').slideUp('slow');		 }   	 } else { jQuery("input[name='address_not_validated']").val('false'); }});    jQuery(".address_not_shipping").click(function()  {     if (jQuery(this).is(":checked")) {	 jQuery('input').each(function(){	 if (jQuery(this).attr('name')=='submit') {jQuery(this).attr('name',''); jQuery(this).after('<input type="hidden" name="formsubmitted" value="1"/>'); }	 });     jQuery("input[name='address_validated']").val('true');	 if (jQuery('#add_1').parents('form:first').attr('name')!='orderBuilder') {	 var parent_form = jQuery(this).parents('form:first').attr('name'); //error box must be inside form for this to work	 setTimeout("submitDoc('"+parent_form+"')",1500);	 jQuery(".txtError").slideUp('slow');	 } else {	 var parent_form = 'orderBuilder';	 setTimeout("submitDoc('"+parent_form+"')",1500);	 jQuery(this).parents('table:first').slideUp('slow');		 }        } else { jQuery("input[name='address_not_shipping']").val('false'); }});     jQuery(".textbox").change(function()  {	  if (in_array(jQuery(this).attr('name'),['country','countySel','add_1','add_2','town','postcode','delInf[country]','delInf[countySel]','delInf[add_1]','delInf[add_2]','delInf[town]','delInf[postcode]'], true)==true) {      jQuery("input[name='address_validated']").val('false');      jQuery("input[name='address_not_validated']").val('false');      jQuery("input[name='address_not_shipping']").val('false');	  }});});function createVars() {  var req;   if(window.XMLHttpRequest){	  // Firefox, Safari, Opera...	  req = new XMLHttpRequest();   } else if(window.ActiveXObject) {	  // Internet Explorer 5+	  req = new ActiveXObject("Microsoft.XMLHTTP");   } else {	  alert("Problem creating the XMLHttpRequest object");   }   return req;}// Make the XMLHttpRequest objectvar xhr = createVars();function validate_address(dbprefix2){var name_d=document.getElementById("name_d").value; //use name_d to avoid possible conflictsvar company=document.getElementById("companyName_d").value;var address_1=document.getElementById("add_1_d").value; var address_2=document.getElementById("add_2_d").value;var city = document.getElementById("town_d").value;var state = document.getElementById("county_d").value;var zip = document.getElementById("postcode_d").value;var country = document.getElementById("country_d").value;var base_split = location.pathname.split('index.php');              //var storepath = base_split[0];xhr.open("get", "modules/shipping/FedEx_Complete/address_validation.php5?ajax=1&id="+name_d.replace(" ","_")+"&company="+company+"&address_1="+address_1+"&address_2="+address_2+"&city="+city+"&state="+state+"&zip="+zip+"&country="+country+"&dbprefix2="+dbprefix2);	      xhr.onreadystatechange = function() {		  if (xhr.readyState == 4 && xhr.status == 200) {		var response = xhr.responseText;		if(jQuery("#dialog-form")) { jQuery("#dialog-form").remove(); }               				if (response){		        //we used to use jQuery before, but it would not work with freaking IE so we now we do not.		        //jQuery("form[name=adminForm]").before(response);                //we tried to use typeof to determine if a function check_is_loaded is present from our .js file so we didn\'t load this multiple times. Shockingly..that didn\'t work but allowing it to load each time did. Maybe it is pulling the script out every time we run it?    			var newscript = document.createElement("script");				newscript.type="text/javascript";				newscript.src ="modules/shipping/FedEx_Complete/includes/js/address_validation.js";	            document.getElementsByTagName('head')[0].appendChild(newscript);											var newdiv = document.createElement("div");				newdiv.setAttribute("id","dialog-form");				newdiv.setAttribute("title","Address Validation Results");                newdiv.innerHTML = response;                document.orderBuilder.insertBefore(newdiv,document.orderBuilder.childNodes[0]);   		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!        //jQuery( "#dialog" ).dialog( "destroy" );						jQuery( "#dialog-form" ).dialog({			autoOpen: true,			width: 730,			modal: false		});			                     			}							}          }    xhr.send(null);    }
