﻿function g(o){return document.getElementById(o);}
function showmapbtn(n){
for(var i=1;i<=3;i++)
{g('map_'+i).className='yc_map_close';}
g('map_'+n).className='yc_map_open';
}
function showleftlist(n){
	if(g('show_btn_'+n).className=="yc_opened"){
	g('show_btn_'+n).className='';
	g('yc_left_list_'+n).className='yc_block';
		}
		else{
	g('show_btn_'+n).className='yc_opened';
	g('yc_left_list_'+n).className='yc_closed';
	
}
	}
function firefox_innerText(){
var lBrowser = {};
lBrowser.agt = navigator.userAgent.toLowerCase();
lBrowser.isW3C = document.getElementById ? true:false;
lBrowser.isIE = ((lBrowser.agt.indexOf("msie") != -1) && (lBrowser.agt.indexOf("opera") == -1) && (lBrowser.agt.indexOf("omniweb") == -1));
lBrowser.isNS6 = lBrowser.isW3C && (navigator.appName=="Netscape") ;
lBrowser.isOpera = lBrowser.agt.indexOf("opera") != -1;
lBrowser.isGecko = lBrowser.agt.indexOf("gecko") != -1;
lBrowser.ieTrueBody =function (){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
};
if(lBrowser.isNS6){ //firefox innerText define
 HTMLElement.prototype.__defineGetter__( "innerText", 
 function(){ 
 return this.textContent; 
 } 
 ); 
 HTMLElement.prototype.__defineSetter__( "innerText", 
 function(sText){ 
 this.textContent=sText; 
 } 
 ); 
}
}
	
function SetSortBY(x)
{
	var SortBy="default";
	if(document.getElementById('Radio_2').checked)SortBy="price";
	if(document.getElementById('Radio_3').checked)SortBy="class";
	var url="CID="+document.getElementById("hdnCID").value+"&SortBy="+SortBy+"&StartDate="+g("hdnStartDate").value+"&EndDate="+g("hdnEndDate").value;
	window.top.location.href="/YangtzeCruise/CruiseSearchList.aspx?"+url;
}


function MM_showHideMonth(x)
{
    var vYear,vMonth;
    var myDate = new Date();
	if(x == 14)
	{
		vYear = myDate.getFullYear() + 1;
		vMonth = 1;
	}
	else if(x == 13)
	{
		vYear = myDate.getFullYear();
		vMonth = myDate.getMonth() + 3;
	}
	else
	{
		vYear = document.getElementById('hdnYear').value;
		vMonth = x;
	}
	var url="/YangtzeCruise/Information.aspx?CID=" + document.getElementById('hdnCID').value;
	url+="&Year="+vYear;
	url+="&Month="+vMonth;
	url+="&Type=2";
	document.location.href=url;	
}

function CruiseType()
{
    var Tbyear= parseInt(document.getElementById('hdnYear').value);
    var d = new Date();
    if(Tbyear == d.getFullYear())
    {
        document.getElementById('aNowYear').style.display = "none";
        document.getElementById('aNextYear').style.display = "";
        document.getElementById('aNextYear').className = "yc_nytp";
        document.getElementById('lyear').innerHTML = Tbyear;
        var isDisplayNextYear =document.getElementById("hidIsDisplayNextYear").value; 
        if(isDisplayNextYear=="1")
        {
            document.getElementById('aNextYear').style.display = "block";
        }
        else
        {
            document.getElementById('aNextYear').style.display = "none";
        }
    }
    else
    {
        document.getElementById('aNowYear').style.display = "";
        document.getElementById('aNextYear').style.display = "none";
        document.getElementById('aNowYear').className = "yc_nytp";
        document.getElementById('lyear').innerHTML = Tbyear;
    }
	MM_showHideMonthNow(document.getElementById('hdnMonth').value);
	var strType = document.getElementById('hdnType').value;
	_g("yc_detail_show_"+strType).className = "yc_block";
	_g("yc_detail_btn_"+strType).className = "yc_detail_btn_on yc_btn_now_" + strType;
}

function MM_showHideMonthNow(id)
{
	for (i=1;i<=12;i++)
	{
		if (i == id)
		{
			document.getElementById('showDayTd'+i).className = 'yc_cdar_now';
		}
		else
		{
			document.getElementById('showDayTd'+i).className = ''; 
		}
			
	}
}

function SubmitBooking()
{	
	if(document.getElementById("AvailType").value=="3")
	{
		if(confirm("OnRequest"))
		{
			document.getElementById("AvailType").value="1";
		}
		else
		{
			return false;
		}
	}
	document.getElementById("BtnSubmit").click();
}

//函数名：CheckTimeHHMM
//功能介绍：检查是否为时间HH:MM   
//参数说明：要检查的字符串
//返回值：false：不是  true：是   [0-2][0-9]:[0-5][0-9]

function CheckTimeHHMM(strExpression)
{
	//alert(strExpression);
	var strRegExp;
	strRegExp=/^(([0-1][0-9])|2[0-3]):[0-5][0-9]$/;
		
	var regTmp;
	var macthAry;
	var strHH
	var strMM
	regTmp = new RegExp(strRegExp);
	macthAry = regTmp.exec(strExpression);
	if (macthAry != null)
	{
		strHH = RemoveZoneH(strExpression.substring(0,2));
		strMM = RemoveZoneM(strExpression.substring(3,5));
		//alert(strHH);
		//alert(strMM);
		
		if(parseInt(strHH)>24)
		{
			return false;
		}
		if(parseInt(strMM)>60)
		{
			return false;
		}
		
		return true;
	}
	else
	{
		return false;
	}
}

//函数名：chkdate
//功能介绍：检查是否为日期
//参数说明：要检查的字符串
//返回值：0：不是日期  1：是日期
function chkdate(datestr)
{
 var lthdatestr
 if (datestr != "")
  lthdatestr= datestr.length ;
 else
  lthdatestr=0;
  
 var tmpy="";
 var tmpm="";
 var tmpd="";
 //var datestr;
 var status;
 status=0;
 if ( lthdatestr== 0)
  return 0


 for (i=0;i<lthdatestr;i++)
 { if (datestr.charAt(i)== '-')
  {
   status++;
  }
  if (status>2)
  {
   //alert("Invalid format of date!");
   return 0;
  }
  if ((status==0) && (datestr.charAt(i)!='-'))
  {
   tmpy=tmpy+datestr.charAt(i)
  }
  if ((status==1) && (datestr.charAt(i)!='-'))
  {
   tmpm=tmpm+datestr.charAt(i)
  }
  if ((status==2) && (datestr.charAt(i)!='-'))
  {
   tmpd=tmpd+datestr.charAt(i)
  }

 }
 year=new String (tmpy);
 month=new String (tmpm);
 day=new String (tmpd)
 //tempdate= new String (year+month+day);
 //alert(tempdate);
 if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
 {
  //alert("Invalid format of date!");
  return 0;
 }
 if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
 {
  //alert ("Invalid month or day!");
  return 0;
 }
 if (!((year % 4)==0) && (month==2) && (day==29))
 {
  //alert ("This is not a leap year!");
  return 0;
 }
 if ((month<=7) && ((month % 2)==0) && (day>=31))
 {
  //alert ("This month is a small month!");
  return 0;
 
 }
 if ((month>=8) && ((month % 2)==1) && (day>=31))
 {
  //alert ("This month is a small month!");
  return 0;
 }
 if ((month==2) && (day==30))
 {
  //alert("The Febryary never has this day!");
  return 0;
 }
 
 return 1;
}

function RemoveZoneM(TimeStr)
{
		var TimeStrs = TimeStr;
		if(TimeStrs.indexOf("0",0)==0)
		{	
			TimeStrs=TimeStr.substr(1,1);
		}
		return TimeStrs;
}
	
function RemoveZoneH( TimeStr)
{
	var TimeStrs = TimeStr;
	if(TimeStr=="00")
	{
		TimeStrs = "24";
	}
	else
	{
		if(TimeStrs.indexOf("0",0)==0)
		{	
			TimeStrs=TimeStr.substr(1,1);
		}
	}
	return TimeStrs;
}

