﻿///<reference path="jquery-1.4.2-vsdoc.js" />

function Pop_login_index(goloc) {
    AjaxPro.timeoutPeriod = 1000 * 60 * 60;
    var ornot = gongpinghouse.index.checkLogin().value;
    if (ornot == "notyet") {
        dologin(goloc);
    }
    else if (ornot == "already") {
        window.location.href = goloc;
    }
}

function Pop_login_main(goloc) {
    AjaxPro.timeoutPeriod = 1000 * 60 * 60;
    var ornot = gongpinghouse.main.checkLogin().value;
    if (ornot == "notyet") {
        dologin(goloc);
    }
    else if (ornot == "already") {
        window.location.href = goloc;
    }
}

$.fn.extend({
    allenMenu: function() {
        $(this).children('ul').children('li').hover(
			function() {
			    if (!$(this).children('ul').hasClass('focus')) {
			        $(this).addClass('focus');
			        $(this).children('ul:first').stop(true, true).animate({ height: 'show' }, 'fast');
			    }
			},
			function() {
			    $(this).removeClass('focus');
			    $(this).children('ul:first').stop(true, true).animate({ height: 'hide', opacity: 'hide' }, 'slow');
			}
		);
        $(this).children('ul').children('li').children('ul').hover(
			function() {
			    $(this).addClass('focus');
			},
			function() {
			    $(this).removeClass('focus');
			}
		);
    }
});

$.fn.extend({
    allenSlide: function() {
        var ads = $(this).find('ul:first li');
        var name = $(this).attr('id');
        var n = ads.length;
        var w = ads.width();
        var h = ads.height();
        var clicked = false;
        var t = 4000;
        var lt = 5000;
        var speed = 'slow';
        var curPage = 0;

        $(this).css('overflow', 'hidden');
        $(this).css('position', 'relative');
        $(this).children('ul:first').width(w * (n + 1));
        var pages = $('<div class="slide-page"></div>');
        for (var i = 1; i <= n; i++) {
            var el = $('<a href="#" id="' + name + '-page-' + i + '">' + i + '</a>');
            eval('el.click(function(){ clicked = true; slideTo(' + i + '); return false; });');
            pages.append(el);
        }
        $(this).append(pages);
        $('#' + name + '-page-1').parent().addClass('on');
        autoSlide();

        /* Fade Version
        */
        function slideTo(page) {
            curPage = page;
            var ml = -1 * w * (page - 1);
            $('#' + name).find('li:eq(' + (curPage - 1) + ')').stop();
            if (page > n) {
                page = 1;
                curPage = 1;
            }
            $('#' + name).find('li').each(function() {
                if ($(this).css("display") != "none") {
                    //$(this).css('z-index', '2');
                    $(this).fadeOut(speed);
                }
            });
            //$('#' + name).find('li:eq('+(page-1)+')').css('z-index', '1');
            $('#' + name).find('li:eq(' + (page - 1) + ')').fadeIn(speed);
            $('#' + name).find('.slide-page > a').removeClass('on');
            $('#' + name + '-page-' + curPage).addClass('on');
        }

        function autoSlide() {
            var tp = curPage;
            if (!clicked) {
                slideTo(tp + 1);
                eval('setTimeout(function() { autoSlide(); }, ' + t + ');');
            } else {
                clicked = false;
                eval('setTimeout(function() { autoSlide(); }, ' + lt + ');');
            }
        }

    }
});

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);
        }
    }
} 
