var found = '';

function homeimage() {
	var idx = 1;
	document.forms[0].intro.src = 'images/intro_'+idx+'.jpg';
}

function autohilite() {
	var path = window.location.pathname;
	var page = path.substring(path.lastIndexOf('\\')+1);
	var prefix = page.substring(0, page.indexOf('.'));
	var element = document.getElementById(''+prefix);
	
	if(element != null) {
		found = prefix;
		element.src = 'images/'+found+'_on.gif';
	} 
}

function hilite(element) {
	if(element.name != found) {
		element.src = 'images/'+element.name+'_on.gif';
		element.style.cursor = 'pointer';
	}
}

function lolite(element) {
	if(element.name != found) {
		element.src = 'images/'+element.name+'_off.gif';
		element.style.cursor = 'default';
	}
}

function load(element) {
	window.location.href = element.name+'.html';
}

function popup(link,width,height) {
	var w = width;
	var h = height;
	var win_l = (screen.width - w) / 2;
	var win_t = (screen.height - h) / 2;
	var win_p = 'height='+h+', width='+w+', top='+win_t+', left='+win_l+', toolbar=no, menubar=no, scrollable=true';
	window.open(link,"Website",win_p);
}

function show(id) {
	var count = 6;
	for(var i=1; i <= count; i++) {
		try {
			var object = document.getElementById(''+i);
			object.style.visibility = 'hidden';
			object.style.display = 'none';
		} catch(error){}
	}
	var element = document.getElementById(''+id);
	element.style.visibility = 'visible';
	element.style.display = 'block';
}

// Dynamic Photo System!
var id = 1;
var minimum = 1;
var maximum = 70;

function preload() {
	try {
		id = parseInt(window.location.search.substring(1));
		update();
	} catch(error) {}
}

function previous() {
	if((id - 1) < minimum) {
		alert('This is the first photo in the set.');
		return false;
	}
	id--;
	update();
}

function next() {
	if((id + 1) > maximum) {
		alert('This is the last photo in the set.');
		return false;
	}
	id++;
	update();
}

function update() {
	var path = 'images/photos/'+id+'_big.jpg';
	document.getElementById('picture').src = path;
}

function subversa() {
	var w = 900;
	var h = 670;
	var win_l = (screen.width - w) / 2;
	var win_t = (screen.height - h) / 2;
	var win_p = 'height='+h+',width='+w+',top='+win_t+',left='+win_l+',toolbar=no,menubar=no,scrollbars=yes';
	window.open('http://www.subversa.co.uk/',"Subversa",win_p);
}