/* test */
Proto.UI.stuck=Class.create({
               
        initialize: function() 
        {
             if(navigator.userAgent.indexOf('ndroid')!=-1){return;}          
        	this.options = Object.extend({
        	
        	                   element: false,
        	                   onStuck:function(){},
        	                   onUnStuck:function(){} 
        	                   
        	                          }, arguments[0] || { });
        	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
                return;
            }                          
            this.element = this.options.element;
            this.offset = this.element.cumulativeOffset();
            this.width=this.options.element.getWidth();
            this.height=this.options.element.getHeight();
            if(typeof window.onscroll == "function"){
            this.oldonscroll =window.onscroll;
            }else{this.oldonscroll =function(){};}
            window.onscroll=function(){this.action();this.oldonscroll();}.bind(this);
        	return(this);              
        },
        action:function(){
            var pagescroll={top:((document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop),left:((document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft)};
	        if(pagescroll.top>=this.offset.top){
	        if( this.element.style.position=='fixed'){ return;}
	           this.element.toFront();
	          //console.warn(this.element);
	           this.element.style.position='fixed';
	           this.element.style.top="0px";
	           //this.element.style.width=this.width+"px";
	           this.element.style.height=this.height+"px";
	           this.element.style.boxShadow="0 3px 1em #000";
	           this.options.onStuck();
	        }
	        else
	        {
	        if( this.element.style.position==''){ return;}
	        this.element.style.position=this.element.style.boxShadow="";this.options.onUnStuck();
	        }
        }        
});
