
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('出发日期不能为空');
		 return false;//sign = false;
		 
	}
	if(IsDate(txtFlyDate)==false)
	{
	// window.alert(ddlFlyTime)
		 window.alert('出发日期错误');
		 return false;//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('返回日期不能为空');
				 return false;//sign = false;
			}
			if(!IsDate(txtFlyReturnDate))
			{
				window.alert('返回日期错误');
				return false;// sign = false;
			}
				if (!compareDate(txtFlyReturnDate,txtFlyDate))
				{
				 window.alert('返回日期必须大于出发日期');
				 return false;//sign = false;
				}
	}
	else
	{
			//window.alert('您选择的是单程');//返程日期
	}
	return sign;
	
}
	
//**************************************************
	
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 
var base64DecodeChars = new Array( 
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, 
    -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, 
    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); 

function base64encode(str) { 
    var out, i, len; 
    var c1, c2, c3; 

    len = str.length; 
    i = 0; 
    out = ""; 
    while(i < len) { 
    c1 = str.charCodeAt(i++) & 0xff; 
    if(i == len) 
    { 
        out += base64EncodeChars.charAt(c1 >> 2); 
        out += base64EncodeChars.charAt((c1 & 0x3) << 4); 
        out += "=="; 
        break; 
    } 
    c2 = str.charCodeAt(i++); 
    if(i == len) 
    { 
        out += base64EncodeChars.charAt(c1 >> 2); 
        out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); 
        out += base64EncodeChars.charAt((c2 & 0xF) << 2); 
        out += "="; 
        break; 
    } 
    c3 = str.charCodeAt(i++); 
    out += base64EncodeChars.charAt(c1 >> 2); 
    out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); 
    out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); 
    out += base64EncodeChars.charAt(c3 & 0x3F); 
    } 
    return out; 
} 

function openWindow()
{
   var stat = document.getElementById('FeeyoSearch_ddlDepart');
    var starValue= base64encode(stat.options[stat.selectedIndex].value);
    var end = document.getElementById('FeeyoSearch_ddlArrive');
   var endValue= base64encode(end.options[end.selectedIndex].value);
   var type = base64encode('0');
   window.open('CurrentFlightInfo/list.aspx?StarCity='+starValue+'&EndCity='+endValue+'&Type='+type+'');
}

function openGuoNeiWindow()
{
   var starCity=document.getElementById("ddlDepart");
   var endCTity=document.getElementById("ddlArrive");
   if(starCity.options[starCity.selectedIndex].value==-1)
   {
      alert("请选择出发城市！");
      return false;
   }
    if(endCTity.options[endCTity.selectedIndex].value==-1)
   {
      alert("请选择到达城市！");
      return false;
   }
   var stat = document.getElementById('ddlDepart');
    var starValue= base64encode(stat.options[stat.selectedIndex].value);
    var end = document.getElementById('ddlArrive');
   var endValue= base64encode(end.options[end.selectedIndex].value);
   var type = base64encode('0');
   window.open('../CurrentFlightInfo/list.aspx?StarCity='+starValue+'&EndCity='+endValue+'&Type='+type+'');
}

function openGuoJiWindow()
{
 var arrCity=document.getElementById("TxtDestCity0").value.replace(/(^\s*)|(\s*$)/g,"");
  if(arrCity=='拼音/英文/中文')
  {
      alert("请选择到达城市！");
      return false;
  }
    var stat = document.getElementById('DropDownListFromCity0');
    var starValue= base64encode(stat.options[stat.selectedIndex].value);
    var end = document.getElementById('ExtenderDestCity0').value;
    var endValue =base64encode(end);
    var type = base64encode('1');
   window.open('../CurrentFlightInfo/list.aspx?StarCity='+starValue+'&EndCity='+endValue+'&Type='+type+'');
}

function openAirNoWindow()
{
 var airNo= document.getElementById("txtNum").value.replace(/(^\s*)|(\s*$)/g,"");
   if(airNo.length==0)
   {
       alert("请填写航班号！");
       return false;
   }
   var airNo = document.getElementById('txtNum').value;
   airNo= base64encode(airNo);
   var type = base64encode('2');
   window.open('../CurrentFlightInfo/list.aspx?StarCity=&EndCity=&Type='+type+'&AirNo='+airNo+'');
}
