function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function popup(url, width, height, name, resizable, scrollbars) {

	pWidth = width;
	pHeight = height;
	
	pTop = Math.ceil((screen.height-pHeight*1.5)/2);
	pLeft = Math.ceil((screen.width-pWidth)/2);
	
	if(resizable != "") {
		pResizable = resizable;
	} else {
		pResizable = "no";
	}
	
	if(scrollbars != "") {
		pScrollbars = scrollbars;
	} else {
		pScrollbars = "no";
	}
	
	if(name != "") {
		pName = name;
	} else {
		pName = "Popup";
	}
	
	winopts = "toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0,scrollbars="+pScrollbars+",resizable="+pResizable+",width="+pWidth+",height="+pHeight+",top="+pTop+",left="+pLeft;
	smallwindow=window.open(url, pName, winopts);
	smallwindow.focus();
}


function buttons() {
	
	var searchbutton = document.getElementById("searchbutton");
	if(searchbutton) {
		searchbutton.onclick = function () {
			if(document.searchform.q.value != "") {
				document.searchform.submit();
			}
		}	
	}

	var printfriendlylink = document.getElementById("printfriendlylink");
	if(printfriendlylink) {
		printfriendlylink.onclick = function () {
			popup(this.href, 750, 600, "Printpreview", "yes", "yes");
			return false;
		}	
	}

	var printlink = document.getElementById("printlink");
	if(printlink) {
		printlink.onclick = function () {
			print();
			return false;
		}	
	}
	
}

function hovershareprice() {
	var sharepriceblock=document.getElementById("spoverview");
	if (sharepriceblock) {
		sharepriceblock.onmouseover = function() {this.className="pricehover";}
		sharepriceblock.onmouseout = function() {this.className="";}
		sharepriceblock.onclick = function() {document.location=document.getElementById("sharepricelink").href;}
	}
}

addLoadEvent(buttons);
addLoadEvent(hovershareprice);
