var i;
var v = 100;
var Inv = 0;
var t = '';
var currentPic = 0;
var maxPics = 7;

var mouseX;
var mouseY;

var myWidth = 0;
var myHeight = 0;

var zqsParm = new Array();
	

//opac highlight
function highlight_def(id,amt) {
}
function highlight_con(id,amt) {
	var amt_format = amt/100;
	//document.getElementById(id).style.filter = 'alpha(opacity:50)';
	document.getElementById(id).style.filter = 'alpha(opacity:' + amt + ')';
	//document.getElementById(id).style.opacity = '0.5';
	document.getElementById(id).style.opacity = amt_format;
}


// mouse events
document.onmousemove = getMousePos;
function getMousePos(e) {
	if (e) {
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else {
		mouseX = event.x;
		mouseY = event.y;
	}	
}	


function getPost() {
	
	var zquery = window.location.search.substring(1);
	var msg = zquery.substring(2,zquery.length);
	
	if (msg == '1') {
		document.getElementById('contactresponse').innerHTML = 'Thanks for your interest, we\'ll respond asap!';
		document.getElementById('contactresponse').style.display = 'block';
	} else {
		document.getElementById('contactresponse').style.display = 'none';
	}
}

function getWindowSize() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

// moves tray --//
function followMouse() {
	getWindowSize();
	//myWidth = document.body.clientWidth;
	if ((mouseX - 82) > (myWidth/2 - 200) && (mouseX - 82) < (myWidth/2 + 250) && (mouseY < 170)) {
		document.getElementById('tray').style.backgroundPosition = (mouseX - 82) + 'px 100%';
	}
	to = setTimeout("followMouse();",0); //repeat function
}





function mainSwap(toswap) {
	for (i=0;i<=4;i++) { // set limit here
		if (i == toswap) {
			document.getElementById('main' + i).style.display = 'block';
		} else {
			document.getElementById('main' + i).style.display = 'none';
		}
	}
}

function sliderSwap(toswap) {
	for (i=0;i<=2;i++) { // set limit here
		if (i == toswap) {
			document.getElementById('slider_' + i).src = 'images/slider_' + i + '_over.png';
			document.getElementById('slider_' + i).style.cursor = 'default';
			document.getElementById('featfull' + i).style.display = 'block';
			
		} else {
			document.getElementById('slider_' + i).src = 'images/slider_' + i + '.png';
			document.getElementById('slider_' + i).style.cursor = 'pointer';
			document.getElementById('featfull' + i).style.display = 'none';
		}
	}
}

function image_prev() {
	if ((currentPic - 1) > -1) {
		currentPic = currentPic - 1;
		//alert(currentPic);
		startFade(currentPic);
	}
}
function image_next() {
	if ((currentPic + 1) <= maxPics) {
		currentPic = currentPic + 1;
		//alert(currentPic);
		startFade(currentPic);
	}
}

function startFade(picInNum) {
	//if (currentPic != picInNum) {
		if (t) clearTimeout(t);
		for (i=0;i<=maxPics;i++) { // set limit here
			if (i == picInNum) {
			} else {
				picObjClear = document.getElementById('feature' + i);
				picDescClear = document.getElementById('div_feature' + i);
				picObjClear.style.zIndex = 1;
				picObjClear.style.opacity = 0.0;
				picObjClear.style.filter = 'alpha(opacity=0)';
				picDescClear.style.display = 'none';
			}
		}
		fadePicIn(picInNum);
		currentPic = picInNum;
	//}
}

function fadePicIn(picInNum) {
	var funcIn = "fadePicIn('" + picInNum + "');";
	Inv = Inv + 5;
	picObji = document.getElementById('feature' + picInNum);
	picDesci = document.getElementById('div_feature' + picInNum);
	picObji.style.zIndex = 100;
	picObji.style.opacity = Inv/100;
	picObji.style.filter = 'alpha(opacity=' + Inv + ')';
	
	picDesci.style.display = 'block';
	
	if (Inv >= 100) {
		Inv = 0;
		clearTimeout(t);
		return;
	}
	t = setTimeout(funcIn,0);
}


function init() {
	getWindowSize();
	//document.getElementById('tray').style.backgroundPosition = (mouseX - 82) + 'px 100%';
	//if (zquery != '') {
		getPost();
	//}
}
