(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);


$.preLoadImages('/assets/img/more_hover.gif', '/assets/img/map_minus.gif','/assets/img/tm_contact_a.gif','/assets/img/tm_customers_a.gif','/assets/img/tm_home_a.gif','/assets/img/tm_klienci_a.gif','/assets/img/tm_kontakt_a.gif','/assets/img/tm_oferta_a.gif','/assets/img/tm_offer_a.gif','/assets/img/wykop_ico_hover.gif','/assets/img/pl_a.gif','/assets/img/en_a.gif','/assets/img/sledzik_ico_hover.gif','/assets/img/facebook_ico_hover.gif','/assets/img/tm_praca_a.gif');
$(document).ready(function(){
	/*$('#himail').click(function(){
									$(this).attr('href','mailto:hi@boldmind.pl');
								});*/
/*
$('.sponsorFlip').bind("click",function(){

		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):

		var elem = $(this);

		// data('flipped') is a flag we set when we flip the element:

		if(elem.data('flipped'))
		{
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:

			elem.revertFlip();

			// Unsetting the flag:
			elem.data('flipped',false)
		}
		else
		{
			// Using the flip method defined by the plugin:

			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden
					// from view with display:none) into the clicked
					// .sponsorFlip div before the flipping animation starts:

					elem.html(elem.siblings('.sponsorData').html());
				}
			});

			// Setting the flag:
			elem.data('flipped',true);
		}
	});
*/
Cufon.replace('h1')('h2')('h3')('h4')('h5')('h6')('h7');Cufon.now();
$('#map_tree .more_less').next('a').css('font-weight','bold');
	$('#map_tree .more_less').toggle(function(){
										 
								  	$(this).removeClass('minus').addClass('plus').attr('src','/assets/img/more.gif').siblings('ul').slideUp('slow');

								  },function(){
									  $(this).removeClass('plus').addClass('minus').attr('src','/assets/img/map_minus.gif').siblings('ul').slideDown('slow');
								  });
	$('#map_tree .more_less').mouseover(function(){
												 	if($(this).hasClass('minus'))
																		{
																			$(this).attr('src','/assets/img/map_minus_hover.gif');
																		}
																		else
																		{
																			$(this).attr('src','/assets/img/more_hover.gif');
																		}
												 });
	$('#map_tree .more_less').mouseout(function(){
												 	if($(this).hasClass('minus'))
																		{
																			$(this).attr('src','/assets/img/map_minus.gif');
																		}
																		else
																		{
																			$(this).attr('src','/assets/img/more.gif');
																		}
										 });
	var mask_color = $('body').css('background-color');	
	$('#container_mask').css({'width':'100%','height':'100%','background-color':mask_color}).fadeOut(550);
		$('.error').each(function(){
		if($(this).text().length>0)
		{
			$(this).next('input').css('border','1px solid #f00');
			$(this).next('textarea').css('border','1px solid #f00');
		}
		else
		{
			$(this).next('input').css('border','1px solid #777');
			$(this).next('textarea').css('border','1px solid #777');
		}
	});		
});
