var screenH = 0;
var screenW = 0;

var footTop = 0;
var size = 0;

var activeDiv = "home";
var page = 1;
var inspiredPage = 1;
var redPage = 1;

window.onresize = function (evt) {

 	setElementsSizeAndPosition();
};

function init()
{

  setElementsSizeAndPosition();
  
  var home = $('home').setStyles({
		display:'block',
		opacity: 1
	});
  
  var page_01 = $('page_01').setStyles({
		display:'none',
		opacity: 0
	});
  
	var page_02 = $('page_02').setStyles({
		display:'none',
		opacity: 0
	});
	
	var page_02 = $('page_02_b').setStyles({
		display:'none',
		opacity: 0
	});
	
	var page_03 = $('page_03').setStyles({
		display:'none',
		opacity: 0
	});
	
	var page_04 = $('page_04').setStyles({
		display:'none',
		opacity: 0
	});
	
	var page_05 = $('page_05').setStyles({
		display:'none',
		opacity: 0
	});
	
	var shoes_detail = $('shoes_detail').setStyles({
		display:'none',
		opacity: 0
	});

	var shoes_inspired_detail = $('inspired_shoes_detail').setStyles({
		display:'none',
		opacity: 0
	});
	
	var shoes_red_detail = $('red_shoes_detail').setStyles({
		display:'none',
		opacity: 0
	});
	
	var blank = $('blank').setStyles({
		display:'none',
		opacity: 0
	});

	//setTimeout("show('about')",500) 
}

var aShoeDescription = new Array();
aShoeDescription[0] = "Modelli";
aShoeDescription[1] = "<b>Gold</b> - raso - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[2] = "<b>Violet</b> - camoscio - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[3] = "<b>Preview 2010 - France 3</b> - camoscio/vernice - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[4] = "<b>France black</b> - pelle/tessuto - tacco 11 cm (disponibile anche 9 cm";
aShoeDescription[5] = "<b>France bordeaux</b> - camoscio/vernice - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[6] = "<b>Rome</b> - raso - swarovski - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[7] = "<b>Canvas 2</b> - pelle/tessuto - tacco 11 cm (disponibile anche 9 cm)";
aShoeDescription[8] = "<b>Flat canvas</b> - pelle/tessuto - tacco 1 cm";

function showShoesDetail(n)
{

		var divFO = $('page_02');
		var divFI = $('shoes_detail').setStyle('display', 'block');
		var bg1 = 'url(images/my0'+n+'.jpg)';
		var bg2 = 'url(images/my0'+n+'_b.jpg)';
		
		var img_01 = $('img_01');
		var img_02 = $('img_02');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);

		var shoeDetailDescription = document.getElementById('shoes_detail_text');
		shoeDetailDescription.innerHTML = aShoeDescription[n];
		
		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
		activeDiv = 'shoes_detail';
	
}

function switchShoesDetail(n)
{

		var bg1 = 'url(images/my0'+n+'.jpg)';
		var bg2 = 'url(images/my0'+n+'_b.jpg)';

		var img_01 = $('img_01');
		var img_02 = $('img_02');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);
		
		var shoeDetailDescription = document.getElementById('shoes_detail_text');
		shoeDetailDescription.innerHTML = aShoeDescription[n];
		
		page = 1;
		showProductPage(page);
}

var inpiredShoesDescription = new Array();
inpiredShoesDescription[0] = "Modelli a tema";
inpiredShoesDescription[1] = "<b>Modelli a tema</b>: Ispirato al brano &#34;Le Onde&#34; di Ludovico Einaudi";

function showInpiredShoesDetail(n)
{

		var divFO = $('page_02');
		var divFI = $('inspired_shoes_detail').setStyle('display', 'block');
		var bg1 = 'url(images/my_inspired'+n+'.jpg)';
		var bg2 = 'url(images/my_inspired'+n+'_b.jpg)';

		var img_01 = $('img_01_inspired');
		var img_02 = $('img_02_inspired');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);
		
		var inspiredDescription = document.getElementById('inspired_shoes_detail_text');
		inspiredDescription.innerHTML = inpiredShoesDescription[n];
		
		
		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
		activeDiv = 'inspired_shoes_detail';
	
}

function switchInspiredShoesDetail(n)
{

		var bg1 = 'url(images/my_inspired'+n+'.jpg)';
		var bg2 = 'url(images/my_inspired'+n+'_b.jpg)';

		var img_01 = $('img_01_inspired');
		var img_02 = $('img_02_inspired');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);
		
		var inspiredDescription = document.getElementById('inspired_shoes_detail_text');
		inspiredDescription.innerHTML = inpiredShoesDescription[n];
		
		inspiredPage = 1;
		showInspiredProductPage(inspiredPage);
}

var redShoesDescription = new Array();
redShoesDescription[0] = "Modelli a tema";
redShoesDescription[1] = "<b>Rings</b> - raso - tacco 11 cm (disponibile anche 9 cm)";
redShoesDescription[2] = "<b>Red passion</b> - pelle - tacco 11 cm (disponibile anche 9 cm)";
redShoesDescription[3] = "<b>Red passion</b> - pelle - tacco 11 cm (disponibile anche 9 cm)";
redShoesDescription[4] = "<b>Red passion</b> - pelle - tacco 11 cm (disponibile anche 9 cm)";

function showRedShoesDetail(n)
{

		var divFO = $('page_02');
		var divFI = $('red_shoes_detail').setStyle('display', 'block');
		var bg1 = 'url(images/my_red'+n+'.jpg)';
		var bg2 = 'url(images/my_red'+n+'_b.jpg)';

		var img_01 = $('img_01_red');
		var img_02 = $('img_02_red');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);
		
		var redDescription = document.getElementById('red_shoes_detail_text');
		redDescription.innerHTML = redShoesDescription[n];
		
		
		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
		activeDiv = 'red_shoes_detail';
	
}

function switchRedShoesDetail(n)
{

		var bg1 = 'url(images/my_red'+n+'.jpg)';
		var bg2 = 'url(images/my_red'+n+'_b.jpg)';

		var img_01 = $('img_01_red');
		var img_02 = $('img_02_red');
		img_01.setStyle('background', bg1);
		img_02.setStyle('background', bg2);
		
		var redDescription = document.getElementById('red_shoes_detail_text');
		redDescription.innerHTML = redShoesDescription[n];
		
		redPage = 1;
		showRedProductPage(redPage);
}

function backToShoesList()
{


		var divFO = $('shoes_detail');
		var divFI = $('page_02').setStyle('display', 'block');

		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
activeDiv = 'page_02';
	
}

function show(selectedDiv)
{
	var divIn = selectedDiv;
	
	if (selectedDiv != activeDiv)
	{
		
	
		var divFO = $(activeDiv);
		var divFI = $('blank').setStyle('display', 'block');

		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
		
		setTimeout("fadeIn('"+divIn+"')",1100);

		//activeDiv = selectedDiv;
	}
	
}

function fadeIn(divIn)
{
	var divFO = $('blank');
		var divFI = $(divIn).setStyle('display', 'block');

		var fadeOut = new Fx.Morph(divFO, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
		var fadeIn = new Fx.Morph(divFI, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
    	'opacity': [1, 0]
		});
	
		fadeIn.start({
    	'opacity': [0, 1]
		});
		activeDiv = divIn;
}


function getScreenSize()
{
 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    screenH = window.innerHeight;
    screenW = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+
    screenH = document.documentElement.clientHeight;
    screenW = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4
    screenH = document.body.clientHeight;
    screenW = document.body.clientWidth;
  }
}

function setElementsSizeAndPosition()
{
	getScreenSize();
	var container = $('container');
  container.setStyle('top', ((screenH/2)-300));
  container.setStyle('left', ((screenW/2)-350));


//	var blank = $('blank');
//	blank.setStyle('height', (screenH-50));
}

function prevClick()
{

 if (page != 1)
 {
 	var id = page -1;
 	showProductPage(id);
 	page = id;
 }
 
}

function nextClick()
{

	if (page != 2)
	 {
	 	var id = page +1;
	 	showProductPage(id);
	 	page = id;
	 }
}

function showProductPage(id)
{
	var node = "img_0"+id;
	var scrollExample = new Fx.Scroll($('nav_parent_container'), {duration: '1000', transition: Fx.Transitions.Back.easeOut});
	scrollExample.toElement(node);

}

function prevClickInspired()
{

 if (inspiredPage != 1)
 {
 	var id = inspiredPage -1;
 	showInspiredProductPage(id);
 	inspiredPage = id;
 }
 
}

function nextClickInspired()
{

	if (inspiredPage != 2)
	 {
	 	var id = inspiredPage +1;
	 	showInspiredProductPage(id);
	 	inspiredPage = id;
	 }
}

function showInspiredProductPage(id)
{
	var node = "img_0"+id+"_inspired";
	var scrollExample = new Fx.Scroll($('nav_parent_container_inspired'), {duration: '1000', transition: Fx.Transitions.Back.easeOut});
	scrollExample.toElement(node);

}
function prevClickRed()
{

 if (redPage != 1)
 {
 	var id = redPage -1;
 	showRedProductPage(id);
 	redPage = id;
 }
 
}

function nextClickRed()
{

	if (redPage != 4)
	 {
	 	var id = redPage +1;
	 	showRedProductPage(id);
	 	redPage = id;
	 }
}

function showRedProductPage(id)
{
	var node = "img_0"+id+"_red";
	var scrollExample = new Fx.Scroll($('nav_parent_container_red'), {duration: '1000', transition: Fx.Transitions.Back.easeOut});
	scrollExample.toElement(node);

}

var flagSubVisibile = 0;
var myInt;

function showSubCollezione(){
	if (flagSubVisibile == 0){
		var sc = $('sub_collezione');
		sc.setStyle('display', 'block');
		var fadeIn = new Fx.Morph(sc, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeIn.start({
			'opacity': [0, 1]
		});
		
		myInt=setInterval('hideSubCollezione()',3000);
	}
}

function hideSubCollezione(){
	if(flagSubVisibile == 0){
		clearInterval(myInt);
		var sc = $('sub_collezione');
		
		var fadeOut = new Fx.Morph(sc, {duration: '1000', transition: Fx.Transitions.Sine.easeOut});

		fadeOut.start({
			'opacity': [1, 0]
		});
		
		sc.setStyle('display', 'none');
	}	
	
}

function setTo1(){
	flagSubVisibile = 1;
}

function setTo0(){
	flagSubVisibile = 0;
}
