﻿// JScript 文件
$.fn.valueIsEmpty = function() {
    if ($(this).val().length < 1)
        return true;
}

$.fn.enable = function() {
    return $(this).attr('disabled', false);
}

$.fn.disable = function() {
    return $(this).attr('disabled', true);
}
$.toJson = function(str) {
    return eval('(' + str + ')');
}

function SetDefaultMenu(objID,className){   
    $(objID).attr("class",className); 
}

function HotelSearchSelected(objID)
{
    if(objID=="hsContent1")
    {
        $('#hotel').attr("src","images/hotel01.jpg");
        $('#tours').attr("src","images/tours02.jpg");
        $('#hsContent1').show();
        $('#hsContent2').hide();
    }
    else
    {
        $('#hotel').attr("src","images/hotel02.jpg");
        $('#tours').attr("src","images/tours01.jpg");
        $('#hsContent1').hide();
        $('#hsContent2').show();   
    }
}

function DoSearch(Type)
{
    if(Type=='Hotel')
    {   
        var City=$('#dropCity').val();
        var CheckInDate=$('#txtCheckInDate').val();
        var CheckOutDate=$('#txtCheckOutDate').val();
        var date1=new Date(CheckInDate.replace(/-/g,'/'));
        var date2=new Date(CheckOutDate.replace(/-/g,'/'));
        if(date1>=date2)
        {
            alert('Check-out date should be after Check-in date !');
            return false;
        } 
        var PriceRange=$('#dropPriceRange').val();
        var HotelName=$('#txtDesignatedHotel').val();
        location.href='HotelList.aspx?CityID='+City+'&d1='+CheckInDate+'&d2='+CheckOutDate+'&PriceRange='+PriceRange+'&HotelName='+HotelName;
    }
    else
    {
    
        var rad2=$('#r2');
        if(rad2.attr("checked"))
        {
            var Keywords=$('#txtTourName').val();
            if(Keywords=='')
            {
                alert('Please enter the tourist routes !');
                return false;
            }
            location.href='TourList.aspx?TourName='+Keywords;
        }
        else
        {   
            var PriceFrom=$('#txtPriceFrom').val();
            var PriceTo=$('#txtPriceTo').val();
            
            if(PriceFrom=='0')
            {
                location.href='TourList.aspx';
                return false;
            }   
            if(parseInt(PriceFrom,10)>parseInt(PriceTo,10))
            {
                alert('Price range void!');
                return false;
            }
            location.href='TourList.aspx?PriceFrom='+PriceFrom+'&PriceTo='+PriceTo;
        }
    }
}

function ShowLeftMenu(objID)
{
    $(".leftMenu h4").each(function(){
        $(this).click(function(){
            $(this).next().toggle();
        });
    });
}
function SetHotelPrice(){
    var a=[1,2,3];
    alert(a.length);
}
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=423;
var swf_height=250;
var files='upload/yinxiangxihu.JPG|upload/pic1.jpg|upload/pic3.jpg';
var links='/ticket.aspx|TourList.aspx|TourList.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 WriteTags()
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");             
    xmlDoc.async = false; //是否异步加载,可能会引起错误,所以设为false;
    xmlDoc.load("Tags.xml"); 
    var childNodes = xmlDoc.documentElement.childNodes;
    for(i=0;i<childNodes.length;i++)
    {
        document.write('<li><a href="TourList.aspx?TourName='+childNodes[i].attributes[0].value+'">'+childNodes[i].attributes[0].value+'</a></li>');
    }
}
function writeVideo(id) {
    if (id == 1) {  // 印象西湖
        document.writeln("<div class=\"scne_video\">");
        document.writeln("    <div class=\"scne_video_title\">Video:<\/div>");
        document.writeln("    <div class=\"scne_video_content\">");
        document.writeln("        <embed src=\"http:\/\/www.youtube.com\/v\/8zGGJ8XDJ-E?hl=en&fs=1\" type=\"application\/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"280\" height=\"180\"><\/embed>");
        document.writeln("    <\/div>");
        document.writeln("<\/div>");
    }
}
function ShowObj(objID)
{
    $("#"+objID).show();
}
function HiddenObj(objID)
{
    $("#"+objID).hide();
}
function GetPosition(obj) {
	var r = new Array();
	r['x'] = obj.attr("offsetLeft");
	r['y'] = obj.attr("offsetTop");
	return r;
}
function CheckChatToolState()
{
    window.status=" ";

    var html="Live Chat";
    $("#chatp").html(html);

    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").html($("#chat").html()+html);
}


