function get_obj(element_id){
    return document.getElementById(element_id);
}

function show_c_cat(cat_id,state){
    get_obj('c_'+cat_id).style.display=state;
}

jQuery(document).ready(function(){
    jQuery('*[is_goods=true]').mouseover(function(){
        this.style.border='1px solid red';
    });
    jQuery('*[is_goods=true]').mouseout(function(){
        this.style.border='1px solid gray';
    });
    jQuery('#next_area').mouseover(function(){
        jQuery('.next_area').css('display','');
    });
    jQuery('#next_area').mouseout(function(){
        jQuery('.next_area').css('display','none');
    });
    jQuery('a[comment_key=true]').click(function (){
        jQuery('a[comment_key=true]').each(function(i){
            this.style.color="#000";
            this.style.fontWeight='100';
        });
        this.style.color="#FF0000";
        this.style.fontWeight='bold';
        jQuery('div[comment_info=true]').each(function(i){
            this.style.display='none';
        });
        jQuery('div[comment_page='+this.id+']').each(function(i){
            this.style.display='';
        });
    });
    jQuery('td[is_qqbtn=true]').mouseover(function(){
        jQuery('div[is_qqnum=true]').each(function(i){
            this.style.display="none";
        });
        jQuery('td[is_qqbtn=true]').each(function(i){
            this.style.backgroundColor='#FFFFFF';
        });
        jQuery('#qqnum_'+this.id).css('display','');
        this.style.backgroundColor='#FFA900';
    });
    jQuery('*[login_box=true]').click(function(){
        if(Number(m_user_id)<=0){
            test1();
            setInterval(smck,1);
            if(location.href.indexOf('#')>0){
                jQuery('#login_next_page').val('/');
            }else{
                jQuery('#login_next_page').val(location.href);
            }
            jQuery('#add_info').css('display','');
            jQuery('#add_info_c').css('display','');
            return false;
        }
    });
    jQuery('a[go_web=true]').click(function(){
        if(this.href != '' && this.href != null && this.href !="http://" && this.href !="http:"){
            this.href="index.php?act=url&url="+this.id;
            return true;
        }else{
            alert("此用户还没有开通商家店铺");
            return false;
        }
    });
});
function display_none(divid){
	document.getElementById(divid).style.display='none';
}
function display_block(divid){
	document.getElementById(divid).style.display='';
}
lastScrollY=0;
lastScrollX=0;
function smck(){
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop
    else{/*Netscape stuff*/}
    percent=.1*(diffY-lastScrollY); 
    if(percent>0)percent=Math.ceil(percent); 
    else percent=Math.floor(percent); 
    document.getElementById("add_info_c").style.top=parseInt(document.getElementById("add_info_c").style.top)+percent+"px";
    document.getElementById("go_web").style.top=parseInt(document.getElementById("go_web").style.top)+percent+"px";
    lastScrollY=lastScrollY+percent;
}


function test1(f){
    var d = document.getElementById('add_info'),wh = getWH(f);
    d.style.cssText +=";width:"+wh.w+'px;height:'+wh.h+'px'
    
    var d = document.getElementById('go_web_bg'),wh = getWH(f);
    d.style.cssText +=";width:"+wh.w+'px;height:'+wh.h+'px'
}
var getWH = function (){
    var d = document,doc = d[d.compatMode == "CSS1Compat"?'documentElement':'body'];
    return function(f){
        return {
            w:doc[(f?'client':'scroll')+'Width'],
            h:f?doc.clientHeight:Math.max(doc.clientHeight,doc.scrollHeight)
        }
    }
}()


function show_go_web_bg(){
    test1();
    display_block('go_web_bg');
    display_block('go_web');
    clearInterval(show_go_web_bg_time);
}

var setInterval_res='';
function h_check_info(){
    $.ajax({//ajax 调用数据
		type: "POST",
		cache:false,
		url: "index.php?act=check_info",
		data: "",
		success: function(msg){
            if(msg != '' && msg != null){
                document.getElementById('msn').innerHTML=msg;
                document.getElementById('msn').style.display="";
                document.getElementById('msn').style.visibility='visible';
                // setInterval_res=setInterval(closeDiv,10000);
            }
		}
	});
}

function closeDiv(){
	document.getElementById('msn').style.visibility='hidden';
    clearInterval(setInterval_res);
}

