window.colorSize_jso = {
     
     last:null, 
     availableDate:null,
     availableDate2:null,
     
     // args:
     // o :== the selector(object)
     // h :== the hidden control id(string) to use for recall and set default values.
     // d :== div element id(string) to manage CSS-class.
     // csscname :== the name(string) to set "className" with.
     changeSizes: function (o,h,d,csscname)
     {  
       // hide all the "groupaselectors" selectors
	   var selectors = o.form.getElementsByTagName("select");
	   for (var i = 0; i < selectors.length; i++)
         if ( selectors[i].name == "groupaselectors" )
		   selectors[i].style.visibility='hidden';
		
		if(o.selectedIndex == 0)
		{
			if (window.colorSize_jso.last)
			{
				window.colorSize_jso.last.style.visibility ='visible';
				window.colorSize_jso.last.disabled = true;
				window.colorSize_jso.last.selectedIndex = 0;
				window.colorSize_jso.last = null;
                document.getElementById(h).value = "";
			}
			document.getElementById("buyPull").value = "";
			return;
		}
		
        var i = o[o.selectedIndex].value;
        var s = document.getElementById(i);        
        var div1 = document.getElementById("selectDiv");
        s.style.top = div1.style.top;
        s.style.left = div1.style.left;
        s.style.visibility='visible';
        s.disabled = false;
        document.getElementById(h).value = i;

        document.getElementById(d).setAttribute("className", csscname);
        document.getElementById(d).setAttribute("class", csscname);

        window.colorSize_jso.last = s;
     },

     // args:
     // o :== the selector(object)
     // h :== the hidden control id(string) to use for recall and set default values.
     // d :== div element id(string) to manage CSS-class.
     // csscname :== the name(string) to set "className" with.
     OnLoad: function (o,h,d,csscname)
     {
        var v = document.getElementById(h).value;
        if ( ! v || v == "" ) return;
        window.colorSize_jso.changeSizes(o,h,d,csscname);
     },
     
     setValue: function (sO)
     {
       //sets the hidden form to the value of the last selected size
       var i=document.getElementById("buyPull");
       i.value = sO[sO.selectedIndex].value;
       window.colorSize_jso.recordBackOrder({selectorObject:sO});
       window.colorSize_jso.availableDate = sO[sO.selectedIndex].getAttribute("xavaildate");
       window.colorSize_jso.availableDate2 = sO[sO.selectedIndex].getAttribute("xavaildateprop");
     },
     
     recordBackOrder: function ( args ) {
		var selectorObject = args.selectorObject;
		if(selectorObject[selectorObject.selectedIndex].text.indexOf("outofstock") < 0)return;
		var s=s_gi('dcdcuggaustraliaprod')
		s.prop3=selectorObject[selectorObject.selectedIndex].value.replace(/\s*/g, '');
		s.eVar13=selectorObject[selectorObject.selectedIndex].value.replace(/\s*/g, '');
		s.tl(true,'o','backordered')
		},
	
	validate: function (O) {
	//creates cookie for continue shopping button on shoppingcart.aspx: brings you back to previously viewed page
	createCookie('returnUrl',document.location.href,0);

	if( O.value == null || O.value == "" ) {
		alert('Please select a size and color.');
	    return false;
	}
	
	var t = new Date(); 
	var dateString = t.getFullYear() + t.get0Month() +   t.get0Date(); dateString = dateString*1;
	
	//compare dates to see if the selectedObject is backordered
	if(window.colorSize_jso.availableDate > dateString)
	{
		x=window.confirm( 'The item you have selected is currently backordered.\nWe estimate this item will ship on or before ' + window.colorSize_jso.availableDate2 + '.\n\nTo reserve this item please add the item to your cart and proceed with the checkout process.\nYou will not be charged until the item ships.\n\n Would you like to add this item to your cart?');
		if(x)
		return true;
		else
		return false;
	}
	
	return true;
	
   },

   "END": "end"
};