if (document.all && document.styleSheets && document.styleSheets[0] &&
document.styleSheets[0].addRule)
{
	document.styleSheets[0].addRule('*', 'behavior: url(media/iepngfix.htc)');
}
var voci = new Array("home", "chisiamo", "partner", "prodotti", "servizi", "nozze", "contatti", "News", "showroom", "convenzioni");

document.write("<div class=\"hide\"><img src=\"media/tasti2/chisiamo_up.jpg\"><img src=\"media/tasti2/showroom_up.jpg\"><img src=\"media/tasti2/servizi_up.jpg\"><img src=\"media/tasti2/prodotti_up.jpg\"><img src=\"media/tasti2/partner_up.jpg\"><img src=\"media/tasti2/lavori_up.jpg\"><img src=\"media/tasti2/home.jpg\"><img src=\"media/tasti2/contatti_up.jpg\"></div>");

function menuBuilt(pagina){
	var txt = "";
	if (pagina == "home") 
		txt = "Home Page";
	else 
		if (pagina == "chisiamo") 
			txt = "Chi Siamo"
		else 
			if (pagina == "partner") 
				txt = "Partners";
			else 
				if (pagina == "prodotti") 
					txt = "Prodotti";
				else 
					if (pagina == "servizi") 
						txt = "Servizi";
					else 
						if (pagina == "nozze") 
							txt = "Lista Nozze";
						else 
							if (pagina == "contatti") 
								txt = "Contatti";
							else 
								if (pagina == "news") 
									txt = "Le nostre news";
								else 
									if (pagina == "showroom") 
										txt = "Showroom";
									else 
										if (pagina == "catalogo") 
											txt = "Catalogo Mir";
										else 
											if (pagina == "convenzioni") 
												txt = "Le nostre convenzioni";
	
	document.title = "Gavillucci Arreda | " + txt;
	
	
	$('menuEls').innerHTML = "";
	if (pagina != "newsId") {
		if (pagina == false) 
			pagina = "home";
		for (i = 0; i < voci.length; i++) {
			path = "";
			if (pagina == voci[i]) 
				path = "_up";
			$('menuEls').innerHTML += "<li><a href=\"?page=" + voci[i] + "\" onclick=\"lPage('" + voci[i] + "'); return false;\"><img src=\"media/tasti2/" + voci[i] + path + ".png\" title=\"" + voci[i] + "\" /><strong>" + voci[i] + "</strong></a></li>";
		}
		
		$('menuEls').innerHTML += "<li><a href=\"javascript:;\" onclick=\"window.open('http://trovamobili.webmobili.it/Ricerca.aspx?idRivenditore=15286','','width=330,height=520,location=center,toolbar=no,menubar=no,scrollbars=no,resizable=no'); return false;\" target=\"_blank\"><img src=\"media/tasti2/trovaprodotti.png\" /><strong>Trovaprodotti</strong></a></li>";
	}
}

function lPage(pagina)
{
	var Rpagina = pagina;
	menuBuilt(pagina);

	new Effect.Fade(

		'body',
		{

			afterFinish: function()
			{

				if(pagina)
				{

					/*
					if(pagina == "home")
						$("body").style.backgroundImage = "url(bg.png)";
					else
						$("body").style.backgroundImage = "url(media/bg.png)";
					*/

					if(pagina == "home") {

						new Ajax.Updater(
							"body",
							"pages/body.php",
							{
								onComplete: function () {
									new Effect.Appear('body');
									$('body').style.backgroundImage="none";
									$('body').style.width="800px";
									$('body').style.left="-400px";
								}
							}
						);

					} else {

						$("body").style.backgroundImage = "url(media/bg.png)";

					}
										
					if(pagina != "showroom")
					{
						new Ajax.Updater(
							"body",
							"pages/"+pagina+".php",
							{
								onComplete: function () {
									new Effect.Appear('body');
									$('body').style.width="800px";
									$('body').style.left="-400px";
								}
							}
						);
					}
					else
					{
						new Ajax.Updater(
							"body",
							"pages/"+pagina+".php",
							{
								onComplete: function () {
									new Effect.Appear('body');
									$('body').style.width="1010px";
									$('body').style.left="-505px";
								}
							}
						);
					}
				}

				if(pagina == "chi_siamo" || pagina == "showroom" || pagina == "home" )
					rotazione = 1;
				else
				{
					if(rotazione == 1)
						rotazione = 2;
				}
			}
		}
	);
}

function cCol()
{
	if($j("#colums").text().length > 0)
	{
		multiColumnSettings=new MultiColumnSettings;
		multiColumnSettings.classNameScreen='screenContainer';
		multiColumnSettings.minHeight=70;
		multiColumnSettings.extraHeight=0;
		multiColumnSettings.numberOfColumns=2;

		new MultiColumn($('columns'),multiColumnSettings);
	}
}

function just(pagina)
{	
	new Effect.Fade(
		'body',
		{
			afterFinish: function()
			{
				new Ajax.Updater(
					"body",
					"pages/"+pagina,
					{
						onComplete: function() {
							new Effect.Appear('body', {
											  //afterFinish: cCol,
											  afterSetup: cCol
											  });
						}
					}
				);
			}
		}
	);
}

function offerte(id)
{
	new Effect.Fade(
		'body',
		{
			afterFinish: function()
			{
				new Ajax.Updater(
					"body",
					"pages/offerte.php?id="+id,
					{
						onComplete: function() {
							new Effect.Appear('body');
						}
					}
				);
			}
		}
	);
}


function init()
{
	new Effect.Fade("loader", {queue: 'front'});
	new Effect.Appear('all', { queue: 'end' });
	new Effect.Appear('header', {queue: 'end'});
	var isIE = (navigator.appName=="Microsoft Internet Explorer");
	var IEversion = navigator.appVersion;
	if(isIE)
	{
		var size = window.top.document.body.offsetHeight;		
		$('footer').style.top = size-25+"px";
		$('mir').style.top = size-65+"px";
		
		document.body.onresize = function (){
			var size = window.top.document.body.offsetHeight;
			$('mir').style.top = size-25+"px";
			$('footer').style.top = size-65+"px";
		}		
	}
	else
	{
		$('footer').style.position = "fixed";
		$('footer').style.width = "80%";
		$('footer').style.bottom = "5px";
		
		$('mir').style.position = "fixed";
		$('mir').style.width = "80%";
		$('mir').style.padding = "5px";
		$('mir').style.textAlign = "right";
		$('mir').style.bottom = "5px";
	}

	$('slide-images').style.display = "none";
	var lis = $('slide-images').getElementsByTagName('li');

	for( i=0; i < lis.length; i++){
		if(i!=0){
			lis[i].style.display = 'none';
		}
	}
	end_frame = lis.length -1;
	
	start_slideshow(start_frame, end_frame, delay, lis);
	lPage("home");
	//$("body").style.backgroundImage = "none";
	musicPlay('media/musica/1.mp3');	
}

Event.observe(window, 'load', init, false);

function addMessage() {
	new Ajax.Updater( 'res', 'pages/send.php', { method: 'post',
					  parameters: $('messaggio').serialize() } );
	$('messaggio').reset();
}

function musicPlay(canzone)
{
	Sound.play(canzone,{replace:true});
}

function musicOff()
{
	$('player').innerHTML = "<a href=\"#\" onClick=\"musicOn();\"><img src=\"media/imgs/play.png\" /></a>";
	Sound.enable();
	Sound.play('',{replace:true});
	Sound.disable();
}

function musicOn()
{
	$('player').innerHTML = "<a href=\"#\" onClick=\"musicOff();\"><img src=\"media/imgs/stop.png\" /></a>";
	Sound.enable();
	musicPlay('media/musica/3.mp3');
}

function checkForm() {
	pass = $j("input#password").val();

	if(pass.length > 0)
		just('nozze.php?password=' + pass);
	else
		alert("Devi inserire una password!");
}

function changeScheda(scheda, totale) {
	
	for(i = 0; i < totale; i++)
	{
		if(i != scheda)
		{
			if($j.browser.msie)
			{
				$j("table#scheda_" + i).hide();
			}
			else {
				$j("table#scheda_" + i).slideUp();
			}
		}
	}
	
	if($j.browser.msie)
	{
		$j("table#scheda_" + scheda).show();
	}
	else {
		$j("table#scheda_" + scheda).slideDown();
	}
}

function foto(url)
{
	$j("body").prepend('<div id="foto" style="display: none; position: absolute; z-index: 9999; padding: 5px; background-color: black"><img src="' + url + '" /></div>');
	$j("div#foto").click(function () {
			$j("div#foto").fadeOut(function () {
				$j("div#foto").remove();
			}); 
		}
	);
	larghezza = document.documentElement.offsetWidth;
	altezza = document.documentElement.offsetHeight;
	
	$j("div#foto img").load(function () {
		altezzaFoto = $j("div#foto").height();
		larghezzaFoto = $j("div#foto").width();
		$j("div#foto").css("cursor", "pointer");
		$j("div#foto").css("left", parseInt(((larghezza-larghezzaFoto)/2).ceil()));
		$j("div#foto").css("top", parseInt(((altezza-altezzaFoto)/2).ceil()));		
		
		$j("div#foto").fadeIn();
	});
}