// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
// add by dingchunlai on 2008-12-11
// 用于在上传单机游戏是做表单验证
function check_download_game_form(form)
{
    if($("download_game_name").value == "")
    {
        $("name_error").innerHTML = "单机游戏名称不能为空"
        return false;
    }
    if($("downloag_game_english_name").value == "")
    {
        $("english_name_error").innerHtml = "单机游戏英文名称不能为空"
        return false;
    }
    if(multiple_upload_attachment_counter == 0)
    {
        $("english_name_error").innerHtml = "请为单机游戏选择显示图片"
        return false;
    }

    if(multiple_upload_logo_counter == 0)
    {
        $("logos_error").innerHtml = "请为单机游戏选择显示图片"
        return false;
    }
    else
    {
        $("attachments_error").innerHtml = ""
    }

    if(multiple_upload_attachment_counter == 0)
    {
        $("attachments_error").innerHtml = "请为单机游戏选择显示游戏文件"
        return false;
    }
    else
    {
        $("attachments_error").innerHtml = ""
    }
    return true
}

// add by dingchunlai on 2008-12-11
// 用于在上传手机游戏是做表单验证
function check_phone_game_form(form)
{
    if($("phone_game_name").value == "")
    {
        $("name_error").innerHTML = "手机游戏名称不能为空"
        return false;
    }
    else
    {
        $("name_error").innerHTML = ""
    }
    if($("phone_game_english_name").value == "")
    {
        $("english_name_error").innerHtml = "手机游戏英文名称不能为空"
        return false;
    }
    else
    {
        $("english_name_error").innerHtml = ""
    }

    if(multiple_upload_logo_counter == 0)
    {
        $("logos_error").innerHtml = "请为手机游戏选择显示图片"
        return false;
    }
    else
    {
        $("attachments_error").innerHtml = ""
    }

    if(multiple_upload_attachment_counter == 0)
    {
        $("attachments_error").innerHtml = "请为手机游戏选择显示游戏文件"
        return false;
    }
    else
    {
        $("attachments_error").innerHtml = ""
    }
    return true
}

// add by dingchunlai on 2008-12-26
// 改变游戏显示屏幕的大小
function big_show_frame(width,height)
{
    document.getElementById("gamefile").height = document.getElementById("gamefile").height - 0 + height*0.1
    document.getElementById("gamefile").width = document.getElementById("gamefile").width - 0 + width*0.1
}
// add by dingchunlai on 2008-12-26
// 改变游戏显示屏幕的大小
function small_show_frame(width,height)
{
    document.getElementById("gamefile").height = document.getElementById("gamefile").height - height*0.1
    document.getElementById("gamefile").width = document.getElementById("gamefile").width - width*0.1
}

if  (window.HTMLElement){
    HTMLElement.prototype.__defineGetter__( "innerText", function(){
        return this.textContent;
    } );
    HTMLElement.prototype.__defineSetter__( "innerText", function(sText){
        this.textContent=sText;
    } );
}
function showdiv(targetid,objN){
    var target=document.getElementById(targetid);
    var clicktext=document.getElementById(objN)
    if (target.style.display=="block"){
        target.style.display="none";
        clicktext.innerText="更多游戏▼";
    } else {
        target.style.display="block";
        clicktext.innerText='关闭▲';
    }
}
document.observe("dom:loaded", function() {
    // only do this if the animation is available
    if ($('topTen') == null ) {
        return false;
    }
    var items = $('items').childElements();
    var details = $$('.details');

    items.each(function(n,i){
        Event.observe(n, 'mouseover', function(event) {
            var element = Event.element(event);
            items.each(function(m){
                $(m).removeClassName('active');
            });
            element.addClassName('active');
            element.childElements().each(function(a){
                Event.observe(a, 'mouseover', function(e){
                    Event.stop(e);
                });
            });

            details.each(function(d,j){
                if(i==j){
                    $(d).show();
                }else{
                    $(d).hide();
                }
            });

        });
    });

});
//加入收藏
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}