/*
*
*	main.js, Copyright (c) 2006, Eric Hossinger
*
*/

//check an object's visibility and swap
function checkVis(id) {

	if(document.getElementById(id).style.visibility == 'hidden') {

		swapVis(id, 'visible');
	
	} else {

		swapVis(id, 'hidden');

	}

}

//swap an image's source
function swapImg(id, img) {

	document.getElementById(id).src=img;

}

//swap an object's css class
function swapClass(id, newClass) {

	document.getElementById(id).className=newClass;

}

//swap an object's visibility
function swapVis(id, vis) {

	document.getElementById(id).style.visibility=vis;

}

function swapBG(dir, file) {

	document.getElementById('background').style.background = "url('images/gallery/" + dir + "/" + file + ".jpg') no-repeat";
	document.getElementById('gindex').value = file;

}

function dis() {

	document.getElementById('qlinks').style.visibility = "hidden";
	document.getElementById('dis1').style.background = "transparent";
	document.getElementById('dis2').style.visibility = "hidden";
	document.getElementById('dis3').style.visibility = "hidden";
	document.getElementById('dis4').style.visibility = "hidden";

	document.getElementById('nav1').style.visibility = "hidden";
	document.getElementById('nav1').style.position = "absolute";

	document.getElementById('nav2').style.visibility = "visible";
	document.getElementById('nav3').style.visibility = "visible";
}

function appear() {

	document.getElementById('qlinks').style.visibility = "visible";
	document.getElementById('dis1').style.background = "#FFF";
	document.getElementById('dis2').style.visibility = "visible";
	document.getElementById('dis3').style.visibility = "visible";
	document.getElementById('dis4').style.visibility = "visible";

	document.getElementById('nav1').style.visibility = "visible";
	document.getElementById('nav1').style.position = "relative";

	document.getElementById('nav2').style.visibility = "hidden";
	document.getElementById('nav3').style.visibility = "hidden";
}

function appear2() {
	appear();
	document.getElementById('dis1').style.background = "#434C54";
}

function prev(dir) {

	var gindex = parseInt(document.getElementById('gindex').value);
	var gmax = parseInt(document.getElementById('gmax').value);

	if(gindex - 1 == 0) {
		file = gmax;
	} else {
		file = gindex - 1;
	}

	swapBG(dir, file);

}

function next(dir) {

	var gindex = parseInt(document.getElementById('gindex').value);
	var gmax = parseInt(document.getElementById('gmax').value);

	if(gindex + 1 > gmax) {
		file = 1;
	} else {
		file = gindex + 1;
	}

	swapBG(dir, file);

}

function show(id) {

	for(i = 1; i < 30; i++) {
	
		if(document.getElementById('p' + i)) {
			swapClass('p' + i, 'inv');
		}

		if(document.getElementById('s' + i)) {
			swapClass('s' + i, 'normal');
		}

	}

	swapClass('p' + id, 'vis');
	swapClass('s' + id, 'highlight');

}

function step1(type) {

	step1_show();

	if(type != 'fl') {
		document.getElementById('fl').style.filter = "alpha(opacity=11)";   
		document.getElementById('fl').style.opacity = "0.11";	
	}

	if(type != 'mt') {
		document.getElementById('mt').style.filter = "alpha(opacity=11)";   
		document.getElementById('mt').style.opacity = "0.11";	
	}

	if(type != 'cc') {
		document.getElementById('cc').style.filter = "alpha(opacity=11)";   
		document.getElementById('cc').style.opacity = "0.11";
	}

	swapClass('h', 'show');
	swapClass('l', 'show');
	swapClass('step2', 'show');
	swapClass('step2_pad', 'padding');

	document.getElementById('h').style.filter = "alpha(opacity=100)";   
	document.getElementById('h').style.opacity = "1";	
	document.getElementById('l').style.filter = "alpha(opacity=100)";   
	document.getElementById('l').style.opacity = "1";	

	document.getElementById('type').value = type;
	step3_hide();

}

function step2(treat) {

	document.getElementById(treat).style.filter = "alpha(opacity=100)";   
	document.getElementById(treat).style.opacity = "1";	

	if(treat != 'h') {
		document.getElementById('h').style.filter = "alpha(opacity=11)";   
		document.getElementById('h').style.opacity = "0.11";	
	}

	if(treat != 'l') {
		document.getElementById('l').style.filter = "alpha(opacity=11)";   
		document.getElementById('l').style.opacity = "0.11";
	}

	var type = document.getElementById('type').value;

	step3_hide();
	swapClass('step3', 'padding');
	swapClass(type + treat, 'step3');

}

function step1_show() {

	document.getElementById('fl').style.filter = "alpha(opacity=100)";   
	document.getElementById('fl').style.opacity = "1";	
	document.getElementById('mt').style.filter = "alpha(opacity=100)";   
	document.getElementById('mt').style.opacity = "1";	
	document.getElementById('cc').style.filter = "alpha(opacity=100)";   
	document.getElementById('cc').style.opacity = "1";	

}

function step3_hide() {

	swapClass('step3', 'hide');
	swapClass('flh', 'hide');
	swapClass('fll', 'hide');
	swapClass('mth', 'hide');
	swapClass('mtl', 'hide');
	swapClass('cch', 'hide');
	swapClass('ccl', 'hide');

}