﻿// JavaScript Document
$(function(){
	//用于游船首页效果		   
	//切换航线图触发事件
	$(".pageNav li").css("cursor","pointer");
	$(".pageNav li").click(function(){
		$(".pageNav li").removeClass("active");
		$(this).addClass("active");
		var _split = $(this).attr("id").split("-");
		var txt = "Cruses Line: "+_split[0]+" &gt; "+_split[1]+" ("+_split[2]+" stream, "+_split[3]+" days)";
		$(".cruiseInfoDetail-Txt").html(txt);
		$("#ShowMap").attr("src","/image/cruise/cruise-map/"+_split[0]+"-"+_split[1]+"-b.jpg").attr("alt",""+_split[2]+"strream: "+_split[0]+" &gt; "+_split[1]+"");
		//调AJAX获得游船推荐列表
		/*$.post("/include/ajax.asp",
			   {strtemp:"cruise-comm-list",v:$(this).attr("id")},
			   function(data){$("#cruiseInfoDetail .searchResults").remove();
			   $(".cruise-comm-list").after(data);});*/
	});
	//用于游船首页效果	
	
	//预定列表价格赋值操作
	$("a[id=nStep]").click(function(){
		var nHref = $(this).attr("href");
		if($("input[name=RooRadio]:checked").val() != null)
		{
			var arr_tmp = $("input[name=RooRadio]:checked").val().split("_");
		}
		else
		{
			var choseprice = jsLanguageTag('choseprice');
			alert(choseprice);
			return false;
		}
		nHref = nHref.replace("price=","price="+arr_tmp[0]);
		nHref = nHref.replace("depdate=","depdate="+arr_tmp[1]);
		nHref = nHref.replace("arrdate=","arrdate="+arr_tmp[2]);
		nHref = nHref.replace("roomtype=","roomtype="+arr_tmp[3]);
		$(this).attr("href",nHref);
	});
	//搜索列表进行筛选操作
	$("#sortType").change(function()
	{
		$("#TmpsortType").val($(this).val());
		$("form[name=cruisesearchpanelform]").submit();
	});
	//游船比对操作
	$("input[name=cCRI_SN]").next("a").click(function()
	{
		if($("input[name=cCRI_SN]:checked").length <= 1)
		{
			alert('err:less than 2');return false;
		}
		var cCRI_SN_split = "" ;	//cCRI_SN_split 取得航期ID
		$("input[name=cCRI_SN]:checked").each(function(){
			cCRI_SN_split = cCRI_SN_split + $(this).val() + "," 
		});
		location.href = "/yangtzecruise/compare-cruise.asp?cruiseid="+cCRI_SN_split
	});
	//淡旺季价格变换操作
	$("input[name=Direction]").click(function(){
		$(".tableOnly").css("display","none");
		$("#"+$(this).val()).css("display","");
	});
	//游船随航线变换操作
	$("#fromto").change(function(){
		var cfrom = $(this).val().split("-")[0];
		var cto = $(this).val().split("-")[1];
		var ajax_PublicFile="/PublicBin/include/ajax.asp";
		$.post(ajax_PublicFile,
			   {strtemp:"change-cruise-option",cfrom:cfrom,cto:cto},
			   function(data){
//				   alert(data);return false;
				   $("#shipname").children().remove();
				   var arri = new Array();
				   arri = data.split(",");
					$.each(arri,function(arriIndexOf,arriValue){
						if(arriValue != "")
						{
							var objOption = $("<option></option>").val(arriValue).text(arriValue);
							$("#shipname").append(objOption);
						}
						});
				   });
	});
	
//大航期表月份年份切换（链接按钮方式）
	$("#calendar_nav a").click(function(){
		var indexMonthVal = $("#intMonth option:selected").val();
		var indexYearVal = $("#intYear option:selected").val();
		if($(this).attr("id") == "date-turn-right")
		{
			if(indexMonthVal == 12)
			{
				$("#intMonth option[value='1']").attr("selected","selected");
				$("#intYear option[value='"+(parseInt(indexYearVal) + 1)+"']").attr("selected","selected");
			}
			else
			{
				$("#intMonth option[value='"+(parseInt(indexMonthVal) + 1)+"']").attr("selected","selected");
			}
		}
		else
		{
			if(indexMonthVal == 1)
			{
				$("#intMonth option[value='12']").attr("selected","selected");
				$("#intYear option[value='"+(parseInt(indexYearVal) - 1)+"']").attr("selected","selected");
			}
			else
			{
				$("#intMonth option[value='"+(parseInt(indexMonthVal) - 1)+"']").attr("selected","selected");
			}
		}
	});
	$("select[name=PriceRow]").change(function(){
		var PriceRow = $(this).val();
		if(PriceRow == 0)
		{
			$("#"+$(this).parents("table").attr("id")+" .js_row").show();
			return;
		}
		var ii = 0;
		$.each($("#"+$(this).parents("table").attr("id")+" .js_row"),function(){
			if(ii > PriceRow)
			{
				$(this).hide();
			}
			else
			{
				$(this).show();
			}
			ii += 1
		});
	});
	$("a[id=js_more_cruiseprice]").click(function(){
		var print_PublicFile="/PublicBin/include/cruise-price-window.asp?cruiseship=";
		ShowIFrame('',print_PublicFile+$(this).attr("name"),750,510,'bottom')
	});
});

//判断email合法
var CheckEmailFormat = function(strEmail)
{
	var pattern1 = /^(([\u4E00-\u9FA5]|[\uFE30-\uFEFF]|[\d]|[a-zA-Z]|[\_\-\.])+[\@])(((([\d]|[a-zA-Z]|[\_\-]|[\[\]\{\}\>\<])+[\.])+)([\d]|[a-zA-Z\_\-])+)$/;
	if(!strEmail.match(pattern1))
	{
		return false;
	}
	return true;
}

