// State in nav

function navstate(){
	var currpage = location.href;
	if(currpage.indexOf('clients') > 0){
		document.getElementById('clients').style.backgroundImage = 'url(images/nav-clients-on.png)';
	} else if(currpage.indexOf('process') > 0){
		document.getElementById('process').style.backgroundImage = 'url(images/nav-process-on.png)';
	} else if(currpage.indexOf('testimonials') > 0){
		document.getElementById('testimonials').style.backgroundImage = 'url(images/nav-testimonials-on.png)';
	} else if(currpage.indexOf('background') > 0){
		document.getElementById('background').style.backgroundImage = 'url(images/nav-background-on.png)';
	} else if(currpage.indexOf('contact') > 0){
		document.getElementById('contact').style.backgroundImage = 'url(images/nav-contact-on.png)';
	}
}
// Fix layout to display footer at very bottom
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('page').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}
window.onload = function() {
	setFooter();
	navstate();
	preload("logo-on.png", "nav-clients-on.png", "nav-process-on.png", "nav-testimonials-on.png", "nav-background-on.png", "nav-contact-on.png", "thumb-1-on.jpg", "thumb-2-on.jpg", "thumb-3-on.jpg", "thumb-4-on.jpg", "thumb-5-on.jpg", "thumb-6-on.jpg");
}
window.onresize = function() {
	setFooter();
}

function killSpam(name,serv,subj)
{
	addy = "mailto:" + name + "@" + serv + "?subject=" + subj;
	window.location = addy;
}

function jump(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Preloader
var loadimgs = new Array();
function preload(){
	for (i=0; i<preload.arguments.length; i++){
		loadimgs[i] = new Image();
		loadimgs[i].src = "images/" + preload.arguments[i];
	}
}

// Thumb rollovers
function swapit(which){
	var findimg = "img" + which;
	var newsrc = "images/thumb-" + which + "-on.jpg";
	document.getElementById(findimg).src=newsrc;
}