You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.0 KiB
JavaScript

//writeCookie("xqin","XQIn.cn",2);
//写入Cookie,名称为 xqin,值为XQin.cn,时间为2个小时
//alert("读取Cookie[xqin]的值为:" + readCookie("xqin"));
//读取Cookie xqin 的值
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire+";path=/";
}
//游船搜索列表的分类搜索
function SortBy()
{
form1.submit();
}
//游船 cruise-price.asp 页面搜索
function PriceSearch(CRI_SN)
{
var cri_ray=readCookie('pricecri_sn');
var cri=cri_ray.split("/");
//alert(cri_ray)
for (var ii=0;ii<cri.length-1;ii++)
{
document.getElementById(cri[ii]).src="/pic/circle.gif";
}
writeCookie("price_cri_sn",CRI_SN,2)
document.getElementById(CRI_SN).src="/pic/selected2.gif";
}
//游船列表游船比较函数
//CSI_SN 游船SN
//CRI_SN 游船航线SN
//writeCookie("CSI_SN","",2) //写游船sn cookie
//writeCookie("CRI_SN","",2) //写游船航线sn cookie
function ShipCompare(CSI_SN,CRI_SN)
{
var SN=document.getElementById(CSI_SN+CRI_SN);
var OldCSI_SN_Cookie=readCookie("C_CSI_SN"); //原来的游船sn
var OldCRI_SN_Cookie=readCookie("C_CRI_SN"); //原来的游船航线sn
//判断用户是否选择超过三次
//如果未选
if (SN.checked){
var IsThree=OldCSI_SN_Cookie.split(",");
//alert(IsThree.length)
if (IsThree.length<=3){
var NewCSI_SN_Cookie=OldCSI_SN_Cookie+CSI_SN+','; //累加游船sn
var NewCRI_SN_Cookie=OldCRI_SN_Cookie+CRI_SN+','; //累加游船航线sn
writeCookie("C_CSI_SN",NewCSI_SN_Cookie,2) //写游船sn cookie
writeCookie("C_CRI_SN",NewCRI_SN_Cookie,2) //写游船航线sn cookie
writeCookie(CSI_SN+CRI_SN,1,2) //已选标志
document.getElementById(CSI_SN+CRI_SN).checked=true;
}
else{
document.getElementById(CSI_SN+CRI_SN).checked=false;
//writeCookie(CSI_SN+CRI_SN,0,2) //未选标志
alert("Select no more than 3 times");
}
}
else//已选
{
document.getElementById(CSI_SN+CRI_SN).checked=false;
writeCookie(CSI_SN+CRI_SN,0,2) //未选标志
NewCSI_SN_Cookie=OldCSI_SN_Cookie.replace(CSI_SN+",","") //去掉此项游船的sn
NewCRI_SN_Cookie=OldCRI_SN_Cookie.replace(CRI_SN+",","") //去掉此项游船航线的sn
writeCookie("C_CSI_SN",NewCSI_SN_Cookie,2) //写游船sn cookie
writeCookie("C_CRI_SN",NewCRI_SN_Cookie,2) //写游船航线sn cookie
}
//alert(readCookie("C_CSI_SN")+'/'+readCookie("C_CRI_SN"))
}