    function draw_circle_mask( x, y, r, state, parent, styleString )
    {
        var dx;
        var dy;
        var fixedR;

        fixedR = r;

        prevdx = 0;
                if ( !styleString )
                    styleString = "";

            for( dx=r,dy=0; (dy)<dx; dy++)
            {
                if( r <=(dy*dy) )
                {
                    dx--;
                    r+=2*dx+1;
                }
                
                if( state & 0x80)
                {
                    var myDiv = document.createElement( 'div' );
                    myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x-fixedR)+"px; top:"+(y+dy)+"px;  width:"+(fixedR-dx)+"px; height:1px;" );
                    parent.appendChild( myDiv );
                }
                if( state & 0x40)
                {
                    var myDiv = document.createElement( 'div' );
                    myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x+dx)+"px; top:"+(y+dy)+"px;  width:"+(fixedR-dx)+"px; height:1px;" );
                    parent.appendChild( myDiv );
                }
                if ( dy != 0)
                {
                    if( state & 0x20)
                    {
                        var myDiv = document.createElement( 'div' );
                        myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x+dx)+"px; top:"+(y-dy)+"px; width:"+(fixedR-dx)+"px; height:1px;" );
                        parent.appendChild( myDiv );
                    }
                    if( state & 0x10)
                    {
                        var myDiv = document.createElement( 'div' );
                        myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x-fixedR)+"px; top:"+(y-dy)+"px; width:"+(fixedR-dx)+"px; height:1px;" );
                        parent.appendChild( myDiv );
                    }
                }
                
                if ( prevdx != dx )
                {
                    prevdx = dx;
                    if ( dx > (dy)  )
                    {
                        if( state & 0x08)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x+dy)+"px; top:"+(y+dx)+"px; width:1px;  height:"+dx+"px;" );
                            parent.appendChild( myDiv );                    
                        }
                        if( state & 0x04)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x-fixedR)+"px; top:"+(y+dx)+"px; width:"+(fixedR-dy)+"px; height:1px;"  );
                            parent.appendChild( myDiv );                    
                        }
                        if( state & 0x02)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x+dy)+"px; top:"+(y-dx)+"px; width:"+(fixedR-dy)+"px;  height:1px;" );
                            parent.appendChild( myDiv );
                        }
                        if( state & 0x01)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.setAttribute("style", styleString+" position:absolute; left:"+(x-fixedR)+"px; top:"+(y-dx)+"px; width:"+(fixedR-dy)+"px; height:1px;" );
                            parent.appendChild( myDiv );
                        }

                    }
                }
                
            }

        }
    function draw_circle( x, y, r, state, parent, color )
    {
        var dx;
        var dy;
        
        var mid = parseInt( r*Math.sqrt(2)/2 );
        
        r = r-1;

        prevdx = 0;
        var styleString = "";

            var fixedR = r;
            for( dx=r,dy=0; (dy)<dx; dy++)
            {        
                if( r <=(dy*dy) )
                {
                
                    dx--;
                    r+=2*dx+1;
                }
                var op = ( ( r - ( dy*dy ) ) / ( 2*dx+1 ) );

                
                if( state & 0x80)
                {
                    var myDiv = document.createElement( 'div' );
                    myDiv.style.position = "absolute";
                    myDiv.style.left = x - dx + 1 + "px";
                    myDiv.style.top = y + dy + "px";
                    myDiv.style.width = dx + "px";
                    myDiv.style.height = "1px";
                    myDiv.style.backgroundColor = color;
                    parent.appendChild( myDiv );

                    var myDiv = document.createElement( 'div' );
                    myDiv.style.position = "absolute";
                    myDiv.style.left = x - dx + "px";
                    myDiv.style.top = y + dy + "px";
                    myDiv.style.width = "1px";
                    myDiv.style.height = "1px";
                    myDiv.style.background = color;
                    myDiv.style.opacity = op;    
                    parent.appendChild( myDiv );
                }
                
                if( state & 0x40)
                {
                    var myDiv = document.createElement( 'div' );
                    myDiv.style.position = "absolute";
                    myDiv.style.left = x + dx + "px";
                    myDiv.style.marginLeft = (-dx+1)+"px";
                    myDiv.style.top = y + dy + "px";
                    myDiv.style.width = dx + "px";
                    myDiv.style.height = "1px";
                    myDiv.style.backgroundColor = color;
                    parent.appendChild( myDiv );                    

                    
                    var myDiv = document.createElement( 'div' );
                    myDiv.style.position = "absolute";
                    myDiv.style.left = x + dx + 1 + "px";
                    myDiv.style.top = y + dy + "px";
                    myDiv.style.width = "1px";
                    myDiv.style.height = "1px";
                    myDiv.style.backgroundColor = color;
                    myDiv.style.opacity = op;
                    parent.appendChild( myDiv );                                        
                }
                if ( dy > 0 )
                {
                    if( state & 0x20)
                    {
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x + dx + "px";
                        myDiv.style.top = y - dy + "px";
                        myDiv.style.width = dx + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.marginLeft = (-dx+1) + "px";
                        myDiv.style.backgroundColor = color;                        
                        parent.appendChild( myDiv );
                        
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x + dx + 1 + "px";
                        myDiv.style.top = y - dy + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.backgroundColor = color;
                        myDiv.style.opacity = op;
                        parent.appendChild( myDiv );                        
                    }
                    if( state & 0x10)
                    {
                        
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x - dx + 1 + "px";
                        myDiv.style.top = y - dy + "px";
                        myDiv.style.width = dx + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.backgroundColor = color;                             
                        parent.appendChild( myDiv );
                        
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x - dx  + "px";
                        myDiv.style.top = y - dy + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.backgroundColor = color;
                        myDiv.style.opacity = op;                        
                        parent.appendChild( myDiv );
                        
                    }
                
                    
    
                    if( state & 0x08)
                    {
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x + dy + "px";
                        myDiv.style.top = y + dx + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.marginTop = (-dx+mid+1) + "px";
                        myDiv.style.height = (dx-mid) + "px";
                        myDiv.style.backgroundColor = color;                            
                        parent.appendChild( myDiv ); 
    
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x + dy  + "px";
                        myDiv.style.top = y + dx + 1 + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.backgroundColor = color;
                        myDiv.style.opacity = op;                           
                        parent.appendChild( myDiv );                         
                    }
                    if( state & 0x04)
                    {
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x - dy + 1 + "px";
                        myDiv.style.top = y + dx + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.marginTop = (-dx+mid+1) + "px";
                        myDiv.style.height = (dx-mid) + "px";
                        myDiv.style.backgroundColor = color;                            
                        parent.appendChild( myDiv );
    
                        var myDiv = document.createElement( 'div' );
                        myDiv.style.position = "absolute";
                        myDiv.style.left = x - dy + 1 + "px";
                        myDiv.style.top = y + dx + 1 + "px";
                        myDiv.style.width = 1 + "px";
                        myDiv.style.height = "1px";
                        myDiv.style.backgroundColor = color;
                        myDiv.style.opacity = op;                           
                        parent.appendChild( myDiv );
                 
                    }
                    if ( dy > 0 )
                    {                      
                        if( state & 0x02)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.style.position = "absolute";
                            myDiv.style.left = x + dy  + "px";
                            myDiv.style.top = y + "px";
                            myDiv.style.width = 1 + "px";
                            myDiv.style.marginTop = -dx + "px";
                            myDiv.style.height = (dx-mid) + "px";
                            myDiv.style.backgroundColor = color;                            
                            parent.appendChild( myDiv );
                        
                            var myDiv = document.createElement( 'div' );
                            myDiv.style.position = "absolute";
                            myDiv.style.left = x + dy + "px";
                            myDiv.style.top = y - 1 + "px";
                            myDiv.style.width = 1 + "px";
                            myDiv.style.height = "1px";
                            myDiv.style.marginTop = -dx + "px";
                            myDiv.style.backgroundColor = color;
                            myDiv.style.opacity = op;                           
                            parent.appendChild( myDiv );
                        }
                        if( state & 0x01)
                        {
                            var myDiv = document.createElement( 'div' );
                            myDiv.style.position = "absolute";
                            myDiv.style.left = x - dy + 1 + "px";
                            myDiv.style.top = y + "px";
                            myDiv.style.width = 1 + "px";
                            myDiv.style.marginTop = -dx + "px";
                            myDiv.style.height = (dx-mid) + "px";
                            myDiv.style.backgroundColor = color;                            
                            parent.appendChild( myDiv );
        
                            var myDiv = document.createElement( 'div' );
                            myDiv.style.position = "absolute";
                            myDiv.style.left = x - dy + 1 + "px";
                            myDiv.style.top = y - 1 + "px";
                            myDiv.style.width = 1 + "px";
                            myDiv.style.height = "1px";
                            myDiv.style.marginTop = -dx + "px";
                            myDiv.style.backgroundColor = color;
                            myDiv.style.opacity = op;                           
                            parent.appendChild( myDiv );
                        }
                    }
                }
            }
            

            if( state & 0x01 )
            {            
                var myDiv = document.createElement( "DIV" );
                myDiv.style.position = "absolute";
                myDiv.style.left = x - dy + 1 +"px";
                myDiv.style.top = y + "px";
                myDiv.style.marginTop = -dx+"px";
                myDiv.style.width = dy+"px";
                myDiv.style.height = "1px";
                myDiv.style.background = color;                
                parent.appendChild( myDiv );
            }
                
            if ( state & 0x02 )
            {
                var myDiv = document.createElement( "DIV" );
                myDiv.style.position = "absolute";
                myDiv.style.left = x +"px";
                myDiv.style.top = y + "px";
                myDiv.style.marginTop = -dx+"px";
                myDiv.style.width = dy+"px";
                myDiv.style.height = "1px";
                myDiv.style.background = color;
                parent.appendChild( myDiv );                
            }
            
            if( state & 0x04 )
            {            
                var myDiv = document.createElement( "DIV" );
                myDiv.style.position = "absolute";
                myDiv.style.left = x - dy + 1 +"px";
                myDiv.style.top = (y+2*dx)+"px";
                myDiv.style.marginTop = -dx+"px";
                myDiv.style.width = dy+"px";
                myDiv.style.height = "1px";
                myDiv.style.background = color;
                parent.appendChild( myDiv );
            }
                
            if ( state & 0x08 )
            {
                var myDiv = document.createElement( "DIV" );            
                myDiv.style.position = "absolute";
                myDiv.style.left = x+"px";
                myDiv.style.top = (y+2*dx)+"px";
                myDiv.style.marginTop = -dx+"px";
                myDiv.style.width = dy+"px";
                myDiv.style.height = "1px";
                myDiv.style.background = color;
                parent.appendChild( myDiv );
            }                 
        }
        
    function makeRoundedCorners( _parent, radius, color )
    {
        var inner = _parent.innerHTML;
        _parent.innerHTML = "";
        
        var divElement = document.createElement( "DIV" );
        divElement.style.position = "relative";
        divElement.style.width = _parent.clientWidth + "px";
        divElement.style.height = _parent.clientHeight + "px";
        _parent.appendChild( divElement );
        
        draw_circle( radius-1, radius, radius, 0x11, divElement, color );
        draw_circle( divElement.clientWidth - radius - 1, radius, radius, 0x22, divElement, color );
        draw_circle( divElement.clientWidth - radius - 1, divElement.clientHeight - radius - 1, radius, 0x48, divElement, color );
        draw_circle( radius-1, divElement.clientHeight - radius - 1, radius, 0x84, divElement, color );

        var cross = document.createElement( "DIV" );
        cross.style.position = "absolute";
        cross.style.top = radius + "px";
        cross.style.left = "0px";
        cross.style.height = divElement.clientHeight - 2 * radius + "px";
        cross.style.width = divElement.clientWidth + "px";
        cross.style.background = color;
        
        var main = document.createElement( "DIV" );
        main.style.position = "absolute";
        main.style.left = radius + "px";
        main.style.width = divElement.clientWidth - 2 * radius + "px";
        main.style.background = color;
        main.style.paddingTop = radius + "px";
        main.style.height = divElement.clientHeight - radius + "px";
        
        divElement.appendChild( cross );        
        divElement.appendChild( main );
      
        main.innerHTML = inner;

    }
    