var nowID = 0;
var nowText = null;
var nowUrl = null;
$(function(){
    $('div.common_box_user_broad_1 a.forget_password').commonLinks({
        color:'#666'
    });
    $('div.common_box_user_broad_1 a.register').commonHighlightLinks();
    $('div.rank_sort').commonBoxSort();
    $('div.news').commonBoxHighlight({fixHight:true});
    $('div.hot_games').commonBoxLarges({fixHight:true});
    $('div.game_lists').commonBoxShade();
    $('div.hot_topics').commonBoxLarges();
});
function noticeClick(id){
    $.get('ajaxNotice.do', {
        noticeID:id,
        content:'text/html; charset=utf-8'
    }, function(data){
        showNotice(data);
    });
}
function showNotice(text1){
    if(!text1 || typeof(text1) != 'string' ){
        return;
    }
    $('body').append('<div class="common_box_prompt_background" style=\"top:-50px;\"></div>');
    $('body').append(text1);
    setPromptBackground();
    $('body').click(function(){
        $('body').find('div.common_box_prompt_background').remove();
        $('body').find('div.index_noticeBox').remove();
    });
    var top = document.documentElement.scrollTop+ (window.innerHeight?window.innerHeight:document.documentElement.offsetHeight)/2;
    if($.browser.safari){
        top = window.pageYOffset + (window.innerHeight?window.innerHeight:document.documentElement.offsetHeight)/2;
    }
    if($.browser.msie){
        top = top - 80;
    }else{
        top = top - 161;
    }
    $('body').find('div.index_noticeBox').css('top',top + 'px');
    var height = $(document).height();
    $('body').find('div.common_box_prompt_background').css('height',height + 50 +'px');
    $(window).resize(function(){
        setPromptBackground();
    });
}
function showImage(type){
    $.ajax({
        url:'ajaxNowIndexHighlightImage.do',
        type:'GET',
        dataType:'xml',
        data:'image_id=' + nowID,
        success:function(data){
            nowID = $(data).find('id').text();
            nowText = $(data).find('text').text();
            nowUrl = $(data).find('url').text();
            if(type == 2){
                append();
            }else{
                if(nowUrl != null && nowUrl.length > 0){
                    $('div#show_image_div').append('<a href="' + nowUrl + '"><img src=\"indexHighlightImage.do?image_id=' + nowID + '\"/></a>');
                }else{
                    $('div#show_image_div').append('<img src=\"indexHighlightImage.do?image_id=' + nowID + '\"/>');
                }
                $('div#show_image_id img').attr({
                    title:$(data).find('text').text(),
                    alt:$(data).find('text').text()
                });
            }
        }
    });
    
}
function append(){
    $('div#show_image_id').empty();
    if(nowUrl != null && nowUrl.length > 0){
        $('div#show_image_id').append('<a href="' + nowUrl + '"><img  src=\"indexHighlightImage.do?image_id=' + nowID + '\" title="' + nowText + '" alt="' + nowText + '" /></a>');
    }else{
        $('div#show_image_id').append('<img  src=\"indexHighlightImage.do?image_id=' + nowID + '\" title="' + nowText + '" alt="' + nowText + '" />');
    }
    $.ajax({
        url:'ajaxNowIndexHighlightImage.do',
        type:'GET',
        dataType:'xml',
        data:'image_id=' + nowID,
        success:function(data){
            nowID = $(data).find('id').text();
            nowText = $(data).find('text').text();
            nowUrl = $(data).find('url').text();
        }
    });
    $('div#show_image_id').find('img').css('opacity','0.2');
    $('div#show_image_id').find('img').fadeTo(4000, 1, function(){
        window.setTimeout(append, 1500);
    });
}


