jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
  	
    jQuery("<img>").attr("src", arguments[i]);         
   
  }


}

$(document).ready(function() {
	

	

	$("a#single_1").fancybox();
		
	$("a#single_21").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	$("a#single_22").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	$("a#single_23").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	$("a#single_24").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	$("a#single_25").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	$("a#single_3").fancybox({
			'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'				: 601,
		'frameHeight'				: 423,
		'padding'						: 0,
		'hideOnContentClick': false
	});
	
	$("a.group").fancybox({
		'hideOnContentClick': false
	});

 // $("#fancy_loading").show();
 /* $.preloadImages("img/monitor.png","img/tit_formazione.png","img/tit_comunicazione.png","img/tit_progettazione.png","img/tit_ufficiostampa.png", 
                   "img/tit_organizzazione.png","img/tit_identita.png","img/tit_attivita.png","img/tit_dicono_di_noi.png","img/tit_portfolio.png","img/tit_contatti.png",
                   "img/background-identita.png","img/background-attivita.png","img/background-portfolio.png","img/background-contatti.png");*/
  //$(".fancy_loading").hide();  

$("#footer div.button").click(function(){

	$clicked = $(this);
	

		// each button div MUST have a "xx-button" and the target div must have an id "xx"
		var idToLoad = $clicked.attr("id").split('-');
     
		//we search trough the content for the visible div and we fade it out
		$("#container").find("div:visible").fadeOut("fast", function(){
			//once the fade out is completed, we start to fade in the right div
			
      //$(this).parent().find("#"+idToLoad[0]).backgroundImage = 'url(img/bakground-'+idToLoad[0]+'.png)';
			//$(this).parent().find("#"+idToLoad[0]).fadeIn();
			//$(this).parent().find("#titolo_"+idToLoad[0]).backgroundImage = 'url(img/titolo_-'+idToLoad[0]+'.png)';
			//$(this).parent().find("#titolo_"+idToLoad[0]).fadeIn();
		 
		  
			if (idToLoad[0]=='content') {$(this).parent().find("#"+idToLoad[0]).fadeIn();}
			else{
				  
			var testo='';
		  $(this).parent().find(".blocklink").fadeOut();			
			switch (idToLoad[0]){
							case 'identita': 
							 $(this).parent().find("#testo_identita").fadeIn();						
							break;
							case 'attivita':
							 //$(this).parent().find("#testo_attivita").fadeIn();									
							break;
							case 'dicono_di_noi':
							break;
							case 'portfolio':
								break;
							case 'contatti':
							//testo="<p><span class='arancio'>BS Eventi</span> sar&agrave; lieta di rispondere alle vostre esigenze, contattateci.</p><p>&nbsp;</p><p><table width='100%' border='0' cellspacing='5' cellpadding='5'>  <tr>    <td width='8%'><img src='img/icona_tel.gif' width='68' height='96' /></td>    <td width='92%'>Tel. +39 0735  595015 <br />Fax +39 0735 595240</td>  </tr> <tr>    <td width='8%'><img src='img/icona_mail.png' width='54' height='38' /></td>    <td width='92%'>Scriveteci.</td>  </tr></table></p><p>&nbsp;</p><p>Bs Eventi Via L. Manara, 134<br />  63039 San Benedetto del Tronto (AP)</p>";
							 //$('#testo_contatti').html(testo);
							  $(this).parent().find(".blocklink").fadeIn();			
							 $(this).parent().find("#testo_contatti").fadeIn();		
							break;
							default : testo='';
				}
				$('#pagina').css({ backgroundImage : 'url(img/background-'+idToLoad[0]+'.png)'});
		      $('#titolo').css({ backgroundImage : 'url(img/tit_'+idToLoad[0]+'.png)'});
		      
					$(this).parent().find("#pagina").fadeIn();			
					$(this).parent().find("#titolo").fadeIn();

		  }
		})
	


//BS Eventi  &egrave; un&rsquo;affermata agenzia di comunicazione integrata e organizzazione eventi,  attiva anche nel settore delle relazioni pubbliche e della formazione  personale.

});
 //$('#content').jScale({w:'60%'})
});
