function writesizes()
	{
	colourselect=document.getElementById('colorselect');
	colour=colourselect.value;
	sizeoptionstd = document.getElementById('sizeoptiontstd');
	while (sizeoptionstd.childNodes[0]) {
    			sizeoptionstd.removeChild(sizeoptionstd.childNodes[0]);
				}
	var hiddeninput = "hidden_" + colour;
	var hiddenobject = document.getElementById(hiddeninput);
	var newoptions = hiddenobject.value;
	var splitoptions = newoptions.split("||");
	newselector = document.createElement("select");

	for (var i in splitoptions)
		{
		if (splitoptions[i]!="") 
			{
			var an_option = document.createElement("option");
			an_option.value = splitoptions[i];
			an_option.innerHTML = splitoptions[i];
			an_option.text = splitoptions[i];
			newselector.appendChild(an_option);
			}
		}
	sizeoptionstd.appendChild(newselector);
	}


function sethtml(div,content)
{
    var search = content;
    var script;
         
    while( script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i))
    {
      search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);
      
      if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break;
      
      block = search.substr(0, search.indexOf(RegExp.$1));
      search = search.substring(block.length + RegExp.$1.length);
      
      var oScript = document.createElement('script');
      oScript.type="text/javascript";
      oScript.text = block;
      document.getElementsByTagName("head").item(0).appendChild(oScript);
    }
   
    document.getElementById(div).innerHTML=content;
} 

function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      sethtml(target,req.responseText);
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div, stylenumber) {
	window.stylenumber=stylenumber;
	pic_src = "php/shframed.php?page=shop&picture=" + stylenumber + "/01";
	document.getElementById('shop_pic').src=pic_src;
	ahah(name,div);
	return false;
}

