﻿// JScript 文件

String.prototype.trim = function()
{
    // 用正则表达式将前后空格
    // 用空字符串替代。
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function $(objID)
{
    return document.getElementById(objID);
}

function changeTab(type)
{
    if(type==1)
    {
        $("cTab1").style.display='';
        $("cTab2").style.display='none';
        $("hTab1").style.backgroundColor='#ffffff';
        $("hTab1").style.color="#000000";        
        $("hTab2").style.backgroundColor='#C5151F';
        $("hTab2").style.color='#ffffff';
        window.parent.document.getElementById("ifSearch").height='181px';
    }
    else
    {
        $("cTab1").style.display='none';
        $("cTab2").style.display='';
        $("hTab1").style.backgroundColor='#C5151F';
        $("hTab1").style.color="#ffffff";
        $("hTab2").style.backgroundColor='#ffffff';
        $("hTab2").style.color="#000000";
        window.parent.document.getElementById("ifSearch").height='261px';
    }
}
function searchTour()
{
    var keywords=$('txtTourKey').value;

    var length=$('dropDays').options[$('dropDays').selectedIndex].value;
    var budget=$('dropBudget').options[$('dropBudget').selectedIndex].value;
    window.parent.location.href='TourList.aspx?act=search&length='+length+'&budget='+budget+'&keywords='+keywords;
    
}
function searchHotel()
{
    var CheckInDate=$("txtCheckInDate").value;
    var CheckOutDate=$("txtCheckOutDate").value;
    var Star=$("dropStar").options[$("dropStar").selectedIndex].value;
    var Location=$("dropArea").options[$("dropArea").selectedIndex].value;
    var Price=$("dropPrice").options[$("dropPrice").selectedIndex].value;
    var Keywords=$('txtHotelKey').value;
    window.parent.location.href='HotelList.aspx?act=search&Location='+Location+'&Star='+Star+'&Price='+Price+'&CheckInDate='+CheckInDate+'&CheckOutDate='+CheckOutDate+'&Keywords='+Keywords;
}
function ShowMenu(objID)
{
    var obj=$(objID);
    if(obj.style.display=="none")
    {
        obj.style.display="";
    }
    else
    {
        obj.style.display="none";
    }
}

function CheckNull(obj,msg)
{
    if(obj.value=="")
    {
        alert(msg);
        return false;
    }
    return true;
}
function SelectRd(obj)
{
    if(obj.type=="radio")
    {
        obj.checked=true;
    }
    else if(obj.type=="text")
    {
        obj.focus();
    }
}

function   GetCookie(sName)   
{   
  var   aCookie   =   document.cookie.split("; ");   
  for   (var   i=0;   i   <   aCookie.length;   i++)   
  {   
      var   aCrumb   =   aCookie[i].split("=");   
      if   (sName   ==   aCrumb[0])   
          return   unescape(aCrumb[1]);
  }   
   return  null;  
}   
  
function CheckVerify(code)
{
    if(code==GetCookie("Code"))
       return true;
    else
       return false; 
}
function WriteFlashPic(obj)
{
var swf_width=424;
var swf_height=186;
var files='upload/shibohui.jpg|upload/watertown.JPG|upload/zaji.gif|upload/sh.jpg';
var links='Tour-190.aspx|Tours-24.aspx|Acrobatics.aspx|Tours-17.aspx';
var texts='|||';

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="focus.swf"><param name="quality" value="high">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
document.write('<embed src="focus.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
document.write('</object>');          

}
function ShowObj(objID)
{
    $(objID).style.display="";
}
function HiddenObj(objID)
{
    $(objID).style.display="none";
}
function GetPosition(obj) {
	var r = new Array();
	r['x'] = obj.offsetLeft;
	r['y'] = obj.offsetTop;
	while(obj = obj.offsetParent) {
		r['x'] += obj.offsetLeft;
		r['y'] += obj.offsetTop;
	}
	return r;
}
function CheckChatToolState()
{    
    window.status=" ";

//    var html="<h4>Live Expert Help</h4>";
//    $("chatp").innerHTML=html;
   $("chatp").innerHTML="Live Chat";
   var html="<table width='100%' cellpadding='0' cellspacing='7' border='0' align='center'><tr>";
    html+='<td><a href="http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=de46ef6f787773b5@apps.messenger.live.com" target="_blank"><img src="http://messenger.services.live.com/users/de46ef6f787773b5@apps.messenger.live.com/presenceimage?mkt=zh-cn"/>Chat with Marissa</a></td>';
    html+='<td><a href="http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=3d0f53e1cd8f7ff9@apps.messenger.live.com" target="_blank"><img src="http://messenger.services.live.com/users/3d0f53e1cd8f7ff9@apps.messenger.live.com/presenceimage?mkt=zh-cn"/>Chat with Sally</a></td>';
    //html+='<td><a href="ymsgr:sendim?yanmarissa0623"><img src="http://opium3.msg.vip.mud.yahoo.com/online?u=yanmarissa0623&t=0&l=cn"/> YM chat</a></td>';
    html+="</tr></table>";
    $("chat").innerHTML +=html;
}
function ShowMaxPic(obj,url)
{   
    var pp=GetPosition(obj);
    $('maxPic').style.display='';    
    $('maxPic').style.top=pp['y']+'px';
    $('maxPic').style.left=pp['x']+111+'px';
    $('maxPic').innerHTML='<img src="images/car/'+url+'" class="pic"  onclick="HiddenObj(\'maxPic\')" style="cursor:pointer;" title="click me to hidden this image !"/>';
}
function getServerTime()
{
    Ajax.GetServerTime(function(res)
    {
        $('time').innerHTML=res.value;
    })
    setTimeout('getServerTime()',60000);
}
function setSearch()
{
    $("search").innerHTML="<iframe id='ifSearch' src='Search.aspx' width='100%' height='181px' scrolling='no' frameborder='0'></iframe>";
}
