(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }       
	   
})(jQuery)

jQuery(document).ready(function() {
	Cufon.replace('#top ul li a, #banner .background .text h2, #banner .background .text .desc, #banner .background .text .tech ul li, #banner .background .link, #content .right h2, #content .right h3, #content .right .banners .banner h4, #content .right .text dt, #banners h2, #banners h3, #banners .text, .right .text, #footer, .contact_form label, div.info', {hover : true });
	$("#top ul li a").hover(
		function() {
			if ($(this).attr('class')!='') $("#"+$(this).attr('class')).show();
		},
		function () {
			if ($(this).attr('class')!='') $("#"+$(this).attr('class')).hide();
		}
	);
	
	$('#banners a').each(
		function() {
			jQuery.preLoadImages($(this).attr('rel'));
		}
	)		
	
	if ($('#banner .images .image').size()>1)
		{
			$('#banner .arrow_left, #banner .arrow_right').show();
			$('#banner').cycle({ 
				speed: 2000,
				timeout: 5000,
				fx:     'fade', 
				slideExpr: '.image',
				prev:   '#banner .arrow_left',
				next:   '#banner .arrow_right'
			});			
		}
	
	if ($('#banner .images .image .photo img').size()>1)
		{
			$('#banner .images .image .photo').cycle({ 
				speed: 2000,
				timeout: 4000,
				fx:     'fade', 
				slideExpr: 'img'
			});	
		}
	
	$('.contact_form').validate({
		errorPlacement: function(error, element) {
	    	error.appendTo(element.parent());
   		}
	});	

});
