function stateSet(thisform,prefix){
	if(!thisform.Country)
	  thisform.Country=document.getElementById(prefix+'Country');
	if(!thisform.State)
	  thisform.State=document.getElementById(prefix+'State');

	if(thisform.Country[thisform.Country.selectedIndex].value=="US-United States")
       thisform.State.selectedIndex=1;
	else if(thisform.Country[thisform.Country.selectedIndex].value=="CA-Canada")
       thisform.State.selectedIndex=64;
    else
      thisform.State.selectedIndex=77;
}

// NOTE: countryid for state divisions is -(country_id*100)
function countrySet(thisform,prefix){
	if(!thisform.Country)
	  thisform.Country=document.getElementById(prefix+'Country');
	if(!thisform.State)
	  thisform.State=document.getElementById(prefix+'State');

	if(thisform.State.selectedIndex >=1 && thisform.State.selectedIndex < 64)
       thisform.Country.selectedIndex=1;
	else if(thisform.State.selectedIndex >= 64 && thisform.State.selectedIndex < 77)
       thisform.Country.selectedIndex=0;
    else
      thisform.Country.selectedIndex=2;
}

function countryBillingSet(thisform){
	if(thisform.BillingState.selectedIndex >=1 && thisform.BillingState.selectedIndex < 64)
       thisform.BillingCountry.selectedIndex=1;
	else if(thisform.BillingState.selectedIndex >= 64 && thisform.BillingState.selectedIndex < 77)
       thisform.BillingCountry.selectedIndex=0;
    else
      thisform.Country.selectedIndex=2;
}
function stateBillingSet(thisform){
	if(thisform.BillingCountry[thisform.BillingCountry.selectedIndex].value=="US-United States")
       thisform.BillingState.selectedIndex=1;
	else if(thisform.BillingCountry[thisform.BillingCountry.selectedIndex].value=="CA-Canada")
       thisform.BillingState.selectedIndex=64;
    else
      thisform.BillingState.selectedIndex=77;
}
function setBox(box,value)
{
   for(i=0;i<box.length;i++)
     if(box[i].value==value)
     {
       	box.selectedIndex=i;
        break;
     }
}

function popup(url,height,width) {
	newwindow=window.open(url,'name','height='+height+',resizable,width='+width);
	if (window.focus) {newwindow.focus()}
	return false;
}

function SetImage(drop)
{
  if(document.getElementById(drop.options[drop.selectedIndex].value) && drop.options[drop.selectedIndex].value!='')
  {
    document.getElementById(drop.options[drop.selectedIndex].value).onmouseover();
  }
  if(!document.getElementById(drop.options[drop.selectedIndex].value) && drop.options[drop.selectedIndex].value!='')
  {
    document.getElementById(drop.options[drop.selectedIndex].value).setAttribute('alt',drop.options[drop.selectedIndex].value);
    document.getElementById(drop.options[drop.selectedIndex].value).setAttribute('title',drop.options[drop.selectedIndex].value);
    document.getElementById('mainimage').src='/gfx/products/no-image.gif';
  }
  else
    ;
}

function SetMainImage(img,src)
{   if(document.getElementById('mainimage')){
    document.getElementById('mainimage').src=src;
    document.getElementById('mainimage').setAttribute('alt',img.getAttribute('alt'));
    document.getElementById('mainimage').setAttribute('title',img.getAttribute('alt'));
    }
    if(document.getElementById('color')){
    document.getElementById('color').innerHTML=img.getAttribute('alt');
   }
}
