
// 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(windowwidth > 900) {

		if(windowwidth > 1100) {

			document.getElementById("pagewrapper").style.marginRight = "10%";
			document.getElementById("pagewrapper").style.marginLeft = "10%";

		} else {

			document.getElementById("pagewrapper").style.marginRight = "60px";
			document.getElementById("pagewrapper").style.marginLeft = "60px";
			
		}

		document.getElementById("wrapper").style.marginLeft = "17px";
		document.getElementById("wrapper").style.marginRight = "15px";
		document.getElementById("topfix").style.height = "30px";
		document.getElementById("footer").style.display = "";
		document.getElementById("footer_fix").style.display = "";

	} else {

		document.getElementById("wrapper").style.marginLeft = "0px";
		document.getElementById("wrapper").style.marginRight = "0px";
		document.getElementById("pagewrapper").style.marginRight = "0px";
		document.getElementById("pagewrapper").style.marginLeft = "0px";
		document.getElementById("topfix").style.height = "0px";
		document.getElementById("footer").style.display = "none";
		document.getElementById("footer_fix").style.display = "none";

	}

	// 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;

		}

	}

}

function mousegoesover() {
	
	this.className = "over";

}

function mousegoesout() {
	this.className = "";
}

function clearfunc() {
        this.value = "";
}




	function runSlideShow(marker3, backid, imageid, imagearray,d) {

		if(parseInt(document.controls.status.value) != 0) {
			return;
		}

		if (!d) var d = 0;

		nextPic = d + 1; if (nextPic >= imagearray.length) nextPic = 0; 

		fadelength = 2000;
		steps = 100;

		// Set Background Image To Match Foreground
		document.getElementById(backid).style.background = "url('"+document.getElementById(imageid).src+"')";

		// Set Foreground Opacity to Transparent
		setTimeout('setOpacity("'+imageid+'",0)',50);

		// Set Foreground to the next Picture
		setTimeout('document.getElementById(\''+imageid+'\').src = \''+imagearray[nextPic]+'\'',100);

		// Loop through changing the Opacity
		for(i = 0; i <= steps; i++) {
			opacity = i/steps * 100;
			setTimeout('setOpacity("'+imageid+'",'+opacity+')',((i*(fadelength/steps))+150));
		}

		d++;
		
		if (d >= imagearray.length) d=0;

		setTimeout( function () { runSlideShow(marker3,backid,imageid,imagearray,d) } ,6000);

	}

	function arrayToString(arr) {
		return str = 'new Array("' + arr.join('", "') + '")';
	}

	function setOpacity(id,value) {
		document.getElementById(id).style.opacity = (value / 100);
		document.getElementById(id).style.MozOpacity = (value / 100);
		document.getElementById(id).style.KhtmlOpacity = (value / 100);
		document.getElementById(id).style.filter = "alpha(opacity=" + value + ")";
	}

	function runSlideShow2(backid2,imageid2,nextPic2,imagearray2) {

		fadelength = 2000;
		steps = 100;

		// Set Background Image To Match Foreground
		document.getElementById(backid2).style.background = "url('"+document.getElementById(imageid2).src+"')";

		// Set Foreground Opacity to Transparent
		setTimeout('setOpacity("'+imageid2+'",0)',50);

		// Set Foreground to the next Picture
		setTimeout('document.getElementById(\''+imageid2+'\').src = \''+imagearray2[nextPic2]+'\'',100);

		// Loop through changing the Opacity
		for(i = 0; i <= steps; i++) {
			opacity = i/steps * 100;
			setTimeout('setOpacity("'+imageid2+'",'+opacity+')',((i*(fadelength/steps))+150));
		}

	}





	function start_left() {

		var slides1 = document.getElementById("banner");

		var scrollbar = document.getElementById("bannerwrapper");
		maxwidth = scrollbar.offsetWidth;

		slides1width = slides1.offsetWidth;
		
		function move_left(obj1) {

			if(document.controls2.status2.value == 1) {

				pos1 = document.getElementById("banner").offsetLeft;

				val1 = pos1 + 1;

				if(pos1 != 0) {
					obj1.style.left = val1 + "px";
				}
	
				setTimeout( function () { move_left(obj1) } ,90);
			}
	
		}

		move_left(slides1);

	}

	function start_right() {

		var slides1 = document.getElementById("banner");

		var scrollbar = document.getElementById("bannerwrapper");
		maxwidth = scrollbar.offsetWidth;

		slides1width = slides1.offsetWidth;
				
		function move_right(obj1) {

			if(document.controls2.status2.value == 0) {

				pos1 = document.getElementById("banner").offsetLeft;

				val1 = pos1 - 1;

				if(pos1 > -(slides1width - maxwidth)) {
					obj1.style.left = val1 + "px";
				}
	
				setTimeout( function () { move_right(obj1) } ,90);
			}
	
		}

		move_right(slides1);

	}

	function checkFooter() {

		if(document.getElementById("banner")) {
	
			start_right();
		
		}

	}
