/** 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();
	   }
	}
}

function selectAllEMag(field1,field2,action,name){

	if (action == "check") {
		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){
		   document.getElementById(field2).style.display = "inline";
		   document.getElementById(field2+"b").style.display = "inline";
		   document.getElementById(field1).style.display = "none";
		   document.getElementById(field1+"b").style.display = "none";
		}else{
		   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";
		}
	}

	if (action == "select") {
	   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";
		for ( var i=0; i < document.emagform.elements.length; i++ ) {
			var b=document.emagform.elements[i];
			document.emagform.elements[i].checked = name;
		}
	}
}

/** 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) {
	window.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 != null && 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() {
	var myVal = document.searchbox.search_what[document.searchbox.search_what.selectedIndex].value;
	if(myVal == "1"){//for product search display supplier list as default tab		        
        var supp_list = document.createElement("input");
        supp_list.setAttribute("type", "hidden");
        supp_list.setAttribute("name", "supp_list");
        supp_list.setAttribute("value", "true");
        
        var compare_table = document.createElement("input");
        compare_table.setAttribute("type", "hidden");
        compare_table.setAttribute("name", "compare_table");
        compare_table.setAttribute("value", "true"); 
        
        document.searchbox.appendChild(supp_list);
        document.searchbox.appendChild(compare_table);        
	} else { //clear values if not a product search
		if (document.searchbox.supp_list!=null)
			document.searchbox.supp_list.value = "";
		if (document.searchbox.compare_table!=null)
			document.searchbox.compare_table.value = "";
	}
	matchKW();
	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;			 
	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) {
	window.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) {
	document.onmousemove = move_layer;
	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 = "";
	document.onmousemove = null;
}
function move_layer(event) {
	event = event || window.event;
	var scrollTop = 0;
	if (document.body && document.body.scrollTop){
		scrollTop=event.clientY + document.body.scrollTop;
	}else if (document.documentElement && document.documentElement.scrollTop){
		scrollTop=event.clientY + document.documentElement.scrollTop;
	}else{
		var eElement=event.target||event.srcElement;
		var xy = getPPPosition(eElement);
		scrollTop=xy[1] + (event.offsetY || event.layerY);
	}

	imgWinDiv.style.left=event.clientX+document.body.scrollLeft+1;
	imgWinDiv.style.top=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;
}

//bootimage, defaultTSName, osfUrl, bootimage180 added for eGSOL v168 
function showPPSummary(e, prodID, inBasket, rollOvInqURL, bootimage80, defaultTSName, osfUrl, bootimage180){
	try {
		donePPOut();
		clearTimeout(timer);
	} catch(s) {}

	var flag = "";
	if(bootimage80 != null && bootimage80 != "")flag="2";
	
	eventElement=e.target||e.srcElement;

	if(bootimage180 != null && bootimage180 != ""){
		$$("showFrame" + flag).innerHTML = '<a target="_blank" href="' 
			+ osfUrl +'"><img id="showFrame'+flag+'_img" height="180" width="180" alt="" src="' 
			+ bootimage180 + '"></a><br><div class="showFrame'+flag+'_link"><a target="_blank" id="showFrame'+flag+'_booth" href="' 
			+ osfUrl + '">View more photos</a></div>';
	} else {
		//this fix for PA pages, script goes wrong after mousing over OSF due to the above condition
		//basically what this does is rest the original showFrame code
		if ($$("showFrame" + flag + "_inq") == null) {
			$$("showFrame" + flag).innerHTML = '<a href="#"><img width="180" height="180" id="showFrame'+flag+'_img" src="http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/BLANK.GIF" alt="" /></a><br /><div class="showFrame'+flag+'_link"><a href="#" id="showFrame'+flag+'_inq">Inquire now</a> | <a href="#" id="showFrame'+flag+'_addbask">&nbsp;</a></div>';
		}
		$$("showFrame" + flag + "_inq").href = rollOvInqURL + "&product_id=" + prodID;
		if (inBasket) {
			$$("showFrame" + flag + "_addbask").innerHTML = "Added to Basket";
			$$("showFrame" + flag + "_addbask").href = "http://" + (((typeof thisHost != "undefined") && (thisHost != null))?thisHost:"www.globalsources.com") + "/gsol/GeneralManager?action=ReMap&where=GoInquiryBasket";
		} else {
			$$("showFrame" + flag + "_addbask").innerHTML = "Add to Basket";
			$$("showFrame" + flag + "_addbask").href = "http://" + (((typeof thisHost != "undefined") && (thisHost != null))?thisHost:"www.globalsources.com") + "/gsol/nsl/GeneralManager?redirect_to=this&action=AddInquiryItem&product_id=" + prodID;
		}
		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";
		$$("showFrame" + flag + "_img").src = src;
		$$("showFrame" + flag + "_img").alt = elementAlt;
		$$("showFrame" + flag + "_img").parentNode.href = elementParentHref;
	}
	
	if(bootimage80 != null && bootimage80 != "") {
		$$("osfcon_div").innerHTML = "<b>This supplier exhibited at:</b><span class='osfshow'><img width='80' height='80' src='" + bootimage80 + "'></span>" + defaultTSName;
		$$("osfmore_a").href = osfUrl;
	}
	
	var xy = getPPPosition(eventElement);
	var showF = $$("showFrame" + flag);
	var showFB = $$("showFrame" + flag + "_bg");
	if(rollOvInqURL==''){
		showF.style.left = showFB.style.left = (xy[0]+imgWidth-55)+"px";
		showF.style.top = showFB.style.top = (xy[1]-50 )+"px";
	}else{
		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";
	
}
function showPPOut(){
	timer = setTimeout("donePPOut()",500);
}
function donePPOut(){
	$$("showFrame").style.display = $$("showFrame_bg").style.display = "none";
	//added for eGSOL v168 
	if($$("showFrame2")){
		$$("showFrame2").style.display = "none";
	}
	if($$("showFrame2_bg")){
		$$("showFrame2_bg").style.display = "none";
	}
}
function clearPPTimer(){
	try {
		clearTimeout(timer);
	} catch(s) {}
}

//added for MR23700: show large PP only with InquireNow hyperlink
function showPPSummaryWithInq(e,prodID,rollOvInqURL){
	try {
		clearTimeout(timer);
	} catch(s) {}

	$$("showFrame_inq").href = rollOvInqURL + "&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://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;
}
//end added for MR23700

function showTradeShows() {
	document.getElementById("menulist3").style.left = document.getElementById("menuon3").offsetLeft - 1;
	
	document.getElementById("bwidth").style.width = (378 - document.getElementById("menuon3").offsetWidth) +"px";
	FF = (navigator.userAgent.indexOf("Firefox")!=-1);
	if(FF){
		document.getElementById("bwidth").style.width = (380 - document.getElementById("menuon3").offsetWidth) +"px";
	}else{
		chrome = (navigator.userAgent.indexOf("Chrome")!=-1);
		if(chrome){
			document.getElementById("bwidth").style.width = (395 - document.getElementById("menuon3").offsetWidth) +"px";
			document.getElementById("menulist3").style.width = "395px";
			document.getElementById("menulist3").style.height = "388px";	
		}
	}
	
	document.getElementById("menulist3").style.display = "block";
	document.searchbox.search_what.style.visibility = "hidden";
}
function hideTradeShows() {
	document.getElementById("menulist3").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 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 showAboutUs() {
	document.getElementById("menulist8").style.left = document.getElementById("menuon8").offsetLeft - 1;
	document.getElementById("menulist8").style.width = document.getElementById("menuon8").offsetWidth + 8;
	document.getElementById("menulist8").style.display = "block";
}
function hideAboutUs() {
	document.getElementById("menulist8").style.display = "none";
}

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
document.write('<div onMouseover="setShow()" onMouseout="delayhidetip()" id="fixedtipdiv" style="z-index:300;padding:2px;position:absolute; border:1px solid #ccc; background-color:#fff; padding:10px; left:186px; top: 22px;line-height:1.3; font-size:11px;font-family: Arial; display:none;" ></div>')

function setShow(){
	var dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv ;
	dropmenuobj.style.display="block";
	dropmenuobj.style.visibility="visible";
}

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.display="block";
		obj.visibility=visible;
	}
	else if (e.type=="click"){
		obj.display="none";
		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")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+0 +"px"
	}
}

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

function delayhidetip(){
	if (ie4||ns6)
	hidetip();
}

function clearhidetip(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
	}
var desc = "<img src='https://www.globalsources.com/gsol/en/clean/images/BLING_SMAILL.GIF' border='0' style='float:left;'><span style='display:block; margin-left:10px; float:left; height:60px; width:190px;'>Verified suppliers have been visited on-site at least 3 times by Global Sources to make sure they are real, export-ready companies.</span>";
var descForUnverified = "<img src='https://www.globalsources.com/gsol/en/clean/images/NOT_VERIF_SMALL.GIF' border='0' style='float:left; '><span style='display:block; margin-left:10px; float:left; height:60px; width:190px;'>Unverified suppliers do not participate in Global Sources verification process. We cannot guarantee the accuracy of their information.</span>";

//end cGSOL_v94_Display Unverified PPs On Verified PPs Search

// For project eGSOL_v109_Implement Additional Navigational Filters (Jan0902)
var filed1HasContent = false;		
function showallcategories(field1,field2,copy1,copy2,moreurl){
	if (document.getElementById(field1).style.display=='none'){
		document.getElementById(field1).style.display='block';

		if (!filed1HasContent) {
			var page_request = false
			if (window.XMLHttpRequest) // if Mozilla, Safari etc
			page_request = new XMLHttpRequest()
			else if (window.ActiveXObject){ // if IE
			try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
			}
			}
			else
			return false;
			page_request.onreadystatechange=function(){
				if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
				document.getElementById(field1).innerHTML=page_request.responseText
			}
			page_request.open('GET', moreurl, true);
			page_request.send(null);
			filed1HasContent = true;
		}
		document.getElementById(field2).innerHTML = copy2;
	} else {
		document.getElementById(field1).style.display='none';
		document.getElementById(field2).innerHTML = copy1;
	}
}
function showallcategories2(field1,field2,copy1,copy2) {
	if (document.getElementById(field1).style.display=='none'){
		document.getElementById(field1).style.display='block';
		document.getElementById(field2).innerHTML = copy2;
	} else {
		document.getElementById(field1).style.display='none';
		document.getElementById(field2).innerHTML = copy1;
	}
}

//-- NAVIGATOR SCRIPTS
function dropdlistshow(i) {
	var btlist = document.getElementById("btlist" + i);
	if (btlist.style.display == 'none') {
		for (x=1;x<=7;x++) { 
			if (document.getElementById("btlist"+ x)!=null) {
				document.getElementById("btlist"+ x).style.display = 'none';
			}
		}
		btlist.style.display = 'block';
	} else {
		btlist.style.display = 'none';
	}
}
function applySortFilt(formObj) {
	if (formObj[formObj.selectedIndex].text.indexOf("Filter by")==0) {
		popSearch(formObj[formObj.selectedIndex].value,'260','320');
	} else {
		if (formObj[formObj.selectedIndex].value != '') {
			location.href = formObj[formObj.selectedIndex].value;
		}
	}
}

//-- PA_XPROMO_RELPA

function pax_displayRelAlert() {
	if (document.pax_reqpalite.elements.length> 0) {
		for (var i=0;i<document.pax_reqpalite.length;i++) {
      	    var e = document.pax_reqpalite.elements[i];
			if(e.type == "checkbox") {
				if(e.checked == true) {
					return true;
				}
			}
        }
        alert("Please select a category before adding.");
        return false; 
	} else {
		setRelAlert.blur();
    }
}
function pax_chkAlertlimit(url, trackingType, curPageName, currentPANum, paCatLimit) {
    var catLimit = paCatLimit;
    var currentPA = currentPANum;
    var x = 0;
    // get number of chk boxes checked
    if (document.pax_reqpalite.elements.length> 0) {
        for (var i=0;i<document.pax_reqpalite.length;i++) {
	    var e = document.pax_reqpalite.elements[i];
	    if ((e.type == "checkbox") && (e.checked == true))
	        x++;
	}
    }
    var totalAdded = currentPA + x;
    if (totalAdded > catLimit) {
		alert("You have exceeded the maximum of "+catLimit+" categories selected for Product Alert. You currently have "+x+" categories selected. With the new categories you wish to add, you would have a total of "+totalAdded+" categories. Please delete some of the categories you wish to add and then click the \"Receive Alerts\" button again.");
    } else {
        url = url + "&ba_pav9="+trackingType+"&cat="+x;
        pax_relAlertAction(url, curPageName);
    }
}
function pax_relAlertAction(url,curPageName) {
	if (pax_displayRelAlert('setRelAlert')) {
		if (curPageName != null && curPageName == "prodalert/EditAlert") {
			var numChkd = 0;
			if (document.pax_reqpalite.elements.length> 0) {
				for (var i=0;i<document.pax_reqpalite.length;i++) {
					var e = document.pax_reqpalite.elements[i];
					if ((e.type == "checkbox") && (e.checked == true))
						numChkd++;
				}
			}
			document.pax_reqpalite.action=url;
			document.pax_reqpalite.submit();
		} else {
			document.pax_reqpalite.action=url ;
			document.pax_reqpalite.submit();
		}
	}
}

/** for product details tools **/

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6){
	function ietruebody(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
}

function ddrivetip(thetext, thecolor, thewidth){
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	if (ns6||ie){
		
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext;
		enabletip=true
		return false
	}
	
}
function positiontip(e){
	
	var offsetxpoint=-220 //Customize x offset of tooltip
	var offsetypoint=-350 //Customize y offset of tooltip
	if(document.getElementById("isProductVerification")!=null){
		 offsetxpoint=-350 //Customize x offset of tooltip
		 offsetypoint=-230 //Customize y offset of tooltip

		}
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-200
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-200
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
			tipobj.style.left=curX+offsetxpoint+"px"
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-10px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
		}
}
document.onmousemove=positiontip

function formatResult(row) {
	return row[0].replace(/(<.+?>)/gi, '');
}
var myACOptions =  {
	  	mustMatch: false,
		max: 10,
		autoFill: false,
		cacheLength: 1,
		selectFirst: false,
		scrollHeight: 220,
		scroll: false,
		formatResult:formatResult
		
	}

function matchKW(){
	var query=document.searchbox.query.value;
	var appKw=jQuery("#apkw").val();
	if(query!=''){
		if(appKw==query){
			jQuery("#apmatch").val("T");
			}else{
				jQuery("#apmatch").val("F");
				}
	}
}

function changeOption(){
	jQuery("#changeOption").val("T");
}

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

function shows(objid){
	document.getElementById(objid).style.display='block';
}
function hides(objid){
	document.getElementById(objid).style.display='none';
}
	
function hidePApop(){
	if(document.getElementById("PApop"))
		document.getElementById("PApop").style.display='none';
}
function showPApop(){
	if(document.getElementById("PApop"))
		document.getElementById("PApop").style.display='block';
}

function checkIM(page, height, width, type, supplierName){   
	if(isIMLogin=="N"){
		if (document.all) {
		    window.event.returnValue = false;
		}
	    window.location.href = imLoginUrl;
	} else {
		if (type=='pop'){
			pop(page, height, width);
		} else if (type=='popup'){
			popup(page, height, width);
		} else if (type=='gsim'){
			gsim(page, supplierName, height, width);
		} else if (type=='secondLevelGsim') {
			secondLevelGsim(page, supplierName, height, width);
		}
	}
}
function locateBottomRight() {
	var msgBar = document.getElementById("messageDiv");
	if (msgBar != null && msgBar.style.display != "none") {
		msgBar.style.top = document.body.clientHeight + document.body.scrollTop
				- msgBar.clientHeight;
		msgBar.style.left = document.body.clientWidth - msgBar.clientWidth;
	}
	setTimeout("locateBottomRight()", 300);
}

function displayWelcomeMessage() {
	var msgBox = document.getElementById("messageBox");
	if (!GetPACookie("showWelcomeMessage")) {
		locateBottomRight();
		if (msgBox != null){
			msgBox.style.display = "";
		}
	}
}

function closeWelcomeMessage() {
	SetPACookie("showWelcomeMessage", "yes");
	var mesDiv = document.getElementById("messageDiv");
	if (mesDiv != null){
		mesDiv.style.display = "none";
	}
}
	
function showhides(CID,TextID,oText,nText) {
	if (document.getElementById) {
		if (document.getElementById(CID).style.display == "block" || document.getElementById("AllLineProds").style.display == "block") {
			document.getElementById(CID).style.display = "none";
			document.getElementById("AllLineProds").style.display="none";
			document.getElementById(TextID).innerHTML = oText;
			document.images["moreicon"].src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/INQ_PLUS.GIF";
		} else {
			document.getElementById(CID).style.display = "block";
			document.getElementById(TextID).innerHTML = nText;
			document.images["moreicon"].src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/INQ_MINUS.GIF";
		}
	} else if (document.layers) {
		if (document[CID].display == "block") {
			document[CID].display = "none";
			document.getElementById("AllLineProds").style.display="none";
			document[TextID].innerHTML = oText;
		} else {
			document[CID].display = "block";
			document.getElementById("AllLineProds").style.display="none";
			document[TextID].innerHTML = nText;
		}
	}
}

// ADDED FOR SEARCH_V23
function showhideNavs(CID,TextID,IconID,oText,nText) {
	if (document.getElementById) {
		if (document.getElementById(CID).style.display == "block") {
			document.getElementById(CID).style.display = "none";
			document.getElementById(TextID).innerHTML = oText;
			document.images[IconID].src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/INQ_PLUS.GIF";
		} else {
			document.getElementById(CID).style.display = "block";
			document.getElementById(TextID).innerHTML = nText;
			document.images[IconID].src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/INQ_MINUS.GIF";
		}
	} else if (document.layers) {
		if (document[CID].display == "block") {
			document[CID].display = "none";
			document[TextID].innerHTML = oText;
		} else {
			document[CID].display = "block";
			document[TextID].innerHTML = nText;
		}
	}
}
//added for MR24970
function initProductTabContent(productid,counts) { //initialise the content for the PP page
	//DO NOTHING!
	//for (var i=1;i<=counts;i++) {
	//	loadProductTabContent(productid,i,false);
	//}
}
function showProductTab(productid,index,counts){
	syncProductTabs(productid,index,counts);
	if (productTabLoaded[index]=='true') {
		jQuery("#prodTabContent").html(productTabContent[index]);
	} else {
		loadProductTabContent(productid,index,true);
	}
}
function syncProductTabs(productid,index,counts) {
	for (var i=1;i<=counts;i++) {
		if (i==index){
			document.getElementById("prodtab_"+index).className="selectTag";
		} else {
			document.getElementById("prodtab_"+i).className="unselectTag";
		}
	}
}
function loadProductTabContent(productid,index,replaceContent) {
	var myUrl = "/gsol/GeneralManager?action=GetProduct&product_id=" + productid + "&page=ProductDetail_Table_" + productTabFiles[index];
	var myhtml = "";
	jQuery.ajax({
		url:myUrl, 				
		cache: false,
		error:function(XMLHttpRequest, textStatus, errorThrown) {
			productTabContent[index] = "<p>Unable to load data for this tab: " + textStatus + " :: " + errorThrown + "</p>";
			productTabLoaded[index] = 'false';
			if (replaceContent) {
				jQuery("#prodTabContent").html(productTabContent[index]);
			}
		},
		success:function(html) {
			myhtml=html;
		},
		complete: function (XMLHttpRequest, textStatus) {
			if (textStatus == "success") {
				productTabContent[index] = myhtml;
				productTabLoaded[index] = 'true';
				if (replaceContent) {
					jQuery("#prodTabContent").html(productTabContent[index]);
				}
			}
		}

	})
}
function gotoContactDetailsTab(productid) {
	showProductTab(productid,jQuery("#prod_section_cnt").attr("value"),jQuery("#prod_section_cnt").attr("value"));
}

var showTipDoc=function(id){return "string"==typeof id?document.getElementById(id):id;};
var showTips = function(hand,eleId,align){
	this.hand = hand;
	this.eleId = eleId;
	this.align = align;
	this.timer = "";
	var self = this;
	var endPos = getPPPosition(this.hand);
	hand.onmouseout = function(){self.timer = setTimeout(function(){showTipDoc(self.eleId).style.display="none";},10);}
	showTipDoc(this.eleId).onmouseout = function(){self.timer = setTimeout(function(){showTipDoc(self.eleId).style.display="none";},10);}
	showTipDoc(this.eleId).onmouseover = function(){clearTimeout(self.timer);}
	showTipDoc(this.eleId).style.display="block";
	showTipDoc(this.eleId).style.top=(endPos[1]-showTipDoc(eleId).offsetHeight)+"px";
	if(this.align == "right"){
		showTipDoc(this.eleId).style.left=(endPos[0]-showTipDoc(eleId).offsetWidth+hand.offsetWidth)+"px";
	} else {
		showTipDoc(this.eleId).style.left=endPos[0]+"px";
	}
}

/******************begin  ADD FOR V19********************/
function closeMsgForm(){
	var ly=document.getElementById("ly");
	var layer=document.getElementById("Layer");
	if(ly!=null){
		ly.style.display='none';
	}
	if(layer!=null){
		layer.style.display='none';
	} 
}

function getRadioBoxValue(){
	var radioBoxValue="";
	var radios=document.getElementsByName("additionalInfoFlag"); 
	for(var i=0; i<radios.length;i++){
		if(radios[i].checked){
			radioBoxValue=radios[i].value;
			}
		}
	return radioBoxValue;
}

function getBrowserType(){
	 var Sys = {};
	var userAgent = navigator.userAgent; 
	var isOpera = userAgent.indexOf("Opera") > -1;
	if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera){
		return "IE";
		}
	else if (userAgent.indexOf("Firefox") > -1){
		return "FF";
		} 
	else if (userAgent.indexOf("Chrome") > -1){
		return "Chrome";
		}  
	}

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  changeSetting(obj,type){
	var divObjX=getposOffset(obj, 'left');
	var divObjY=getposOffset(obj, 'top');
	var divX=0;
	var divY=0;
	var radioBox=document.getElementById("radioValue");
	var layer=document.getElementById("Layer");
	if(layer!=null){
		if(getBrowserType()=="IE"){
			if(type=="buyerActivity"){
				divX=70;
				if(obj.value=='Y'){
					divY=180;
				}else{
					divY=210;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}else{
				divX=77;
				if(obj.value=='Y'){
					divY=163;
				}else{
					divY=193;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}
		}
		if(getBrowserType()=="FF"){
			if(type=="buyerActivity"){
				divX=66;
				if(obj.value=='Y'){
					divY=168;
				}else{
					divY=198;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}else{
				divX=74;
				if(obj.value=='Y'){
					divY=170;
				}else{
					divY=200;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}
		}
		if(getBrowserType()=="Chrome"){
			if(type=="buyerActivity"){
				divX=65;
				if(obj.value=='Y'){
					divY=168;
				}else{
					divY=198;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}else{
				divX=73;
				if(obj.value=='Y'){
					divY=168;
				}else{
					divY=198;
				}
				layer.style.left=divObjX+divX+"px";
				layer.style.top=divObjY-divY+"px";
			}
		}
	}
	if(radioBox.value != obj.value){
		radioBox.value=obj.value ;
		if(obj.value == 'Y' && type=="buyerActivity"){
			document.getElementById('actitipySeting').submit();
		}else if(obj.value == 'N'){
			layer.style.display='block';
		}
	}
}


function loginSub(){
	var userEmail=document.getElementById("fld_UserEmail").value; 
	if(userEmail==null||userEmail==""){
		alert("Please enter Login Name or E-mail");
		document.getElementById("fld_UserEmail").focus();
		return false;
		}else{
			document.getElementById("actitipySeting").action="/GeneralManager?action=BuyerActivitySettingAdmin&page=useradmin/buyer_activity_admin";
			document.getElementById("actitipySeting").submit();
		}
}

function subInfo(){
	var radioBoxValue=getRadioBoxValue();
	document.getElementById("actitipySeting").action="/GeneralManager?action=BuyerActivitySetting&page=useradmin/buyer_activity_admin&activitySettingFlag="+radioBoxValue;
	document.getElementById("actitipySeting").submit();
	}

function subBack(){
	document.getElementById("actitipySeting").action="/GeneralManager?page=useradmin/buyer_activity_admin";
	document.getElementById("actitipySeting").submit();
	}

function    lockMsgForm(){
	var ly=document.getElementById("ly");
	var layer=document.getElementById("Layer");
	if(ly!=null){
		ly.style.display='none';;   
	}
	if(layer!=null){
		layer.style.display='none';
	}
	  return   false;   
	   } 
/******************end  ADD FOR V19********************/

// store inquiry-cross-promo infor for co-reg [dev10/02]
function saveCrossRegistration(inquiryId,inqactiontype) {
	var myUrl = "/gsol/GeneralManager?action=SaveCrossRegistration&inquiry_id=" + inquiryId + "&inqactiontype=" + inqactiontype + "&page=commons/aptrack&source=cPA_aftconfeRFI" ;
	jQuery.ajax({
		url:myUrl, 				
		cache: false,
		error:function(XMLHttpRequest, textStatus, errorThrown) {
				$("#co-reg-after").html("<p>encounter error when handling cn subscribe action: " + textStatus + " :: " + errorThrown + "</p>");	
				$("#co-reg-before").css('display','none');
				$("#co-reg-after").css('display','block');
		},
		success:function(html) {
		},
		complete: function (XMLHttpRequest, textStatus) {
			if (textStatus == "success") {
					$("#co-reg-before").css('display','none');
					$("#co-reg-after").css('display','block');
			}
		}

	})
}

function funcOnProd(prods){
	prods.mouseenter(function(){
		var $this = $(this);
		PPInq.insertAfter($this);
		$('#InqSPD').html($this.children('img').eq(0).attr('SPDtit'));
		//todo change the url
		$('#InqBtn').attr('href',$this.attr('inquiry_url'));
		$this.parent().addClass("licur");
		if($this.parent().parent().parent().hasClass("PPBox")) {
			$this.parent().parent().parent().addClass("PPcur");
		}
		PPInq.show();
	});
	prods.parent().mouseleave(function(){
		PPInq.hide();
		$(this).removeClass("licur");
		if($(this).parent().parent().hasClass("PPBox")) {
			$(this).parent().parent().removeClass("PPcur");
		}
	});
	$('#KWCon .FirstPP').mouseleave(function(){
		$('.prodimg a:eq(1)',$(this)).hide();
	});
	$('#KWCon .FirstPP').mouseenter(function(){
		$('.prodimg a:eq(1)',$(this)).show();
	});

}
function expandSuppProds(expandObj,expandURL, hideNum) {
	var $this = expandObj;
	var more_a = $('#KWCon .PPBox .ViewMore');
	if($this.children("a").html().indexOf("Hide")>=0){
		$this.children("img").attr('src', 'http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/SHOW_ICON.GIF');
		$this.children("a").html($this.children("a").data('oldHTML'));
		$this.parent().nextAll().hide();
		var staticLiNum = $this.next("ul.productcon").data("staticLiNum");
		var filter = staticLiNum > 0 ? 'li:gt('+(staticLiNum-1)+')' : 'li';
		$this.next("ul.productcon").children(filter).hide();
		return;
	}else{
		$this.children("a").data('oldHTML',$this.children("a").html());
		$this.children("img").attr('src', 'http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/HIDE_ICON.GIF');
		$this.children("a").html("Hide all <b>"+hideNum+"</b> matching products");
	}
	if($this.next("ul.productcon").data("staticLiNum") != null){
		$this.parent().nextAll().show();
		$this.next("ul.productcon").children("[id!='placeholderPPMouseOver']").show();
	}else{
		var url = expandURL;
		$.get(url,function(data){
			var staticLiNum = $this.next("ul.productcon").children("[id!='placeholderPPMouseOver']").length;
			$this.next("ul.productcon").data("staticLiNum",staticLiNum);
			var forFirstRow = 5 - staticLiNum;
			var $data = $('<div></div>');
			$data.append($(data));
			var $firstRowLi = $data.children('li:lt('+forFirstRow+')');
			var lis;
			if(forFirstRow > 0) {
				lis = $data.children('li:gt('+(forFirstRow-1)+')');
			}else{
				lis = $data.children('li');
			}
			$this.next("ul.productcon").append($firstRowLi);
			for (var i=0;i<lis.length ;i=i+8 ) {
				var $ul = $('<ul class="productcon"></ul>');
				$ul.append(lis.slice(i,(i+8<lis.length) ? i+8:lis.length));
				$this.parent().parent().append($ul);
			}
			$this.parent().parent().append($data.children('div'));
			funcOnProd($this.next("ul.productcon").children("li").children("a:first-child"));
			funcOnProd($this.parent().nextAll("ul.productcon").children('li').children("a:first-child"));
		},'text')
	}
}
function loadProdconImages() {
	$("ul[class='productcon'] li img[imgsrc]").each(function(p,thisProdRow){
		$(thisProdRow).attr('src',$(thisProdRow).attr('imgsrc'));
	});
	$("div[class='FirstPP'] span[class='prodimg'] a img[imgsrc]").each(function(p,thisProdRow){
		$(thisProdRow).attr('src',$(thisProdRow).attr('imgsrc'));
	});
	$("ul[class='productcon']").show();
}
function clickFB() {
	var url = location.href;
	var title = document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer', 'toolbar=0, status=0, width=626, height=436'); 
}
function loadGPlus() {
	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
}
