﻿/*
Name: configurator.js
Purpose: Size and Width Configurator AJAX Engine
Created: 4/13/2008 Vic Berggren
*/
var xmlHttp;var browser = "";var uagString = new String(navigator.userAgent);
if (uagString.indexOf("Firefox") > -1 || uagString.indexOf("Chrome") > -1 || uagString.indexOf("Safari") > -1) {browser = "FF";}else {browser = "IE";}
function LS(){switch(browser){case "IE": xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");break;default: xmlHttp = new XMLHttpRequest(); break;}with(document){getElementById("sizes").options.length = 1;getElementById("sizes").disabled = true;getElementById("widths").options.length = 1;getElementById("widths").disabled = true;var g = (getElementById("gender").options[getElementById("gender").selectedIndex].text);}if (g !="Gender"){var requestUrl = location.protocol + "//" + location.host + "/config_s.asp?g=" + encodeURIComponent(g);var isAsyncRequest = true; if(xmlHttp){with (xmlHttp){onreadystatechange = RS;open("GET", requestUrl, isAsyncRequest);send(null);}}}}
function RS(){with(xmlHttp){if(readyState == 4){(status == 200) ? DS(responseText) : DS(status);}}}
function AS(t,v){var opt = document.createElement("option");document.getElementById("sizes").options.add(opt);opt.text = t;opt.value = v;}
function DS(s){var y = s.split(",");document.getElementById("sizes").disabled = false;for(var m = 0; m < y.length; m++) AS(y[m], y[m]);}
function FW(){switch(browser){case "IE": xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");break;default: xmlHttp = new XMLHttpRequest(); break;}with (document){getElementById("widths").options.length = 1;getElementById("widths").disabled = true;var g = (getElementById("gender").options[getElementById("gender").selectedIndex].text);var s = (getElementById("sizes").options[getElementById("sizes").selectedIndex].text);}if (g !="Gender" && s != "Shoe Size"){var requestUrl = location.protocol + "//" + location.host + "/config_w.asp?g=" + encodeURIComponent(g) + "&s=" + s;var isAsyncRequest = true;if(xmlHttp){with(xmlHttp){onreadystatechange = RW;open("GET", requestUrl, isAsyncRequest);send(null);}}}}
function RW(){if(xmlHttp.readyState == 4){(xmlHttp.status == 200) ? LW(xmlHttp.responseText) : LW(xmlHttp.status);}}
function AW(t,v){var opt = document.createElement("option");document.getElementById("widths").options.add(opt);opt.text = t;opt.value = v;}
function LW(w){var z = w.split(",");document.getElementById("widths").disabled = false;for(var l = 0; l < z.length; l++) AW(z[l], z[l]);}
function gsas(){with(document){var g = (getElementById("gender").options[getElementById("gender").selectedIndex].text);var s = (getElementById("sizes").options[getElementById("sizes").selectedIndex].text);var w = (getElementById("widths").options[getElementById("widths").selectedIndex].text);}window.location.href = location.protocol + "//" + location.host + "/shoe-finder.asp?g=" + g + "&s=" + s + "&w=" + w;}