$(document).ready(
	function() {
		$('#twitter-logo').hover(function(){ $(this).attr('src', 'img/social/logo-twitter.png'); }, function(){ $(this).attr('src', 'img/social/logo-twitter-gray.png'); });
		$('#facebook-logo').hover(function(){ $(this).attr('src', 'img/social/logo-facebook.png'); }, function(){ $(this).attr('src', 'img/social/logo-facebook-gray.png'); });

		$('#search-text').focus(function(){ $(this).animate({width: 200}, 200);  });
		$('#search-text').blur(function(){  $(this).animate({width: 120}, 200); });
		
		$(".clickable").bind("click", function() {
	        window.location = $(this).attr('data-url');
	    });
	    
	    
	    $(".image-loading img").hide();
	    
	    $('.image-loading img').load(function() {
			$(this).fadeIn('slow');
		});
		
		$("#show-contact-form").click(function() {
	        showContactForm();
	
	        return false;
	    });
		
		setTimeout('showLoadingImages()', 1500);
	}
);

function showLoadingImages(){
	//patch a bug...
	$('.image-loading img:hidden').fadeIn('slow');
}


function showContactForm(){
    $.fancybox({
        'padding'       : 0,
        'autoScale'     : true,
        'width'			: 650,
        'height'		: 650,
        'transitionIn'  : 'none',
        'transitionOut' : 'none',
        'autoDimensions': true,
        'title'         : this.title,
        'href'          : '/contact-us/form',
        'type'          : 'iframe',
        'overlayColor'	: '#000'
    });
}

(function($) {
  var cache = [];
  $.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)
