// Editing Instructions
// 1. Change '#your_div_id' to whatever the ID attribute of your DIV is
// 2. Change '175' to whatever the height of your header is, if you have no header, set to 0
/********************************
*   (C) 2009 - Thiago Barbedo   *
*   - tbarbedo@gmail.com        *
*********************************/

$(document).ready(function() {
	if (((document.documentElement.clientWidth-750)/2) < -25 ){
		//$('#menu_float').css('left',-25);
	} else  {
		$('#menu_float').css('left',((document.documentElement.clientWidth-750)/2));
	}

	$(window).scroll(function() {

		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
							  
		if (scrOfY > 35) {
			//alert($('#menu_float').pageYOffset + 5);
			$('#menu_float').stop(true, false).delay(3000).animate( { top:scrOfY + 5 }, { queue:false, duration:1000} )
			//$('#menu_float').css('top', self.pageYOffset + 5);
		} else if (scrOfY < 35) {
			$('#menu_float').stop(true, false).delay(3000).animate( { top: 75 - scrOfY}, { queue:false, duration:1000} )
		}
				
		if (((document.documentElement.clientWidth-750)/2) < -25 ){
			$('#menu_float').css('left',-25);
		} else  {
			$('#menu_float').css('left',((document.documentElement.clientWidth-750)/2));
		}

            
   
	});

	$(window).resize(function() {
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
							  
		if (scrOfY > 35) {
			//alert($('#menu_float').pageYOffset + 5);
			$('#menu_float').stop(true, false).delay(3000).animate( { top:scrOfY + 5 }, { queue:false, duration:1000} )
			//$('#menu_float').css('top', self.pageYOffset + 5);
		} else if (scrOfY < 35) {
			$('#menu_float').stop(true, false).delay(3000).animate( { top: 75 - scrOfY}, { queue:false, duration:1000} )
		}
				
		if (((document.documentElement.clientWidth-750)/2) < -25 ){
			$('#menu_float').css('left',-25);
		} else  {
			$('#menu_float').css('left',((document.documentElement.clientWidth-750)/2));
		}
	

            
            
      
	});

});



/*
window.onscroll = function()
{
    if( window.XMLHttpRequest ) {
        if (document.documentElement.scrollTop > 175 || self.pageYOffset > 175) {
            $('#menu_float').css('position','fixed');
            $('#menu_float').css('top','0');
        } else if (document.documentElement.scrollTop < 175 || self.pageYOffset < 175) {
            $('#menu_float').css('position','absolute');
            $('#menu_float').css('top','375px');
        }
    }
}*/
