function button(page){
    var locale=page.locale;
    var prefix = 'https://oggchat2.icoa.com/cb?cid='+page.cid+'&link=';
    var imgSrc = '_oggchat-img3-on.png';
    if (locale)
    { 
        imgSrc = '_oggchat-img3-'+locale+'-on.png';
    }
    var style="";
    var html="";
    var txt=document.getElementById("oggchat")

    var mBottom = '50px';
    var mTop = '50px';
    var mLeft = '50px';
    var mRight = '50px';
    var newStyle = "";
    var styles="";
    var scrollHeight=0;
    var vLen=0;
    var font = "Verdana";
    var fontSize="10pt";

    if (page.font_size)
    {
        fontSize = page.font_size;
    }
    if (page.font)
    {
        font = page.font;
    }

    if (page.align == 'right')
    {
        if (page.top_margin)
        {
            mTop = page.top_margin;
            scrollHeight = mTop.substring(0,mTop.length-2);

        }
        if (page.bottom_margin)
        {
            mBottom = page.bottom_margin;
            scrollHeight = mTop.substring(0,mTop.length-2);
        }

        
        
        style="#oggchat {font: 12px normal Verdana, Arial, Helvetica, sans-serif;position: fixed;right:0;";
        if (page.top_margin)
        {
            style+="top:"+mTop+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+"+scrollHeight+" : document.body.scrollTop+"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";

        }
        else if (page.bottom_margin)
        {
            style+="bottom:"+mBottom+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight)-"+scrollHeight+" : document.body.scrollTop+(document.body.clientHeight-this.clientHeight)-"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";

        }
        else
        {
            style+="top:"+mTop+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+"+scrollHeight+" : document.body.scrollTop+"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";

        }
        
        style+="#oggchat ul {padding:0px;margin:0;list-style: none;}";
        style+="#oggchat ul li{padding:0px;margin: 0;list-style: none;}";
        //This is the + sign
        style+="#oggchat ul li a{padding:2px;float:left;text-decoration: none;position: relative;}";
        style+="#oggchat ul li a:hover{background-color: "+page.hover_color+";}";
        style+="#oggchat img {z-index:9999}";
        style+="#chatpanel span {}</style>";
        
        html = "<ul id='mainpanel'><li id='chatpanel'><a href='' target='_blank' onClick=\"window.open(encodeURI('https://oggchat2.icoa.com/cp?font="+font+"&fontsize="+fontSize+"&bgcolor=ffffff&cid="+page.cid+"&website="+page.website+"&height="+page.window_height+"&width="+page.window_width+"'), 'Chat', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width="+page.window_width+",height="+page.window_height+"&r='+document.referrer);return false;\" class='chat'><span><img src='"+prefix+imgSrc+"' id='btnImg' onload='checkOffline()' border='0' /></span> </a>";
        html+="</li></ul>";
        //style+=html;
        //new
        styles = document.createElement('style');
	styles.setAttribute('type', 'text/css');
        if (styles.styleSheet) {   // IE
            styles.styleSheet.cssText = style;
        } else {                // the world
            newStyle = document.createTextNode(style);
            styles.appendChild(newStyle);
        }
        document.getElementsByTagName('head')[0].appendChild(styles);
        //end new

        txt.innerHTML=html;
    }
    else if (page.align == 'left')
    {
        
        if (page.top_margin)
        {
            mTop = page.top_margin;
            scrollHeight = mTop.substring(0,mTop.length-2);
            
        }
        if (page.bottom_margin)
        {
            mBottom = page.bottom_margin;
            scrollHeight = mTop.substring(0,mTop.length-2);
        }

        style="#oggchat {font: 12px normal Verdana, Arial, Helvetica, sans-serif;position: fixed;left:0;";
        
        if (page.top_margin)
        {
            style+="top:"+mTop+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+"+scrollHeight+" : document.body.scrollTop+"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";

        }
        else if (page.bottom_margin)
        {
            style+="bottom:"+mBottom+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight)-"+scrollHeight+" : document.body.scrollTop+(document.body.clientHeight-this.clientHeight)-"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";

        }
        else
        {
            style+="top:"+mTop+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+"+scrollHeight+" : document.body.scrollTop+"+scrollHeight+");}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        
        }
        
        

        style+="#oggchat ul {padding:0px;margin:0;list-style: none;}";
        style+="#oggchat ul li{padding:0px;margin: 0;list-style: none;}";
        //This is the + sign
        style+="#oggchat ul li a{padding:2px;float:left;text-decoration: none;position: relative;}";
        style+="#oggchat ul li a:hover{background-color: "+page.hover_color+";}";
        style+="#oggchat img {z-index:9999}";
        style+="#chatpanel span {}</style>";
        
        html = "<ul id='mainpanel'><li id='chatpanel'><a href='' target='_blank' onClick=\"window.open(encodeURI('https://oggchat2.icoa.com/cp?font="+font+"&fontsize="+fontSize+"&bgcolor=ffffff&cid="+page.cid+"&website="+page.website+"&height="+page.window_height+"&width="+page.window_width+"'), 'Chat', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width="+page.window_width+",height="+page.window_height+"&r='+document.referrer);return false;\" class='chat'><span><img src='"+prefix+imgSrc+"' id='btnImg' onload='checkOffline()' border='0' /></span> </a>";
        html+="</li></ul>";
        //style+=html;
        //new
        styles = document.createElement('style');
	styles.setAttribute('type', 'text/css');
        if (styles.styleSheet) {   // IE
            styles.styleSheet.cssText = style;
        } else {                // the world
            newStyle = document.createTextNode(style);
            styles.appendChild(newStyle);
        }
        document.getElementsByTagName('head')[0].appendChild(styles);
        //end new

        txt.innerHTML=html;
    }
    else if (page.align == 'bottom')
    {
        
        if (page.left_margin)
        {
            mLeft = page.left_margin;
        }
        if (page.right_margin)
        {
            mRight = page.right_margin;
        }

        imgSrc = '_oggchat-img4-on.png';
        if (locale)
        {
            imgSrc='_oggchat-img4-'+locale+'-on.png';
        }
        style="#oggchat {font: 12px normal Verdana, Arial, Helvetica, sans-serif;position: fixed;bottom:0;";
        
        if (page.left_margin)
        {
            style+="left:"+mLeft+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight) : document.body.scrollTop+(document.body.clientHeight-this.clientHeight));}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        else if (page.right_margin)
        {
            style+="right:"+mRight+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight) : document.body.scrollTop+(document.body.clientHeight-this.clientHeight));}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        else
        {
            style+="left:"+mLeft+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight) : document.body.scrollTop+(document.body.clientHeight-this.clientHeight));}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        
        style+="#oggchat ul {padding:0px;margin:0;list-style: none;}";
        style+="#oggchat ul li{padding:0px;margin: 0;list-style: none;}";
        style+="#oggchat ul li a{padding:2px;float:left;text-decoration: none;position: relative;}";
        style+="#oggchat ul li a:hover{background-color: "+page.hover_color+";}";
        style+="#oggchat img {z-index:9999}";
        style+="#chatpanel span {}";

        html = "<ul id='mainpanel'><li id='chatpanel'><a href='' target='_blank' onClick=\"window.open(encodeURI('https://oggchat2.icoa.com/cp?font="+font+"&fontsize="+fontSize+"&bgcolor=ffffff&cid="+page.cid+"&website="+page.website+"&height="+page.window_height+"&width="+page.window_width+"'), 'Chat', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width="+page.window_width+",height="+page.window_height+"&r='+document.referrer);return false;\" class='chat'><span><img src='"+prefix+imgSrc+"' id='btnImg' onload='checkOffline()' border='0' /></span> </a>";
        html+="</li></ul>";
        //style+=html;
        //new
        styles = document.createElement('style');
	styles.setAttribute('type', 'text/css');
        if (styles.styleSheet) {   // IE
            styles.styleSheet.cssText = style;
        } else {                // the world
            newStyle = document.createTextNode(style);
            styles.appendChild(newStyle);
        }
        document.getElementsByTagName('head')[0].appendChild(styles);
        //end new
        
        txt.innerHTML=html;
    }
    else if (page.align == 'top')
    {
        if (page.left_margin)
        {
            mLeft = page.left_margin;
        }
        if (page.right_margin)
        {
            mRight = page.right_margin;
        }

        imgSrc = '_oggchat-img4-on.png';
        if (locale)
        {
            imgSrc='_oggchat-img4-'+locale+'-on.png';
        }
        style="#oggchat {font: 12px normal Verdana, Arial, Helvetica, sans-serif;position: fixed;top:0;";
        if (page.left_margin)
        {
            style+="left:"+mLeft+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop: document.body.scrollTop);}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        else if (page.right_margin)
        {
            style+="right:"+mRight+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop: document.body.scrollTop);}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        else
        {
            style+="left:"+mLeft+";z-index:9999;background:"+page.bg_color+";border-top:none;}";
            style+="*html #oggchat {position: absolute;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop: document.body.scrollTop);}";
            //style+="body {background-image: url('images/spacer.gif');background-repeat: no-repeat;background-attachment: fixed;}";
        }
        
        style+="#oggchat ul {padding:0px;margin:0;list-style: none;}";
        style+="#oggchat ul li{padding:0px;margin: 0;list-style: none;}";
        //This is the + sign
        style+="#oggchat ul li a{padding:2px;float:left;text-decoration: none;position: relative;}";
        style+="#oggchat ul li a:hover{background-color: "+page.hover_color+";}";
        style+="#oggchat img {z-index:9999}";
        style+="#chatpanel span {}</style>";



        html = "<ul id='mainpanel'><li id='chatpanel'><a href='' target='_blank' onClick=\"window.open(encodeURI('https://oggchat2.icoa.com/cp?font="+font+"&fontsize="+fontSize+"&bgcolor=ffffff&cid="+page.cid+"&website="+page.website+"&height="+page.window_height+"&width="+page.window_width+"'), 'Chat', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width="+page.window_width+",height="+page.window_height+"&r='+document.referrer);return false;\" class='chat'><span><img src='"+prefix+imgSrc+"' id='btnImg' onload='checkOffline()' border='0' /></span> </a>";
        html+="</li></ul>";
        //style+=html;
        //new
        styles = document.createElement('style');
	styles.setAttribute('type', 'text/css');
        if (styles.styleSheet) {   // IE
            styles.styleSheet.cssText = style;
        } else {                // the world
            newStyle = document.createTextNode(style);
            styles.appendChild(newStyle);
        }
        document.getElementsByTagName('head')[0].appendChild(styles);
        //end new

        txt.innerHTML=html;
    }
}
function checkOffline()
{
    var img = document.getElementById('btnImg');
    //or however you get a handle to the IMG
    var width = img.width;
    var panel = document.getElementById('oggchat');

    if (width == 1)
    {
        panel.style.visibility = "hidden";
    }

}

