﻿
<!--

function showCateString() {
	var fobj = document.search;
	var qryCode = fobj.QRY.value;
	var qryLang = fobj.langx.value;
	var myAjax = new Ajax.Updater('cate_str', '/censv1/en/search/show_search.jsp?qry=' + qryCode+'&lang='+qryLang, {method: 'get'});
}


function loadData(){
  var temp_cookie = '', cookie_name ='', cookie_value = '', strName = '', strName2 = '', strchk = '', str2 = '', temp_cookie_str2 = '';
  
  	
  all_cookies = document.cookie.split( ';' );		
  theValue = document.search.QRY.value;	
  theLangx = document.search.langx.value;	
  
  //取出 cens_keyword 的 cookie值
  for ( i = 0; i < all_cookies.length; i++ ) {	
	   temp_cookie = all_cookies[i].split( '=' );	   
	   cookie_name = temp_cookie[0].replace(/^\s+|\s+$/g, '');	   
	   if (cookie_name == 'cens_keyword') {
		   cookie_value = unescape( temp_cookie[1].replace(/^\s+|\s+$/g, '') );			   
       }
   }	
      
   //拆cookie的值
   temp_cookie_str = cookie_value.split("|");      
   if (temp_cookie_str == '') { var k = 0;} else { var k = temp_cookie_str.length;}   
   if (k > 18) { counter2 = k - 18; } else { counter2 = 0; }
   for ( i = 0; i < k; i++ ) {
	 temp_cookie = temp_cookie_str[i].split( '|' ); 		
	 if (i < counter2) {
	 } else {
	   if (temp_cookie != '') {
	   if (strName == '') { strName = temp_cookie; } else { strName = strName+"|"+temp_cookie; }	
       if (strName2 == '') {
		   strName2 = "<a href='/censv1" + theLangx + "search_list.jsp?TYPE=prd&QRY="+ encodeURI(temp_cookie)+"'>" +temp_cookie+  "</a>, ";
	   } else {
  	       strName2 = "<a href='/censv1" + theLangx + "search_list.jsp?TYPE=prd&QRY="+ encodeURI(temp_cookie)+"'>" +temp_cookie+  "</a>"+ ", " + strName2;
	   }
	   }
	 }    

	 if (temp_cookie == theValue) {strchk = '1';}		 
	}
	 
  //寫入cookie
  if (theValue != '') {
	 var theName  = "cens_keyword";
	 var theDay   = 30;
	 var setDay = new Date();
	 setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
	 var expDay = setDay.toGMTString();
	 if (strchk != '1') document.cookie = theName + "="+escape(strName)+"|"+escape(theValue)+";expires="+expDay+";path=/";
	}
	

  //顯示cookie值, 若無cookie, 則抓 supplier_keyword 購買字句較多的
   if (strName2 != '') {
	   var langstring = "<b>My Recent Search Keywords:</b>";
	   if (theLangx == '/zh/') langstring = "我的搜尋記錄:";
	   if (theLangx == '/gb/') langstring = "我的搜寻记录:";
	   strName2 = langstring + " " + strName2.substring(0,strName2.length-2); 
	   cate_str.innerHTML = strName2;	
   } else {
	   showCateString()			
   }	
	
}




//-->
