
function onColor(td){
 if(td.style.backgroundColor!="#ff6699"){
  td.style.backgroundColor='#ffff99';
  td.style.color='#0600ff';
 }
}

function onClickColor(td){
 if(td.style.backgroundColor!="#ff6699"){
  td.style.backgroundColor='#ff6699';
  td.style.color='#0600ff';
 }else{
  td.style.backgroundColor='';
  td.style.color='#000000';
 }
}

function offColor(td){
 if(td.style.backgroundColor!="#ff6699"){
  td.style.backgroundColor='';
  td.style.color='#000000';
 }
}


var tt='start';
var ii='start';
function turnit(ss,bb) {

  if (ss.style.display=="none") {
    if(tt!='start') tt.style.display="none";
    if(ii!='start') ii.src="";
    ss.style.display="";
    tt=ss;
    ii=bb;
    bb.src="";
  }
  else {
    ss.style.display="none"; 
    bb.src="";
  }
}


function DoSearchAction(StartCity,ArrivalCity,FlyDate)
{
	try
	{
		var str = FlyDate;
		 
		if(str.indexOf("/") != -1)
		{
			var astr = str.split('/')
			str = astr[2] + "-" + astr[0] + "-" + astr[1];
		}
		
		document.getElementById("StartCity").value = StartCity;
		document.getElementById("ArrivalCity").value = ArrivalCity;
		document.getElementById("FlyDate").value = FlyDate;
		document.DoSearch.action = "waiting.aspx?sid=<%=GetGuiid()%>"
		document.all["DoSearch"].submit();	
	}
	catch(e){}
}

function IsDate(sDate) {
	var iYear, iMonth, iDay, iIndex

	var	reg
	reg = new RegExp('[^0-9-]','')
	if (sDate.search(reg) >= 0)
		return false;
	
	iIndex = sDate.indexOf('-');
	if ( iIndex == -1 )
		return false;
	else {
		iYear = parseFloat(sDate.substr(0, iIndex));
		if ( isNaN(iYear) || iYear < 1900 || iYear > 2099 )
			return false;
		else
			sDate = sDate.substring(iIndex + 1, sDate.length);
	}
	
	iIndex = sDate.indexOf('-');
	if ( iIndex == -1 )
		return false;
	else {
		iMonth = parseFloat(sDate.substr(0, iIndex));
		if ( isNaN(iMonth) || iMonth < 1 || iMonth > 12 )
			return false;
		else
			sDate = sDate.substring(iIndex + 1, sDate.length);
	}
	
	iIndex = sDate.indexOf('-');
	if ( iIndex >= 0 )
		return false;
	else {
		iDay = parseFloat(sDate);
		if ( isNaN(iDay) || iDay < 1 || iDay > 31 )
			return false;
	}
	
	
	switch(iMonth) {
		case 4:
		case 6:
		case 9:
		case 11:
			if ( iDay > 30 )
				return false;
			else
				break;
		case 2:
			if ( ( ( iYear % 4 == 0 && iYear % 100 != 0 ) || iYear % 400 == 0 ) && iDay > 29 )
				return false;
			else if ( (iYear % 4 != 0 || (iYear % 100 == 0 && iYear % 400 != 0)) && iDay > 28 )
				return false;
			else
				break;
		default:
	}
	return true;
}

function check()
{

	if (document.getElementById("Search1_RadioButtonListAirType0").checked == true)
	{
		if (document.getElementById("Search1_textFlyDate").value == '')
		{
			alert("出发日期不能为空！");
			return false;
		}
		
		if (!IsDate(document.getElementById("Search1_textFlyDate").value))
		{
			alert("出发日期错误！");
			return false;
		}
	}
	
	if (document.getElementById("Search1_RadioButtonListAirType1").checked == true)
	{
		if (document.getElementById("Search1_textFlyDate").value == '')
		{
			alert("出发日期不能为空！");
			return false;
		}
		
		if (!IsDate(document.getElementById("Search1_textFlyDate").value))
		{
			alert("出发日期错误！");
			return false;
		}
		
		if (document.getElementById("Search1_textBackDate").value == '')
		{
			alert("返回日期不能为空！");
			return false;
		}
		
		if (!IsDate(document.getElementById("Search1_textBackDate").value))
		{
			alert("返回日期错误！");
			return false;
		}

		if (!compareDate(document.getElementById("Search1_textBackDate").value, document.getElementById("Search1_textFlyDate").value))
		{
			alert("返回日期必须大于出发日期！");
			return false;
		}
		
	}
	
	return true;
}
function CheckLinkMan() {

                   var eInfor = "";

                   var pass = true;

 

                   //alert("sss");

                   

                   if ( document.forms[0].txtLinkManName.value == ""  ) {

                       eInfor+='请输入联系人姓名! \n';

                       document.all["CheckLinkMan"].innerText = eInfor;

                       document.forms[0].txtLinkManName.focus();

                       pass = false;

                   }
   }
function compareDate(DateOne,DateTwo)
{

	var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));
	var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);
	var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));

	var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));
	var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);
	var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));

	if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) >=
	Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
	{
	return true;
	}
	else
	{
	return false;
	}

}
//******************查询页面数据校验********************
		function  String.prototype.Trim()   
{
return   this.replace(/(^\s*)|(\s*$)/g,"");
}   
  function   String.prototype.Ltrim(){return   this.replace(/(^\s*)/g,   "");}   
  function   String.prototype.Rtrim(){return   this.replace(/(\s*$)/g,   "");}   
			 function BeginTime(id) 
			{ 
				date = new Date();
				var h=date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
				
				//alert(h);
				var timestring = showModalDialog("selecttime.htm", "", "dialogLeft:"+(event.screenX-13)+";dialogTop:"+(event.screenY-15)+";dialogWidth:165px; dialogHeight:205px; edge:raised;help:off;status:off;scroll:off");
				if(timestring!="")
				{
				
					document.getElementById(id).value = timestring+" ";//+h; 
				}   
			}
			function checksubminQueryDate()
{
	var txtFlyReturnDate =document.all("txtFlyReturnDate").value.Trim();
	var txtFlyDate =document.all("txtFlyDate").value.Trim();
	//window.alert(txtFlyDate);
	//window.alert(txtFlyReturnDate);
	var sign=true;
	if(txtFlyDate=='' )
	{
		 window.alert('起飞日期不能为空');
		 sign = false;
	}
	if(IsDate(txtFlyDate)==false)
	{
	// window.alert(ddlFlyTime)
		 window.alert('出发日期错误');
		 sign = false;
	}
	var RadFlyWay;
	radobj=document.getElementsByName("RadFlyWay");
	for(i=0;i<radobj.length;i++) {
	if(radobj[i].checked==true) {
	RadFlyWay = radobj[i].value
	}
	}
	if(RadFlyWay=='1')
	{
			//window.alert('您选择的是往返');//返程日期
			if(txtFlyReturnDate=='' )
			{
				 window.alert('往返日期不能为空');
				 sign = false;
			}
			if(!IsDate(txtFlyReturnDate))
			{
				// window.alert('往返日期错误');
				// sign = false;
			}
				if (!compareDate(txtFlyReturnDate,txtFlyDate))
				{
				 window.alert('返回日期必须大于出发日期');
				 sign = false;
				}
	}
	else
	{
			//window.alert('您选择的是单程');//返程日期
	}
	return sign;
	
}
	
//**************************************************
	
			
