var url = "xls_ajax_handler.php"; // The server-side scriptvar postState = '';var postCountry = '';var state = '\US:AK:Alaska|\US:AL:Alabama|\US:AR:Arkansas|\US:AS:American Samoa|\US:AZ:Arizona|\US:CA:California|\US:CO:Colorado|\US:CT:Connecticut|\US:DC:D.C.|\US:DE:Delaware|\US:FL:Florida|\US:FM:Micronesia|\US:GA:Georgia|\US:GU:Guam|\US:HI:Hawaii|\US:IA:Iowa|\US:ID:Idaho|\US:IL:Illinois|\US:IN:Indiana|\US:KS:Kansas|\US:KY:Kentucky|\US:LA:Louisiana|\US:MA:Massachusetts|\US:MD:Maryland|\US:ME:Maine|\US:MH:Marshall Islands|\US:MI:Michigan|\US:MN:Minnesota|\US:MO:Missouri|\US:MP:Marianas|\US:MS:Mississippi|\US:MT:Montana|\US:NC:North Carolina|\US:ND:North Dakota|\US:NE:Nebraska|\US:NH:New Hampshire|\US:NJ:New Jersey|\US:NM:New Mexico|\US:NV:Nevada|\US:NY:New York|\US:OH:Ohio|\US:OK:Oklahoma|\US:OR:Oregon|\US:PA:Pennsylvania|\US:PR:Puerto Rico|\US:PW:Palau|\US:RI:Rhode Island|\US:SC:South Carolina|\US:SD:South Dakota|\US:TN:Tennessee|\US:TX:Texas|\US:UT:Utah|\US:VA:Virginia|\US:VI:Virgin Islands|\US:VT:Vermont|\US:WA:Washington|\US:WI:Wisconsin|\US:WV:West Virginia|\US:WY:Wyoming|\US:AA:Military Americas|\US:AE:Military Europe/ME/Canada|\US:AP:Military Pacific|\CA:AB:Alberta|\CA:MB:Manitoba|\CA:AB:Alberta|\CA:BC:British Columbia|\CA:MB:Manitoba|\CA:NB:New Brunswick|\CA:NL:Newfoundland and Labrador|\CA:NS:Nova Scotia|\CA:NT:Northwest Territories|\CA:NU:Nunavut|\CA:ON:Ontario|\CA:PE:Prince Edward Island|\CA:QC:Quebec|\CA:SK:Saskatchewan|\CA:YT:YGBon Territory|\AU:AAT:Australian Antarctic Territory|\AU:ACT:Australian Capital Territory|\AU:NT:Northern Territory|\AU:NSW:New South Wales|\AU:QLD:Queensland|\AU:SA:South Australia|\AU:TAS:Tasmania|\AU:VIC:Victoria|\AU:WA:Western Australia|\BR:AC:Acre|\BR:AL:Alagoas|\BR:AM:Amazonas|\BR:AP:Amapa|\BR:BA:Baia|\BR:CE:Ceara|\BR:DF:Distrito Federal|\BR:ES:Espirito Santo|\BR:FN:Fernando de Noronha|\BR:GO:Goias|\BR:MA:Maranhao|\BR:MG:Minas Gerais|\BR:MS:Mato Grosso do Sul|\BR:MT:Mato Grosso|\BR:PA:Para|\BR:PB:Paraiba|\BR:PE:Pernambuco|\BR:PI:Piaui|\BR:PR:Parana|\BR:RJ:Rio de Janeiro|\BR:RN:Rio Grande do Norte|\BR:RO:Rondonia|\BR:RR:Roraima|\BR:RS:Rio Grande do Sul|\BR:SC:Santa Catarina|\BR:SE:Sergipe|\BR:SP:Sao Paulo|\BR:TO:Tocatins|\NL:DR:Drente|\NL:FL:Flevoland|\NL:FR:Friesland|\NL:GL:Gelderland|\NL:GR:Groningen|\NL:LB:Limburg|\NL:NB:Noord Brabant|\NL:NH:Noord Holland|\NL:OV:Overijssel|\NL:UT:Utrecht|\NL:ZH:Zuid Holland|\NL:ZL:Zeeland|\GB:AVON:Avon|\GB:BEDS:Bedfordshire|\GB:BERKS:Berkshire|\GB:BUCKS:Buckinghamshire|\GB:CAMBS:Cambridgeshire|\GB:CHESH:Cheshire|\GB:CLEVE:Cleveland|\GB:CORN:Cornwall|\GB:CUMB:Cumbria|\GB:DERBY:Derbyshire|\GB:DEVON:Devon|\GB:DORSET:Dorset|\GB:DURHAM:Durham|\GB:ESSEX:Essex|\GB:GLOUS:Gloucestershire|\GB:GLONDON:Greater London|\GB:GMANCH:Greater Manchester|\GB:HANTS:Hampshire|\GB:HERWOR:Hereford & Worcestershire|\GB:HERTS:Hertfordshire|\GB:HUMBER:Humberside|\GB:IOM:Isle of Man|\GB:IOW:Isle of Wight|\GB:KENT:Kent|\GB:LANCS:Lancashire|\GB:LEICS:Leicestershire|\GB:LINCS:Lincolnshire|\GB:MERSEY:Merseyside|\GB:NORF:Norfolk|\GB:NHANTS:Northamptonshire|\GB:NTHUMB:Northumberland|\GB:NOTTS:Nottinghamshire|\GB:OXON:Oxfordshire|\GB:SHROPS:Shropshire|\GB:SOM:Somerset|\GB:STAFFS:Staffordshire|\GB:SUFF:Suffolk|\GB:SURREY:Surrey|\GB:SUSS:Sussex|\GB:WARKS:Warwickshire|\GB:WMID:West Midlands|\GB:WILTS:Wiltshire|\GB:YORK:Yorkshire|\EI:CO ANTRIM:County Antrim|\EI:CO ARMAGH:County Armagh|\EI:CO DOWN:County Down|\EI:CO FERMANAGH:County Fermanagh|\EI:CO DERRY:County Londonderry|\EI:CO TYRONE:County Tyrone|\EI:CO CAVAN:County Cavan|\EI:CO DONEGAL:County Donegal|\EI:CO MONAGHAN:County Monaghan|\EI:CO DUBLIN:County Dublin|\EI:CO CARLOW:County Carlow|\EI:CO KILDARE:County Kildare|\EI:CO KILKENNY:County Kilkenny|\EI:CO LAOIS:County Laois|\EI:CO LONGFORD:County Longford|\EI:CO LOUTH:County Louth|\EI:CO MEATH:County Meath|\EI:CO OFFALY:County Offaly|\EI:CO WESTMEATH:County Westmeath|\EI:CO WEXFORD:County Wexford|\EI:CO WICKLOW:County Wicklow|\EI:CO GALWAY:County Galway|\EI:CO MAYO:County Mayo|\EI:CO LEITRIM:County Leitrim|\EI:CO ROSCOMMON:County Roscommon|\EI:CO SLIGO:County Sligo|\EI:CO CLARE:County Clare|\EI:CO CORK:County Cork|\EI:CO KERRY:County Kerry|\EI:CO LIMERICK:County Limerick|\EI:CO TIPPERARY:County Tipperary|\EI:CO WATERFORD:County Waterford|\';// Country data table//// To edit the list, just delete a line or add a line. Order is important.// The order displayed here is the order it appears on the drop down.//var country = '\NONE: |\AF:Afghanistan|\AL:Albania|\DZ:Algeria|\AS:American Samoa|\AD:Andorra|\AO:Angola|\AI:Anguilla|\AQ:Antarctica|\AG:Antigua and Barbuda|\AR:Argentina|\AM:Armenia|\AW:Aruba|\AU:Australia|\AT:Austria|\AZ:Azerbaijan|\AP:Azores|\BS:Bahamas|\BH:Bahrain|\BD:Bangladesh|\BB:Barbados|\BY:Belarus|\BE:Belgium|\BZ:Belize|\BJ:Benin|\BM:Bermuda|\BT:Bhutan|\BO:Bolivia|\BA:Bosnia And Herzegowina|\XB:Bosnia-Herzegovina|\BW:Botswana|\BV:Bouvet Island|\BR:Brazil|\IO:British Indian Ocean Territory|\VG:British Virgin Islands|\BN:Brunei Darussalam|\BG:Bulgaria|\BF:Burkina Faso|\BI:Burundi|\KH:Cambodia|\CM:Cameroon|\CA:Canada|\CV:Cape Verde|\KY:Cayman Islands|\CF:Central African Republic|\TD:Chad|\CL:Chile|\CN:China|\CX:Christmas Island|\CC:Cocos (Keeling) Islands|\CO:Colombia|\KM:Comoros|\CG:Congo|\CK:Cook Islands|\
XE:Corsica|\CR:Costa Rica|\CI:Cote d` Ivoire (Ivory Coast)|\HR:Croatia|\CU:Cuba|\CY:Cyprus|\CZ:Czech Republic|\DK:Denmark|\DJ:Djibouti|\DM:Dominica|\DO:Dominican Republic|\TP:East Timor|\EC:Ecuador|\EG:Egypt|\SV:El Salvador|\GQ:Equatorial Guinea|\ER:Eritrea|\EE:Estonia|\ET:Ethiopia|\FK:Falkland Islands (Malvinas)|\FO:Faroe Islands|\FJ:Fiji|\FI:Finland|\FR:France (Includes Monaco)|\FX:France, Metropolitan|\GF:French Guiana|\PF:French Polynesia|\TA:French Polynesia (Tahiti)|\TF:French Southern Territories|\GA:Gabon|\GM:Gambia|\GE:Georgia|\DE:Germany|\GH:Ghana|\GI:Gibraltar|\GR:Greece|\GL:Greenland|\GD:Grenada|\GP:Guadeloupe|\GU:Guam|\GT:Guatemala|\GN:Guinea|\GW:Guinea-Bissau|\GY:Guyana|\HT:Haiti|\VA:Holy See (Vatican City State)|\HN:Honduras|\HK:Hong Kong|\HU:Hungary|\IS:Iceland|\IN:India|\ID:Indonesia|\IR:Iran|\IQ:Iraq|\IE:Ireland|\EI:Ireland (Eire)|\IL:Israel|\IT:Italy|\JM:Jamaica|\JP:Japan|\JO:Jordan|\KZ:Kazakhstan|\KE:Kenya|\KI:Kiribati|\KP:Korea|\KW:Kuwait|\KG:Kyrgyzstan|\LA:Laos|\LV:Latvia|\LB:Lebanon|\LS:Lesotho|\LR:Liberia|\LY:Libya|\LI:Liechtenstein|\LT:Lithuania|\LU:Luxembourg|\MO:Macao|\MK:Macedonia|\MG:Madagascar|\ME:Madeira Islands|\MW:Malawi|\MY:Malaysia|\MV:Maldives|\ML:Mali|\MT:Malta|\MH:Marshall Islands|\MQ:Martinique|\MR:Mauritania|\MU:Mauritius|\YT:Mayotte|\MX:Mexico|\FM:Micronesia|\MD:Moldova|\MC:Monaco|\MN:Mongolia|\MS:Montserrat|\MA:Morocco|\MZ:Mozambique|\MM:Myanmar (Burma)|\NA:Namibia|\NR:Nauru|\NP:Nepal|\NL:Netherlands|\AN:Netherlands Antilles|\NC:New Caledonia|\NZ:New Zealand|\NI:Nicaragua|\NE:Niger|\NG:Nigeria|\NU:Niue|\NF:Norfolk Island|\MP:Northern Mariana Islands|\NO:Norway|\OM:Oman|\PK:Pakistan|\PW:Palau|\PS:Palestine|\PA:Panama|\PG:Papua New Guinea|\PY:Paraguay|\PE:Peru|\PH:Philippines|\PN:Pitcairn|\PL:Poland|\PT:Portugal|\PR:Puerto Rico|\QA:Qatar|\RE:Reunion|\RO:Romania|\RU:Russian Federation|\RW:Rwanda|\KN:Saint Kitts And Nevis|\SM:San Marino|\ST:Sao Tome and Principe|\SA:Saudi Arabia|\SN:Senegal|\XS:Serbia-Montenegro|\SC:Seychelles|\SL:Sierra Leone|\SG:Singapore|\SK:Slovak Republic|\SI:Slovenia|\SB:Solomon Islands|\SO:Somalia|\ZA:South Africa|\GS:South Georgia|\KR:South Korea|\ES:Spain|\LK:Sri Lanka|\NV:Nevis|\SH:St. Helena|\LC:St. Lucia|\PM:St. Pierre and Miquelon|\VC:St. Vincent|\SD:Sudan|\SR:Suriname|\SJ:Svalbard|\SZ:Swaziland|\SE:Sweden|\CH:Switzerland|\SY:Syrian Arab Republic|\TW:Taiwan|\TJ:Tajikistan|\TZ:Tanzania|\TH:Thailand|\TG:Togo|\TK:Tokelau|\TO:Tonga|\TT:Trinidad/Tobago|\XU:Tristan da Cunha|\TN:Tunisia|\TR:Turkey|\TM:Turkmenistan|\TC:Turks and Caicos|\TV:Tuvalu|\UG:Uganda|\UA:GBraine|\AE:United Arab Emirates|\GB:United Kingdom|\US:United States|\UM:United States Minor Outlying|\UY:Uruguay|\UZ:Uzbekistan|\VU:Vanuatu|\XV:Vatican City|\VE:Venezuela|\VN:Vietnam|\VI:Virgin Islands (U.S.)|\WF:Wallis and Furuna Islands|\EH:Western Sahara|\WS:Western Samoa|\YE:Yemen|\YU:Yugoslavia|\ZR:Zaire|\ZM:Zambia|\ZW:Zimbabwe|\';function submit(){ new Ajax.Updater( 'result', 'alert.html', {  method: 'get',  onSuccess: function() {   new Effect.Opacity('result',    { duration: 2.0, from: 0.0, to: 1.0 } );   new Effect.Opacity('result',    { delay: 10.0, duration: 2.0, from: 1.0, to: 0.0 } );  }	} );}function TrimString(sInString) {  if ( sInString ) {    sInString = sInString.replace( /^\s+/g, "" );// strip leading    return sInString.replace( /\s+$/g, "" );// strip trailing  }}function populateShippingCountry(defaultCountry) {  if ( postCountry != '' ) {    defaultCountry = postCountry;  }  var countryLineArray = country.split('|');  // Split into lines  var selObj = document.getElementById('shipcountrySelect');  selObj.options[0] = new Option('Select Country','');  selObj.selectedIndex = 0;  for (var loop = 0; loop < countryLineArray.length; loop++) {    lineArray = countryLineArray[loop].split(':');    countryCode  = TrimString(lineArray[0]);    countryName  = TrimString(lineArray[1]);    if ( countryCode != '' ) {      selObj.options[loop + 1] = new Option(countryName, countryCode);    }    if ( defaultCountry == countryCode ) {      selObj.selectedIndex = loop + 1;    }  }}function populateShippingState() {  var selObj = document.getElementById('shipstateSelect');  var foundState = false;  // Empty options just in case new drop down is shorter  if ( selObj.type == 'select-one' ) {    for (var i = 0; i < selObj.options.length; i++) {      selObj.options[i] = null;    }    selObj.options.length=null;    selObj.options[0] = new Option('Select State','');    selObj.selectedIndex = 0;  }  // Populate the drop down with states from the selected country  var stateLineArray = state.split("|");  // Split into lines  var optionCntr = 1;  for (var loop = 0; loop < stateLineArray.length; loop++) {    lineArray = stateLineArray[loop].split(":");    countryCode  = TrimString(lineArray[0]);    stateCode    = TrimString(lineArray[1]);    stateName    = TrimString(lineArray[2]);  if (document.getElementById('shipcountrySelect').value == countryCode && countryCode != '' ) {    // If it's a input element, change it to a select      if ( selObj.type == 'text' ) {        parentObj = document.getElementById('shipstateSelect').parentNode;        parentObj.removeChild(selObj);        var inputSel = document.createElement("SELECT");        inputSel.setAttribute("name","shipping_state");        inputSel.setAttribute("id","shipstateSelect");        parentObj.appendChild(inputSel) ;        selObj = document.getElementById('shipstateSelect');        selObj.options[0] = new Option('Select State','');        selObj.selectedIndex = 0;      }      if ( stateCode != '' ) {        selObj.options[optionCntr] = new Option(stateName, stateCode);      }      // See if it's selected from a previous post      if ( stateCode == postState && countryCode == postCountry ) {        selObj.selectedIndex = optionCntr;      }      foundState = true;      optionCntr++    }  }  	if (document.getElementById('shipcountrySelect').value == "US")  	{  		showCounty(choice="ship");  	}  	else {  	  hideCounty(choice="ship"); }     // If the country has no states, change the select to a text box  if ( ! foundState ) {    parentObj = document.getElementById('shipstateSelect').parentNode;    parentObj.removeChild(selObj);  // Create the Input Field    var inputEl = document.createElement("INPUT");    inputEl.setAttribute("id", "shipstateSelect");    inputEl.setAttribute("type", "text");    inputEl.setAttribute("name", "shipping_state");    inputEl.setAttribute("size", 20);    inputEl.setAttribute("value", postState);    parentObj.appendChild(inputEl) ;  }}function initShipCountry(country) {  if (country == ''){     country = 'NONE';  }     populateShippingCountry(country);  populateShippingState();}// Populates the country selected with the counties from the country listfunction populateCountry(defaultCountry) {  if ( postCountry != '' ) {    defaultCountry = postCountry;  }  var countryLineArray = country.split('|');  // Split into lines  var selObj = document.getElementById('countrySelect');  selObj.options[0] = new Option('Select Country','');  selObj.selectedIndex = 0;  for (var loop = 0; loop < countryLineArray.length; loop++) {    lineArray = countryLineArray[loop].split(':');    countryCode  = TrimString(lineArray[0]);    countryName  = TrimString(lineArray[1]);    if ( countryCode != '' ) {      selObj.options[loop + 1] = new Option(countryName, countryCode);    }    if ( defaultCountry == countryCode ) {      selObj.selectedIndex = loop + 1;    }  }}function isNumberInput(field, event) {  var key, keyChar;  if (window.event)    key = window.event.keyCode;  else if (event)    key = event.which;  else    return true;  // Check for special characters like backspace  if (key == null || key == 0 || key == 8 || key == 13 || key == 27)    return true;  // Check to see if it's a number  keyChar =  String.fromCharCode(key);  if (/\d/.test(keyChar))     {     window.status = "";     return true;    }   else    {    window.status = "Field accepts numbers only.";    return false;   }}function populateState() {  var selObj = document.getElementById('stateSelect');  var foundState = false;  // Empty options just in case new drop down is shorter  if ( selObj.type == 'select-one' ) {    for (var i = 0; i < selObj.options.length; i++) {      selObj.options[i] = null;    }    selObj.options.length=null;    selObj.options[0] = new Option('Select State','');    selObj.selectedIndex = 0;  }  // Populate the drop down with states from the selected country  var stateLineArray = state.split("|");  // Split into lines  var optionCntr = 1;  for (var loop = 0; loop < stateLineArray.length; loop++) {    lineArray = stateLineArray[loop].split(":");    countryCode  = TrimString(lineArray[0]);    stateCode    = TrimString(lineArray[1]);    stateName    = TrimString(lineArray[2]);  if (document.getElementById('countrySelect').value == countryCode && countryCode != '' ) {    // If it's a input element, change it to a select      if ( selObj.type == 'text' ) {        parentObj = document.getElementById('stateSelect').parentNode;        parentObj.removeChild(selObj);        var inputSel = document.createElement("SELECT");        inputSel.setAttribute("name","billing_state");        inputSel.setAttribute("id","stateSelect");        parentObj.appendChild(inputSel) ;        selObj = document.getElementById('stateSelect');        selObj.options[0] = new Option('Select State','');        selObj.selectedIndex = 0;      }      if ( stateCode != '' ) {        selObj.options[optionCntr] = new Option(stateName, stateCode);      }      // See if it's selected from a previous post      if ( stateCode == postState && countryCode == postCountry ) {        selObj.selectedIndex = optionCntr;      }      foundState = true;      optionCntr++    }  	  }    	if (document.getElementById('countrySelect').value == "US")  	{  		showCounty(choice="bill");  	}  	else {  	  hideCounty(choice="bill"); }     // If the country has no states, change the select to a text box  if ( ! foundState ) {    parentObj = document.getElementById('stateSelect').parentNode;    parentObj.removeChild(selObj);  // Create the Input Field    var inputEl = document.createElement("INPUT");    inputEl.setAttribute("id", "stateSelect");    inputEl.setAttribute("type", "text");    inputEl.setAttribute("name", "billing_state");    inputEl.setAttribute("size", 20);    inputEl.setAttribute("value", postState);    parentObj.appendChild(inputEl) ;  }  }function initCountry(country) {  if (country == ''){     country = 'NONE';  }       populateCountry(country);  populateState(); }function showCounty(choice){   if (choice == "bill"){   document.getElementById('countyspan').style.display = 'inline';}   else
   {      document.getElementById('shipcountyspan').style.display = 'inline';}}function hideCounty(){   if (choice == "bill"){   document.getElementById('countyspan').style.display = 'none';}   else {   document.getElementById('shipcountyspan').style.display = 'none';}   }function initState(stateName, stateCode){        if (stateName != '' && stateCode != ''){		selObj = document.getElementById('stateSelect');		selObj.options[0] = null;        selObj.options[0] = new Option(stateName, stateCode);        selObj.selectedIndex = 0;       }        else if (stateCode != ''){       selObj = document.getElementById('stateSelect');       selObj.setAttribute("name", "billing_state");       selObj.setAttribute("value", stateCode);       }       }function initShipState(stateName, stateCode){        if (stateName != '' && stateCode != ''){		selObj = document.getElementById('shipstateSelect');		selObj.options[0] = null;        selObj.options[0] = new Option(stateName, stateCode);        selObj.selectedIndex = 0;       }         else if (stateCode != ''){       selObj = document.getElementById('shipstateSelect');       selObj.setAttribute("name", "shipping_state");       selObj.setAttribute("value", stateCode);       }      }function handleMatrix() {	if (http.readyState == 4) {				var product = {};		var price;		var description;		var parentDiv;		var inventory;			product = eval('(' + http.responseText + ')');	    document.getElementById('photo').src = product.photo;		description = document.createElement('div');		description.setAttribute("id", "description");		description.innerHTML = product.description;		r = document.getElementById("description");		parentDiv = r.parentNode;		parentDiv.replaceChild(description, r); 				price = document.createElement('div');		price.setAttribute("id", "price");		price.innerHTML = product.price;		r = document.getElementById("price");		parentDiv = r.parentNode;		parentDiv.replaceChild(price, r);		inventory = document.createElement('div');		inventory.setAttribute("id", "inventory");		inventory.innerHTML = product.inventory;		r = document.getElementById("inventory");		parentDiv = r.parentNode;		parentDiv.replaceChild(inventory, r);			}	return false;	}function getMatrix() {	var size = document.getElementById("web_size").value;	var color = document.getElementById("web_color").value;	var productCode = document.getElementById("item").value;	var newURL = url + '?action=matrix&product='+escape(productCode)+"&color="+escape(color)+"&size="+escape(size);	http.open("GET", newURL, true);	http.onreadystatechange = handleMatrix;	http.send(null);		return false;}function handleShipping() {	if (http.readyState == 4) {				var s = eval('(' + http.responseText + ')');		var r;		price = document.createElement('div');		price.setAttribute("id", "shipping");		price.innerHTML = s.shipping;		r = document.getElementById("shipping");		parentDiv = r.parentNode;		parentDiv.replaceChild(price, r);				price = document.createElement('div');		price.setAttribute("id", "total");		price.innerHTML = s.total;		r = document.getElementById("total");		parentDiv = r.parentNode;		parentDiv.replaceChild(price, r);	}	return false;	}function getShippingTotal( shippingMethod) {	var newURL = url + '?action=addShipping&method='+shippingMethod;	http.open("GET", newURL, true);	http.onreadystatechange = handleShipping;	http.send(null);		return false;}function getHTTPObject() {  var xmlhttp;  /*@cc_on  @if (@_jscript_version >= 5)    try {      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");    } catch (e) {      try {        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");      } catch (E) {        xmlhttp = false;      }    }  @else  xmlhttp = false;  @end @*/  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {    try {      xmlhttp = new XMLHttpRequest();    } catch (e) {      xmlhttp = false;    }  }  return xmlhttp;}var http = getHTTPObject();
