function cursorHand(){
	document.body.style.cursor = 'pointer';
}
function cursorOrig(){
	document.body.style.cursor = 'default';
}
function showTextpane(showtype){
	switch(showtype)
	{
	case 'portfolio':
		new Effect.Fade(document.getElementById('page'),
			{
				duration: 1.0,
				to: 0.65,
				afterFinish : function(obj) {
					new Effect.Appear(document.getElementById('TextPane'), { duration: 1.0, to: 0.88 });
					document.getElementById('navText').style.background='url(images/navPortfolio.png)';
					new Effect.Appear(document.getElementById('navText'), { duration: 1.0, to: 0.88 });
				}
			});
		break;
	case 'gallery':
		new Effect.Fade(document.getElementById('page'),
			{
				duration: 1.0,
				to: 0.65,
				afterFinish : function(obj) {
					new Effect.Appear(document.getElementById('TextPane'), { duration: 1.0, to: 0.88 });
					document.getElementById('navText').style.background='url(images/navGallery.png)';
					new Effect.Appear(document.getElementById('navText'), { duration: 1.0, to: 0.88 });
				}
			});
		break;
	case 'contact':
		//document.getElementById('TextPane').innerHTML = '<img src="images/contact2.jpg">';
		new Effect.Fade(document.getElementById('page'),
			{
				duration: 1.0,
				to: 0.65,
				afterFinish : function(obj) {
					new Effect.Appear(document.getElementById('TextPane'), { duration: 1.0, to: 0.88 });
					document.getElementById('navText').style.background='url(images/navContact.png)';
					new Effect.Appear(document.getElementById('navText'), { duration: 1.0, to: 0.88 });
				}
			});
		/*new Effect.Appear(document.getElementById('alert'),
			{
				duration: 1.0,
				to: 0.65,
				afterFinish : function(obj) {
					new Effect.Appear(document.getElementById('TextPane'), { duration: 1.0, to: 0.88 });
				}
			});*/
		break;
	default:
	}
}


/********************/
/***** PAGES FX *****/
/********************/

function showHome(){
	//clearTextpane('portfolio');
	if (document.getElementById('TextPane').style.display != "none")
	{
		new Effect.Opacity( document.getElementById('navText'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('navText').style.display = 'none';
			}
		 } );
		 new Effect.Opacity( document.getElementById('TextPane'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('TextPane').style.display = 'none';
				fillHome();
			}
		 } );
	} else {
		fillHome();
	}
}
function fillHome(){
	new Effect.Opacity( document.getElementById('page'),
		 {
			duration: 0.25,
			from : 1.0,
			to : 0.0,
			afterFinish : function(obj) {
				//document.getElementById('logoText').style.display = 'block';
				randomizeImages('home');
				new Effect.Opacity(document.getElementById('page'), { duration: 1.2, from : 0.0, to : 1.0 } );
				new Effect.Appear(document.getElementById('logoText'), {duration: 1.2, from : 0.0, to : 1.0});
			}
	 } );
}
function showPortfolio(){
	//clearTextpane('portfolio');
	if (document.getElementById('TextPane').style.display != "none")
	{
		new Effect.Opacity( document.getElementById('navText'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('navText').style.display = 'none';
			}
		 } );
		new Effect.Opacity( document.getElementById('TextPane'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('TextPane').style.display = 'none';
				fillPortfolio();
			}
		 } );
	} else {
		fillPortfolio();
	}
}
function fillPortfolio(){
	new Effect.Opacity( document.getElementById('page'),
		 {
			duration: 0.25,
			from : 0.65,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('logoText').style.display = 'none';
				randomizeImages('portfolio');
				new Effect.Opacity(document.getElementById('page'), {
					duration: 1.5,
					from : 0.0,
					to : 1.0,
					afterFinish : function(obj) {
						showTextpane('portfolio');
					}
				} );
			}
	 } );
}

function showGallery(){
	//clearTextpane('portfolio');
	if (document.getElementById('TextPane').style.display != "none")
	{
		new Effect.Opacity( document.getElementById('navText'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('navText').style.display = 'none';
			}
		 } );
		 new Effect.Opacity( document.getElementById('TextPane'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('TextPane').style.display = 'none';
				fillGallery();
			}
		 } );
	} else {
		fillGallery();
	}
}
function fillGallery(){
	new Effect.Opacity( document.getElementById('page'),
		 {
			duration: 0.25,
			from : 1.0,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('logoText').style.display = 'none';
				randomizeImages('gallery');
				new Effect.Opacity(document.getElementById('page'), {
					duration: 1.5,
					from : 0.0,
					to : 1.0,
					afterFinish : function(obj) {
						showTextpane('gallery');
					}
				} );
			}
	 } );
}

function showContact(){
	//clearTextpane('portfolio');
	if (document.getElementById('TextPane').style.display != "none")
	{
		new Effect.Opacity( document.getElementById('navText'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('navText').style.display = 'none';
			}
		 } );
		 new Effect.Opacity( document.getElementById('TextPane'),
		 {
			duration: 0.5,
			from : 0.88,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('TextPane').style.display = 'none';
				fillContact();
			}
		 } );
	} else {
		fillContact();
	}
}
function fillContact(){
	new Effect.Opacity( document.getElementById('page'),
		 {
			duration: 0.25,
			from : 1.0,
			to : 0.0,
			afterFinish : function(obj) {
				document.getElementById('logoText').style.display = 'none';
				randomizeImages('contact');
				new Effect.Opacity(document.getElementById('page'), {
					duration: 1.5,
					from : 0.0,
					to : 1.0,
					afterFinish : function(obj) {
						showTextpane('contact');
					}
				} );
			}
	 } );
}




// end autoplay
function init() {
	randomizeImages('home');
	//new Effect.Appear(document.getElementById('page'), {duration: 1.2, from : 0.0, to : 1.0});
	new Effect.Appear(document.getElementById('page'), {
		duration: 1.2,
		from : 0.0,
		to : 1.0,
		afterFinish : function(obj) {
			new Effect.Appear(document.getElementById('logoText'), {duration: 1.2, from : 0.0, to : 1.0});
			new Effect.Appear(document.getElementById('dockdiv1'), {duration: .6, from : 0.0, to : 1.0});
			new Effect.Appear(document.getElementById('dockdiv2'), {duration: .6, from : 0.0, to : 1.0});
			new Effect.Appear(document.getElementById('dockdiv3'), {duration: .6, from : 0.0, to : 1.0});
			new Effect.Appear(document.getElementById('dockdiv4'), {duration: .6, from : 0.0, to : 1.0});
		}
	});
}

function randomizeImages(sPage) {
	var rndImage1 = ([Math.round(Math.random()*2)+1])
	var rndImage2 = ([Math.round(Math.random()*2)+1])
	var rndImage3 = ([Math.round(Math.random()*2)+1])
	var rndImage4 = ([Math.round(Math.random()*2)+1])
	
	switch (sPage)
	{
		case 'home':
			var section = 'a';
			var pageImage = rndImage1
			break;
		case 'portfolio':
			var section = 'b';
			var pageImage = rndImage2
			break;
		case 'gallery':
			var section = 'd';
			var pageImage = rndImage3
			break;
		case 'contact':
			var section = 'c';
			var pageImage = rndImage4
			break;
		default:
			var section = 'a';
			var pageImage = rndImage1
			break;
	}

	document.getElementById('page').style.background='url(images/envila-' + section + '0' + pageImage + '.jpg)';
	document.images['dockImage1'].src= 'images/envila-a0' + rndImage1 + '_sm.png';
	document.images['dockImage2'].src= 'images/envila-b0' + rndImage2 + '_sm.png';
	document.images['dockImage3'].src= 'images/envila-d0' + rndImage3 + '_sm.png';
	document.images['dockImage4'].src= 'images/envila-c0' + rndImage4 + '_sm.png';
}

//window.onresize = handleResize;
window.onload = init;