// jQuery SmoothScroll | Version 11-06-11

$(document).ready(function() {
	
	
	$('.valv_close').click(function() {
		$(this).css('cursor','pointer');
		$.unblockUI(); 
	});

	$('.product_valv').click(function() {
		$.blockUI({ 
			message: $('#product_valv_popup_'+$(this).attr('id')),
			css: { border:'0', width: '800px', margin: '-240px 0 0 -150px', cursor: 'arrow'  },
			overlayCSS: {cursor: 'pointer'}
		}); 
		$('.blockOverlay').attr('title', 'Click to unblock').click($.unblockUI); 
		
	});
	
	
	
	
	// smooth scrolling
   $('a[href*=#]').click(function() {



      // skip SmoothScroll on links inside sliders or scroll boxes also using anchors or if there is a javascript call

      if($(this).parent().attr('class')=='scrollable_navigation' || $(this).attr('href').indexOf('javascript')>-1) return;



      // duration in ms

      var duration=1000;

	  var offset = -190;

      // easing values: swing | linear

      var easing='swing';



      // get / set parameters

      var newHash=this.hash;

      var oldLocation=window.location.href.replace(window.location.hash, '');

      var newLocation=this;



      // make sure it's the same location      

      if(oldLocation+newHash==newLocation)

      {

         // get target

         var target=$(this.hash+', a[name='+this.hash.slice(1)+']').offset().top + offset;



         // adjust target for anchors near the bottom of the page

         if(target > $(document).height()-$(window).height()) target=$(document).height()-$(window).height();         



         // set selector

         if($.browser.safari) var animationSelector='body:not(:animated)';

         else var animationSelector='html:not(:animated)';



         // animate to target and set the hash to the window.location after the animation

         $(animationSelector).animate({ scrollTop: target }, duration, easing, function() {



            // add new hash to the browser location
			// exiang: need to disabloe this due to the stupid fixed menu
            //window.location.href=newLocation;
            //window.location.hash=newHash;
			 

         });



         // cancel default click action

         return false;

      }

   });



});
