﻿/*加载延迟 start-----*/
addDOMLoadEvent = (function() {
    var load_events = [],
    load_timer,
    script,
    done,
    exec,
    old_onload,
    init = function() {
        done = true;
        clearInterval(load_timer);
        while (exec = load_events.shift())
        exec();
        if (script) script.onreadystatechange = '';
    };

    return function(func) {
        if (done) return func();
        if (!load_events[0]) {
            if (document.addEventListener)
            document.addEventListener("DOMContentLoaded", init, false);
            /*for Safari*/
            if (/WebKit/i.test(navigator.userAgent)) {
                load_timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState))
                    init();
                },
                10);
            }
            old_onload = window.onload;
            window.onload = function() {
                init();
                if (old_onload) old_onload();
            };
        }
        load_events.push(func);
    }
})();
/*加载延迟 end-----*/

/*获取文字资源*/
function GetWords(i){
    var zh_cn ='官方新闻|会员信息|请输入登录信息！|登录名或密码错误！|会员已锁定！|'/*0-4*/
        +'会员已过期！|个人中心|密码修改|我的购物车|首页|'/*5-9*/
        +'上一页|下一页|尾页|点击显示右边|点击显示左边|'/*10-14*/
        +'您的账号即将过期，请于 | 前办理续约！「台湾城乡发展股份有限公司」感谢您的使用！|';/*15-*/
    var zh_tw = '官方新聞|會員訊息|請輸入登入訊息！|登入名或密碼錯誤！|會員已鎖定！|'
        +'會員已過期！|個人中心|密碼修改|我的購物車|首頁|'
        +'上一頁|下一頁|尾頁|點擊顯示右邊|點擊顯示左邊|'
        +'您的帳號即將過期，請於 | 前辦理續約！「台灣城鄉發展股份有限公司」感謝您的使用！|';

    var strList=zh_tw.split('|');
    if(strList.length>i){
        return strList[i];
    }
}

/*根路径*/
var baseUrl = getRootPath() + '/';
var siteAccessPath = 'http://ume.com.tw/';
if(baseUrl=='http://www.ume.com.tw/')
    siteAccessPath = 'http://ume.com.tw/';
var netShopPath = 'http://umego.tw/';

var zoomi=1;
/***
* 成员共用js
**/
function common() {
    /*当前用户名*/
    var userName = document.getElementById('txtHomePageUserName');
    if (userName == null) userName = document.getElementById('txtUserName');

    /*加载内容*/
    this.IndexInit = function() {
        this.InitUserLoginBox();
        this.InitImagePage();
        this.NewsDetail();
        /*判断是否是首页*/
        var isFrist = document.getElementById('isFrist');
        /*旧版本*/        if (isFrist == null) isFrist = document.getElementById('txtIsHomePage');
        /*新版本*/        if (isFrist != null && userName != null && isFrist.value == '1') {
            if (baseUrl != null) {
                this.SystemNews();
                this.SystemProduct();
                this.SystemAD();
                this.LoadUserAd();
            }
        }
        /*iframe*/
        $('.STATICSITEINFO').each(function() {
            $(this).attr("allowtransparency", "true")
            $(this).contents().find('body').css({
                'background-color': 'transparent',
                'color': '#333333'
            });
        });
    }

    /*系统新闻*/
    this.SystemNews = function() {        
        var newsLayer = document.getElementById('newsLayer');

        if (newsLayer != null) {
            var fnews = document.createElement("script");
            fnews.src = siteAccessPath + "SysUserModule.aspx?divName=newsLayer&operate=news&userName=" + userName.value + "&random=" + Math.random();;
            newsLayer.appendChild(fnews);
            return;
          $.ajax({
                type: 'post',
                url: siteAccessPath + 'SysUserModule.aspx?operate=news&userName=' + userName.value,
                success: function(msg) {
                    if (msg.length > 0) {

                        newsLayer.innerHTML = "<strong style=\"font-size: 14px;\"><u>"+GetWords(0)+"</u></strong>";
                        newsLayer.innerHTML = newsLayer.innerHTML + msg;
                    }
                }
            });
          
        }
          
    }

    /*系统产品*/
    this.SystemProduct = function() {
        var productLayer = document.getElementById('productLayer');
        if (productLayer != null) {
            var fpro = document.createElement("script");
            fpro.src = siteAccessPath + "SysUserModule.aspx?divName=productLayer&operate=product&userName=" + userName.value + "&random=" + Math.random();
            productLayer.appendChild(fpro);
            return;

            $.ajax({
                type: 'post',
                url: siteAccessPath + 'SysUserModule.aspx?operate=product&userName=' + userName.value,
                success: function(msg) {
                    productLayer.innerHTML = msg;
                }
            });
        }
    }

    /*系统广告*/
    this.SystemAD = function() {
        var adLayer = document.getElementById('adLayer');
        if (adLayer != null) {
            var fad = document.createElement("script");
            fad.src = siteAccessPath + "SysUserModule.aspx?divName=adLayer&operate=ad&userName=" + userName.value + "&random=" + Math.random();
            adLayer.appendChild(fad);
            return;

            $.ajax({
                type: 'post',
                url: siteAccessPath + 'SysUserModule.aspx?operate=ad&userName=' + userName.value,
                success: function(msg) {
                    adLayer.innerHTML = msg;
                    if (document.getElementById('txtMarqueePars') != null) {
                        var pars = $('#txtMarqueePars').val().split('|');
                        /*参数*/
                        if (pars.length > 4) {
                            var marqueeSys = new Marquee(pars[0], pars[1], pars[2], pars[3], pars[4]);
                            marqueeSys.Start();
                        }
                    }
                },
                error: function(msg) {
                    alert(msg);
                }
            });
        }
    }

    /*随机图片*/
    this.ImageRandom = function() {
  $('.RandomClass').each(function(){        
        var number=parseInt($(this).find('.IRNumberClass').eq(0).val());/*滚动图片数*/        var width=$(this).find('.IRWidthClass').eq(0).val();/*宽*/        var height=$(this).find('.IRHeightClass').eq(0).val();/*高*/        var imgs=$(this).find('.IRImgsClass').eq(0).val().split('|');/*图片列表*/
var imgList="";
       if(imgs.length>0){
       for(var i=0;i<imgs.length;i++)
       {

          var src=imgs[i];
          if(src.split(';').length>1){
            imgList+="<a href=\""+src.split(';')[1]+"\" target=\"_blank\"><img src=\""+src.split(';')[0]+"\" width=\""+width+"px\"  height=\""+height+"px\" style=\"margin-top:5px\" border=\"0\" class=\"Resizable\"/></a>" 
          }else{
            imgList+="<img src=\""+src+"\" width=\""+width+"\"  height=\""+height+"\" style=\"margin-top:5px\" border=\"0\" class=\"Resizable\"/>" 
          }
       }
       $(this).append(imgList);
       ImageRandomReset(document.getElementById($(this).find('.IRWidthClass').attr("Id")));
       }

    });

    }

    /*新闻详细页面，隐藏左边部分*/
    this.NewsDetail = function() {
        if (window.location.href.indexOf('Detail.htm') != -1) {
            $('#LEFT_Td').css('display', 'none');
        }
    }

    /*初始化用户登入框*/
    this.InitUserLoginBox = function() {
        if ($('.LoginBox').size() > 0) {
            var login = document.createElement("script");
            login.src = netShopPath + 'Operate.aspx?operate=LoginState' + "&random=" + Math.random();
            $('.LoginBox .content').append(login);
            return;
            /*查看商场登录状态*/
            $.ajax({
                type: 'post',
                url: netShopPath + 'Operate.aspx?operate=LoginState',
                success: function(msg) {
                    if (msg.length > 0) {
                        $('.LoginBox span').html(GetWords(1));
                        $('.LoginBox .content').html('<a href=\"' + netShopPath + 'User/UserInfo.aspx' + '\">'+GetWords(6)+'</a><a href=\"' + netShopPath + 'User/ModifyPassword.aspx' + '\">'+GetWords(7)+'</a><a href=\"' + netShopPath + 'User/ShoppingCart.aspx' + '\">'+GetWords(8)+'</a>');
                    }
                }
            });
        }
    }

    /*初始化图片分页*/
    this.InitImagePage = function() {        
        $('input[id^=txtImgPage]').each(function() {
            var curPage = $(this).parent().find('#curPage').val();
            /*当前页*/            if (curPage == undefined) {
                $('<input type=\"hidden\" value=\"1\" id=\"curPage\" />').appendTo($(this).parent());
                curPage = $('#curPage').val();
            }            
            if(!isNaN(curPage)){
                curPage = parseInt(curPage);
                ImagePage(curPage, $(this));
            }
        });
    }

    /*用户广告*/
    this.LoadUserAd = function() {
        $.ajax({
            type: 'post',
            url: siteAccessPath + 'Operate.aspx?operate=getAd&userName=' + userName.value,
            success: function(msg) {
                $('form').eq(0).append(msg);
            }
        });
    }   
}
/*-----------------*/

/*获得0到maxValue的随机数*/
function GetRandom(maxValue) {
    return parseInt(Math.random() * (maxValue + 1));
}

/*站点搜索*/
function userSearch() {
    var keys = document.getElementById('txtKeys');
    if (keys != null) {
        window.open(siteAccessPath + 'SearchResult.aspx?key=' + escape(keys.value));
    } else {
        window.open(siteAccessPath + 'SearchResult.aspx');
    }
}

/*获得网站跟路径*/
function getRootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(0).indexOf('/'));
    return (prePath + postPath);
}

/*Google搜索*/
function SearchGoogle(mid)
 {
    var key = document.getElementById('txtGkeys_' + mid);
    if (key != null) {
        window.open(siteAccessPath + 'GoogleSearch.aspx?search=' + encodeURIComponent(key.value));
    }

}

/*Google搜索*/
function SearchG()
 {
    $('input[id^=txtGkeys]').each(function() {
        $(this).keydown(function(event) {
            if (event.keyCode == 13) {
                if ($(this).attr('id').split('_').length > 1) {
                    SearchGoogle($(this).attr('id').split('_')[1]);
                }
            }
        });
    });

}

/*站内搜索*/
function SiteSearch() {
    $('input[id^=txtKeys]').each(function() {
        $(this).keydown(function(event) {
            if (event.keyCode == 13) {
                userSearch();
            }
        });
    });
}

/*清除页面action 及viewstate*/
function clearAction() {
    $('#form1').attr('action', '');
    $('#form1').attr('method', '');
    $('#form1').submit(function() {
        return false;
    });
    $('#__VIEWSTATE').remove();
    $('<input type=\"text\" name=\"notAutoSubmit\" style=\"display:none\"/>').appendTo($('form').eq(0));

}

/*图片随机设置*/
function ImageRandomReset(obj)
{
    var imgArray = new Array();
    var number = parseInt($(obj).parent().find('.IRNumberClass').eq(0).val())
    var imgLength = $(obj).parent().find('img').length
    for (var i = 0; i < imgLength; i++)
    {
        imgArray[i] = i;
    }
    var imgShow = getArrayItems(imgArray, number);
    $(obj).parent().find('img').parent().hide();
    $(obj).parent().find('img').parent('a').parent().hide();

    for (var j = 0; j < imgShow.length; j++)
    {
        $(obj).parent().find('img').eq(imgShow[j]).parent().show();
        $(obj).parent().find('img').eq(imgShow[j]).parent('a').parent().show();
    }
}

/*从一个给定的数组arr中,随机返回num个不重复项*/
function getArrayItems(arr, num) {
    /*新建一个数组,将传入的数组复制过来,用于运算,而不要直接操作传入的数组;*/
    var temp_array = new Array();
    temp_array = arr;
    /*取出的数值项,保存在此数组*/
    var return_array = new Array();
    for (var i = 0; i < num; i++) {
        /*判断如果数组还有可以取出的元素,以防下标越界*/
        if (temp_array.length > 0) {
            /*在数组中产生一个随机索引*/
            var arrIndex = Math.floor(Math.random() * temp_array.length);
            /*将此随机索引的对应的数组元素值复制出来*/
            return_array[i] = temp_array[arrIndex];
            /*然后删掉此索引的数组元素,这时候temp_array变为新的数组*/
            temp_array.splice(arrIndex, 1);
        } else {
            /*数组中数据项取完后,退出循环,比如数组本来只有10项,但要求取出20项.*/
            break;
        }
    }
    return return_array;
}

/*用户登录（需要与商场结合）*/
function UserLogin() {
    /*在商场Cookie中存入登录信息*/    if ($('.LoginBox #txtUserName').val().length == 0 || $('.LoginBox #txtPassword').val().length == 0) {
        alert(GetWords(2));
        return;
    }
    var data = 'name=' + $('.LoginBox #txtUserName').val() + '&pass=' + $('.LoginBox #txtPassword').val();
    var url = netShopPath + 'Operate.aspx?operate=login&' + data + "&random=" + Math.random();;
    var login = document.createElement("script");
    login.src = url;
    $('.LoginBox .content').append(login);
    return;
    var url= siteAccessPath+'UserLogin.aspx';
    $.ajax({
        type: 'post',
        url: url,
        data: data,
        success: function(msg) {
            var msgs=msg.split('|');
            if (msg.length > 0) {
                if (msgs[0] == '-1') {
                    alert(GetWords(3));
                } else if (msgs[0] == '-2') {
                    alert(GetWords(4));
                } else if (msgs[0] == '-3') {
                    alert(GetWords(5));
                } else if (msgs[0] == '1') {
                    $('.LoginBox span').html(GetWords(1));
                    $('.LoginBox .content').html('<a href=\"' + netShopPath + 'User/UserInfo.aspx' + '\">個人中心</a><a href=\"' + netShopPath + 'User/ModifyPassword.aspx' + '\">'+GetWords(7)+'</a><a href=\"' + netShopPath + 'User/ShoppingCart.aspx' + '\">'+GetWords(8)+'</a>');
                }
            }
        }
    });
}
/*用户注册（需要与商场结合）*/
function UserRegister() {
/*传入商场的注册页面*//*注册完成时需跳转到当前页面*/var userName = '';
    var url = window.location.href.split('/');
    if (url.length > 2) {
        userName = url[url.length - 2];
    }
    window.location.href = netShopPath + 'UserRegister.aspx?name=' + userName + '&source=' + window.location.href;

}

/*图片分页*/
function ImagePage(curPage,obj){

    if($(obj).parent('.pager').html()!=null){
        obj=$(obj).parent('.pager');
    }        
    var pageSize=$(obj).parent().find('input[id^=txtImgPage]').val().split('|')[0];
    var count=$(obj).parent().parent().find('.imgListDiv').length;
    
    /*隐藏所有图片*/    $(obj).parent().parent().find('.imgListDiv').css('display','none');
    
    /*总页数*/    pageSize=parseInt(pageSize);
    var pageCount = Math.ceil(count/pageSize);

    if(curPage<=0)curPage=1;
    if(curPage>pageCount)curPage=pageCount;
    /*开始结束编号*/    var start = (curPage-1)*pageSize;
    var end = start+pageSize-1;


    $(obj).parent().parent().find('.imgListDiv').each(function(i){
        if(i>=start && i<=end){
            $(this).css('display','block');
/*            $(this).parent().css('display','block');*/
        }
    });
    if(pageCount>1){
    $(obj).parent().find('.pager').html("");
    var sFirst="<a href=\"javascript:void(0)\" onclick=\"ImagePage(1,this);\">首頁</a>";
    var sPre="<a href=\"javascript:void(0)\" onclick=\"ImagePage("+(curPage-1)+",this);\">上一頁</a>";
    var sNext="<a href=\"javascript:void(0)\" onclick=\"ImagePage("+(curPage+1)+",this);\">下一頁</a>";
    var sLast="<a href=\"javascript:void(0)\" onclick=\"ImagePage("+pageCount+",this);\">尾頁</a>"
    var sHtml="";

    if(curPage==1&&curPage!=pageCount)
    {
    sHtml=sNext+sLast
    }
    else if(curPage==pageCount)
    {
       sHtml=sFirst+sPre
    }
    else if(curPage!=1&&curPage!=pageCount)
    {
          sHtml=sFirst+sPre+sNext+sLast
    }
    if($(obj).parent().find('.pager').html()==null){
    $("<div class=\"pager\">"+sHtml+"</div>").appendTo($(obj).parent());
    }
    else
    {
        $(obj).parent().find('.pager').html(sHtml)
    }
      
    }
}
/*-----显示内容初始化 start ----- **/
function closeOperate(type, width) {
    var w = parseInt($('#center_td').width()) + parseInt(width);
    if (type == 'right') {
        $('#menuRight_td').css('display', 'none');
        $('#right_td').css('display', 'none');
        $('#center_td').css('width', w);
        $('#center_td').attr('colspan', 2);
        $('#menuCenter_td').attr('colspan', 2);
        $('#menuCenter_td').css('width', w);
        $("<span onclick=\"openOperate('right','" + width + "');\">"+GetWords(13)+"</span>").appendTo($('#right_div'));

    } else {
        $('#menuLeft_td').css('display', 'none');
        $('#left_td').css('display', 'none');
        $('#center_td').css('width', w);
        $('#menuCenter_td').css('width', w);
        $("<span onclick=\"openOperate('left','" + width + "');\">"+GetWords(14)+"</span>").appendTo($('#left_div'));
    }

}
/*显示内容初始化*/function initDisplay() {
    if ($('#hfContentDisplay').html() != null) {
        var val = $('#hfContentDisplay').val().split('|');
        if (val.length > 0) {
            var cVal;
            $(val).each(function(i) {
                cVal = val[i].split(',');
                if (cVal.length > 2) {
                    if (cVal[1] == 'none') {
                        closeOperate(cVal[0], cVal[2]);
                    }
                }
            });
        }
    }
}
/*-----显示内容初始化 end ----- **/
function initStaticNav() {
    $('div[class^=STATICNAV_]').mousemove(function() {
        $('.' + $(this).attr('className') + '_CHILD').css('display', 'block');
    }).mouseout(function() {
        $('.' + $(this).attr('className') + '_CHILD').css('display', 'none');
    });
}

/*选项卡切换*/
function bindTab() {
    $('.topTab').each(function() {
        $(this).find('.titleTab a').each(function(i) {
            $(this).mouseover(function() {
                $(this).parent().find('a').attr('className', '');
                $(this).parent().find('a').eq(i).attr('className', 'on');
                $(this).parent().parent().find('.con').css('display', 'none');
                $(this).parent().parent().find('.con').eq(i).css('display', 'block');
            });
        });
    });
}

function initImgZoom() {
    /*单一图片*/
    var srcs = 'cImageClass'.split('|');
    for (var i = 0; i < srcs.length; i++) {
        $('.' + srcs[i]).each(function() {
            $(this).find('img').each(function() {
                $(this).parent().html("<a href=\"" + $(this).attr('src') + "\" rel=\"lightbox\" title=\"\">" + $(this).parent().html() + "</a>");
            });
        });
    }
}

/*初始化站点状态*/
this.InitSiteStatus = function() {
    /*当前用户名*/
    var userName = '';
    if ($('#txtHomePageUserName').html() != null) {
        userName = $('#txtHomePageUserName').val();
    }

    if (userName.length == 0) {
        return;
    }

    var msg = '';
    $.ajax({
        type: 'post',
        url: siteAccessPath + 'Operate.aspx?operate=getStatus&userName=' + userName,
        success: function(result) {
            var temp = result.split('|');
            
            if (temp[0] == 'close') {
                /*关闭*/
                window.location.href = siteAccessPath + 'Close.html';
            } else if (temp[0] == 'maintenance') {
                /*维护*/
                window.location.href = siteAccessPath + 'Maintenance.html';
            } else if (temp[0] == 'try' && temp.length > 1) {
                /*即將過期*/
                msg = GetWords(15) + temp[1] + GetWords(16);
            } else if (temp[0] == 'over') {
                /*试用*/
                window.location.href = siteAccessPath + 'BeOverdue.html';
            }
             else if (temp[0] == 'none') {
                /*试用*/
/*alert("無法獲取站點狀態！");*/
            }
            if (msg.length > 0) {

                $('<div style=\"border:solid 1px red; padding:5px; \"><marquee onmouseover=\"this.stop()\" onmouseout=\"this.start()\">' + msg + '</marquee></div>').insertBefore('form');
                $('#STATIC_HEADER').css('top', parseInt($('#STATIC_HEADER').css('top')) + 50);
            }
        },
         error:function (XmlHttpRequest, textStatus, errorThrown){   

         }
    });
}

 /*顶部公告*/
this.InitNotice= function(){
    /*当前用户名*/
    var userName = '';
    if ($('#txtHomePageUserName').html() != null) {
        userName = $('#txtHomePageUserName').val();
    }
    if (userName.length == 0) {
        return;
    }
    $.ajax({
        type: 'post',
        url: siteAccessPath + 'Operate.aspx?operate=getNotice&userName=' + userName,
        success: function(result) {
            if (result.length > 0) {
                $('<div style=\"border:solid 1px red; padding:5px; \"><marquee onmouseover=\"this.stop()\" onmouseout=\"this.start()\">' + result + '</marquee></div>').insertBefore('form');
                $('#STATIC_HEADER').css('top', parseInt($('#STATIC_HEADER').css('top')) + 50);
            }
        }
    });
}

/*计数器*/
this.CounterStyle=function(){
    /*当前用户名*/
    var userName = '';
    if ($('#txtHomePageUserName').html() != null) {
        userName = $('#txtHomePageUserName').val();
    }
    if (userName.length == 0) {
        return;
    }
    $.ajax({
        type: 'post',
        url: siteAccessPath + 'Operate.aspx?operate=getcounter&userName=' + userName,
        success: function(result) {
            if (result.length > 0) {
                $('#STATIC_FOOTER').append('<div>歷史瀏覽數：'+result+'</div>');
            }
        }
    });
}

this.SiteIcon=function(){
    /*当前用户名*/
    var userName = '';
    if ($('#txtHomePageUserName').html() != null) {
        userName = $('#txtHomePageUserName').val();
    }
    if (userName.length == 0) {
        return;
    }
    $.ajax({
        type: 'post',
        url: siteAccessPath + 'Operate.aspx?operate=geticon&userName=' + userName,
        success: function(result) {
            if (result.length > 0) {
                var html='<LINK rel="Bookmark" href="'+siteAccessPath.substring(0,siteAccessPath.length-1)+result+'" />';
                html+='<LINK rel="Shortcut Icon" href="'+siteAccessPath.substring(0,siteAccessPath.length-1)+result+'" />';
                $('head').append(html);
            }
        }
    });
    /*<LINK rel="Bookmark" href="http://uploadico.55.la/upload/ico/2011/05/25/10/1_1306289920.ico" >
<LINK rel="Shortcut Icon" href="http://uploadico.55.la/upload/ico/2011/05/25/10/1_1306289920.ico" />*/
}

/*检举*/
this.LoadTime=function(){
    var url=siteAccessPath+'Accusation.aspx';
    url+='?page='+escape(location.href);
    url+='&type=';
    var html='<div style="position: absolute; top: 0; right: 0; font-weight:bold;">';
 /*   html+='<span style="cursor:pointer;" onclick="location.href=\''+url+'1'+'\'"><img src="'+siteAccessPath+'Images/img_del.png" />檢舉</span>';
    html+='<span style="cursor:pointer;" onclick="location.href=\''+url+'2'+'\'"><img src="'+siteAccessPath+'Images/img_remove.png" />移除要求</span>';
    html+='<span style="cursor:pointer;" onclick="window.print();"><img src="'+siteAccessPath+'Images/img_print.png" />列印</span>';
    if ($.browser.msie)
 {
 document.body.style.zoom=iZoom
 }
 else
 {
  document.body.style.MozTransform= "scale("+iZoom+")";
  document.body.style.MozTransformOrigin='48% 0%' ; 
 }*/

    var myDate=new Date();    
    html+='<span>今天是西元'+myDate.toLocaleDateString()+' 周'+GetWeek(myDate.getDay())+'</span>';
/*    html+='<span style="cursor:pointer;" onclick="ChangeWindowZoom(-0.2);">【縮小】</span>';
    html+='<span style="cursor:pointer;" onclick="ChangeWindowZoom(1);">【還原】</span>';
    html+='<span style="cursor:pointer;" onclick="ChangeWindowZoom(0.2);">【放大】</span>';*/
    html+='</div>';
    $('body').append(html);
}
function ChangeWindowZoom(zoom){
    if(zoom==1)
        zoomi=1;
    else
        zoomi=zoom+zoomi;
        
    if ($.browser.msie)
    {
        document.body.style.zoom=zoomi;
    }
    else
    {
        document.body.style.MozTransform= "scale("+zoomi+")";
        document.body.style.MozTransformOrigin='48% 0%' ; 
    }
}

function GetWeek(week){
    var returnVal='一';
    switch (week)
    {
        case 1:
        returnVal = '一';
        break;
        case 2:
        returnVal = '二';
        break;
        case 3:
        returnVal = '三';
        break;
        case 4:
        returnVal = '四';
        break;
        case 5:
        returnVal = '五';
        break;
        case 6:
        returnVal = '六';
        break;
        case 0:
        returnVal = '日';
        break;
    }
    return returnVal;
}



/*=======================================*/
/*未延迟的加载事件*/
$(document).ready(function() {

    /*logo banner初始化*/
    /*Google搜索添加事件*/
    SearchG();
    SiteSearch();
    initStaticNav();
    bindTab();
    var c = new common();
    /*图片随机*/
    c.ImageRandom();
    /*系统内容初始化*/
    c.IndexInit();
    clearAction();
    /*显示内容初始化*/    initDisplay();
    initImgZoom();
    /*初始化公告*/    InitNotice();
    /*站点状态*/    InitSiteStatus();
    /*计数器样式*/    CounterStyle();
    /*站点图标*/
    SiteIcon();
    LoadTime();
});
/*=======================================*/


/*用户信息统计*/
function Track(siteId, pageId)
 {

    if (typeof($) == "undefined") {
        return;
    }
    $.post(siteAccessPath + "GuestTrack.ashx", {
        SiteId: siteId,
        PageId: pageId
    },
    null);

}

/*process dynamic module data*/
function DynamicModule()
{

    if (typeof($) == "undefined") {
        return;
    }
    $("div[class^='DynamicModule_']").each(function() {
        var module = this.className.split("_")[1];
        var val = eval("new " + module + "Module()");
        val.Target = this;
        val.Process();
    });

}
DynamicModule.Handler = siteAccessPath + "GetDynamicModuleData.ashx";
DynamicModule.Handler = siteAccessPath + "DynamicModuleDataBase.ashx";

/*Site Statistics*/
function cSiteStatisticsModule()
 {

    this.Target = null;
    this.Process = function() {
        if (this.Target == null) {
            return;
        }
        var datas = document.getElementById("Value_" + this.Target.id).value.split(",");
        var map = {};
        map["Module"] = "cSiteStatistics";
        map["Lang"] = datas[0];
        map["SiteId"] = datas[1];
        var _target = this.Target;
        $.post(DynamicModule.Handler, map, 
        function(result) {         
            ProcessResult(result, _target);
        });
    }

    ProcessResult = function(result, target) {
        target.innerHTML = result;
    };

}

/*Guest Book*/
function cGuestBookModule()
 {
    this.Target = null;
    this.Process = function() {
        if (this.Target == null) {
            return;
        }
        var datas = document.getElementById("Value_" + this.Target.id).value.split(",");
        var map = {};
        map["Lang"] = datas[0];
        map["SiteId"] = datas[1];
        map["Count"] = datas[2];
        map["ModuleId"] = datas[3];
        iframe = $("<iframe allowtransparency=\"true\" align=\"top\" scrolling=\"no\" frameborder=\"0\" style=\"width:100%;\" ></iframe>");

        var _target = $(this.Target);
        _target.children().remove();
        _target.append(iframe);
        var src = siteAccessPath + "Components/GuestBookModule.aspx?SiteId=" + map["SiteId"] + "&ModuleId=" + map["ModuleId"];
        iframe.attr("id", "iframe" + map["ModuleId"]);
        iframe.attr("src", src);
    }
}

cGuestBookModule.SetIframeHeight = function(moduleId) {
    var iframe = document.getElementById("iframe" + moduleId);
    var scrollHeight = iframe.contentWindow.document.body.scrollHeight;
    var height = scrollHeight;
    iframe.style.height = height + 'px';
}
