function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
  //This is how you create the object in Netscape/FireFox/Safari
  XMLHttpRequestObject = new XMLHttpRequest();
  }else if (window.ActiveXObject) {
    //This is how you create the object in IE
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function getData(dataSource, divID) 
{
  if (XMLHttpRequestObject){
    //setup the object to be used later
    var obj = document.getElementById(divID);
    
    //GET is used to retrieve data, and POST is used to send data to the server
    XMLHttpRequestObject.open("GET", dataSource);
    
    XMLHttpRequestObject.onreadystatechange = function ()
    {
      if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
        //This sets the div contents to the responseText
        obj.innerHTML = XMLHttpRequestObject.responseText;
      }
    }
    //When using the GET method, you need to SEND null to connect to the server and request your data using the XMLHttpRequestObject
    //this 'SEND' is what actually downloads the data
    XMLHttpRequestObject.send(null);
  }
}
function getData2(dataSource, divID) 
{
  //if (XMLHttpRequestObject){
    //setup the object to be used later
    var obj = document.getElementById(divID);
    
    //GET is used to retrieve data, and POST is used to send data to the server
    //XMLHttpRequestObject.open("GET", dataSource);
    
    //XMLHttpRequestObject.onreadystatechange = function ()
    //{
      //if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
        //This sets the div contents to the responseText
        //alert(dataSource);
		obj.innerHTML = dataSource;
      //}
    //}
    //When using the GET method, you need to SEND null to connect to the server and request your data using the XMLHttpRequestObject
    //this 'SEND' is what actually downloads the data
   // XMLHttpRequestObject.send(null);
  //}
}

//I found this dropbox code at http://www.plus2net.com/javascript_tutorial/dropdown-code.php. I give them credit for this awesome-ness.
function SelectSubCat(prodid){
// ON selection of category this function will work
removeAllOptions(document.order.ChooseSize);
//addOption(document.order.ChooseSize, "", "ChooseSize", "");
//alert(document.order.ColorSelect.value);
if(document.order.ColorSelect.value == 'Navy'){
addOption(document.order.ChooseSize,"6 month", "6 month");
addOption(document.order.ChooseSize,"12 month", "12 month");
addOption(document.order.ChooseSize,"18 month", "18 month");
}
if(document.order.ColorSelect.value == 'Turquoise'){
addOption(document.order.ChooseSize,"6 month", "6 month");
addOption(document.order.ChooseSize,"12 month", "12 month");
}
}
////////////////// 

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}
function addOption(selectbox, value, text ) { var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
if(value=="6 month"){
optn.setAttribute("selected","selected")};
selectbox.options.add(optn);
} 
var winW = 400;
      var winH = 200;
      var winX = (screen.availWidth-winW)/2;
      var winY = (screen.availHeight-winH)/2;
	  var info = "'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=no,width="+winW+",height="+winH+",left="+winX+",top="+winY+"'";

function checkEmail(email,form,fieldname)
{

if(email.length > 0)
   {
   if(isNaN(email)){
      form.elements[fieldname].style.background = "pink";
	  form.elements[fieldname].value = "";
	  alert("You need to enter a number in the Quantity box.");
	}else if(email.indexOf('.') >= 0){
   form.elements[fieldname].style.background = "pink";
   form.elements[fieldname].value = "";
   alert("You need to enter a whole number in the Quantity box. No decimals.");
   }else if(email <= 0){
   form.elements[fieldname].style.background = "pink";
   form.elements[fieldname].value = "";
   alert ("You need to enter a positive number greater than zero in the Quantity box.");  
   }else{
   form.elements[fieldname].style.background = "white";
   }
   }
}
function checkEmail2(title,email,form,fieldname)
{
if((title=="Toot-Toot+Train+Onesie") && (document.order.ColorSelect.selectedIndex == 2) && (document.order.ChooseSize.selectedIndex == 3)){
alert("This size is not currently available in this color. \n Sorry for the inconvenience!");
document.order.ChooseSize.options[0].selected = true;
document.order.ColorSelect.options[0].selected = true;
}
}