﻿/*
author:char
date:2009.12.1
*/
if(typeof $ =="undefined"){
    var $ =function(id){
        return document.getElementById(id);
    }
}
var timer_msg;
var timer_close;
function msg_make(){
    var str="<div id='msg_div' style='visibility:hidden;Z-INDEX:99999; right:0;WIDTH:180px; POSITION:absolute; top:0px; HEIGHT:110px;overflow:hidden;'>";
    str+="<div style='background:url(/images/images/top.jpg) no-repeat;width:156px;height:18px;float:left;'><div style='margin:4px 0 0 5px;font-size:12px;color:#ffffff;font-weight:bold;'>红扣子商城提醒您</div></div>";
    str+="<div style='background:url(/images/images/close.jpg) no-repeat;width:24px;height:18px;cursor:pointer;float:left;' onclick='msg_close()' title='关闭'>&nbsp;</div>";
    str+="<div id='msg_text' style='background:url(/images/images/main.jpg);width:180px;height:92px;margin:0;clear:both;text-align:center;'>";
    str+="</div></div>";
    $("buymsg").innerHTML=str;
    $("msg_div").onmouseover=function(){clearTimeout(timer_close);}
    $("msg_div").onmouseout=function(){timer_close=setTimeout("msg_close();",1000);}
}
function msg_show(txt){
    if($("msg_div")==null){
	    msg_make();
    }
    clearTimeout(timer_close);
    $("msg_div").style.top=document.documentElement.scrollTop+document.documentElement.clientHeight;
    $("msg_text").innerHTML=txt;
    $("msg_div").style.visibility="visible";
    msg_play();
}
function msg_play(){
    if(parseInt($("msg_div").style.top)>document.documentElement.scrollTop+document.documentElement.clientHeight-parseInt($("msg_div").style.height)){
        $("msg_div").style.top=parseInt($("msg_div").style.top)-5;
        timer_msg=setTimeout("msg_play();",10);
    }else{
        clearTimeout(timer_msg);
	    timer_close=setTimeout("msg_close();",2500);
    }
}
var count=0;
function msg_close(){
    if(parseInt($("msg_div").style.top)<document.documentElement.scrollTop+document.documentElement.clientHeight&&count<110){
        count+=5;
        $("msg_div").style.top=parseInt($("msg_div").style.top)+5;
        timer_msg=setTimeout("msg_close();",10);
    }else{
        clearTimeout(timer_msg);
	    $("msg_div").style.visibility="hidden";
	    count=0;
    }
}