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.

384 lines
11 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=/";
}
//线路中add-ons保存用户所选小包价ID
function SafeSightID(id){
var SightID="";
var ISCheck=document.getElementById(id).value;
//ISCheck=parseInt(ISCheck)
//alert(ISCheck);
//获取用户已选标志1=已选0=未选
if (ISCheck=="1"){
if (id!=0){
SightID=readCookie("SightID")+id+"/";
writeCookie("SightID",SightID,2); //把小包价的ID累加进cookie中
writeCookie(id,"1",2); //单独写某ID的属性值到cookie用来加载时记录用户所选过的
document.getElementById(id).src="/pic/remove.gif"; //当用户选过时,改变按钮
document.getElementById(id).value="0";
}
}
else{
var SightValue=readCookie("SightID");
SightValue=SightValue.replace(id+"/","");
writeCookie(id,"0",2);
writeCookie("SightID",SightValue,2);
document.getElementById(id).src="/pic/tour-extend-addons.gif";
document.getElementById(id).value="1";
}
SightID=readCookie("SightID");
var sm=SightID.split("/");
var smlenght=parseInt(sm.length)-1;
if (parseInt(smlenght)>0) {
document.getElementById("SightCookie").innerHTML="("+smlenght+")";
}
else{document.getElementById("SightCookie").innerHTML="";}
//alert(readCookie("SightID"));
}
//线路中add-ons保存用户所选娱乐信息ID
//Button版
function SafeEnterTaimentID_Button(id){
var SightID="";
var ISCheck=document.getElementById(id).value;
//ISCheck=parseInt(ISCheck)
//alert(ISCheck);
//获取用户已选标志1=已选0=未选
if (ISCheck=="1"){
if (id!=0){
SightID=readCookie("EntertainmentID")+id+"/";
writeCookie("EntertainmentID",SightID,2); //把小包价的ID累加进cookie中
writeCookie(id,"1",2); //单独写某ID的属性值到cookie用来加载时记录用户所选过的
document.getElementById(id).src="/pic/remove.gif"; //当用户选过时,改变按钮
document.getElementById(id).value="0";
}
}
else{
var SightValue=readCookie("EntertainmentID");
SightValue=SightValue.replace(id+"/","");
writeCookie(id,"0",2);
writeCookie("SightID",SightValue,2);
document.getElementById(id).src="/pic/tour-extend-addons.gif";
document.getElementById(id).value="1";
}
SightID=readCookie("EntertainmentID");
var sm=SightID.split("/");
var smlenght=parseInt(sm.length)-1;
if (parseInt(smlenght)>0) {
document.getElementById("SightCookie").innerHTML="("+smlenght+")";
}
else{document.getElementById("SightCookie").innerHTML="";}
//alert(readCookie("SightID"));
}
//线路中add-ons保存用户所选娱乐信息ID
function SafeEnterTaimentID(id){
var En_ID="";
var IsChecked=document.getElementById("E"+id).checked;
//alert(IsChecked)
//如果选项未被勾选则执行存cookie操作
if (IsChecked){
if (id!=0){
En_ID=readCookie("EntertainmentID")+id+"/";
writeCookie("EntertainmentID",En_ID,2);
writeCookie("E"+id,"checked",2);
document.getElementById("E"+id).checked=true;
}
}
//否则把勾选去掉并去除此娱乐的cookie ID
else{
var EnterTaiment=readCookie("EntertainmentID");
EnterTaiment=EnterTaiment.replace(id+"/","");
writeCookie("EntertainmentID",EnterTaiment,2);
document.getElementById("E"+id).checked=false;
}
//alert(readCookie("EntertainmentID"));
}
//清除所有小包价娱乐的选项
function ClearID()
{
writeCookie("EntertainmentID","",2);
//alert(readCookie("EntertainmentID"));
}
//清除所有小包价add-ones的选项
function ClearPageID()
{
writeCookie("SightID","",2);
//alert(readCookie("SightID"));
}
//淡旺季线路的酒店及其价格切换函数
function dan_wan(leftID,rightID)
{
document.getElementById("dj1").style.background="url('')";
document.getElementById("wj1").style.background="url('')";
document.getElementById(leftID).style.background="url('/images/tour/bg2-tour-price.jpg')";
document.getElementById("dj").style.display="none";
document.getElementById("wj").style.display="none";
document.getElementById(rightID).style.display="";
}
//用户提问表单验证
function check_question_input(objform)
{
if (objform.realname.value=="")
{ alert("Your full name can not be empty,Please check again!");
return false;
}
if (objform.email.value=="")
{ alert("Your Email can not be empty,Please check again!");
return false;
}
else{
var pattern1 = /^(([\u4E00-\u9FA5]|[\uFE30-\uFEFF]|[\d]|[a-zA-Z]|[\_\-\.])+[\@])(((([\d]|[a-zA-Z]|[\_\-]|[\[\]\{\}\>\<])+[\.])+)([\d]|[a-zA-Z\_\-])+)$/;
str=objform.email.value
if(!str.match(pattern1) ){
alert("Email error!");
return false;
}
}
if (objform.question.value=="" )
{ alert("Your question can not be empty,Please check again!");
return false;
}
return true;
}
//固定发团价格列表页面的年份价格列表切换
function PriceList()
{
document.getElementById("nav1").style.border="#ded1b1 4px solid;";
document.getElementById("nav1").style.color="#6b6b6b;";
document.getElementById("nav2").style.border="#ded1b1 4px solid;";
document.getElementById("nav2").style.color="#6b6b6b;";
}
//根据标签ID改变所属层的消隐属性
function Show_Or_Disappear(SonID)
{
var OldIDStyle=document.getElementById(SonID).style.display
if (OldIDStyle==""){
document.getElementById(SonID).style.display="none";
}
else{
document.getElementById(SonID).style.display="";
}
}
$(function(){
$("#priceShift li").css("cursor","pointer").click(function(){
$("#priceShift li").removeClass("active");
$("#wj,#dj").hide();
$("#"+$(this).attr("class")).show();
$(this).addClass("active");
});
//打印页使用到的 /tour/print.asp
$(".removeButton img,#print").css("cursor","pointer");
$(".removeButton img").click(function(){
if($(this).attr("name") == "print")
{
$("#contentPrint").slideDown();
$(".removeButton img").attr("src","/pic/print-remove.gif").attr("name","remove");
}
else
{
$("#contentPrint").slideUp();
$(".removeButton img").attr("src","/pic/print2.gif").attr("name","print");
}
});
$("#print").click(function(){
window.print();
});
//打印页使用到的
//complete-tour-list.asp
$("#complete_tour_list_button").css("cursor","pointer").click(function(){
var _arr = "";
var arrbox = $("input[name=complete_tour_list_checkbox]:checked");
if(arrbox.length < 2)
{
alert('up to 2');
return false;
}
else
{
$.each(arrbox,function(i,n){
_arr = _arr + $(this).val() + ","
});
location.href="/tour/tour-comparison.asp?delete_name="+_arr;
}
});
//complete-tour-list.asp
//add-ons-list.asp
$(".js_addons_button").click(function(){
var id = $(this).attr("id").split("_")[1];
if($(this).attr("name") == "Select")
{
$(this).attr("name","Remove").html("Remove");
var En_ID=readCookie("EntertainmentID")+id+"/";
writeCookie("EntertainmentID",En_ID,2);
}
else
{
$(this).attr("name","Select").html("Select");
var EnterTaiment=readCookie("EntertainmentID");
EnterTaiment=EnterTaiment.replace(id+"/","");
writeCookie("EntertainmentID",EnterTaiment,2);
}
});
//add-ons-list.asp
//day-trip-list.asp
$(".js_daytrip_button").click(function(){
var id = $(this).attr("id").split("_")[1];
if($(this).attr("name") == "Select")
{
$(this).attr("name","Remove").html("Remove");
var En_ID=readCookie("SightID")+id+"/";
writeCookie("SightID",En_ID,2);
}
else
{
$(this).attr("name","Select").html("Select");
var EnterTaiment=readCookie("SightID");
EnterTaiment=EnterTaiment.replace(id+"/","");
writeCookie("SightID",EnterTaiment,2);
}
});
//day-trip-list.asp
//线路明细页轮播效果
var imgCount = $("#imgCount").html();
var pagesize = 6;
var last_id;
$("#highlightsRight img").css("cursor","pointer").click(function(){
var src = $(this).attr("src");
$("#highlightsImg img").fadeTo("fast",0.5,function(){
$(this).attr("src",src).fadeTo("fast",1);
});
$(".description").html($(this).attr("name"));
});
$(".preNext img.nouse").css("cursor","pointer").click(function(){
if($(this).attr("name") == "next")
{
var id = $("#highlightsRight .listImg:visible").attr("id").split("_")[1];
$(".preNext img[name=prev]").show();
execShowImg(parseInt(id) + pagesize);
checkButtonID("next");
}
else
{
var id = $("#highlightsRight .listImg:visible").attr("id").split("_")[1];
$(".preNext img[name=next]").show();
execShowImg(parseInt(id) - pagesize);
checkButtonID("prev");
}
});
var checkButtonID = function(m_strButton)
{
if(m_strButton == "next")
{
$.each($("#highlightsRight .listImg:visible"),function(){
last_id = $(this).attr("id").split("_")[1];
});
if(last_id == imgCount)
{
$(".preNext img[name=prev]").show();
$(".preNext img[name=prevnone]").hide();
$(".preNext img[name=next]").hide();
$(".preNext img[name=nextnone]").show();
}
}
else if(m_strButton == "prev")
{
last_id = $("#highlightsRight .listImg:visible").attr("id").split("_")[1];
if(last_id == 1)
{
$(".preNext img[name=prev]").hide();
$(".preNext img[name=prevnone]").show();
$(".preNext img[name=nextnone]").hide();
$(".preNext img[name=next]").show();
}
}
}
var execShowImg = function(m_intFirstNo)
{
$("#highlightsRight .listImg").hide();
for(var i=m_intFirstNo; i<(m_intFirstNo + pagesize); i++)
{
$("#js_"+i).show();
}
}
//线路明细页轮播效果
//tour-itinerary.asp
$("#js_itinerary_addons_button").click(function(){
var url = $(this).attr("name");
var tmpSN = "";
tmpSN = $(this).parents("form").children("input:checked").length;
url += "&len="+tmpSN;
return ShowIFrame('',url,320,130,'bottom')
});
//主题线路排序
//\\****/tour/china-tour-list.asp
$("input[name=tour_list_orderby]").click(function(){
location.href=$(this).val();
});
});
$(function(){
$(".priceTitle img").hover(
function () {
$(".priceTerms").show();
},
function () {
//$(".priceTerms").hide();
}
);
$(".priceTerms .closeIt").click(function(){
$(".priceTerms").hide();
});
$(".tailorTour img,tailor-made img").click(function(){
$.cookie("Cht_tour_list", "");
$.cookie("Cht_tour_tailorInfo", "", {path: "/"});
GetCookie("Cht_tour", "tailorInfo");
$.cookie("Cht_tour_tailorInfo", $("#tailorInfo").html().replace(/\<br[\s\/]*\>/g, "\n"), {path: "/"});
});
});