﻿/*清除错误*/
function killErrors(){
    return true;
}
window.onerror = killErrors;
/*============
//加载样式css 开始
==============*/
$(function(){
        var NameLi=$(".nav_sec > ul > li:eq(0)");
        var NameLong=NameLi.find("a").text().length	
        if(NameLong<=5)
        {
            if(NameLi.attr("class")=="on")
                NameLi.attr("class","homepage_1_on");
            else
                NameLi.attr("class","homepage_1_off")
        }
        else if(NameLong<=7)
        {
            if(NameLi.attr("class")=="on")
                NameLi.attr("class","homepage_2_on");
            else
                NameLi.attr("class","homepage_2_off")
        }
        else
        {
            if(NameLi.attr("class")=="on")
                NameLi.attr("class","homepage_3_on");
            else
                NameLi.attr("class","homepage_3_off")
        }
});
function ConentListCss(EventID)
{
    var obj= $(".lists > div:eq(1)");
    if(EventID=="440")
        obj.addClass("t_pices").removeClass("t_information");
    else if(EventID=="442")
        obj.addClass("t_guidelines").removeClass("t_information");
    else if(EventID=="439")
        obj.addClass("t_gonglve").removeClass("t_information");
    else if(EventID=="438")
        obj.addClass("t_notes").removeClass("t_information"); 
}
/*============
//加载样式css 结束
==============*/

/*添加到收藏*/
function AddFavorite(sURL, sTitle)
{
    try
    {
         window.external.addFavorite(sURL, sTitle);
     }
    catch (e)
    {
        try
        {
             window.sidebar.addPanel(sTitle, sURL, "");
         }
        catch (e)
        {
             alert("加入收藏失败，请使用Ctrl+D进行添加");
         }
     }
}
/*设成成首页*/
function SetHome(obj,vrl){
        try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl); }
        catch(e){
                if(window.netscape) {
                        try {
                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                         }
                        catch (e) {
                                 alert("此操作被浏览器拒绝！");
                         }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                  }
         }
}
/*标签切换函数*/
function ChangeTab(IDPre,CssPre,num,select)
{
    if(document.getElementById(IDPre+"_"+select).className==CssPre+"_on")
        return;
	for(var i=1;i<=num;i++)
	{
	    if(i==select)
	    {
	    	document.getElementById(IDPre+"_"+i).className=CssPre+"_on";
	        document.getElementById(IDPre+"_"+i+i).style.display="block";
	    }
	    else
	    {
		    document.getElementById(IDPre+"_"+i).className=CssPre+"_off";
		    document.getElementById(IDPre+"_"+i+i).style.display="none";
		}
	}
}
/*分析价格字段串 460|0|20|f*/
function SplitPrice(prices,index)
{
    var s=prices.split("|");
    if(s.length==4){return s[index]+"元/人";}else{return "";}
}
/*回车搜索*/
function SearchLinesOnkeyDown(type,e)
{
    var key = window.event ? e.keyCode:e.which;
    if(key==13)
    {
        SearchLines(type);
        return false;
    }
    return true;
}
/*===================
线路查询 type=1：高级搜索
====================*/
function SearchLines(type)
{
    var st=document.getElementById("LineKeyWord").value;    
    st=st.trim();
    if((st=="")||(st=="请输入目的地或景点"))
    {
        st="关键字不限制";
    }    
    var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\][\]\{\}:;'\,.<>?]{0,19}$/; 
    if (!patrn.exec(st) && (st!=""))
    {
      alert("关键字包含非法字符");
      return;
    }    
    var pageUrl="/lineSearch/";
    patrn=/^\d+$/; 
    if(patrn.exec(st))//根据ID直接查询
    {
        pageUrl="/line/"+st+".aspx";
    }
    else
    {
        var ChuJingGuoNei="0_0",LineIsTour="0",JourneyDays="0-0",LinePrice="0-0";
        if(type==1)
        {
            ChuJingGuoNei=document.getElementById("ChuJingGuoNei");
            if(ChuJingGuoNei.value=="1")
                ChuJingGuoNei="1_0";
            else
                ChuJingGuoNei="0_1";
                        
            LineIsTour=document.getElementById("LineIsTour");
            LineIsTour=LineIsTour.value;

            JourneyDays=document.getElementById("JourneyDays");
            JourneyDays=JourneyDays.value;
        }
        

        LinePrice=document.getElementById("LinePrice");
        LinePrice=LinePrice.value;
            
        pageUrl=pageUrl+encodeURIComponent(st)+"_"+ChuJingGuoNei+"_"+LineIsTour+"_"+JourneyDays+"_"+LinePrice+"_1.aspx"
     }
    this.location=pageUrl;
}
/*===================
提交咨询
===================*/
var s___c
function SaveConsult()
{
    var patrn=/<[a-zA-Z][a-zA-Z0-9]*>/; 
    var GuestName=$("#consult input[name='GuestName']")
    if(GuestName.val()=="")
    {
        alert("请输入姓名。");
        GuestName.focus();
        return;
    }  
    if (patrn.exec(GuestName.val()) && (GuestName.val()!=""))
    {
        alert("姓名包含非法字符。");
        GuestName.focus();
        return;
    }
    var Content=$("#consult textarea[name='Content']")
    if(Content.val()=="")
    {
        alert("请输入咨询内容。");
        Content.focus();
        return;
    }
    if (patrn.exec(Content.val()) && (Content.val()!=""))
    {
        alert("咨询内容包含非法字符。");
        Content.focus();
        return;
    } 
    
    
    var c=$("#consult").serialize();
    if(c==s___c)
    {
        alert("请不要重复咨询");
        return;
    }
    $.post("/Consult/Save.ashx",c,function(data){alert(data);});
    s___c=c;
}
/*取得TAG对应的URL*/
function GetTagGoUrl(id)
{
    $.get("/JavaScript/TagGoUrl.ashx?LineTagID="+id,
     function(data){data=data.toString();if(data!=""){window.location=data;}}
    );
}
//div显示或隐藏菜单
var delayShowFlag_t;
function Div_DisplayMenu(objName,val)
{ 
    var n=0;   
    if(val=="none")
    {
        n=500;
    }
    else
    {
        clearTimeout(delayShowFlag_t); 
        n=0;
    }
    delayShowFlag_t=setTimeout(
         function()
         {
            var list= document.getElementById(objName); list.style.display=val;            
         }
     ,n);
}

//div显示或隐藏菜单
function Div_DisplayNoDelay(objName,val)
{ 
   var list= document.getElementById(objName);
   list.style.display=val; 
}

String.prototype.trim= function(){  
    // 用正则表达式将前后空格  
    // 用空字符串替代。  
    return this.replace(/(^\s*)|(\s*$)/g, "");  
}
/*===================
flash输出图片
====================*/
function FlashPics(swf_width,swf_height,pics,links,texts)
{
	//var swf_width=520;
	//var swf_height=179;
	var config='5|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';
	//-- config 参数设置 -- 自动播放时间(秒)|文字颜色|文字背景色|文字背景透明度|按键数字颜色|当前按键颜色|普通按键色彩 --
	//var pics='/UpFiles/banner/banner4.jpg|/UpFiles/banner/banner1.jpg';
	//var links='';
	//var texts='';
	var outputstr='<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 +'">';
	outputstr=outputstr+'<param name="movie" value="/App_Themes/swf/focus.swf" />';
	outputstr=outputstr+'<param name="quality" value="high" />';
	outputstr=outputstr+'<param name="menu" value="false" />';
	outputstr=outputstr+'<param name=wmode value="opaque" />';
	outputstr=outputstr+'<param name="FlashVars" value="config='+config+'&bcastr_flie='+pics+'&bcastr_link='+links+'&bcastr_title='+texts+'" />';
	outputstr=outputstr+'<embed src="/App_Themes/swf/focus.swf" wmode="opaque" FlashVars="config='+config+'&bcastr_flie='+pics+'&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" />';
	outputstr=outputstr+'</object>';
	document.write(outputstr);
}

