﻿$(document).ready(function(){
		$(".hDLList tr[class!=moreTr] td").css({borderTop:"1px solid #EBE9E9",borderBottom:"none"})
		$(":button").css({cursor:"pointer",paddingLeft:"0px"}); //所有按钮手型 
		if($("#dialog").length>0){ 
			$("#dialog").dialog("destroy");//弹出层背景变灰  初始化
		}
		WinUrlContent=$("#dialogURL").html(); //全局变量，记录dialogURL div中html,用于关闭层时，恢复dialogURL中数据 
		$("#closeMesg").click(function(){$("#mesg").hide()})//关闭mesg
	


//团购管理 取消对话框
$("a[name='txtCancelBtn']").click(function(){
		var flag=0;
		$(".mesgCancel").show();
		$(".mesgCancel").css("position","absolute")
		var X = $(this).position().left-125+"px"; 
		var Y = $(this).position().top-10+"px"; 
		$(".mesgCancel").css("left",X);
		$(".mesgCancel").css("top",Y);	
		var index=$("a[name='txtCancelBtn']").index(this);
		$(".mesgCancel input[class='enter']").click(function(){ $(".mesgCancel").hide();if(flag>=1)return;cancelFun(index);flag++;}) //cancelFun为取消方法	
		$(".mesgCancel input").click(function(){$(".mesgCancel").hide();})
 })


		
//全选操作
$("#slctAll").click(function(){
	if($(this).attr("checked")==true){$(":checkbox:not(:last)").attr("checked","true");}
	else{$(":checkbox").removeAttr("checked");  $(".mesgDel").css("display","none");}//取消全选
							 })  


	
//取消整张订单对话框操作
$("#bt_cancelOrder").click(function(){				 
	$("#win_cancelOrder").show();		
	var X = $(this).position().left-$("#win_cancelOrder").width()+78+"px"; 
	var Y = $(this).position().top+21+"px"; 
	$("#win_cancelOrder").css("left",X);
	$("#win_cancelOrder").css("top",Y);	
	$(this).attr("disabled","true");							 
						 })



//解绑定对话框操作
$("#bt_unbind").click(function(){				 
	$("#win_unbind").toggle(300);		
	var X = $(this).position().left+7+"px"; 
	var Y = $(this).position().top+18+"px"; 
	$("#win_unbind").css("left",X);
	$("#win_unbind").css("top",Y);								 
						 })

$("#win_unbind #btn_cancel").click(function(){$("#win_unbind").toggle(300);})
$("#win_unbind #btn_unbind").click(function(){$("#win_unbind").toggle(300);unbind();})


//绑定对话框操作
$("#bt_bind").click(function(){
	$("#win_bind").toggle(300);		
	var X = $(this).position().left+7+"px"; 
	var Y = $(this).position().top+18+"px"; 
	$("#win_bind").css("left",X);
	$("#win_bind").css("top",Y);
	$("#win_successBind").css("left",X);
	$("#win_successBind").css("top",Y);
	$("#win_failBind").css("left",X);
	$("#win_failBind").css("top",Y);
						 })

$("#win_cancelOrder :button[value='取消整张订单']").click(function(){funCancelOrder();$("#win_cancelOrder").hide();})
$("#win_cancelOrder :button[value='返回']").click(function(){$("#win_cancelOrder").hide();$("#bt_cancelOrder").removeAttr("disabled");})

$("a:contains('退改签规则')").mouseover(function(){
	var indx=$("a:contains('退改签规则')").index(this);
	$("#win_cancelRule").show();
	var X = $(this).position().left-$("#win_cancelRule").width()+66+"px"; 
	var Y = $(this).position().top+16+"px"; 
	$("#win_cancelRule").css({left:X,top:Y,height:"auto",position:"absolute"});
	//有的规则并没有contentRule，报脚本错误，暂时这样处理
	try{
	$("#win_cancelRule div").html(eval("contentRule"+indx));
	}
	catch(e){
	}
										
})

$("a:contains('退改签规则')").mouseout(function(){
	$("#win_cancelRule").hide();									
})

$("a:contains('取消规则')").mouseover(function(){var indx=$("a:contains('取消规则')").index(this);$("#win_cancelRule").show();var X=$(this).position().left-$("#win_cancelRule").width()+66+"px";var Y=$(this).position().top+16+"px";$("#win_cancelRule").css({left:X,top:Y,height:"auto",position:"absolute"});try{$("#win_cancelRule div").html(eval("contentRule"+indx));}
catch(e){}})
$("a:contains('取消规则')").mouseout(function(){$("#win_cancelRule").hide();})

$("a:contains('订单状态说明')").mouseover(function(){
	$("#win_orderStatusIntro").show();
	var X = $(this).position().left-$("#win_orderStatusIntro").width()+78+"px"; 
	var Y = $(this).position().top+16+"px"; 
	$("#win_orderStatusIntro").css("left",X);
	$("#win_orderStatusIntro").css("top",Y);	
	$("#win_orderStatusIntro").css("height","auto");	
										
})

$("a:contains('订单状态说明')").mouseout(function(){
	$("#win_orderStatusIntro").hide();									
})



$("#win_bind #btn_closewin").click(function(){$("#win_bind").toggle(300);})
$("#win_bind #btn_cancel2").click(function(){$("#win_bind").toggle(300);})
$("#win_bind #btn_verify").click(function(){$("#win_bind").toggle(300);verifyMob();})
$("#btn_closewin").click(function(){$("#win_successBind").toggle(300);})
$("#btn_closeFailwin").click(function(){$("#win_failBind").toggle(300);})

$("#btn_reSend").click(function(){$("#win_failBind").toggle(0);$("#win_bind").toggle(300);})

//$("#win_activityTimit").oneTime(3000,function(){
// 				$("#win_activityTimit:visible").slideUp(350);
//				});
//$("#btn_closeFailwin2").click(function(){$("#win_activityTimit").slideUp(350)});


	
//自定义select控件
$(".slctArea li.slctInput ul").css("width",$(".slctArea li.slctInput").width()+28);	
$(".slctArea li.slctInput").hover(function(){$(this).find("ul").css("display","block")},function(){$(this).find("ul").css("display","none")});
$(".slctArea .slctList li").mouseover(function(){$(this).css("background","#e1ebff")});
$(".slctArea .slctList li").mouseout(function(){$(this).css("background","#FFF")});
$(".slctArea #slctList1 li").live("click",function(){$(".slctArea li.slctInput #slctValue1").text($(this).html());$(this).parent().css("display","none")});
$(".slctArea #slctList2 li").live("click",function(){$(".slctArea li.slctInput #slctValue2").text($(this).html());$(this).parent().css("display","none")});






//sideNav菜单定位 dtIdx为一级 dtIdx二级

var dtIndx=(!window.dtIdx||dtIdx==null)?0:dtIdx;
var ddIndx=(!window.ddIdx||ddIdx==null)?0:ddIdx;
if(window.sideNavCtrl){sideNavCtrl(dtIndx,ddIndx)}
			   
$(".tList table:visible").find("th:first").css("border-left","0");//修正列表页th双线边框
$(".tList table:visible").find("tr").mouseover(function(){$(this).css("background-color","#e0ebff");})
$(".tList table:visible").find("tr").mouseout(function(){$(this).css("background-color","#FFF");})

$(".tList .rows tr").mouseover(function(){$(this).css("background-color","#e0ebff");})
$(".tList .rows tr").mouseout(function(){$(this).css("background-color","#FFF");})
	
$(".tList table:visible").find("tr:last td").addClass("tdLast");//为表格最后一行添加样式

$(".tList .noTdLast:visible").find("tr:last td").addClass("cleanTdLast");

$("#changePage>a").click(function(){$("#changePage>a").removeClass("btnOn");$(this).addClass("btnOn")});//翻页样式切换


//资金帐户信息切换
ownMoney=!window.ownMoney?0:ownMoney;//帐户余额
num_income=!window.num_income?0:num_income;//收入/支出明细记录条数
times_details=!window.times_details?0:times_details;//充值次数
amount_details=!window.amount_details?0:amount_details;//充值总额
times_cash=!window.times_cash?0:times_cash;//提现次数
amount_cash=!window.amount_cash?0:amount_cash;//提现总额
ownCoin=!window.ownCoin?0:ownCoin;//金币数量

//tab选项卡控制
$("#tabs>a").click(function(){
	$("#searchArea").hide(); //隐藏 更多筛选条件弹出						
	$("#tabs>a").removeClass("tabOn");
	//$(this).addClass("tabOn");
	$("#tabs>a").css("background-position","0 -30px");
	$("#tabs>a>div").css("background-position","right -30px");
	$(this).css("background-position","0 0");
	$(this).find("div").css("background-position","right 0")
			
	$('#tabArea>table').hide();
	$('#tabArea>table:eq('+$('#tabs>a').index(this)+')').show();
	$("#orderInfo").empty();
	if(window.sucessCount){
		if(sucessAmount[$('#tabs>a').index(this)]!=null){	
		$("#orderInfo").html("成功订单（<span>"+sucessCount[$('#tabs>a').index(this)]+"</span>）：<span class=\"til\">"+sucessAmount[$('#tabs>a').index(this)]+"元</span>");
		}
		else{
		$("#orderInfo").html("成功订单（<span>"+sucessCount[$('#tabs>a').index(this)]+"</span>）")

		}
	}
	
	})

function setTabIndex(){
$('#tabArea>table:not(:first)').hide();
	
//$("#tabs>a:first").addClass("tabOn"); //IE6不兼容a标签套用此样式
$("#tabs>a:first").css("background-position","0 0");
$("#tabs>a:first>div").css("background-position","right 0");

$("#tabs>a:first").find("div").css("background-position","right 0")
}


//若tabIndex定位参数未定义则默认第一个为当前状态
function showTabArea(index){
	$('#tabs>a:eq('+index+')').css("background-position","0 0");
	$('#tabs>a:eq('+index+')>div').css("background-position","right 0");
	$('#tabArea>table').hide();
	$('#tabArea>table:eq('+index+')').show();
	}
if(!window.tabIndex){setTabIndex()}
else{
	switch(tabIndex){
	case 1:
	showTabArea(1);
	$("#countInfo div").replaceWith("<div>目前资金账户余额：<span class=\"txt12org\">&nbsp;￥"+ownMoney+"&nbsp;</span></div>")
	$("#listInfo span").replaceWith("<span>共充值"+times_details+"次，总计充值"+amount_details+"元</span>");
	break;
	case 2:
	showTabArea(2);
	$("#countInfo div").replaceWith("<div>目前资金账户余额：<span class=\"txt12org\">&nbsp;￥"+ownMoney+"&nbsp;</span></div>")
	$("#listInfo span").replaceWith("<span>共提现"+times_cash+"次，总计"+amount_cash+"元</span>");
	break;
	case 3:
	showTabArea(3);
	$("#countInfo div").replaceWith("<div>目前有金币：<span class=\"txt12org\">&nbsp;"+ownCoin+"&nbsp;</span>枚（1枚金币＝1元人民币）</div>")
	$("#listInfo span").replaceWith("<span></span>");
	break;
	default:
	showTabArea(0);
	$("#countInfo div").replaceWith("<div>目前资金账户余额：<span class=\"txt12org\">&nbsp;￥"+ownMoney+"&nbsp;</span></div>");
	$("#listInfo span").replaceWith("<span>共"+num_income+"条记录</span>");
	}
}

		
//按字母查找乘机人样式控制
		$("#selectPeople>a:not(:first)").click(function(){$("#selectPeople>a").removeClass();$("#selectPeople>a:first").addClass("slctAll");$(this).addClass("slctOn")});
		$("#selectPeople>a:first").click(function(){$("#selectPeople>a:not(:first)").removeClass();$("#selectPeople>a:first").addClass("slctAll");$(this).addClass("allSlctOn")});
		$("#selectPeople>a:first").addClass("allSlctOn");
		



			
//我的旅行订单管理排序控制
$(".sortDiv span").css("cursor","pointer");
function setSortStyle(obj,classN,type){
var tabInx=obj.parent().parent().parent().parent().parent().index()-1;
$(".sortDiv span").removeClass("sortUpOn");
$(".sortDiv span").removeClass("sortDownOn");
obj.addClass(classN);
listOrder(type,tabInx);
}

$(".sortUpODay:visible").live("click",function(){setSortStyle($(this),"sortUpOn","sortUpODay")});
$(".sortUpLDay:visible").live("click",function(){setSortStyle($(this),"sortUpOn","sortUpLDay")});
$(".sortUpPrice:visible").live("click",function(){setSortStyle($(this),"sortUpOn","sortUpPrice")});

$(".sortDownOday:visible").live("click",function(){setSortStyle($(this),"sortDownOn","sortDownOday")});
$(".sortDownLDay:visible").live("click",function(){setSortStyle($(this),"sortDownOn","sortDownLDay")});
$(".sortDownPrice:visible").live("click",function(){setSortStyle($(this),"sortDownOn","sortDownPrice")});

	

$("#searchArea").hide();
$("#searchCriteria").hide();
$("#closeSearch").click(function(){$("#searchArea").hide()});
$("#btn_cleanSall").click(function(){$("#searchCriteria").hide();refind(); $("#searchArea").show(); cleanAllSearch()})
$("#searchArea :button[value='筛 选']").click(function(){$("#closeSearch").show();$("#searchArea").hide(); $("#searchCriteria").show(); shaiXuan()})

//如果searched为true，则显示已选择的筛选条件div（用于页面刷新时保留div显示）
if(window.searched){
		if(searched==true){
		$("#searchArea").show();
		$("#searchArea div").hide();
		$("#searchCriteria").show();
		$("#closeSearch").hide();
		}
		else{
		$("#searchCriteria").hide();
		$("#searchArea").hide();
		}
}


$(".listRecord li:first").css("paddingTop","5px");
$(".listRecord li:last").css("border","none");
$("#historyOrder ul:not(:first)").hide();

//我的团购管理 团购意愿 展开收缩
$(".btn_viewMore").parent().find(".moreInfo").hide();
$(".btn_viewMore").toggle(
  function () {
    $(this).removeClass();
	$(this).addClass("btn_viewMoreOn");
	$(this).parent().find(".moreInfo").show();
  },
  function () {
    $(this).removeClass();
	$(this).addClass("btn_viewMore");
	$(this).parent().find(".moreInfo").hide();
  }
);

//机票搜索结果 退改签 弹出层
var txt_div=["退票规定：<br />收取票面价(不含税)的10%作为退票费<br />改签规定：<br />不论是航班离站前或后，同舱位免费变更，不限次数。","退票规定：<br />我靠2<br />改签规定：<br />222222","退票规定：<br />333333<br />改签规定：<br />33333","退票规定：<br />444444<br />改签规定：<br />656323532","退票规定：<br />6565323232<br />改签规定：<br />964132132","退票规定：<br />9632312653<br />改签规定：<br />32132323232","退票规定：<br />6513231321322132<br />改签规定：<br />61132323232","as","sssddd","3r32rds","g4grd","54gt","jhngbv","jyjujhgfd","hjytgfd","fq43f3fe","g454refd","g54tf"];

//modify by zhangyun 修改了部分逻辑
$("#changeNotice").hide();
$("a:contains('退改签')").live("mouseover",
function(){
	var indx=$("a:contains('退改签')").index(this);

var nextObj = $(this).next();
if(nextObj.val() != 'undefined'){
	txt_div[indx] = nextObj.attr("value");
}
if(typeof(txt_div[indx]) != "undefined"){
$("#changeNotice").show();
var X = $(this).position().left-60+"px"; 
var Y = $(this).position().top+22+"px"; 
$("#changeNotice").css("left",X);
$("#changeNotice").css("top",Y);	
$("#changeNotice").wrapInner("<p></p>");
$("#changeNotice p").replaceWith("<img src=\"images/b2cImg/frimages/notice_arrow.jpg\"/>"+txt_div[indx]);
}
})

$("a:contains('退改签')").live("mouseout",
function(){
	$("#changeNotice p").empty();
	$("#changeNotice").hide();
	})


//机票搜索结果列表 全部价格div控制

function showAllPrice(nowIndx){
$("#div"+nowIndx).addClass("checked");
$("#div"+nowIndx).find("ul:first").css("borderBottom","1px solid #c7e0ea");
$("#div"+nowIndx).find(".linelist02").show();
$("#span"+nowIndx).find("a").replaceWith("<a href=\"javascript:void(0);\" class=\"txt_blue3\" style=\"_padding-top:2px;\">收起全部价格<img src="+CTX+"\/images/b2cImg/frimages/ico_closePrice.gif /></a>");
}
function closeAllPrice(perIndx){
$("#div"+perIndx).find("ul:first").css("borderBottom","none");
$("#div"+perIndx).removeClass("checked");
$("#div"+perIndx).find(".linelist02").hide();
$("#span"+perIndx).find("a").replaceWith("<a href=\"javascript:void(0);\" class=\"txt_blue3\">查看全部价格<img src="+CTX+"\/images/b2cImg/frimages/listmore.jpg /></a>");
}

var f_curOpenItem=null;//记录上次点击索引
$(".linelist span[name='txt_allPrice']").live("click",function(){
var _id=$(this).attr("id");
var nowPosition=_id.substring(4);

if(f_curOpenItem!=null){
	var prePosition=f_curOpenItem;
	if(nowPosition!=prePosition){
		closeAllPrice(prePosition);
		showAllPrice(nowPosition);
		f_curOpenItem=nowPosition;
	}
	else{
		closeAllPrice(prePosition);
		f_curOpenItem=null;
	}
}
else{
	f_curOpenItem=nowPosition;
	showAllPrice(nowPosition);
}
});


//机票搜索日期tab切换
$(".changeday .cday li").live("click",function(){$(".changeday .cday li").removeClass();$(this).addClass("choosed"); changeDay($(".changeday .cday li").index(this))})


//关闭搜索loading
function closeLoading(){
	$(".loading").css("visibility","hidden");
	}



//预定房间操作
function resetFillOrderHlist(){
$(".fillOrderHList01").removeClass("fillOrderHList01Choosed"); 
$(".fillOrderHList01 .frBtn").attr("value","预定此房间")
	}

$(".fillOrderHList01 :button[value='预定此房间']").live("click",function(){
resetFillOrderHlist();//初始化
var indx=$(".fillOrderHList01 .frBtn").index(this);
	$(".fillOrderHList01").eq(indx).addClass("fillOrderHList01Choosed"); 
	$(this).attr("value","取消预定");
	book(indx);
})

$(".fillOrderHList01 :button[value='取消预定']").live("click",function(){
resetFillOrderHlist();//初始化
var indx=$(".fillOrderHList01 .frBtn").index(this);
$(".fillOrderHList01").eq(indx).removeClass("fillOrderHList01Choosed"); 
$(this).attr("value","预定此房间");
	cancel(indx);
})


//前台选择支付方式
var payWayIndex;
if(window.initPayWay){payWayIndex = initPayWay()}//对外提供接口
payWayIndex= typeof(payWayIndex)=='undefined'?2:payWayIndex;//预设默认支付方式接口
$(".payWayMainContent p").hide();
$(".payWayMainContent p").eq(payWayIndex).show();
$(".payWaySelect :radio").eq(payWayIndex).attr('checked',true); 
$(".payWaySelect li").click(function(){
var indx=$(".payWaySelect li").index(this);
$(".payWayMainContent p").hide();
$(".payWayMainContent p").eq(indx).show();
$(".payWaySelect :radio").attr('checked',false); 
$(".payWaySelect :radio").eq(indx).attr('checked',true); 
})




//酒店详情查看全部价格开始
function resetMoreList(){
$(".hotelDetailList table.moreList").hide();
$(".hotelDetailList .btn_showAllPrice").empty();
$(".hotelDetailList .btn_showAllPrice").append("查看全部价格 <img src=\"images/frimages/listmore.jpg\" />");
	}

$(".hotelDetailList .btn_showAllPrice:contains('查看全部价格')").live("click",function(){
resetMoreList();//初始化
var indx=$(".btn_showAllPrice").index(this);
	$(".hotelDetailList table.moreList").eq(indx).show(); 
	$(".hotelDetailList table:visible.moreList").css("borderTop","none");
	$(this).empty();
	$(this).append("收起全部价格 <img src=\"images/frimages/ico_closePrice.gif\" />");
})

$(".hotelDetailList .btn_showAllPrice:contains('收起全部价格')").live("click",function(){
resetMoreList();//初始化
var indx=$(".btn_showAllPrice").index(this);
	$(".hotelSearchList01 table.moreList").eq(indx).hide(); 
	$(this).empty();
	$(this).append("查看全部价格 <img src=\"images/frimages/listmore.jpg\" />");
})
//酒店详情页查看全部价格结束



//前台机票 、酒店首页热门城市切换
$(".hotCityTabTItle li:first").addClass("choosed");
$(".hotCityTabTItle li").live("hover",function(){
var indx=$(".hotCityTabTItle li").index(this);
$(".hotCityTabTItle li").removeClass(); 
$(this).addClass("choosed");	
changeHotCity(indx);
})


//表单控件提示文字颜色
$(":text").css("color","#9f9d9d");
$("textarea").css("color","#9f9d9d");
//$(":text[class='defaultVal']").css("color","#333");
//表单focus状态控制
$(":text").live("focus",function(){$(this).css("color","#333");})
$("textarea").live("focus",function(){$(this).css("color","#333");})
//$(":text[class!='defaultVal']").one("focus", function(){$(this).val(""); $(this).css("color","#333");})
$(":text").one("focus", function(){$(this).select(); $(this).css("color","#333");})
$("textarea").one("focus", function(){$(this).select(); $(this).css("color","#333");})


//修正填写订单标题位置
$(".fillOrderHead span:contains('提示')").css({position:"absolute",top:"15px",left:"20px"})
$(".fillOrderHead>img").css({position:"absolute",top:"24px",left:"100px"})


});
