﻿
//更正PNG不透明的问题
function correctPNG() 
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

//根据浏览器加载CSS文件
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
{
	document.write('<link rel=stylesheet type="text/css" href="/css/ie.css" />');
	window.attachEvent("onload", correctPNG);
}else{
		document.write('<link rel=stylesheet type="text/css" href="/css/ff.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("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
                       }
                       var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                       prefs.setCharPref('browser.startup.homepage',vrl);
                }
       }
}

//登陆表单验证
function loginCheck()
{
	if(document.getElementById('userid').value=='' || document.getElementById('userid').value.length<=3)
	{
		alert('提示：请输入您的会员账号。');
		document.getElementById('userid').focus();
		return false;
	}
	if(document.getElementById('userpass').value=='' || document.getElementById('userpass').value.length<=3)
	{
		alert('提示：请输入您的会员卡密码。');
		document.getElementById('userpass').focus();
		return false;
	}
	loginFrm.submit();
}

//预订表单检查
function bookCheck()
{
	if(document.getElementById('province').value=='')
	{
		alert('提示：请选择地区。');
		document.getElementById('province').focus();
		return false;
	}
	if(document.getElementById('city').value=='')
	{
		alert('提示：请选择城市。');
		document.getElementById('city').focus();
		return false;
	}
	if(document.getElementById('hotel').value=='')
	{
		alert('提示：请选择您想入住的酒店。');
		document.getElementById('hotel').focus();
		return false;
	}
	if(document.getElementById('checkinDate').value=='')
	{
		alert('提示：请输入您想入住的日期。');
		document.getElementById('checkinDate').focus();
		return false;
	}
	if(document.getElementById('leaveDate').value=='')
	{
		alert('提示：请输入您计划离开酒店的日期。');
		document.getElementById('leaveDate').focus();
		return false;
	}
	bookFrm.submit();
}

function showTab(obj)
{
	if(obj=='tabNews')
	{
		document.getElementById('tabNews').className="NewsTab_on";
		document.getElementById('blockNews').style.display="";
		document.getElementById('tabReport').className="NewsTab";
		document.getElementById('blockReport').style.display="none";
	}else{
		document.getElementById('tabReport').className="NewsTab_on";
		document.getElementById('blockReport').style.display="";
		document.getElementById('tabNews').className="NewsTab";
		document.getElementById('blockNews').style.display="none";
	}
}

//通用函数
function $(id)
{
    return document.getElementById(id);
}

//显示人才招聘信息
function ShowRecruit(id)
{
    if($(id).style.display=="none")
    {
        $(id).style.display="block";
    }
    else
    {
        $(id).style.display="none"
    }   
}

//城市资讯
function ShowInformation(id,obj)
{
    $("city").style.display="none"; 
    $("display").style.display="none"; 
    $("airplane").style.display="none"; 
    $("car").style.display="none"; 
    $("train").style.display="none";
    $("weather").style.display="none";
    $(id).style.display="";  
    
    $("cityHead").className="ttd";
    $("displayHead").className="ttd";
    $("airplaneHead").className="ttd"; 
    $("carHead").className="ttd";
    $("trainHead").className="ttd";
    $("trainHead").className="ttd";
    $("weatherHead").className="ttd";
    obj.className="ttd_on";
}

//显示服务信息
function ShowService(id,obj)
{
    $("periphery").style.display="none"; 
    $("shopRepas").style.display="none"; 
    $("shopService").style.display="none"; 
    $("roomService").style.display="none"; 
    $("driveRoute").style.display="none"; 
    $("creditCard").style.display="none"; 
    $("information").style.display="none"; 
    $(id).style.display="";  
    
    $("peripheryHead").className="chainlocate_button";
    $("shopRepasHead").className="chainlocate_button";
    $("shopServiceHead").className="chainlocate_button";
    $("roomServiceHead").className="chainlocate_button"; 
    $("driveRouteHead").className="chainlocate_button";
    $("creditCardHead").className="chainlocate_button";
    $("informationHead").className="chainlocate_button";
    obj.className="chainlocate_button_on";
}

//周边信息
function ShowPeriphery(id,obj)
{
    $("traffic").style.display="none"; 
    $("journey").style.display="none"; 
    $("repast").style.display="none"; 
    $("shopping").style.display="none"; 
    $("pastime").style.display="none";
    $("hospital").style.display="none";
    $("bank").style.display="none";
    $("postoffice").style.display="none";
    $("other").style.display="none";
    $(id).style.display="";  
    
    $("trafficHead").className="ttd";
    $("journeyHead").className="ttd";
    $("repastHead").className="ttd"; 
    $("shoppingHead").className="ttd";
    $("pastimeHead").className="ttd";
    $("hospitalHead").className="ttd";
    $("bankHead").className="ttd";
    $("postofficeHead").className="ttd";
    $("otherHead").className="ttd";
    obj.className="ttd_on";
}
//新开酒店、筹备酒店、优惠与促销
function showHomeTab(id)
{
    if(id=="promotion_head")
    {
        $("shop_head").className="shop_head_off";
        $("prepare_head").className="shop_head_off";
        $("shop").style.display="none";
        $("prepare").style.display="none";
    }
    else if(id=="shop_head")
    {
        $("shop_head").className="shop_head_on";
        $("prepare_head").className="shop_head_off";
        $("shop").style.display="";
        $("prepare").style.display="none";
    }
    else if(id=="prepare_head")
    {
        $("shop_head").className="shop_head_off";
        $("prepare_head").className="shop_head_on";
        $("shop").style.display="none";
        $("prepare").style.display="";
    }
}
