function CopyText(obj) {
	ie = (document.all)? true:false
	if (ie){
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
		alert('已成功复制到剪贴板！');
	}
}

function compareDate(DateOne,DateTwo,AllowEq)
{
   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 (AllowEq)
   {
		if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) > Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
		{
			return true;
		}
		else
		{
			return false;
		}      
   }
   else
   {
       	if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) >= Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
		{
			return true;
		}
		else
		{
			return false;
		}      
   }
   
}


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 AddToday(k)
{
       hh=new Date;
	   jj=new Date(hh.getYear(),hh.getMonth(),hh.getDate()+k)
	   y=jj.getFullYear();
	   m=jj.getMonth();
	   d=jj.getDate();
	   strdate=y+"-"+(m+1)+"-"+d;
	   return strdate;
}

//Old Func
function FormatNum(PriceType,Text)
{
	if (PriceType!="RMB")
	{
		return PriceType+""+Text;
	}
	else
	{
		return "￥"+Text;
	}

}
		
function ConfirmMsg(Msg){
    return(confirm(Msg));   
}

function btnClick()
{  
    if (event.keyCode==13)
    {   
	event.keyCode=9;
        event.returnValue = false;
	document.all.BtnSearch.click(); 
    }
}

function ShowHideFlight(Id,HideText,ShowText){
     
     RowId="R"+Id; 
     TxtId="T"+Id;
     LId  ="L"+Id;
     IId  ="I"+Id;
     if (document.all[RowId].style.display=="none")
     {
        document.all[RowId].style.display="";
        document.all[IId].src="../Images/niu4.gif";
        document.all[TxtId].innerText="只显示最低价";
        document.all[LId].style.display="none";
     }
     else
     {
          document.all[RowId].style.display="none";
          document.all[IId].src="../Images/niu3.gif";
          document.all[TxtId].innerText="显示所有舱位";
          document.all[LId].style.display="";
     }
} 
  
function ShowHide(Id,HideText,ShowText){
     
     RowId="R"+Id; 
     TxtId="T"+Id;
     if (document.all[RowId].style.display=="none")
     {
        document.all[RowId].style.display="";
        document.all[TxtId].innerText=HideText;
     }
     else
     {
          document.all[RowId].style.display="none";
          document.all[TxtId].innerText=ShowText;
     }
  }     

var Win
function OpenWin(Name,strUrl,width,height)
{
var str = "height=" + height + ",innerHeight=" + height;
str += ",width=" + width + ",innerWidth=" + width;
if (window.screen) {
var ah = screen.availHeight - 30;
var aw = screen.availWidth - 10;

var xc = (aw - width) / 2;
var yc = (ah - height) / 2;

str += ",left=" + xc + ",screenX=" + xc;
str += ",top=" + yc + ",screenY=" + yc;
}
  
   if (!Win || Win.closed)
   {
     Win=open(strUrl,Name,"resizable=0,scrollbars=1," + str);
   }else{
     Win.location.href=strUrl;
     Win.focus();
   }  
}

