/* Search Results Paging*/
function sack(file) {this.xmlhttp = null;this.resetData = function() {this.method = "POST";	this.queryStringSeparator = "?";this.argumentSeparator = "&"; this.URLString = ""; this.encodeURIString = true;this.execute = false;this.element = null;this.elementObj = null;this.requestFile = file;this.vars = new Object();this.responseStatus = new Array(2);};this.resetFunctions = function() { 		this.onLoading = function() { };this.onLoaded = function() { };	this.onInteractive = function() { };this.onCompletion = function() { };	this.onError = function() { };this.onFail = function() { };};	this.reset = function() {this.resetFunctions();	this.resetData();};
	this.createAJAX = function() {try {	this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");	} catch (e1) {	try {this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	} catch (e2) {this.xmlhttp = null;	}}	if (! this.xmlhttp) {if (typeof XMLHttpRequest != "undefined") {this.xmlhttp = new XMLHttpRequest();} else {this.failed = true;	}}};
	this.setVar = function(name, value){this.vars[name] = Array(value, false);};this.encVar = function(name, value, returnvars) {if (true == returnvars) {return Array(encodeURIComponent(name), encodeURIComponent(value));} else {	this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);}}
	this.processURLString = function(string, encode) {encoded = encodeURIComponent(this.argumentSeparator);	regexp = new RegExp(this.argumentSeparator + "|" + encoded);varArray = string.split(regexp);for (i = 0; i < varArray.length; i++){urlVars = varArray[i].split("=");	if (true == encode){this.encVar(urlVars[0], urlVars[1]);} else {this.setVar(urlVars[0], urlVars[1]);}}}
	this.createURLString = function(urlstring) {if (this.encodeURIString && this.URLString.length) {this.processURLString(this.URLString, true);}if (urlstring) {if (this.URLString.length) {this.URLString += this.argumentSeparator + urlstring;} else {this.URLString = urlstring;	}}
		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());urlstringtemp = new Array();for (key in this.vars) {if (false == this.vars[key][1] && true == this.encodeURIString) {encoded = this.encVar(key, this.vars[key][0], true);	delete this.vars[key];this.vars[encoded[0]] = Array(encoded[1], true);key = encoded[0];	}
			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];}
		if (urlstring){this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);} else {this.URLString += urlstringtemp.join(this.argumentSeparator);}}
	this.runResponse = function() {	eval(this.response);}
	this.runAJAX = function(urlstring) {if (this.failed) {this.onFail();} else {this.createURLString(urlstring);if (this.element) {this.elementObj = document.getElementById(this.element);	}
			if (this.xmlhttp) {	var self = this;if (this.method == "GET") {	totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;	this.xmlhttp.open(this.method, totalurlstring, true);	} else {this.xmlhttp.open(this.method, this.requestFile, true);	try {this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")	} catch (e) { }	}
				this.xmlhttp.onreadystatechange = function() {	switch (self.xmlhttp.readyState) {case 1:self.onLoading();	break;	case 2:self.onLoaded();	break;	case 3:self.onInteractive();			break;	case 4:self.response = self.xmlhttp.responseText; self.responseXML = self.xmlhttp.responseXML; self.responseStatus[0] = self.xmlhttp.status; self.responseStatus[1] = self.xmlhttp.statusText;	if (self.execute) {	self.runResponse();	}if (self.elementObj) {	elemNodeName = self.elementObj.nodeName;elemNodeName.toLowerCase();	if (elemNodeName == "input"	|| elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") {self.elementObj.value = self.response;	} else {self.elementObj.innerHTML = self.response;	}}if (self.responseStatus[0] == "200") {self.onCompletion();} else {self.onError();	}self.URLString = "";	break;}	};
				this.xmlhttp.send(this.URLString);}}}; this.reset(); this.createAJAX();}
function getPage(num) {var contentDiv = document.getElementById('contents');var rows =  contentDiv.getElementsByTagName('div');var links = contentDiv.getElementsByTagName('a');for (var i=0; i<rows.length; i++) {if (rows[i].className == 'p-row') {rows[i].style.display = "none";if (rows[i].id.match(/\d+$/) == num) {rows[i].style.display = "block";}}}for (var j=0; j<links.length; j++) {	if (links[j].innerHTML == num) {links[j].className = "chosen";}	else {links[j].className = "";}}}
function toggleQuoteForm() {var frm = document.getElementById('display-form');if (frm.style.display == 'none') {frm.style.display = 'block'} else {frm.style.display = 'none'}}
function popIn(url,wid,hei,currpart) {	var scrollHeight = document.body.clientHeight;	var scrollWidth = document.body.clientWidth; var centerPt = (parseFloat(scrollWidth) - 731) / 2;	var transBg = document.getElementById('dnyerTransBG');	transBg.style.height = scrollHeight + "px";	
if (url.match(/showimage/)) { var localcontents = '<div id="popInInner"><div id="closeUPS"><a href="#" onclick="closePopIn(); return false;"><img src="images/closePopIn.jpg" /></a><span>PICTURE - '; if (currpart) { localcontents += currpart + '</span></div><iframe src="' + url + '" width="' + wid + '" height="' + hei + '" frameborder="0"></iframe></div>';} else {localcontents += 'Image Enlarge</span></div><iframe src="' + url + '" width="' + wid + '" height="' + hei + '" frameborder="0"></iframe></div>';}}
else { var localcontents = '<div id="popInInner"><div id="closeUPS"><a href="#" onclick="closePopIn(); return false;"><img src="images/closePopIn.jpg" /></a><span>DRAWING - ' + currpart + '</span></div><iframe src="' + url + '" width="' + wid + '" height="' + hei + '" frameborder="0"></iframe></div>';}
var popInCtnr = document.getElementById('dnyerPopIn');	popInCtnr.innerHTML = localcontents;	idOffset("dnyerPopIn", 731, hei);	var popInInner = document.getElementById('popInInner');	popInCtnr.style.display = "block";	popInInner.style.width = wid;	popInCtnr.style.left = centerPt + "px";}function closePopIn() {	var transBg = document.getElementById('dnyerTransBG');	var ifrm = document.getElementById('dnyerPopIn');	transBg.style.height = "0px";	ifrm.style.display = "none";}function idOffset( id , wid, hei) {	var topOff = 60 + document.documentElement.scrollTop;	var leftOff = document.body.scrollLeft;	if ( typeof( window.innerWidth ) == 'number' ) {if ( window.innerWidth > wid ) {leftOff += ( window.innerWidth / 2 ) - (wid / 2); 	}} else if( document.documentElement && document.documentElement.clientWidth ) {if ( document.documentElement.clientWidth > wid ) {	leftOff += ( document.documentElement.clientWidth / 2 ) - (wid / 2);}} else if( document.body && document.body.clientWidth ) {	if ( document.body.clientWidth > wid ) {leftOff += ( document.body.clientWidth / 2 ) - (wid / 2); }}
	if ( document.getElementById ) {document.getElementById( id ).style.top = topOff + "px";}else if ( document.layers ) { 	document.layers[ id ].style.top = topOff + "px";}else if ( document.all ) {document.all[ id ].style.top = topOff + "px";}}function stretch( id ) {	var fillWidth = "100%";	var fillHeight = "100%";if ( document.documentElement.scrollHeight < document.body.scrollHeight ) {fillHeight = document.body.scrollHeight; 	} else if ( document.documentElement && document.documentElement.scrollHeight ) {fillHeight = document.documentElement.scrollHeight;}if ( document.documentElement.scrollWidth < document.body.scrollWidth ) {	fillWidth = document.body.scrollWidth; 	} else {fillWidth = document.documentElement.scrollWidth;}	if ( fillHeight < screen.height ) {			fillHeight = screen.height;	}if ( fillWidth < screen.width ) {fillWidth = screen.width;	}var styleHei = document.getElementById( id );	styleHei.style.height = fillHeight;	var styleWid = document.getElementById( id );	styleWid.style.width = fillWidth;}function hide( id ) {	if ( document.getElementById ) {document.getElementById( id ).style.visibility = "hidden";}	else if ( document.layers ) {	document.layers[ id ].visibility = "hide"; 	}else if ( document.all ) {	document.all[ id ].style.visibility = "hidden";}}function show( id ) {	if ( document.getElementById ) {	document.getElementById( id ).style.visibility = "visible";	}  	else if ( document.layers ) {	document.layers[ id ].visibility = "show"; 	}else if ( document.all ) {	document.all[ id ].style.visibility = "visible";	}} function innerDims (id) {var newID = document.getElementById(id);var x,y;if (self.innerHeight) {	x = self.innerWidth;y = self.innerHeight;}	else if (document.documentElement && document.documentElement.clientHeight) {	x = document.documentElement.clientWidth;	y = document.documentElement.clientHeight;}	else if (document.body) {x = document.body.clientWidth;	y = document.body.clientHeight;	}document.newID.style.height = y;document.newID.style.width = x;}var ajax = new Array(); function getGap(sel){	var selVal = sel.options[sel.selectedIndex].value; document.getElementById('gap-size').options.length = 0;	document.getElementById('mount-size').disabled = true;	document.getElementById('mount-method').disabled = true;	if(selVal.length>0){	var index = ajax.length;ajax[index] = new sack();ajax[index].requestFile = 'js/getgap.php?selVal='+selVal;	ajax[index].onCompletion = function(){ createGap(index) };		ajax[index].runAJAX();	}} function createGap(index){ var obj = document.getElementById('gap-size');obj.disabled = false;eval(ajax[index].response);} function getMount(sel) {	var selVal = sel.options[sel.selectedIndex].value;	document.getElementById('mount-size').options.length = 0; document.getElementById('mount-method').disabled = true;	if(selVal.length>0){var index = ajax.length;	ajax[index] = new sack();	ajax[index].requestFile = 'js/getmount.php?selVal='+selVal;	ajax[index].onCompletion = function(){ createMount(index) };ajax[index].runAJAX();}} function createMount(index){	var obj = document.getElementById('mount-size');	obj.disabled = false;	eval(ajax[index].response);} function getMethod(sel){	var selVal = sel.options[sel.selectedIndex].value;	document.getElementById('mount-method').options.length = 0;	var prevSelVal = document.getElementById('gap-size').value;	if(selVal.length>0){	var index = ajax.length;ajax[index] = new sack();	ajax[index].requestFile = 'js/getmethod.php?selVal='+selVal+'&prevSelVal='+prevSelVal;	ajax[index].onCompletion = function(){ createMethod(index) }; ajax[index].runAJAX();}} function createMethod(index){	var obj = document.getElementById('mount-method');	obj.disabled = false;	eval(ajax[index].response);	} 
	
function toggleTab (tab) {
	var tabul = document.getElementById("tab_ul");
	var tabLis = tabul.getElementsByTagName("li");
	for (var j=0;j<tabLis.length;j++){
		tabLis[j].className = "off";
	}
	tab.parentNode.className = "on";
	var tabcontents = document.getElementById("tabcontents");
	var tabconts = tabcontents.getElementsByTagName("div");
	for (var i=0;i<tabconts.length;i++){
		if (tabconts[i].id.match(/tabcont/))
			tabconts[i].className = "tab-off";
	}
	document.getElementById("tabcont" + tab.id.match(/\d+/)).className = "tab-on";
}

function moveLeft () {
	var elem = document.getElementById("tab_ul");
	var curr_ml = parseInt(elem.style.marginLeft.match(/\d+/));
	if (curr_ml+80 >= 220)
		curr_ml = 220;
	else
		curr_ml += 80;
	if (curr_ml != 0)
		elem.style.marginLeft = "-" + curr_ml + "px";
	else
		elem.style.marginLeft = curr_ml + "px";
}

function moveRight () {
	var elem = document.getElementById("tab_ul");
	var curr_ml = parseInt(elem.style.marginLeft.match(/\d+/));
	if (curr_ml-80 <= 0)
		curr_ml = 0;
	else
		curr_ml -= 80;
	if (curr_ml != 0)
		elem.style.marginLeft = "-" + curr_ml + "px";
	else
		elem.style.marginLeft = curr_ml + "px";
}

function formchkr (frm) {
	var inps = frm.getElementsByTagName('input');
	var count = 0;
	for (var i=0; i<inps.length; i++) {
		if (inps[i].value == "" && inps[i].name != "submit" && inps[i].name != "reset") {
			count++;
			inps[i].style.border = "1px solid #ff0000";
		}
		else if (inps[i].name == "submit" || inps[i].name == "reset"){
			inps[i].style.border = "none";
		}
		else {
			inps[i].style.border = "1px solid #D2D2D2";
		}
	}
	if (count > 0) {
		alert("Please fill in all of the form criteria before submitting your request!");
		return false;
	}
	else
		return true;
}
