
//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 
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('/css/images/tour/bg2-tour-price.jpg')";
   document.getElementById(leftID).style.marginLeft="5px";
   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("Votre nom ne peut pas être vide,Vérifier à nouveau s'il vous plaît!");
		return false;
	}
	if (objform.email.value=="")
	{   alert("Votre Email ne peut pas être vide, Vérifier à nouveau s'il vous plaît!");
		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("Erreur d'Email!");
         return false;
	   }
    }
    if (objform.question.value=="" )
	{   alert("Votre question ne peut pas être vide, Vérifier à nouveau s'il vous plaît!");

		return false;
	}
    return true;
}

//固定发团价格列表页面的年份价格列表切换
$(function(){
	$(".changeGPPrice").click(function(){
		var y = $(this).text();
		$(".MonCalendar").hide();
		$(".tableGroupTourPrice").hide();
		$("#"+y).show();
		$(".changeGPPrice").attr("id","nav2");
		$(this).attr("id","nav1");
		$("#ButtonCalendar").attr("class",y);
	});
});
//根据标签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(){
	$("#question").blur(function(){
		if($(this).val()=="")
		{
			$(this).val("Écrire vos questions ici et Nous vous répondrons dans un jour ouvrable....");
		}
	}).focus(function(){
		if($(this).val()=="Écrire vos questions ici et Nous vous répondrons dans un jour ouvrable....")
		{
			$(this).val("");
		}
	})
})
