var isImageGalleryMode = false;

/* CSS CHANGES */
document.write('<style type="text/css"> ');
document.write('#vida_side_photo, #vida_side_photo_fg, #vida_side_photo2, #vida_side_photo2_fg { display:none; } ');
if (vidaFirstLoad) {
//	document.write('#vida_nav_top { display:none; } ');
//	document.write('#vida_nav_side { display:none; } ');
	document.write('#vida_scraps { display:none; } ');
	document.write('#vida_screen { display:block; } ');
	document.write('html { overflow-y:hidden;} ');
}
document.write('</style> ');

/* OPACITY CODE */
function setOpacity(object,value) {
	object.style.opacity = value/10;
	object.style.filter = 'alpha(opacity=' + value*10 + ')';
}

/* RANDOM CODE */
function rand ( n ) {
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

/* INIT CODE */
function develop(step,el) {
	p = document.getElementById(el);
	setOpacity(p,step);
	if (step < 10 ) setTimeout( 'develop('+(step+rand(2)/8)+',"'+el+'")' , 100);
}
function slideLeftPhotosIn(step,photoNum) {	
	p = document.getElementById('vida_side_photo'+photoNum);
	pp = document.getElementById('vida_side_photo'+photoNum+'_fg');
	
	x = p.style.left; y = p.style.top;
	
	if ( parseInt(x) < 18 ) {
		p.style.left = pp.style.left = parseInt(x)+25+'px';
		if ( photoNum == 2) {
			jj = 75;
			ii = 5;
		} else {
			jj = 56;
			ii = 4;
		}
		p.style.top = pp.style.top = parseInt(y)+(jj-ii*step)+'px';
	    setTimeout('slideLeftPhotosIn('+(step+1)+',"'+photoNum+'")',5);
	} else {
		setTimeout( 'develop(0,"vida_side_photo'+photoNum+'_contents")' , 250);
	}
}
function initializePhoto(photoNum,top) {
	p = document.getElementById('vida_side_photo'+photoNum);
	pp = document.getElementById('vida_side_photo'+photoNum+'_fg');
	p.style.left = pp.style.left = '-382px';
	p.style.top = pp.style.top = '-200px';
	setOpacity(document.getElementById('vida_side_photo'+photoNum+'_contents'),0);
	p.style.display = pp.style.display = 'block';
    setTimeout('slideLeftPhotosIn(1,"'+photoNum+'")',1500+rand(250) );
}
function fadein(elid,level) {
	el = document.getElementById(elid);
	setOpacity(el,level);
	el.style.display = 'block';
	if (level <= 10) {
		setOpacity(el,level);
		setTimeout( 'fadein("'+el.id+'",'+(level+1)+')',100);
	} else {
		setOpacity(el,10);
	}
}
function fadeout(elid,level) {
	el = document.getElementById(elid);
	setOpacity(el,level);
	if (level > 0 ) {
		setOpacity(el,level);
		setTimeout( 'fadeout("'+el.id+'",'+(level-1)+')',50);
	} else {
		setOpacity(el,0);
		el.style.display = 'none';
	}
}
function doThisOnLoad() {
	//this used to fix an IE background issue and add an issue in FF that caused the BG below the text to be displaced when the width of the window was too narrow.
	//now, both problems seem fixed without this line.
	//document.getElementById('vida_static_bg').style.height = document.getElementById('vida_main_content').offsetHeight+200+'px';
	
	if (vidaFirstLoad) {
		document.getElementsByTagName("html")[0].style.overflowY='hidden';
		document.getElementById('vida_scraps').style.display = 'block';
		if (document.getElementById('vida_main_content').offsetHeight+200 > document.body.offsetHeight) {
			document.getElementById('vida_screen').style.height = document.getElementById('vida_main_content').offsetHeight+200+'px';
		} else {
			document.getElementById('vida_screen').style.height = document.body.offsetHeight+'px';
		}
		setTimeout( "document.getElementsByTagName('html')[0].style.overflowY='scroll'",1200);
		setTimeout( "fadeout('vida_screen',10)",1200 );
//		setTimeout( "fadein('vida_nav_top',0)",1500 );
//		setTimeout( "fadein('vida_nav_side',0)",1500 );
	}

	if (vidaBringThePhotosInBeforeFade) {
		initializePhoto('','-200px');
		initializePhoto('2','-200px');
	} else {
		p = document.getElementById('vida_side_photo');
		p_fg = document.getElementById('vida_side_photo_fg');
		pp = document.getElementById('vida_side_photo2');
		pp_fg = document.getElementById('vida_side_photo2_fg');
		setOpacity(document.getElementById('vida_side_photo'+''+'_contents'),0);
		setOpacity(document.getElementById('vida_side_photo'+'2'+'_contents'),0);
		p.style.display = p_fg.style.display = pp.style.display = pp_fg.style.display = 'block';
		setTimeout( 'develop(0,"vida_side_photo'+''+'_contents")' , 250);
		setTimeout( 'develop(0,"vida_side_photo'+'2'+'_contents")' , 250);
	}
	
	if (isImageGalleryMode) {
		onImageGalleryLoad();
	}

}
window.onload = function() { doThisOnLoad(); }
window.onpageshow = function (evt) {
	if (evt.persisted) window.onload();
}
