// JavaScript Document
num_row =1;
function setC() 
{
   var expdate = new Date ();
   expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
   SetCookie ('','');
}
//setC();
SetCookie ('','');
function SetCookie (type,value) 
{ 
	tempt  ='';
	tempt = GetCookie('word');		
	if(tempt != null)
	{
		array_history = tempt.split(',');
		for(i=1;i<array_history.length;i++)
		{
			word = array_history[i].split('-');
			if(value == word[0]) return;
		}	
	}		
	tempt += (value !='')?','+value+'-'+type:value+'-'+type;
    document.cookie = 'word' + "=" + escape (tempt);
}
function GetCookie(name) {
   var arg = name+"=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   }
   return null;
}
function ShowHistory()
{
	var nam1=GetCookie('word');		
	if(tempt == null)	return;						
	if(nam1.indexOf (",") >0)
	{
		array_history = nam1.split(',');
		strHTMl ='';
		num_word = eval(array_history.length) -1;
		for(i=num_word;i > 0 ;i--)
		{
			array_word = array_history[i].split('-');
			strHTMl += "<span><a href=\"javascript: SearchHistory('"+array_word[1]+"','"+array_word[0]+"');\" title=\"Tìm từ\">"+array_word[0]+'</a></span>';
		}
		document.getElementById("div_history").innerHTML = strHTMl;		
	}
}
function SearchHistory(strType,strWord)
{
	if(strType ==1 || strType ==2)
	{		
		document.getElementById("cbColletion").value  = strType;
	}
	document.getElementById("txtFindWord").value = strWord;
	SubmitForm();
}
function getCookieVal(offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape (document.cookie.substring(offset, endstr));
}

