﻿function Stamp(instance, src, href, target, x, y){
    this.Instance = instance;
    this.Target = target;
    this.Src = src;
    this.Href = href;
    this.X = x;
    this.Y = y;
}

Stamp.prototype = {
    init : function(){
        /*
        1、取是否关闭过，如果关闭过就不显示，否则就执行第二步；
        2、显示
        */
        
        var cki = Stamp_Get_Cookie("Stamp_Closed");        
        var HTML = new Array();
        if(!cki){
            HTML.push('<div id="Stamp_Image_ID" style="z-index:1000;position:absolute; left:'+this.X+'px;top:'+this.Y+'px;">');
            HTML.push('<img alt="" src="'+this.Src+'" usemap="#stamp" border="0"/>');
            HTML.push('<map id="stamp" name="stamp">');
            HTML.push('<area href="'+this.Href+'" target="'+this.Target+'"  coords="158, 1, 167, 155" shape="rect"/>');
            HTML.push('<area href="'+this.Href+'" target="'+this.Target+'" coords="0, 0, 156, 167" shape="rect"/>');
            HTML.push('<area href="#" onclick="'+this.Instance+'.close();"  coords="158, 158, 168, 168" shape="rect"/>');
            HTML.push('</map></div>');
           
            document.write(HTML.join(''));
        }
    },
    
    close : function(){
        document.getElementById("Stamp_Image_ID").style.display = "none";
        Stamp_Set_Cookie("Stamp_Closed" , "closed");
    }
}

function Stamp_Get_Cookie(key){
    return CookieManager.getCookie(key);
}

function Stamp_Set_Cookie(key, value){
    CookieManager.setCookie(key, value,null,"/");
}

//使用示例           参数说明: 实例名,         图章地址,    链接地址             链接打开方式  位置X, 位置Y
var StampInstance = new Stamp("StampInstance", "/Images/stamp.gif", "#", "",700, 200);
//StampInstance.init();