function ShipCountryChanged( dropdown )
{
  var index = dropdown.selectedIndex;
  var value = dropdown.options[index].value;
  
  location.href = '?cmd=setshippingcountry&c=' + value;
  return true;
}

function ShipMethodChanged( )
{
  location.href = '?cmd=setshippingmethod&m=';
  return true;
}

function toggleBox(box_id) {
  var box = document.getElementById(box_id);
  if (box.style.display == "none") box.style.display = "block";
  else box.style.display = "none";
}

var lastDiv = "";
function showDiv(divName) {
	// hide last div
	if (lastDiv) {
		document.getElementById(lastDiv).className = "hiddenDiv";
	}
	//if value of the box is not nothing and an object with that name exists, then change the class
	if (divName && document.getElementById(divName)) {
		document.getElementById(divName).className = "visibleDiv";
		lastDiv = divName;
	}
}

function data_copy()
{
  if(document.form.copy[0].checked){
    document.form.s1.value=document.form.b1.value;
    document.form.s2.value=document.form.b2.value;
    document.form.ss.value=document.form.bs.value;
    document.form.shn.value=document.form.bhn.value;		
    document.form.sz.value=document.form.bz.value;
    document.form.sc.value=document.form.bc.value;
    document.form.shipcountry.value=document.form.billcountry.value;
  }else{
    document.form.s1.value="";
    document.form.s2.value="";
    document.form.ss.value="";
    document.form.shn.value="";		
    document.form.sz.value="";
    document.form.sc.value="";
    document.form.shipcountry.value="";
  }
}

function setVisible(id, visible) {
    var o = document.getElementById(id); //get the element based on it's id
    //if the element exists then set it's visiblity
    if (typeof(o) != 'undefined') o.style.visibility = visible ? 'visible' : 'hidden';
    if (typeof(o) == 'undefined') alert("Element with id '" + id + "' not found.");
}

function setDisplay(id, visible) {
    var o = document.getElementById(id);
    if (typeof(o) != 'undefined') o.style.display = visible ? 'block' : 'none';
    if (typeof(o) == 'undefined') alert("Element with id '" + id + "' not found.");
}

