//////////////////////////国际预定表格
function bookingTable(){
	if($("#bookInfo").length>0){
		$("#bookInfo>table tr:even").css("background","#f5f5f5");
	}
}
function orderTable(){
	if($("#orderInfo").length>0){
		$(".orderInfo>table tr:even").css("background","#f5f5f5");
	}
}
function tableA(){
	if($("table.styA").length>0){
		$("table.styA tr:even").css("background","#f5f5f5");
	}
}


//////////////////////////注册弹出层
function openLayer(){
	$("#overlay").width($(document).width());
	$("#overlay").height($(document).height());
	$("#overlay").fadeIn("fast");
	var _x = ($(window).width() - $("#registerWra").width())/2;
	var _y = ($(window).height() - $("#registerWra").height())/2;
	var pageScroll = getPageScroll();
	_x += pageScroll[0];
	_y += pageScroll[1];
	$("#registerWra").css("left",_x);
	$("#registerWra").css("top",_y);
	$("#registerWra").fadeIn("slow");

}
function closeReg(){
	$("#registerWra").hide();
	$("#overlay").fadeOut("fast");	
}
function register(){
	if($("#registerWra").length>0){
		if($("#overlay").length < 1){$("body").append("<div id='overlay'></div>");}
	//	$("input#registerBtn").click();
		$("#overlay").click(closeReg);
		$("#registerWra span.close").click(closeReg);
	}
}

//////////////////////////登陆
function openLogin(){
	$("#overlay").width($(document).width());
	$("#overlay").height($(document).height());
	$("#overlay").fadeIn("fast");
	var _x = ($(window).width() - $("#login1Wra").width())/2;
	var _y = ($(window).height() - $("#login1Wra").height())/2;
	var pageScroll = getPageScroll();
	_x += pageScroll[0];
	_y += pageScroll[1];
	$("#login1Wra").css("left",_x);
	$("#login1Wra").css("top",_y);
	$("#login1Wra").fadeIn("slow");
}

function closeLogin(){
	$("#login1Wra").hide();
	$("#overlay").fadeOut("fast");
}

function login(){
	if($("#login1Wra").length>0){
		if($("#overlay").length < 1){$("body").append("<div id='overlay'></div>");}
		$("#overlay").click(closeLogin);
		$("#login1Wra span.close").click(closeLogin);
	}
}
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

//////////////////////////取票方式
function qupiao(){
	if($("#qpBtns").length>0){
		$("tbody#qp1,tbody#qp2,tbody#qp3").hide();
		$("#qpBtns input").each(function(i){
			$(this).click(function(){
				$("tbody#qp1,tbody#qp2,tbody#qp3").hide();
				$("tbody#qp1,tbody#qp2,tbody#qp3").eq(i).show();
			});
		});
		var _index = $("#qpBtns input").index($("#qpBtns input:checked"));
		$("tbody#qp1,tbody#qp2,tbody#qp3").eq(_index).show();
	}
}
//////////////////////////新闻检索
function newsSearch(){
	if($("#newsSearch").length>0){
		$("#newsSearch input.text").attr("value","关键字搜索");
		$("#newsSearch input.text").focus(function(){
			if($(this).attr("value") == "关键字搜索"){
				$(this).attr("value","")
			}
		});
		$("#newsSearch input.text").blur(function(){
			if($(this).attr("value") == ""){
				$(this).attr("value","关键字搜索");
			}
		});
	}
}



function setDatefunc(){
	if($("span#date").length>0){
		var day="";
		var month="";
		var ampm="";
		var ampmhour="";
		var myweekday="";
		var year="";
		mydate=new Date();
		myweekday=mydate.getDay();
		mymonth=mydate.getMonth()+1;
		myday= mydate.getDate();
		myyear= mydate.getYear();
		year=(myyear > 200) ? myyear : 1900 + myyear;
		if(myweekday == 0)
		weekday=" 星期日 ";
		else if(myweekday == 1)
		weekday=" 星期一 ";
		else if(myweekday == 2)
		weekday=" 星期二 ";
		else if(myweekday == 3)
		weekday=" 星期三 ";
		else if(myweekday == 4)
		weekday=" 星期四 ";
		else if(myweekday == 5)
		weekday=" 星期五 ";
		else if(myweekday == 6)
		weekday=" 星期六 ";
		$("span#date").text(year+"年"+mymonth+"月"+myday+"日 "+weekday);
	}
}

function addFav(){
	if($("#fav").length>0){
		$("#fav a").eq(0).click(function(){
			SetHome(this,window.location);
		});
		$("#fav a").eq(1).click(function(){
			AddFavorite(window.location,document.title);
		});
	}
}

    function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e)
            {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    }
    function SetHome(obj,vrl)
    {
        try
        {
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
    }

function seePass(){
	if($("#seepass").length>0){
	$("a#seepass").hover(function(){$("span#hiddenPass").show()},function(){$("span#hiddenPass").hide()});
	}
}

function flightInfo(){
	if($("table#flightInfo").length>0){
		$("td.plantType span.a").each(function(){
			$(this).hover(function(){
				if($(this).find("span.b").length>0){
					$(this).find("span.b").fadeIn("fast");
				}
			},
			function(){
				$(this).find("span.b").hide();
			}
			);
		});
	}
}
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function indScroll(){
	if($("#indScroll1").length>0){
		new Marquee("indScroll1",0,1,300,60,20,4000,3000,20);
	}
}

/*////////////////////使用奖金*/

function useCupon(){
	if($("#useCupon").length>0){
		var resultNum = $("input.priceNum").attr("value")-parseInt($("span.cuponNum").text());
		if(resultNum<0){
		resultNum = 0;
		}
		$("span#resultNum").text(resultNum);
		
		$("img.useBtn").click(function(){
			$("p#useCuponInner").show();	
		});
		$("img.useLater").click(function(){
			$("p#useCuponInner").hide();
		});
		$("img.useNow").click(function(){
			$("input.priceNum").attr("value",resultNum);
			$("input#finalValue").attr("value",resultNum);
			$("p#useCuponInner").hide();
			$("img.useBtn").hide();
		});
	}
}
function booking(){
			$("#registerLogin").toggle();
			$("#loginForm").hide();

	if($("#bookInfo img#loginBtn").length>0){
		$("#bookInfo img#loginBtn").click(function(){
			$("#registerLogin").toggle();
			$("#loginForm").hide();
		});
	}
	if($("#bookInfo img#registerBtn").length>0){
		$("#bookInfo img#registerBtn").click(function(){
			$("#loginForm").toggle();
			$("#registerLogin").hide();
		});
	}
}
function loginBooking(){
	alert("dfdsfsf");
	$("input#usernames").attr("value",$("input#Monbel").attr("value"));
	$("#loginForm").show();
}
function clearFocus(){
	if($("input#suggest1").length>0){
		$("input#suggest1").focus(function(){
			if($(this).attr("value") == "英文/中文"){
				$(this).attr("value","")
			}
		});
		$("input#suggest1").blur(function(){
			if($(this).attr("value") == ""){
				$(this).attr("value","英文/中文");
			}
		});
	}
	if($("textarea#searchKey").length>0){
		$("textarea#searchKey").focus(function(){
			if($(this).attr("value") == "常见问题解答1000例，请用关键字搜索"){
				$(this).attr("value","")
			}
		});
		$("textarea#searchKey").blur(function(){
			if($(this).attr("value") == ""){
				$(this).attr("value","常见问题解答1000例，请用关键字搜索");
			}
		});
	}
	if($("#company #comCap input#keyword").length>0){
		$("#company #comCap input#keyword").focus(function(){
			if($(this).attr("value") == "到达城市"){
				$(this).attr("value","")
			}
		});
		$("#company #comCap input#keyword").blur(function(){
			if($(this).attr("value") == ""){
				$(this).attr("value","到达城市");
			}
		});
	}
	
}
$(document).ready(bookingTable);
$(document).ready(orderTable);
$(document).ready(tableA);
$(document).ready(register);
$(document).ready(login);
$(document).ready(qupiao);
$(document).ready(newsSearch);
$(document).ready(setDatefunc);
$(document).ready(addFav);
$(document).ready(seePass);
$(document).ready(flightInfo);
$(document).ready(indScroll);
$(document).ready(useCupon);
$(document).ready(booking);
$(document).ready(clearFocus);