function makeInputElement(formObj,elemType,elemName,elemVal) {
	aNode = document.createElement('Input');
	aNode.setAttribute('type', elemType);
	aNode.setAttribute('name', elemName);
	aNode.setAttribute('value', elemVal);
	formObj.appendChild(aNode);
}
function categorySelected(point_id,srchForm,srchType) {
	if (srchType == "ADV") {
		for (var i = 0; i < srchForm.select_category.options.length; i++) {
			if (srchForm.select_category.options[i].selected) {
				//Begin: add by iris on 20060515 [PZ_Feb06/01]
				if(currentCatalogIndex == i) {
					srchForm.from.value = "";
				} else {
					srchForm.from.value = "searchboxdropdown";
				}
				//End: add by iris on 20060515 [PZ_fEB06/01]
				selected_point_id = point_ids[i];
				selected_catalog_id = srchForm.select_category.options[i].value;
				srchForm.action=domain_names[i];
				break;
			}
		}
		if(srchForm.prod_id != null) {
			var switchedCatalogs = ((currentCatalogId != selected_catalog_id) && (selected_catalog_id != ""));
			if (switchedCatalogs && srchForm.prod_id.checked) {
				checkSearchWithinCategory(point_id,srchForm,srchType);
			}
		}
	}
}
function setSearchValues(srchType,formObj) {
	if (srchType == "PRODUCT") {
		if ((formObj.AGG != null) && formObj.AGG.value == "Y")
			formObj.point_search.value='off';
		else
		formObj.point_search.value='on';
		formObj.page.value = 'search/ProductSearchResults';
		formObj.product_search.value="on";
		formObj.supplier_search.value="off";
		formObj.article_search.value="off"; 		
	} else if (srchType == "SUPPLIER") {
		if ((formObj.AGG != null) && formObj.AGG.value == "Y")
			formObj.point_search.value='off';
		else
		formObj.point_search.value='on';
		formObj.page.value = 'search/SupplierSearchResults';
		formObj.supplier_search.value="on";
		formObj.product_search.value="off";
		formObj.article_search.value="off";
	} else if (srchType == "ARTICLE") {
		formObj.AGG.value='N';
		formObj.point_search.value='off';
		formObj.page.value = 'search/ArticleSearchResults';
		formObj.article_search.value="on";
		formObj.supplier_search.value="off";
		formObj.product_search.value="off";
		formObj.AGG.value='';
		formObj.AGG.name='';
	}
}
function checkSearchWithinCategory(point_id,srchForm,srchType) {
	if (typeof document.advsearchbox != "undefined")
		document.advsearchbox.searchWithin.checked=false;
	var switchedCatalogs = ((currentCatalogId != selected_catalog_id) && (selected_catalog_id != "") && (srchType=="ADV"));
	var msg4="To search within a different category, please do a new search.";
	if (switchedCatalogs && srchForm.prod_id.checked) {
		alert(msg4);
		srchForm.prod_id.checked=false;
		if ((typeof document.advsearchbox != "undefined") && srchType == "ADVANCED")
			document.advsearchbox.searchWithin.checked=true;
	} else {
		srchForm.point_id.value=point_id;
		if ((typeof document.advsearchbox != "undefined") && srchType == "ADVANCED")
			document.advsearchbox.searchWithin.checked=false;
	}
}

function checkSearchWithinResults(FORMOBJ,POINTID,PRODID,SRCHPAGE,SRCHTYPE) {
	var switchedCatalogs = ((currentCatalogId != selected_catalog_id) && (selected_catalog_id != ""));
	var searchWithinMsg1="To search for suppliers or news, do a new search.";
	var searchWithinMsg2="To search for product or news, do a new search.";
	var searchWithinMsg3="To search for product or suppliers, do a new search.";
	var searchWithinMsg4="To search within a different category, please do a new search.";
	if ((SRCHTYPE == "ADV") && (typeof document.advsearchbox != "undefined")) {
		if (switchedCatalogs && FORMOBJ.searchWithin[1].checked) {
			alert(searchWithinMsg4);
			FORMOBJ.searchWithin[0].checked=true;
		} else {
			if (SRCHPAGE == "PRODUCT") {
				if((FORMOBJ.search_what.value == "2" || FORMOBJ.search_what.value == "3") && FORMOBJ.searchWithin[1] != null && FORMOBJ.searchWithin[1].checked == true) {
					alert(searchWithinMsg1);
					FORMOBJ.searchWithin[0].checked=true;
				}
			}
			if (SRCHPAGE == "SUPPLIER") {
				if((FORMOBJ.search_what.value == "1" || FORMOBJ.search_what.value == "3") && FORMOBJ.searchWithin[1] != null && FORMOBJ.searchWithin[1].checked == true) {
					alert(searchWithinMsg2);
					FORMOBJ.searchWithin[0].checked=true;
				}
			}
			if (SRCHPAGE == "ARTICLE") {
				if((FORMOBJ.search_what.value == "2" || FORMOBJ.search_what.value == "1") && FORMOBJ.searchWithin[1] != null && FORMOBJ.searchWithin[1].checked == true) {
					alert(searchWithinMsg3);
					FORMOBJ.searchWithin[0].checked=true;
				} 
			}
		}
		if (FORMOBJ.searchWithin[1].checked) {
			FORMOBJ.type.value = "step";
			selected_prod_id = PRODID;
			FORMOBJ.point_id.value = POINTID;
		}
	} else {
		if (SRCHPAGE == "PRODUCT") {
			if((FORMOBJ.search_what.value == "2" || FORMOBJ.search_what.value == "3") && FORMOBJ.searchWithin != null && FORMOBJ.searchWithin.checked == true) {
				alert(searchWithinMsg1);
				FORMOBJ.searchWithin.checked=false;
			}
		}
		if (SRCHPAGE == "SUPPLIER") {
			if((FORMOBJ.search_what.value == "1" || FORMOBJ.search_what.value == "3") && FORMOBJ.searchWithin != null && FORMOBJ.searchWithin.checked == true) {
				alert(searchWithinMsg2);
				FORMOBJ.searchWithin.checked=false;
			}
		}
		if (SRCHPAGE == "ARTICLE") {
			if((FORMOBJ.search_what.value == "2" || FORMOBJ.search_what.value == "1") && FORMOBJ.searchWithin != null && FORMOBJ.searchWithin.checked == true) {
				alert(searchWithinMsg3);
				FORMOBJ.searchWithin.checked=false;
			} 
		}
		if (FORMOBJ.searchWithin.checked) {
			FORMOBJ.type.value = "step";
			selected_prod_id = PRODID;
			FORMOBJ.point_id.value = POINTID;
		}
	}
}
function syncSearchTabs(myVal) {
	vtab = document.getElementById?document.getElementById("veriftabs"):veriftabs;
	vmes = document.getElementById?document.getElementById("verimessage"):verimessage;
	vtext = document.getElementById?document.getElementById("veriftext"):veriftext;
	unvtext = document.getElementById?document.getElementById("unveriftext"):unveriftext;
		if (myVal == "3") {
			vtab.style.visibility = 'hidden';
			//vmes.style.visibility = 'hidden';	
			document.searchbox.query.className = 'srch-query-box-allbord';
		} else if (myVal == "2") {
			vtab.style.visibility = 'visible';
			//vmes.style.visibility = 'visible';	
			document.searchbox.query.className = 'srch-query-box';
		} else if (myVal == "1") {
			vtab.style.visibility = 'visible';
			//vmes.style.visibility = 'visible';	
			document.searchbox.query.className = 'srch-query-box';
		}
	}
function goWebSearch(webSrchFrm, normSrchForm) {
	if (normSrchForm.query.value.length > 0 && normSrchForm.query.value!='Enter product keyword to search' && normSrchForm.query.value!='Enter supplier name to search') {
		if (normSrchForm.search_what[normSrchForm.search_what.selectedIndex].value == "3") {
			setUpHeaderSearch();
		} else {
		webSrchFrm.query.value = normSrchForm.query.value;
		webSrchFrm.submit();
		}
	} else {
		alert("Please enter a keyword first\nto start your search.");
	}
}
function getGoogleResults(googleForm, normSrchForm) {
	if (normSrchForm.query.value.length > 0) {
		googleForm.q.value = normSrchForm.query.value;
		googleForm.submit();
	} else {
		alert("Please enter a keyword first\nto start your search.");
	}
}
function tabSetHeaderSearch(aggValStr) {
	if (document.searchbox.query.value.length > 0) {
		document.searchbox.AGG.value = aggValStr;
		setUpHeaderSearch();
	} else {
		alert("Please enter a keyword first\nto start your search.");
	}
}
function setUpHeaderSearch() {
	if (document.searchbox.AGG.value == "Y")
		goUnverifiedSearch();
	else
		submitHeaderSearch();
}
function uncheckWithin() {
	if (typeof document.searchbox.prod_id != "undefined") {
		document.searchbox.prod_id.checked = false;
	} else if (typeof document.searchbox.searchWithin != "undefined") {
		document.searchbox.searchWithin.checked = false;
	}
}
function goUnverifiedSearch() {
	document.searchbox.catalog_id.value = gsol_cat_id;
	document.searchbox.point_id.value = gsol_root_id;
	categorySelected(gsol_root_id,document.searchbox,'SIMPLE');
	if (typeof document.searchbox.prod_id != "undefined") {
		document.searchbox.prod_id.value = "0";
		selected_prod_id = "0";
	} else if (typeof document.searchbox.searchWithin != "undefined") {
		selected_prod_id = "0";
	}
	submitHeaderSearch();

}
function showToolTip(){
	if (document.cookie.indexOf("gs_srchtab_callout_displayed=yes")<0) {
		var obj = document.getElementById('calloutBubble');
		var butn = document.getElementById('redNewButton');
		if (butn!=null) {
			obj.style.display = 'block';
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
			var leftPos = findPos(butn,'x') + 60;
			obj.style.left = leftPos + 'px';
			obj.style.top = (findPos(butn,'y') - 112) + st + 'px';
		}
		var date = new Date();
			date.setTime(date.getTime()+(999*24*60*60*1000));
	    document.cookie = "gs_srchtab_callout_displayed=yes; expires=" + date.toGMTString() + "; domain=.globalsources.com; path=/"; 
	}
}	
function hideToolTip() {
	document.getElementById('calloutBubble').style.display = 'none';
}
function findPos(obj,pos) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	if (pos=="x")
		return curleft;
	if (pos=="y")
		return curtop;
}