google.load("jquery", "1.4");
google.setOnLoadCallback(function() {
    if(jQuery)(function($) {
	$('#hcont nav li').each(function(i, el) {
	    $(el).addClass('nav_'+i);
	});
	$('#lcol nav a').each(function(i, el) {
	    linkarray = $(el).attr('href').split('/');
	    last = $(linkarray).last()[0];
	    if(!$(el).hasClass('noanchor')) {
	    $(el).attr('href', '#unq_' + last);
	    }
	});

       if(window.location.hash) {
       var easing='swing';
       var duration=1000;
       var target=$(window.location.hash).offset().top - 150;
      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {
      });
      }


	$('#container a[href*=#]').click(function() {

	   // duration in ms
	   var duration=1000;

	   // easing values: swing | linear
	   var easing='swing';

	   // get / set parameters
	   var newHash=this.hash;
	   var target=$(this.hash).offset().top - 150;
	   var oldLocation=window.location.href.replace(window.location.hash, '');
	   var newLocation=this;

	   // make sure it's the same location      
	   if(oldLocation+newHash==newLocation) {
	      // animate to target and set the hash to the window.location after the animation
	      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

		 // add new hash to the browser location
		 //window.location.href=newLocation;
	      });
	      // cancel default click action
	      return false;
	   }
	});
	//home page image rotation:
	var limages = ['/img/solutions.png', '/img/experiences.png', '/img/products.png'];
	var rimages = ['/img/piechart.jpg', '/img/surf.jpg', '/img/chairs.jpg'];
	count = 0;
	loop = 0;

	function switchImage() {
	    if(count >= limages.length) count = 0;
	    $('#limage, #rimage').fadeTo(1000, 0.01, function() {
	    });
	    setTimeout(function() {
		$('#limage').attr('src', limages[count]);
		$('#rimage').attr('src', rimages[count]);
		$('#limage, #rimage').fadeTo(1000, 1, function() {
		});
		count = count + 1;
		if(loop >= 25) {
		 clearInterval(myInterval);
		}
	    }, 1500);
	}

	var myInterval = setInterval(function() {
	    loop++;
	    switchImage();
	}, 4 * 1000);

	(function($) {
	  var cache = [];
	  // Arguments are image paths relative to the current page.
	  $.preLoadImages = function() {
	    var args_len = arguments[0].length;
	    for (var i = args_len; i--;) {
	      var cacheImage = document.createElement('img');
	      cacheImage.src = arguments[0][i];
	      cache.push(cacheImage);
	    }
	  }
	})(jQuery)

        $.preLoadImages(limages);
        $.preLoadImages(rimages);



    })(jQuery);
});

