
$(function(){
		   
	//网站顶部鼠标移上去显示会员中心信息
	$("#pcenter").hover(
		function(){
			$(this).addClass("Mcenter");
			$(this).find(".sub_select").show(); 	
		},
		function(){
			$(this).removeClass("Mcenter");
			$(this).find(".sub_select").hide();	
		}
	);
	
	//预订查询选项
	$(".sMenu").bind("click",function(){
		$(".s_content").hide();//隐掉所有右边内容
		//初始化机票，酒店，景点，旅游，签证选项卡
		_$("s_ticket").className="s_ticket";
		_$("s_hotel").className="s_hotel";
		_$("s_att").className="s_att";
		_$("s_travel").className="s_travel";
		_$("s_visa").className="s_visa";
		var cont=$(this).attr("rel");
		_$("s_"+cont).className="s_"+cont+"_hover";//改变获得焦点的对象的背景
		_$(cont).style.display='block';//显示当前点击
	});
	
	//景点搜索框里默认值和颜色
	$(".textValue").each(function(){
		_this=$(this);
		_this.attr("value",_this.attr("rel")).css("color","#CCC");//设置搜索框默认值和值的显示颜色
	});
	
	//表格隔行换色
	$("#list_tab tr:even").addClass("list_tr");
	
	//酒店-详细-周边类似酒店鼠标放上去显示图片
	  $(".ls_l").mouseover(
		  function(){
			  $(".ls_img").each(function(){$(this).hide();});
			  $(this).children(".ls_img").show();
		  }
	  );
	//招贤纳才 招聘详细
	$(".j_t").toggle(
		function(){$(this).next(".job_d").show();},
		function(){$(this).next(".job_d").hide();}
	);
	
	//帮助中心导航栏展开缩起
	$(".help_list").find("dt").bind('click',
		function(){
			if($(this).attr('class')=='hexpand'){
				$(this).attr('class','hfold');
				$(this).next().show();
			}else{
				$(this).attr('class','hexpand');
				$(this).next().hide();	
			}
		}
	);
});

//关于我们快速通道
function ksShow(){
	_$("ks_h").className="ks_h2";
	_$("ks_select").style.display="inline";
}
function ksHidden(){
	_$("ks_h").className="ks_h";
	_$("ks_select").style.display="none";
}

//非jquery的快捷获取对象
function _$(id){
	return document.getElementById(id);	//根据该对象的id获取该对象
}

//机票单程-往返切换
function exchange_dc(object){
	if(object.checked){
		_$("t_from").style.display="none";//单程
		_$("ToDate").value="yy-mm-dd";
	}
}
function exchange_wf(object){
	if(object.checked){
		_$("t_from").style.display="block";//往返
	}
}

//机票列表页的搜索单程和往返切换
function jpSearchEx(focusObj,bulrObj){
	_$(focusObj).className='hover';
	_$(bulrObj).className='';
	if(focusObj=='dc'){
		_$('t_from').style.display="none";
	}else{
		_$('t_from').style.display="block";	
	}	
}

//设置搜索框默认值
function sFocus(_this){if($(_this).attr('value')==$(_this).attr('rel')){$(_this).attr('value','');}}//清空获得焦点时搜索框内的
function sBlur(_this){if(!$(_this).attr('value')){$(_this).attr('value',$(_this).attr('rel')).css('color','#CCC');}}//失去焦点时，搜索框内提示显示，字体颜色调暗
function sKeydown(_this){$(_this).bind("keydown",function(){$(_this).css("color","#333");});}//设置获得焦点搜索框输入内容时字体的颜色

//已知数量选项卡的切换
function setTab(name,current,n){
	for(var i=1;i<=n;i++){
		_$(name+i).className=current==i?"hover":"";	
		_$('s_'+name+'_'+i).style.display=current==i?"block":"none";
	}	
}


//酒店列表筛选显示更多的商圈和品牌
function showMore(mObj,obj){
	if(_$(obj).style.display=='none'){
		_$(obj).style.display='block';
		mObj.className='hotel_s_more more_up_bg';
	}else if(_$(obj).style.display=='block'){
		_$(obj).style.display='none';
		mObj.className='hotel_s_more more_down_bg';	
	}
}

//酒店该房型的具体信息展开和收起
function roomExpand(obj,roomInfo,current){
	if(_$(roomInfo+current).style.display=='none'){
		_$(roomInfo+current).style.display='block';	
		obj.className='u1 u1_sw2';
	}else if(_$(roomInfo+current).style.display=='block'){
		_$(roomInfo+current).style.display='none';	
		obj.className='u1 u1_sw';	
	}	
}
function roomHide(obj){
	obj.parentNode.style.display="none";	
}

//酒店列表显示所有房型信息
function showAll(obj,roomAll,current){
	if(_$(roomAll+current).style.display=='none'){
		_$(roomAll+current).style.display='block';	
		obj.className='expand_more_a2';
	}else if(_$(roomAll+current).style.display=='block'){
		_$(roomAll+current).style.display='none';	
		obj.className='expand_more_a';	
	}		
}


//酒店列表显示所有房型信息caiyulu修改函数
function showAll_li(obj, uc2_is_show, current){
	if($('.uc2_is_show'+ current).css('display')=='none'){
		$('.uc2_is_show'+ current).css('display', 'block');
		obj.className='expand_more_a2';
	}else if($('.uc2_is_show'+ current).css('display')=='block'){
		$('.uc2_is_show'+ current).css('display','none');
		obj.className='expand_more_a';	
	}		
}



function showDrail(obj){
	if(_$(obj).style.display=='none'){
		_$(obj).style.display='block';	
	}else if(_$(obj).style.display=='block'){
		_$(obj).style.display='none';		
	}	
}

//注册个人会员和加盟商代理切换
function regSetTab(name,current,n){
	for(var i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var cont=document.getElementById("con_"+name+"_"+i);
		menu.className=current==i?name+i+"_hover":name+i;
		cont.style.display=current==i?"block":"none";
	}	
}


//首页机票查询前端验证
function checkTicket(){
	if(!$("#city_from").val()){
		alert("请选择出发城市！");	
		$("#city_from").focus();
		return false;
	}	
	if(!$("#city_to").val()){
		alert("请选择到达城市！");	
		$("#city_to").focus();
		return false;
	}
	if($("#city_from").val()==$("#city_to").val()){
		alert("出发城市和到达城市不能相同！");
		$("#city_to").focus();
		return false;
	}
	if(!$("#FromDate").val() || $("#FromDate").val()=='yy-mm-dd'){
		alert("请选择出发时间！");
		$("#FromDate").focus();
		return false;
	}
	if(_$("iwf").checked){
		if(!$("#ToDate").val() || $("#ToDate").val()=='yy-mm-dd'){
			alert("请选择返程时间！");	
			$("#ToDate").focus();
			return false;
		}	
		var Ftime=$("#FromDate").val();
		var AtimeF=Ftime.split("-");
			Ftime=new Date(AtimeF[0],AtimeF[1],AtimeF[2]);
		var Ftimes=Ftime.getTime();
		
		var Ttime=$("#ToDate").val();
		var AtimeT=Ttime.split("-");
			Ttime=new Date(AtimeT[0],AtimeT[1],AtimeT[2]);
		var Ttimes=Ttime.getTime();
		
		if(Ttimes<Ftimes){
			alert("返程时间不能在出发时间之前！");
			_$("ToDate").focus();
			return false;
		}
		
	}
	document.getElementById("ticketform").submit();
	return false;
}

/************************************ 
(1)电话号码由数字和－组成 (2)电话号码为 7 到 13 位
(3)13 开头的头的手机号码必须为 11 位
************************************/
function phoneCheck(str) {
    var rst = str.substr(0,2);
    var re = /^[1][3]\d{9}$/;
    var re1 = /^[1][5]\d{9}$/;
    var re2 = /^[1][8]\d{9}$/;
    var reg = /^((\d{3,4}\-)?\d{7,8}(\-\d)?)$/;
    if((rst == 13)||(rst == 15)||(rst == 18)){
        if((str.length!=11)&&(!re.test(str)||!re1.test(str)||!re2.test(str))){
            return false;
        }
    }else if((rst != 13)&&!reg.test(str)){
        return false;
    }
    return true;
}
/* 验证邮箱格式 */
function isEmail(strEmail) { 
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true; else return false; 
}

/*身份证验证*/
function validateIdCard(obj)
{
 var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"};
  var iSum = 0;
 //var info = "";
 var strIDno = obj;
 var idCardLength = strIDno.length;
 if(!/^\d{17}(\d|x)$/i.test(strIDno)&&!/^\d{15}$/i.test(strIDno))
		return 1; //非法身份证号

 if(aCity[parseInt(strIDno.substr(0,2))]==null)
 return 2;// 非法地区

  // 15位身份证转换为18位
 if (idCardLength==15)
 {
	sBirthday = "19" + strIDno.substr(6,2) + "-" + Number(strIDno.substr(8,2)) + "-" + Number(strIDno.substr(10,2));
  var d = new Date(sBirthday.replace(/-/g,"/"))
  var dd = d.getFullYear().toString() + "-" + (d.getMonth()+1) + "-" + d.getDate();
  if(sBirthday != dd)
				return 3; //非法生日
			  strIDno=strIDno.substring(0,6)+"19"+strIDno.substring(6,15);
			  strIDno=strIDno+GetVerifyBit(strIDno);
 }

	   // 判断是否大于2078年，小于1900年
	   var year =strIDno.substring(6,10);
	   if (year<1900 || year>2078 )
		   return 3;//非法生日

	//18位身份证处理

   //在后面的运算中x相当于数字10,所以转换成a
	strIDno = strIDno.replace(/x$/i,"a");

  sBirthday=strIDno.substr(6,4)+"-"+Number(strIDno.substr(10,2))+"-"+Number(strIDno.substr(12,2));
  var d = new Date(sBirthday.replace(/-/g,"/"))
  if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
				return 3; //非法生日
	// 身份证编码规范验证
  for(var i = 17;i>=0;i --)
   iSum += (Math.pow(2,i) % 11) * parseInt(strIDno.charAt(17 - i),11);
  if(iSum%11!=1)
				return 1;// 非法身份证号

   // 判断是否屏蔽身份证
	var words = new Array();
	words = new Array("11111119111111111","12121219121212121");

	for(var k=0;k<words.length;k++){
		if (strIDno.indexOf(words[k])!=-1){
			return 1;
		}
	}

 return 0;
}


//确定定位
function uu8_getAP(obj)
{
	position = new Object();
	position.x = 0;
	position.y = 0;
	var tempobj = obj;
		while(tempobj!=null && tempobj!=document.body)
		{

			position.x += tempobj.offsetLeft;
			position.y += tempobj.offsetTop;

			tempobj = tempobj.offsetParent
		}
	return position;
}

//获取鼠标左边
function uu8_mousePosition(ev){ 
    if(ev.pageX || ev.pageY){ 
        return {x:ev.pageX, y:ev.pageY}; 
    } 
	var obj=document.getElementsByTagName("body")[0].parentNode;
    return { 
        x:ev.clientX + obj.scrollLeft - obj.clientLeft, 
        y:ev.clientY + obj.scrollTop  - obj.clientTop 
    }; 
} 

