
/* noSpam: anti-spam mailto links */
function nospam(user, domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

/* externalLink: standards compliant target attribute for links */
function externalLink() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
	}
}

function shownhide(id){
  if(document.getElementById(id)){
    var theElement = document.getElementById(id);
    if(theElement.style.display == "none"){
      theElement.style.display = "block";
    }else{
      theElement.style.display = "none";
    }
  }
}

function remove_product( productid ){
  if(confirm("Are you sure you want to remove this product?")){
    window.location.href = "/www/removeproduct/" + productid;  
  }
}

function update_description(text) {
  document.getElementById('section-description').innerHTML = text;
}

function update_cart() {
  new Ajax.Updater('cart-items', '/www/updatecart', {asynchronous:true, evalScripts:true, parameters:Form.serialize($('cart'))});
}

function hide_cart() {
  document.getElementById('cart-items').style.display = 'none';
}

function restart(FormObject) {
  Form.reset(FormObject);
}
function windowOnload() {
  externalLink();
}

if ((document.getElementById || document.all) && document.images) {
	window.onload = windowOnload;
}

