﻿$(function($){
    var len  = $(".list > li").length;
    var index = 0;
    var adTimer;
    $(".list li").mouseover(function(){index = $(".list li").index(this);showImg(index);}).eq(0).mouseover();
    $(".pic").hover(function(){clearInterval(adTimer);},function(){adTimer = setInterval(function(){showImg(index); index++; if(index == len){index = 0;}},5000);}).trigger("mouseleave");
})
function showImg(index){
    //var picHeight = $(".pic").height();
    //$(".slideup").stop(true,false).animate({top : -picHeight*index},500);
	$(".slideup li").hide().eq(index).delay().fadeIn(800);
    $(".list li").removeClass("on").eq(index).addClass("on");
    $("#tit").html($(".slideup img").eq(index).attr("alt"));
}
$(function($){
    $("#tbag li").eq(0).mouseover(function(){
        $(this).css({"background":"url(images/site/ser_hotel.jpg) no-repeat"});
        $("#tbag li").eq(1).css({"background":"url(images/site/bigbag.jpg) no-repeat 1px 0"});
        $("#ser_show").show();
        $("#bigbag_show").hide();
    })
    $("#tbag li").eq(1).mouseover(function(){
        $("#tbag li").eq(0).css({"background":"url(images/site/ser_hotel01.jpg) no-repeat"});
        $("#tbag li").eq(1).css({"background":"url(images/site/bigbag01.jpg) no-repeat 1px 0"});
        $("#ser_show").hide();
        $("#bigbag_show").show();
    })
})
function show_hide(){
    if(document.getElementById('city-flyout').style.display == 'block'){
        document.getElementById('city-flyout').style.display = 'none';
    }else if(document.getElementById('city-flyout').style.display == 'none'){
        document.getElementById('city-flyout').style.display = 'block';
    }
}
/*
function AddFavorite(){
    if(document.all){
        window.external.addFavorite(document.URL,document.title);  //IE内核浏览器
    }else if(window.sidebar){
        window.sidebar.addPanel(document.title,document.URL,'');  //非IE内核浏览器
    }
}
*/
function AddFavorite() {
    sURL = document.URL;
    sTitle = document.title;
    try { //IE
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {
        try { //Firefox
            window.sidebar.addPanel(sTitle, sURL, "");
        } catch (e) {
            //try{//Chrome无法自动收藏，用创建快应用程序的捷方式来替代。
            //    createShortcut();
            //} catch(e){
                alert("您的浏览器不支持自动加入收藏，请使用浏览器菜单手动设置.");   
            //}
        }
    }
}
function createShortcut() {
    var desktop = google.gears.factory.create("beta.desktop");
    var description = "将喜事网连接添加到桌面";
    var name = "Online Radio";
    var icons = {
        "16x16": "images/icon16.png",
        "32x32": "images/icon32.png",
        "48x48": "images/icon48.png",
        "128x128": "images/icon128.png"
    };
    desktop.createShortcut(name,  // 应用名称，貌似不支持中文
                           "hello_world_shortcuts.html",  // url需考虑跨域问题
                           icons,  // icons (至少一个尺寸)
                           description);  // 应用描述 (可选)
}
function rd(a, path){
    if(!a || !path || a.href.indexOf("rd.xishiwang.com") > 0 ) {
        return false;
    }
    path = path.replace(/(^[\s]*)|([\s]*$)/g, "");
    path = path.replace(/^[\/]*/, "/");
    path = path.replace(/[\/]*$/, "/");
    a.href = a.href.replace(/(^[\s]*)|([\s]*$)/g, "");
    a.href = a.href.replace(/^http:\/\/rd\.marry10\.com\/.*\*/, "");
    a.href = "http://rd.xishiwang.com" + path + "*" + a.href;
    return false;
}

