function checkFooter() {

	var search = document.getElementById("search");

	if(search) {
		search.value = "Search";
		if(search.value == "Search") {
			search.onfocus = clearfunc;
		}
	}

}



function checkIndex() {
	if (document.getElementById('homeimg')) {
		getElements();
	}
}


// Home page slideshow
// More info: http://www.artlines.co.uk/blog/8

//GET ELEMENTS
//------------

var homediv;
function getElements() {
	if (document.getElementById("homeimg")) {
		homediv = document.getElementById("homeimg");
		
		var preLoad = new Array();
		for (var j=0; j<imgsArray.length; j++) {
			preLoad[j] = new Image(559,399)
			preLoad[j].src = "images/"+imgsArray[j];
		};
		setTimeout("homefade();", 2000);
	};

}
//HOMEPAGE SLIDESHOW
//------------------

var newimg;
var imgsArray = new Array();
imgsArray[0] = "Home_Roll_5.jpg";
imgsArray[1] = "Home_Roll_6.jpg";
imgsArray[2] = "Home_Roll_1.jpg";
imgsArray[3] = "Home_Roll_2.jpg";
imgsArray[4] = "Home_Roll_3.jpg";
imgsArray[5] = "Home_Roll_4.jpg";
var newimgInc = 1;
var timer = 0;
function homefade() {

	newimg = document.createElement("img");
	newimg.src = "images/"+imgsArray[newimgInc];
	newimg.style.opacity = "0";
	newimg.style.filter = "alpha(opacity=0)";
	homediv.appendChild(newimg);
	if (newimgInc == (imgsArray.length-1)) {
		newimgInc = 0;
	} else {
		newimgInc++;
	};
	
	timer = setInterval("homefadeTrans();", 10);	

}

var trans = 0;
function homefadeTrans() {

	if (trans == 100) {
		clearTimeout(timer);
		timer = 0;
		trans = 0;
		
		homediv.removeChild(homediv.getElementsByTagName("img")[0]);		
		setTimeout("homefade();", 2000);
		return false;
	};

	newimg.style.opacity = trans/100;
	newimg.style.filter = "alpha(opacity="+trans+")";
	trans = trans+1;

}




// STORE REQUIRED ACTIONS IN VARIABLE //

var W3CDOM = (document.getElementsByTagName);

function init() {

	windowwidth = window.innerWidth;
	pagewidth = document.getElementById("pagewrapper").offsetWidth;

	if (!windowwidth) {
		windowwidth = document.documentElement.clientWidth;
	}

	if (!windowwidth || windowwidth == 0) {
		windowwidth = document.body.clientWidth;
		pagewidth = document.getElementById("pagewrapper").offsetWidth;
	}

	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	}

	/*
	if (document.getElementById('home_content_col2')) {
		//document.getElementById("home_content_col2a_pad").style.height = ok + "px";
		//document.getElementById("home_content_col2b_pad").style.height = ok + 'px';
	}
	*/





	// Change projects_thumbs/photos_thumbs position.

	if (windowwidth > 990) {
		if (document.getElementById('projects_thumbs')) {
			document.getElementById('projects_thumbs').style.width = '124px';
		}
		if (document.getElementById('photos_thumbs')) {
			document.getElementById('photos_thumbs').style.width = '150px';
		}

	} else {
		if (document.getElementById('projects_thumbs')) {
			document.getElementById('projects_thumbs').style.width = '100%';
		}
		if (document.getElementById('photos_thumbs')) {
			document.getElementById('photos_thumbs').style.width = '100%';
		}
	}


	if (windowwidth > 1024) {
		if (document.getElementById('mainbox_text')) {
			document.getElementById('mainbox_text').style.marginLeft = '650px';
		}
	} else {
		if (document.getElementById('mainbox_text')) {
			document.getElementById('mainbox_text').style.marginLeft = '0';
		}
	}


	if(windowwidth > 890) {

		document.body.style.marginTop = "63px";
		document.body.style.marginBottom = "63px";
		document.body.style.marginLeft = "3.9%";
		document.body.style.marginRight = "3.9%";
		

		/*
		document.getElementById("headerwrapper").style.marginRight = "4%";
		document.getElementById("headerwrapper").style.marginLeft = "4%";
		document.getElementById("bodywrapper").style.marginRight = "4%";
		document.getElementById("bodywrapper").style.marginLeft = "4%";
		document.getElementById("footerwrapper").style.marginRight = "4%";
		document.getElementById("footerwrapper").style.marginLeft = "4%";
		*/
	} else {
		document.body.style.marginTop = "0";
		document.body.style.marginBottom = "0";
		document.body.style.marginLeft = "0";
		document.body.style.marginRight = "0";


		/*
		document.getElementById("headerwrapper").style.marginRight = "0";
		document.getElementById("headerwrapper").style.marginLeft = "0";
		document.getElementById("bodywrapper").style.marginRight = "0";
		document.getElementById("bodywrapper").style.marginLeft = "0";
		document.getElementById("footerwrapper").style.marginRight = "0";
		document.getElementById("footerwrapper").style.marginLeft = "0";
		*/
	}

	if(document.getElementById("rightcolumn")) {
if (ieversion == 6) {
		document.getElementById("rightcolumn").style.height = document.getElementById("bodywrapper").offsetHeight - 205 + "px";
} else {
		document.getElementById("rightcolumn").style.height = document.getElementById("bodywrapper").offsetHeight + "px";
}
	}
	if(document.getElementById("leftcolumn")) {
		document.getElementById("leftcolumn").style.height = document.getElementById("bodywrapper").offsetHeight + "px";
	}


	if (ieversion == 6) {

//		document.getElementById("rightside2").style.height = document.getElementById("headerwrapper").offsetHeight - 21 + "px";
//		document.getElementById("leftside2").style.height = document.getElementById("headerwrapper").offsetHeight - 21 + "px";

	} else if (ieversion == undefined) {

//		document.getElementById("rightside2").style.height = document.getElementById("headerwrapper").offsetHeight - 21 + "px";
//		document.getElementById("leftside2").style.height = document.getElementById("headerwrapper").offsetHeight - 21 + "px";

	} else {

//		document.getElementById("rightside2").style.height = document.getElementById("headerwrapper").offsetHeight - 41 + "px";
//		document.getElementById("leftside2").style.height = document.getElementById("headerwrapper").offsetHeight - 41 + "px";

	}

	// IF ACTIONS ARE NOT SUPPORTED STOP SCRIPT //
	if (!W3CDOM) return;

	var menu = document.getElementById('menu');

	if(menu) {

		var ptags = menu.getElementsByTagName('li');

		for (var i=0;i<ptags.length;i++) {

			ptags[i].onmouseover = mousegoesover;
			ptags[i].onmouseout = mousegoesout;

		}

	}

	var quickmenu = document.getElementById('quickmenu');

	if(quickmenu) {

		var ptags = quickmenu.getElementsByTagName('li');

		for (var i=0;i<ptags.length;i++) {

			if(ptags[i].className != "divider") {

				ptags[i].onmouseover = mousegoesover2;
				ptags[i].onmouseout = mousegoesout2;
	
			}

		}

	}

}

function mousegoesover2() {
	this.className = "over";
}

function mousegoesout2() {
	this.className = "";
}

function mousegoesover() {
	this.className = "over";
}

function mousegoesout() {
	this.className = "";
}

function clearfunc() {
	this.value = "";
}





	function addEvent(obj,type,func) {
		if (obj.addEventListener) { obj.addEventListener(type,func,false); return true; }
		if (obj.attachEvent) { return obj.attachEvent("on"+type,func); }
		return false;
	}

	function removeEvent(obj,type,func) {
		if (obj.removeEventListener) { obj.removeEventListener(type,func,false); return true; }
		if (obj.detachEvent) { return obj.detachEvent("on"+type,func); }
		return false;
	}

	function findEvent(e) {
		if (!e) var e = window.event;
		return e;
	}
			
	function findTarget(e) {
		if (e.target) t = e.target;
		else if (e.srcElement) t = e.srcElement;
		while (t.nodeType != 1) {
			document.title += t;
			t = t.parentNode;
		}
		return t;
	}

	function findPos(obj) {
		var x = y = 0;
		if (obj.offsetParent) {
			x = obj.offsetLeft;
			y = obj.offsetTop;
			while (obj = obj.offsetParent) {
				x += obj.offsetLeft
				y += obj.offsetTop
			}
		}
		return [x,y];
	}

	function findViewportSize() {
		var x = y = 0;
		if (self.innerHeight) { // if !ie
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // if ie6 strict
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) { // all other ie
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		return [x,y];
	}

	function findPageSize() {
		var x = y = 0;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) { // if !ie mac
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		} else { // if ie mac
			x = document.body.offsetWidth;
			y = document.body.offsetHeight;
		}
		return [x,y];
	}

	function findPageOffset() {
		var x = y = 0;
		if (self.pageYOffset) { // if !ie 
			x = self.pageXOffset;
			y = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) { // if ie6 strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		} else if (document.body) { // all other ie
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		return [x,y];
	}

	function findMousePos(e)
	{
		var x = y = 0;
		if (e.pageX || e.pageY) {
			x = e.pageX;
			y = e.pageY;
		} else if (e.clientX || e.clientY) 	{
			x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		return [x,y];
	}

	function vector() {
		this.x = 0; this.y = 0; this.z = 0;
	}

	function addClass(object,classname) {
		object.className += " "+classname;
	}

	function checkClass(object,classname) {
		classes = object.className.split(' ');
		var i;
		for (i=0;i<classes.length;i++) {
			if (classes[i] == classname) return true;
		}
		return false;
	}

	function removeClass(object,classname)
	{
		classes = object.className.split(' ');
		var i; var newclass = "";
		for (i=0;i<classes.length;i++) {
			if (classes[i] != classname) newclass += " "+classes[i];
		}
		object.className = newclass;
	}

