var sTypeActive = 'main';
function tabClick(type) {

	document.getElementById('link_'+sTypeActive).style.textDecoration = "underline";
	document.getElementById('link_'+type).style.textDecoration = "none";
	sTypeActive = type;
   doSearch(type);
   setFormAction(type);
}

function doSearch(type) {
		if(type == null)  type =  sTypeActive;

		if(type == 'main') {
			document.homepage.action = "AJmain.jhtml";
		} else if(type == 'image') {
			document.homepage.action = "AJimage.jhtml";
		} else if(type == 'news') {
			document.homepage.action = "AJnews.jhtml";
		} else {
			document.homepage.action(sTypeActive);
		}

		if(document.getElementById('searchfor').value != "") {
			document.homepage.submit();
		}
}

function centerSearch() {
   if(pageHeight() > 200) {
		var marginTop = (pageHeight() - 150) / 2;
		document.getElementById('container').style.marginTop = marginTop;
		document.getElementById('sgpane').style.top=marginTop+86;
   }
   if(pageWidth() > 600) {
	var marginLeft = (pageWidth() - 600) / 2;
	document.getElementById('container').style.marginLeft = marginLeft;
	document.getElementById('sgpane').style.left=marginLeft+143;
  }
}

function pageWidth() {
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
	return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
