/** popupsearch.js **/

function popSearch(page,height,width) {
	popSearch(page,height,width,"no");
}
function popSearch(page,height,width,scrlbar) {
	params = "height=" + height + ",width=" + width + ",status=yes,toolbar=no,directories=no,menubar=no,location=no,scrollbars=" + scrlbar + ",resizable=yes,top=50,left=50,screenX=50,screenY=50"
	popSearchBox = open(page,"SearchBox",params);
	popSearchBox.focus();
}


/** searchandlisting.js **/


/** originally from main file by jansen **/

function hasCheckedForBasket(){
	var inquiryFormName="inquiry";
	var inquiryForm;
	var ret=false;
	var objColls=inquiryForm=document.getElementsByName(inquiryFormName);
	if(objColls.length>0)
		inquiryForm=objColls[0];
	for (var i=0;i<inquiryForm.elements.length;i++) {
		var e=inquiryForm.elements[i];
		if ((e.type=='checkbox') && e.name!='toggleSA' && e.disabled==false && e.checked==true) {
			ret=true;
			break;
		} 
	}
	return ret;
}

function loseSelectBasketAlert(){
	//important,if no add basket button,then return directly
	//the variant hasAddBasketButton if definded in the jsp page which has the ADD TO BASKET button
	if(typeof(hasAddBasketButton)=='undefined') return true;
	var ret=true;
	if(hasCheckedForBasket()==true){
		if(window.confirm("You have not added the selected items to your basket.\nDo you wish to proceed without adding?")==true)
			ret=true;
		else
			ret=false;
	}
	return ret;
}

//added by Yiweiping 2005-05-11 : judge if the checkbox is selected 
function hasCheckedCategory(formName){
	var inquiryFormName=formName;
	var inquiryForm;
	var ret=false;
	var objColls=inquiryForm=document.getElementsByName(inquiryFormName);
	if(objColls.length>0)
		inquiryForm=objColls[0];
	for (var i=0;i<inquiryForm.elements.length;i++) {
		var e=inquiryForm.elements[i];
		if ((e.type=='checkbox') && e.disabled==false && e.checked==true) {
			ret=true;
			break;
		} 
	}
	return ret;
}

function loseSelectAlert(formName){
	//the variant hasAddBasketButton if definded in the jsp page which has the ADD TO BASKET button
	var ret=true;
	var formName ;
	if ( formName == null || formName=="" )
	{
		formName = document.forms[1].name ;
	}
	if(hasCheckedCategory("setalert")==true){
		if(window.confirm("You have not added the selected categories to your Product Alert. \nDo you wish to proceed without adding?")==true)
			ret=true;
		else
			ret=false;
	}
	return ret;
}
//added by Yiweiping 2005-05-11 : end

/** originally from main pages **/

self.name = "mother";
function checkMax (minfield,maxfield) {
	if (maxfield.value=='' && minfield.value!='') {
		maxfield.value = minfield.value;
	} else {
		curMin = parseInt(minfield.value);
		curMax = parseInt(maxfield.value);
		if (curMax < curMin) {
			maxfield.value = minfield.value;
		}
	}
}

/** originally from JSSelectClearAll **/

function all(name) {
	for ( var i=0; i < document.inquiry.elements.length; i++ ) {
    	var b=document.inquiry.elements[i];
        document.inquiry.elements[i].checked = name;
	}
}
// used for the all ticker because above methods not supported
function tickAll(chkboxset,tickerset,state) {
	if (chkboxset != null) {
		if (chkboxset.length>1) {
			for (var i=0; i < chkboxset.length; i++ ) {
				var chkbox = chkboxset[i];
				chkbox.checked = state;
	   		}
		} else {
			chkboxset.checked = state;
		}
	}
	for (var j=0; j < tickerset.length; j++ ) {
		var ticker = tickerset[j];
		if (ticker.checked != state) {
			ticker.checked = state;	
		}
	}
}
function syncTickers(mycheckbox,tickerset) {
	if(mycheckbox.checked==false) {
		if (tickerset != null) {
			for (var j=0; j < tickerset.length; j++ ) {
				var ticker = tickerset[j];
				ticker.checked = false;	
			}
		}
	}
}
function syncSA(thisChkBox,saTickerBox,saTxtDiv) {
	if(thisChkBox.checked==false) {
		if (saTickerBox!=null && saTickerBox!=undefined && saTickerBox.checked) {
			saTickerBox.checked = false;
			var saTxtDivElem = null;
			if (saTxtDiv!=null) {
				saTxtDivElem = document.getElementById(saTxtDiv);
			}
			if (saTxtDivElem==null) {
				dispToggleTitle(saTickerBox);
			} else if (saTxtDivElem!=null) {
				dispToggleDiv(saTickerBox,saTxtDiv);
			}
		}
	}
}

function selectAllCheckBox(checkBoxName){
	if(checkBoxName!=null){
		if (checkBoxName.length>1) {
			var	somethingNotChecked = false;
			var somethingChecked = false;
			var oEl=document.getElementsByName(checkBoxName);
			var checkboxDivider = document.getElementsByName("upperCheckBoxes");
			var maxBoxesToCheck = oEl.length;
			if (checkboxDivider!=null && checkboxDivider.length>0) {
				maxBoxesToCheck = parseInt(checkboxDivider.item(0).value);
			}
			for (var i=0;i<maxBoxesToCheck;i++){
				var cboxItem = oEl.item(i);
				if (cboxItem.style.display!="none") {
				if (oEl.item(i).checked) {
					somethingChecked = true;
				} else {
					somethingNotChecked = true;
				}
			}
			}
			if (somethingChecked==true && somethingNotChecked==true) {
				for (var i=0;i<maxBoxesToCheck;i++){
					var cboxItem = oEl.item(i);
					if (cboxItem.style.display!="none") {
					oEl.item(i).checked=true;
						rowHighlight(cboxItem);
					}
				}
			} else if (somethingChecked==true && somethingNotChecked==false) {
				for (var i=0;i<maxBoxesToCheck;i++){
					var cboxItem = oEl.item(i);
					if (cboxItem.style.display!="none") {
					oEl.item(i).checked=false;
						rowHighlight(cboxItem);
					}
				}
			} else if (somethingChecked==false && somethingNotChecked==true) {
				for (var i=0;i<maxBoxesToCheck;i++){
					var cboxItem = oEl.item(i);
					if (cboxItem.style.display!="none") {
					oEl.item(i).checked=true;
						rowHighlight(cboxItem);
					}
				}
			}
		} else {
			if (checkBoxName.style.display!="none") {
			if (checkBoxName.checked) {
				checkBoxName.checked = false;
					rowHighlight(checkBoxName);
			} else {
				checkBoxName.checked = true;
					rowHighlight(checkBoxName);
				}
			}
		}
	}
}
function selectAllUnverified(checkBoxName,startFrom){
	if(checkBoxName!=null){
		if (checkBoxName.length>1) {
			var	somethingNotChecked = false;
			var somethingChecked = false;
			var oEl=document.getElementsByName(checkBoxName);
			var maxBoxesToCheck = oEl.length;
			for (var i=startFrom;i<maxBoxesToCheck;i++){
				if (oEl.item(i).checked) {
					somethingChecked = true;
				} else {
					somethingNotChecked = true;
				}
			}
			if (somethingChecked==true && somethingNotChecked==true) {
				for (var i=startFrom;i<maxBoxesToCheck;i++){
					oEl.item(i).checked=true;
					rowHighlight(oEl.item(i));
				}
			} else if (somethingChecked==true && somethingNotChecked==false) {
				for (var i=startFrom;i<maxBoxesToCheck;i++){
					oEl.item(i).checked=false;
					rowHighlight(oEl.item(i));
				}
			} else if (somethingChecked==false && somethingNotChecked==true) {
				for (var i=startFrom;i<maxBoxesToCheck;i++){
					oEl.item(i).checked=true;
					rowHighlight(oEl.item(i));
				}
			}
		} else {
			if (checkBoxName.checked) {
				checkBoxName.checked = false;
				rowHighlight(checkBoxName);
			} else {
				checkBoxName.checked = true;
				rowHighlight(checkBoxName);
			}
		}
	}
}


/** originally from JSPopupHelp **/

function popup(page,height,width) {
	params = "height=" + height + ",width=" + width + ",status=no,toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,resizable=yes,top=50,left=50,screenX=50,screenY=50"
	popHelp = open(page,"HelpWindow",params);
	popHelp.focus();
}

//get visitors' screen resolution, append to a image url, 
//then write to current document
function writeScreenResolution(blankGIF){
	var r;
	do {
		r=Math.ceil(Math.random()*10000000000);
	} while(r<1000000000);
	var w=screen.width;
	var h=screen.height;
	var resolURL=blankGIF+"?resol="+w+"by"+h+"&rand="+r;
	document.write("<img src=\""+resolURL+"\" width=0 height=0 border=0>");
}

//added by jacky xiao for mr10907
var allSelect = true;
function selectAll(){
	var lst = document.getElementsByTagName("input");

    for(i=0;i<lst.length;i++){
		if((lst[i].type=="checkbox")&&(lst[i].checked!=true))
          allSelect = false;
	}
	
	if(!allSelect){
	   for(i=0;i<lst.length;i++){
		 if((lst[i].type=="checkbox")&&(lst[i].checked!=true))lst[i].click();
	   }
	   allSelect = true;
	}else{
	   allSelect = false;
	   for(i=0;i<lst.length;i++){
		 if(lst[i].type=="checkbox")lst[i].click();
	   }
	}
}

/** below are added/extracted for MR #11483: Javascript and code enhancement for web page performance **/

function changeItemsPerPage(obj){
	document.inquiry.action="http://www.globalsources.com/gsol/GeneralManager?action=SetItemsPerPage&redirect_to=this" + "&items_per_page=" + obj.value;
	document.inquiry.submit();
}

// originally from JSPopup.js
function popup(categories) {
	window.open(categories,"catalog",'toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars=1,width=400,height=450,resizable=0,screenX=100,screenY=100');
}

function pop(page,height,width)
{
	params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=1,resizable=1,top=50,left=50,screenX=50,screenY=50";
	mypopup = window.open(page,"PopupWindow",params);
	mypopup.focus();
}

function gsim(url,supplierName,height,width)
{
        page=url+escape(supplierName);
        params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=1,resizable=1,top=50,left=50,screenX=50,screenY=50";
        mypopup = window.open(page,"PopupWindow",params);
        mypopup.focus();
}

function secondLevelGsim(url,supplierName,height,width){
        page=url+escape(supplierName);
        params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=1,resizable=1,top=50,left=150,screenX=50,screenY=50";
        mypopup = window.open(page,"PopupWindow2",params);
        mypopup.focus();
}
// end JSPopup.js

function openbig_papers(link) {
	msg=open(link,"DisplayWindow","HEIGHT=440,WIDTH=640,status=1,toolbar=1,directories=1,menubar=1,location=1,scrollbars=1,resizable=1,top=50,left=50");
}

function submitSearchAll(mySearchForm) {
	if ((mySearchForm.query.value == "") || (mySearchForm.query.value == "Enter keywords")){
		alert("Please enter a keyword first\nto start your search.");
	} else {
		makeInputElement(mySearchForm,'hidden','action','GetPoint');
		makeInputElement(mySearchForm,'hidden','action','DoFreeTextSearch');
		mySearchForm.submit();
	}
}

function submitSearchInAll() {
	if (document.searchboxInAll.query.value == "") {
		alert("Please enter a keyword first\nto start your search.");
	} else {
		document.searchboxInAll.submit();
	}
}

/* TP/TCS ALPHA PAGINATION */
function exposeSet(whichSet,whichBlock) {
	setToShow = document.getElementById(whichSet);
	blockToHide = document.getElementById(whichBlock);
	for (a=0; a<setArray.length; a++) {
		if (whichSet != setArray[a])
			document.getElementById(setArray[a]).style.display = 'none';
	}
	for (w=0;w<blockArray.length;w++) {
		if (whichBlock != blockArray[w]);
			document.getElementById(blockArray[w]).style.display = 'inline';
	}
	setToShow.style.display = 'block';
	blockToHide.style.display = 'none';
}
	
// originally from searchboxscripts.js
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") {
		if (formObj.AGG != null) {
			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";
		if (formObj.AGG != null) {
			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 == "4" || FORMOBJ.search_what.value == "5" || 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 == "4" || FORMOBJ.search_what.value == "5" || 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;
	vtext = document.getElementById?document.getElementById("veriftext"):veriftext;
	unvtext = document.getElementById?document.getElementById("unveriftext"):unveriftext;
		if (myVal == "3") {
			//vtab.style.visibility = 'hidden';
			document.searchbox.query.className = 'srch-query-sbox';
		} else if (myVal == "2") {
			vtab.style.visibility = 'visible';
			document.searchbox.query.className = 'srch-query-sbox';
		} else if (myVal == "1") {
			vtab.style.visibility = 'visible';
			document.searchbox.query.className = 'srch-query-sbox';
		}
	}
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"){
		if(document.searchbox.searchWithin == null  || !document.searchbox.searchWithin.checked)
			document.searchbox.AGG.value ="";
		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;
}
//end searchboxscripts.js

//orginally from supplier.js
function opencsfvideo(linkhere) 
{
	msg=window.open(linkhere,"DisplayWindow","HEIGHT=525,WIDTH=340,status=no,toolbar=no,directories=no,menubar=no,location=no,scrollbars=no,top=100,left=50,resizable=no");
}
//add for MR#5972 by Felix in Apr 13,2006.
function openInSelf(obj){
	var val = obj.value;
	if (val=='Select' || val=='Empty') return false;
	var selectBox = document.formCategory.category;
	var obj1 = document.formCategory.category.options[selectBox.selectedIndex].text;
	document.formCategory.cateValue.value=obj1;			 
//	val = val + "&selectedCate=" + obj1;			 
	msg=window.open(val,"_parent","");
}

function all(name) {
	for ( var i=0; i < document.inquiry.elements.length; i++ ) {
    	var b=document.inquiry.elements[i];
        document.inquiry.elements[i].checked = name;
	}
}
function selectAllOnPage(name, field1, field2) {
	document.getElementById(field1).style.display = "inline";
	document.getElementById(field1+"b").style.display = "inline";
	document.getElementById(field2).style.display = "none";
	document.getElementById(field2+"b").style.display = "none";
	all(name);
}
// used for the all ticker because above methods not supported
function tickAll(chkboxset,tickerset,state) {
	if (chkboxset != null) {
		if (chkboxset.length>1) {
			for (var i=0; i < chkboxset.length; i++ ) {
				var chkbox = chkboxset[i];
				chkbox.checked = state;
	   		}
		} else {
			chkboxset.checked = state;
		}
	}
	for (var j=0; j < tickerset.length; j++ ) {
		var ticker = tickerset[j];
		if (ticker.checked != state) {
			ticker.checked = state;	
		}
	}
}
//use link to check all boxes instead of all_ticker, Jansen Oct12, 2004
//modified version to make the link a toggle instead
function openbig(link) {
	msg=open(link,"DisplayWindow","HEIGHT=440,WIDTH=640,status=1,toolbar=1,directories=1,menubar=1,location=1,scrollbars=1,resizable=1,top=50,left=50");
}

function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}
//end supplier.js

function putolURL(lechengURL) {
redirectURL = "/am/page/section?section_name=" + lechengURL;
window.location = redirectURL;
}

function addToFavorite(){
    if(navigator.appName=="Netscape"){
		alert("Please press ^D (CTRL-D) to bookmark this page");
    }else if(parseInt(navigator.appVersion)>3){
	    var pagetitle = document.title.toString();
        if (pagetitle=="") {
           pagetitle = "Global Sources: The Largest Base of Suppliers";
        }
        var urlstr = document.location.toString();
        var patternQnMark = /\?/;
        var patternSlash = /\//;
        var patternGM = /GeneralManager/;
        urlstr = urlstr.replace(/http:\/\//,"");
        if (patternSlash.test(urlstr)) {
            if ((urlstr.substring(urlstr.length-4,urlstr.length)==".jsp") ||
                (urlstr.substring(urlstr.length-4,urlstr.length)==".com") ||
                (urlstr.substring(urlstr.length-1,urlstr.length)=="/"))
            {
                window.external.AddFavorite(document.location+"?ref=bmk",pagetitle)
            } else {
                window.external.AddFavorite(document.location+"&ref=bmk",pagetitle)
            }
        }  else if (patternQnMark.test(document.location) || patternGM.test(document.location)) {
            window.external.AddFavorite(document.location+"&ref=bmk",pagetitle)
        } else {
            window.external.AddFavorite(document.location+"?ref=bmk",pagetitle)
        }
    }
}

// originally from JSSelectClearAll.js

function all(name) {
	for ( var i=0; i < document.inquiry.elements.length; i++ ) {
    	var b=document.inquiry.elements[i];
        document.inquiry.elements[i].checked = name;
	}
}
// used for the all ticker because above methods not supported
function tickAll(chkboxset,tickerset,state) {
	if (chkboxset != null) {
		if (chkboxset.length>1) {
			for (var i=0; i < chkboxset.length; i++ ) {
				var chkbox = chkboxset[i];
				chkbox.checked = state;
	   		}
		} else {
			chkboxset.checked = state;
		}
	}
	for (var j=0; j < tickerset.length; j++ ) {
		var ticker = tickerset[j];
		if (ticker.checked != state) {
			ticker.checked = state;	
		}
	}
}
//use link to check all boxes instead of all_ticker, Jansen Oct12, 2004
//modified version to make the link a toggle instead
//end JSSelectClearAll.js

function imSendInquiry(url) {
    document.imForm.action=url ;
    document.imForm.submit();
}

function secondLevelPop(page,height,width){
    params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=1,resizable=1,top=50,left=150,screenX=50,screenY=50";
    mypopup = window.open(page,"PopupWindow2",params);
    mypopup.focus();
}

function updateCountCatagories () {
   setTimeout("self.location.reload()",10000);
}

function inquireAllLoading(type,totalRecs) {
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#cccccc";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	bgObj.style.opacity="0.6";
	bgObj.style.left="0";
	bgObj.style.width=screen.width;//document.body.scrollWidth;//document.body.clientWidth;
	bgObj.style.height=document.body.scrollHeight; //document.body.offsetHeight;
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);
	document.body.style.overflow="hidden";
	
	var selectList = document.getElementsByTagName('select');
	for (i=0; i<selectList.length; i++) {
		selectList[i].style.display = "none";
	}

	var msgObj=document.createElement("div")
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	msgObj.style.position = "absolute";
	msgObj.style.left = "50%";
	msgObj.style.top = document.body.scrollTop + document.body.clientHeight/2;
	msgObj.style.marginLeft = "-225px" ;
	msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="25px";
	msgObj.style.zIndex = "10001";
	document.body.appendChild(msgObj);

	var popStr;
	if (type == "products" || type =="suppliers") {
		popStr = totalRecs + " ";
		popStr += (totalRecs>1?type:type.substring(0,type.length-1));
	} else {
		popStr = type;
	}
	var txt=document.createElement("p");
	txt.setAttribute("id","msgTxt");
	txt.innerHTML="<table width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr><td bgcolor=\"#000000\">"
		+ "<table width=\"350\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" bgcolor=\"#FFFFCC\">"
		+ "<tr><td align=\"center\">&nbsp;</td></tr>"
		+ "<tr><td align=\"center\" nowrap><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">"
		+ "You have selected " + popStr + " to include in your inquiry."
		+ (totalRecs>1?"<br>Please wait while page loads.":"")
		+ "</font></td></tr>"
		+ "<tr><td align=\"center\"><img src=\"http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/AJAX-LOADER.GIF\" width=\"220\" height=\"19\"></td></tr>"
		+ "<tr><td align=\"center\"><a href=\"javascript:removeObjs();\"><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Cancel</font></a></td></tr>"
		+ "<tr><td align=\"center\">&nbsp;</td></tr>"
		+ "</table></td></tr></table>";
	document.getElementById("msgDiv").appendChild(txt);
}

function removeObjs () {
	if (document.all) { // for IE
		document.execCommand("Stop");
	} else {
		window.stop();
	}
	document.body.style.overflow="auto";
	var selectList = document.getElementsByTagName('select');
	for (i=0; i<selectList.length; i++) {
		selectList[i].style.display = "";
	}
	var bgObj = document.getElementById("bgDiv");
	var msgObj = document.getElementById("msgDiv");
	document.body.removeChild(bgObj);
	document.body.removeChild(msgObj);
}

var imgWinDiv = document.getElementById("enlarge_images");
function show(largeImgURL) {
	imgWinDiv.innerHTML = "<img src='" + largeImgURL + "' border='1' >";
}
function showPdt(pdtID) {
	var myProdDir = pdtID.substring(pdtID.length-3,pdtID.length);
	imgWinDiv.innerHTML = "<img src='http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/pdt.static.globalsources.com/IMAGES/PDT/SMALL/" + myProdDir + "/S" + pdtID + ".jpg' border='1'>";
	//imgWinDiv.innerHTML = "<img src='http://pdt.static.dev.globalsources.com/IMAGES/PDT/SMALL/" + myProdDir + "/S" + pdtID + ".jpg' border='1'>";
}
function hide() {
	imgWinDiv.innerHTML = "";
}
function move_layer(event) {
	event = event || window.event;
	imgWinDiv.style.left=event.clientX+document.body.scrollLeft+1;
	imgWinDiv.style.top =event.clientY+document.body.scrollTop+1;
}
function hlChecked(thisChkBox,chkBoxes,numElems,origColor) {
	var hlbkg = "#d6ddee";
	if (chkBoxes.length == undefined) {
		var chkBox = chkBoxes;
		var elem1 = "HL" + chkBox.value + "A";
		var obj1 = document.getElementById(elem1);
		var elem2 = "HL" + chkBox.value + "B";
		if (chkBox.checked && (obj1!=null && obj1!=undefined)) {
			obj1.style.backgroundColor = hlbkg;
			if (obj1.className=='gridprdHL')
				obj1.className='gridprdNoHL';
			if (numElems == 2) {
				var obj2 = document.getElementById(elem2);
				if (obj2!=null && obj2!=undefined) {
				obj2.style.backgroundColor = hlbkg;
				if (obj2.className=='gridprdHL')
					obj2.className='gridprdNoHL';
			}
			}
		} else if (obj1!=null && obj1!=undefined && (chkBox.value == thisChkBox.value)) {
			obj1.style.backgroundColor = origColor;
			if (numElems == 2) {
				var obj2 = document.getElementById(elem2);
				if (obj2!=null && obj2!=undefined)
				obj2.style.backgroundColor = origColor;
			}
		}
	} else {
		for (var j=0; j < chkBoxes.length; j++ ) {
			var chkBox = chkBoxes[j];
			var elem1 = "HL" + chkBox.value + "A";
			var obj1 = document.getElementById(elem1);
			var elem2 = "HL" + chkBox.value + "B";
			if (chkBox.checked && (obj1!=null && obj1!=undefined)) {
				obj1.style.backgroundColor = hlbkg;
				if (obj1.className=='gridprdHL')
					obj1.className='gridprdNoHL';
				if (numElems == 2) {
					var obj2 = document.getElementById(elem2);
					if (obj2!=null && obj2!=undefined) {
					obj2.style.backgroundColor = hlbkg;
					if (obj2.className=='gridprdHL')
						obj2.className='gridprdNoHL';
				}
				}
			} else if (obj1!=null && obj1!=undefined && (chkBox.value == thisChkBox.value)) {
				obj1.style.backgroundColor = origColor;
				if (numElems == 2) {
					var obj2 = document.getElementById(elem2);
					if (obj2!=null && obj2!=undefined)
					obj2.style.backgroundColor = origColor;
				}
			}
		}
	}
}

/** Added for Product Mouse Over MR **/
function getPPPosition(tag){
	var Position =[0,0];
	while(tag){
		tn=tag.tagName.toUpperCase();
		Position[0]+=tag.offsetLeft;
		Position[1]+=tag.offsetTop;
		if(tn=="BODY") break;
		tag=tag.offsetParent;
	}
	return Position;
}
function showPPSummary(e,prodID,inBasket,rollOvInqURL){
	try {
		clearTimeout(timer);
	} catch(s) {}

	$("showFrame_inq").href = rollOvInqURL + "&product_id=" + prodID;

	if (inBasket) {
		$("showFrame_addbask").innerHTML = "Added to Basket";
		$("showFrame_addbask").href = "http://" + (((typeof thisHost != "undefined") && (thisHost != null))?thisHost:"www.globalsources.com") + "/gsol/GeneralManager?action=ReMap&where=GoInquiryBasket";
	} else {
		$("showFrame_addbask").innerHTML = "Add to Basket";
		$("showFrame_addbask").href = "http://" + (((typeof thisHost != "undefined") && (thisHost != null))?thisHost:"www.globalsources.com") + "/gsol/nsl/GeneralManager?redirect_to=this&action=AddInquiryItem&product_id=" + prodID;
	}

	eventElement=e.target||e.srcElement;
	var elementSrc = eventElement.src;
	var elementAlt = eventElement.alt;
	var elementParentHref = eventElement.parentNode.href;
	
	var toUse = prodID;
	var myProdDir = toUse.substring(toUse.length-3,toUse.length);
	//var src = "http://pdt.static.dev.globalsources.com/IMAGES/PDT/SMALL/" + myProdDir + "/S" + toUse + ".jpg";
	var src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/pdt.static.globalsources.com/IMAGES/PDT/SMALL/" + myProdDir + "/S" + toUse + ".jpg";
	
	var xy = getPPPosition(eventElement);
	var showF = $("showFrame");
	var showFB = $("showFrame_bg");
	showF.style.left = showFB.style.left = (xy[0]+imgWidth)+"px";
	showF.style.top = showFB.style.top = (xy[1]-overTop )+"px";
	showF.style.display = showFB.style.display = "block";
	$("showFrame_img").src = src;
	$("showFrame_img").alt = elementAlt;
	$("showFrame_img").parentNode.href = elementParentHref;
}
function showPPOut(){
	timer = setTimeout("donePPOut()",500);
}
function donePPOut(){
	$("showFrame").style.display = $("showFrame_bg").style.display = "none";
}
function clearPPTimer(){
	try {
		clearTimeout(timer);
	} catch(s) {}
}

function showOnlineSourcing() {
	document.getElementById("menulist2").style.width = document.getElementById("menuon").offsetWidth + 1;
	document.getElementById("menulist2").style.display = "block";
	document.searchbox.search_what.style.visibility = "hidden";
}
function hideOnlineSourcing() {
	document.getElementById("menulist2").style.display = "none";
	document.searchbox.search_what.style.visibility = "visible";
	document.searchbox.search_what.style.display = "inline";   //jun2009 -- to fix the dhtml dropdown that won't overlap on the select list
}

function rowHighlight(checkboxObj) {
	var hlbkg = "#d6ddee";
	var origColor = checkboxObj.style.backgroundColor;
	var elem1 = "HL" + checkboxObj.value + "A";
	var obj1 = document.getElementById(elem1);
	var elem2 = "HL" + checkboxObj.value + "B";
	if (obj1!=null && obj1!=undefined) {
		if (checkboxObj.checked) {
			obj1.style.backgroundColor = hlbkg;
			if (document.getElementById(elem2)!=null && document.getElementById(elem2)!=undefined) {
				var obj2 = document.getElementById(elem2);
				obj2.style.backgroundColor = hlbkg;
				if (obj2.className=='gridprdHL')
					obj2.className='gridprdNoHL';
			}
		} else {
			obj1.style.backgroundColor = origColor;
			if (obj1.className=='gridprdHL')
				obj1.className='gridprdNoHL';
			if (document.getElementById(elem2)!=null && document.getElementById(elem2)!=undefined) {
				var obj2 = document.getElementById(elem2);
				obj2.style.backgroundColor = origColor;
				if (obj2.className=='gridprdHL')
					obj2.className='gridprdNoHL';
			}
		}
	}
}
/*
 * Temp Scripts for select all -> inquire now
 */
function dispToggleTitle(cBoxObj) {
	if (cBoxObj.checked)
		cBoxObj.title = "Uncheck to deselect all items in this section";
	else
		cBoxObj.title = "Check to select all items in this section";
}
function dispToggleDiv(cBoxObj,textDivID) {
	var textDiv = document.getElementById(textDivID);
	if (cBoxObj.checked && textDiv!=null)
		textDiv.innerHTML = "Uncheck to deselect all items in this section";
	else if (!cBoxObj.checked && textDiv!=null)
		textDiv.innerHTML = "Check to select all items in this section";
}
function inqSelectCheckBox(checkBoxName,boolCheck,cBoxObj,textDivID,startFrom) {
	if (cBoxObj!=null && textDivID==null) {
		dispToggleTitle(cBoxObj);
			}
	if (cBoxObj!=null && textDivID!=null) {
		dispToggleDiv(cBoxObj,textDivID);
		}
	if(checkBoxName!=null){
		if (checkBoxName.length>1) {
			var oEl=checkBoxName;
			var checkboxDivider = document.getElementsByName("upperCheckBoxes");
			var maxBoxesToCheck = oEl.length;
			if (checkboxDivider!=null && checkboxDivider.length>0 && startFrom==0) {
				maxBoxesToCheck = parseInt(checkboxDivider.item(0).value);
			}
			for (var i=startFrom;i<maxBoxesToCheck;i++){
				var cboxItem = oEl.item(i);
				if (cboxItem.style.display!="none") {
					if (boolCheck) {
						oEl.item(i).checked=true;
					} else {
						oEl.item(i).checked=false;
					}
					rowHighlight(cboxItem);
				}
			}
		} else {
			if (checkBoxName.style.display!="none") {
				if (boolCheck) {
					checkBoxName.checked = true;
				} else {
					checkBoxName.checked = false;
				}
				rowHighlight(checkBoxName);
			}
		}
	}
}

//Add below for project cGSOL_v94_Display Unverified PPs On Verified PPs Search
var tipwidth='150px' //default tooltip width
var tipbgcolor='#FFFFFF'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="0px" //horizontal offset of tooltip from anchor link
var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
	document.write('<div id="fixedtipdiv" style="padding:2px;visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
		}

function showhidden(obj, e, visible, hidden, tipwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (tipwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=tipwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}else{
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
		}
	return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidetip()
	dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
	dropmenuobj.innerHTML=menucontents

	if (ie4||ns6){
		showhidden(dropmenuobj.style, e, "visible", "hidden", tipwidth)
		dropmenuobj.x=getposOffset(obj, "left")/3
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+5 +"px"
	}
}

function hidetip(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden"
	}
}

function delayhidetip(){
	if (ie4||ns6)
		delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
	}
var desc = "<font style='font-family: Arial,sans-serif;font-size:13'><img src='http://www.globalsources.com/gsol/en/clean/images/BLING.GIF' style='float:left; margin:0 5px 5px 0;'><strong>All verified suppliers have been visited by Global Sources at least 3 times to check the accuracy of their information and confirm that they are qualified exporters with a primary <br>business office. </strong></font>";
var descForUnverified = "<font style='font-family: Arial,sans-serif;font-size:13'><img src='http://www.globalsources.com/gsol/en/clean/images/NOT_VERIF.GIF' style='float:left; margin:0 5px 5px 0;'><strong>All unverified suppliers have not been verified by Global Sources. We cannot guarantee the accuracy of company and product information.</strong></font>";
//end cGSOL_v94_Display Unverified PPs On Verified PPs Search
