var currslide = '';
var slidefamily = '';


var items = [];

function toggle (id) {
	if (items[id]) 	{
		document.getElementById('item'+id).style.display = 'none';
		document.getElementById('less'+id).style.display = 'none';
		document.getElementById('more'+id).style.display = 'block';
	} else 	{
		document.getElementById('item'+id).style.display = 'block';
		document.getElementById('less'+id).style.display = 'block';
		document.getElementById('more'+id).style.display = 'none';
	}
	items[id] = !items[id];
}

function swap_slideshow_up(alias) {
	// current counter matches index of
	// page alias in children array + 1 for start/top page

	/* variables are: 
	pagenameslide1 - pagenameslide9
	pagenameslide_max = 9
	pagenamecounter = 3
	*/
		
	// hide currently displayed slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "none"');

	// on last slide, next arrow shows first slide
	// when we've reached last slide, set counter to 0, it will increment to 1 a few lines down
	if (eval(alias+'counter=='+alias+'slide_max')) {
		eval(alias+'counter = 0');
	}

	// increment counter
	eval(alias+'counter++');
        
	// show next slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "block"');

	/*
	arrow vars are aliasleftarrrow and aliasrightarrow and aliasdisplaynum
	*/

	// change the arrow colors
	if (eval(alias+'counter=='+alias+'slide_max')) {
		// hide 'next' arrow on last slide
		//eval('document.getElementById(\''+alias+'rightarrow\').style.visibility = "hidden"');
        } else {
		// otherwise show 'next' arrow
		eval('document.getElementById(\''+alias+'rightarrow\').style.visibility = "visible"');
	}
	if (eval(alias+'counter==1')) {
		// hide 'previous' arrow on first slide
		eval('document.getElementById(\''+alias+'leftarrow\').style.visibility = "hidden"');
	} else {
		// otherwise show 'previous' arrow
		eval('document.getElementById(\''+alias+'leftarrow\').style.visibility = "visible"');
	}

	// change the index number displayed on the page
	eval('document.getElementById(\''+alias+'displaynum\').innerHTML = '+alias+'counter');

	// hide the text in case its showing
	swap_slideshow_img(alias);
		
}
function swap_slideshow_down(alias) {
	// current counter matches index of
	// page alias in children array + 1 for start/top page

	// return from function if there are no slides left to show
	if (eval(alias+'counter==1')) {
		return true;
	}

	// hide currently displayed slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "none"');

	// decrement counter after swapping slide
	eval(alias+'counter = '+alias+'counter - 1');

	// show next slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "block"');

	// change the arrow colors
	if (eval(alias+'counter==1')) {
		// hide 'previous' arrow on first slide
		eval('document.getElementById(\''+alias+'leftarrow\').style.visibility = "hidden"');
	} else {
		// otherwise show 'previous' arrow
		eval('document.getElementById(\''+alias+'leftarrow\').style.visibility = "visible"');
	}
	if (eval(alias+'counter=='+alias+'slide_max')) {
		// hide 'next' arrow on last slide
		eval('document.getElementById(\''+alias+'rightarrow\').style.visibility = "hidden"');
	} else {
		// otherwise show 'next' arrow
		eval('document.getElementById(\''+alias+'rightarrow\').style.visibility = "visible"');
	}

	// change the index number displayed on the page
	eval('document.getElementById(\''+alias+'displaynum\').innerHTML = '+alias+'counter');
        
	// hide the text in case its showing
	swap_slideshow_img(alias);
}
function swap_slideshow_text(alias) {
	// hide currently displayed slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "none"');
	// show text
	eval('document.getElementById(\''+alias+'slidetext\').style.display = "block"');
	// change the content of the plussign <td>
	eval('document.getElementById(\''+alias+'plussign\').innerHTML = \'<a href="" onclick=\\\'swap_slideshow_img("'+alias+'");return false;\\\'>+ Project Gallery</a>\'');
}
function swap_slideshow_img(alias) {
	// hide text
	eval('document.getElementById(\''+alias+'slidetext\').style.display = "none"');
	// show currently displayed image slide
	eval('document.getElementById(\''+alias+'slide'+eval(alias+'counter')+'\').style.display = "block"');
	// change the content of the plussign <td>
	eval('document.getElementById(\''+alias+'plussign\').innerHTML = \'<a href="" onclick=\\\'swap_slideshow_text("'+alias+'");return false;\\\'>+ Project Overview</a>\'');
}

function rollover(link) {
	eval('document.thumb_'+link+'.src = "img/thumb_'+link+'_on.jpg"');
}

function rollout(link) {
	if (link==currslide) return true;
	else eval('document.thumb_'+link+'.src = "img/thumb_'+link+'.jpg"');
}

function change_slideshow(slidefamily) {
	if (currslide == slidefamily) return true;
	else {
		eval('document.thumb_'+currslide+'.src = "img/thumb_'+currslide+'.jpg"');
		eval('document.thumb_'+slidefamily+'.src = "img/thumb_'+slidefamily+'_on.jpg"');
		eval('document.getElementById(\'slidepanel'+currslide+'\').style.display = "none"');
		eval('document.getElementById(\'slidepanel'+slidefamily+'\').style.display = "block"');
		currslide = slidefamily;
	}
}

var targetCase = '';
function QueryString(key) {
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++) {
		if (QueryString.keys[i]==key) {
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse() {
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	var isFound = false;
	for (var i=0;i<pairs.length;i++) {
		var pos = pairs[i].indexOf('=');
		if (pos >= 0) {
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;
			isFound = true;
		}
	}
	return isFound;
}

function initFunctions () { initRollovers(); }

window.onload = initFunctions;
