function go(form) {
   window.location = form.range.options[form.range.selectedIndex].value;

}
   
function preload_images () {
   var d = document;
	 if (!d.imgs) { d.imgs = new Array(); }
	 var j = d.imgs.length, args = preload_images.arguments, i;
	 for (i = 0; i < args.length; i++) {
		  d.imgs[j] = new Image;
			d.imgs[j].src = args[i];
			j++;
	 }
}


 function bookmark(title)
 {

   var urlAddress = location.href;
   var pageName = title;
   var browser = navigator.appName;

  if (browser == 'Microsoft Internet Explorer')
  {
     window.external.AddFavorite(urlAddress,pageName)
  }
  else if (browser == 'Netscape')
  { 
     alert("Your browser does not support this feature.  Use CTRL-D to bookmark this page");
  }
  else
  { 
   alert("Your browser does not support this feature.");
  }
 }


function addbookmark()
{
bookmarkurl="http://www.womens-hats.com"
bookmarktitle="Womens-Hats.com: Stylish and unique hats for todays woman"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function stateField(theForm) {
 var cntForm = theForm.length;
 for(var i=0;i<cntForm;i++) {
  item = theForm.elements[i];
  if(item.name.substr(0,7) == 's_state') {
   newItem = item.value.split('.');
   var cntItems = newItem.length; var fixedST = '';
   for(var x=0;x<cntItems;x++) {
    if(newItem[x] != '.') {
     fixedST = fixedST + newItem[x];
    }
   }
   item.value = fixedST;
  }
 }
 return true;
}

function checkCC(cField) {
  ccField = document.getElementById('ccField');
  for(var i=0,n=cField.options.length;i<n;i++) {
    ccField.options[0] = null;
  }
  if(cField.value != 'United States') {
    ccField.options[0] = new Option('American Express','AX');
  } else {
    ccField.options[0] = new Option('Visa','VI');
    ccField.options[1] = new Option('Mastercard','MC');
    ccField.options[2] = new Option('American Express','AX');
    ccField.options[3] = new Option('Discover','DI');
  }
}
//This is used to hide/expand any div you want
//here you place the ids of every element you want. For example: Array('a1','a2','a3','thiscanbeanything')
var ids=new Array('shipping_form');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function paymentMethod(method) {
  if (method == 'creditcard') {
    togglePO(true,'#EEE');
    toggleGC(true,'#EEE');
    toggleCC(false,'white');
    document.getElementById('billing_info').style.display="block"; 
  } else if (method == 'purchaseorder') {
    toggleGC(true,'#EEE');
    toggleCC(true,'#EEE');
    togglePO(false,'white');
    document.getElementById('billing_info').style.display="block"; 
  } else if (method == 'giftcertificate') {
    togglePO(true,'#EEE');
    toggleCC(true,'#EEE');
    toggleGC(false,'white');
    document.getElementById('billing_info').style.display="block"; 
  } else if (method == 'paypal') {
    togglePO(true,'#EEE');
    toggleCC(true,'#EEE');
    toggleGC(true,'#EEE');
    document.getElementById('billing_info').style.display="block"; 
  } else {
    togglePO(true,'#EEE');
    toggleCC(true,'#EEE');
    toggleGC(true,'#EEE');
    document.getElementById('billing_info').style.display="block"; 
  }
}

function toggleCC(val,col) {
  if (document.ship_form.print_cc.value == 'y') {
    document.ship_form.ccname.disabled=val;
    document.ship_form.cctype.disabled=val;
    document.ship_form.ccnum.disabled=val;
    document.ship_form.ccexpy.disabled=val;
    document.ship_form.ccname.style.background=col;
    document.ship_form.cctype.style.background=col;
    document.ship_form.ccnum.style.background=col;
    document.ship_form.ccexpy.style.background=col;
    if (typeof document.ship_form.cvv2 != 'undefined') {
      document.ship_form.cvv2.disabled=val;
      document.ship_form.cvv2.style.background=col;
    }
    document.ship_form.ccexpm.disabled=val;
    document.ship_form.ccexpm.style.background=col;
  }
}

function togglePO(val,col) {
  if (document.ship_form.print_po.value == 'y') {
    document.ship_form.purchase_order.disabled=val;
    document.ship_form.purchase_order.style.background=col;
  }
}

function toggleGC(val,col) {
  if (document.ship_form.print_gc.value == 'y') {
    document.ship_form.gift_certificate.disabled=val;
    document.ship_form.gift_certificate.style.background=col;
  }
}

function cardType(type) {
  if (type == 'PL') {
    toggleCT(true,'#EEE');
  } else {
   toggleCT(false,'white');
  }
}

function toggleCT(val,col) {
  document.ship_form.ccexpy.disabled=val;
  document.ship_form.ccexpy.style.background=col;
  document.ship_form.ccexpm.disabled=val;
  document.ship_form.ccexpm.style.background=col;
  if (typeof document.ship_form.cvv2 != 'undefined') {
    document.ship_form.cvv2.disabled=val;
    document.ship_form.cvv2.style.background=col;
  }
}
