var FieldPos;
function ExtractField(s)
{ 
	i=FieldPos;
	while ((i<=s.length) & s.charAt(i)!=";" )
		i++;
	rs=s.substring(FieldPos,i);
	if (s.charAt(i)==";") 
		i++;
	FieldPos=i;
	return rs;
}

function FieldName(s)
{
	i=s.indexOf("=");
	if (i>-1)
	{ 
		i1 = 0;
	    while ((i1<i) & (s.charAt(i1)==" ")) 
			i1++;
		return s.substring(i1,i);
	}
	else return s;
}

function FieldValue(s)
{ 
	i=s.indexOf("=");
	if (i>-1) 
		return s.substring(++i,s.length);
	else
		return "";
}

function FindCookie(name)
{ 
	var rs,s,aField,aName,aValue;
	rs="";
	s=unescape(document.cookie);
	FieldPos=0;
	while (FieldPos<=s.length)
	{
		aField=ExtractField(s,FieldPos);
		aName=FieldName(aField);
		aValue=FieldValue(aField);
		if (aName==name)
			rs=aValue;
	}
	return rs;
}

function writeCookie(cname,cvalue)
{ 
	now=new Date();
	new_date =new Date("December 31, "+now.getYear());
	document.cookie=cname+"="+escape(cvalue)+";expires="+new_date.toGMTString()+";path=/;";
	temp=FindCookie(cname);
	if (temp.length==0)
		document.cookie=cname+"="+escape(cvalue)+"";
}

function GetCookie2Str(strTag, isHidenType)
{
	var type;
	if (isHidenType)
	{
		type = "hiden";
	}
	else
	{
		type = "taxis";
	}
	var strAll = FindCookie("TableHiden");
	if (strAll.indexOf(strTag+type + ":") >= 0)
	{
		var str2set = strAll.substring(strAll.indexOf(strTag+type + ":"), strAll.length);
		str2set = str2set.substring(str2set.indexOf(":") + 1, str2set.indexOf("|"));
		return str2set;
	}
	else
	{
		return "";
	}
}

function SetStr2Cookie(strTag, strValue, isHidenType)
{
	var type;
	if (isHidenType)
	{
		type = "hiden";
	}
	else
	{
		type = "taxis";
	}
	var strAll = FindCookie("TableHiden");
	if (strAll.indexOf(strTag+type + ":") >= 0)
	{
		var strOld = strTag+type + ":" + GetCookie2Str(strTag, isHidenType);
		var strNew = strTag+type + ":" + strValue;
		strAll = strAll.replace(strOld, strNew);
	}
	else
	{
		strAll = strAll + strTag+type + ":" + strValue + "|";
	}
	writeCookie("TableHiden",strAll);
}
