// Form Lightbox Effect

// Set Lightbox Variable for window.resize function
var lightBoxVar = 0;

// Sizes overlay div to 100% of browser height, either window height or container div height, whatever is taller
function overlaySize() {
	winH = document.body.offsetHeight;
	totalHeight = document.getElementById('Table_01').offsetHeight;
	if(winH > totalHeight) {
		document.getElementById('overlay').style.height = winH + "px";
	} else {
		document.getElementById('overlay').style.height = (totalHeight + 75) + "px";
	}
}
	
// Close the lightbox
function closeWin() {
	document.getElementById('overlay').style.display="none";
	document.getElementById('lightbox_content').style.display="none";
	lightBoxVar = 0;
	showSelect(); /* Remove if IE6 code not used below */
}

// Create Overlay and Form Container, add lightbox content to form container
function createDivs() {
var div = document.createElement('div');
		var container = document.createElement('div');
    	div.id = 'overlay';
		container.id = 'lightbox_content';
if (document.body.firstChild){
      	document.body.insertBefore(div, document.body.firstChild);
		document.body.insertBefore(container, document.body.firstChild);
		} else {
      	document.body.appendChild(div);
		document.body.appendChild(container);
		}
}

// Calls create div function, sends zip code variable to iframe url
function showForm() {
		removeSelect(); /* Remove if IE6 code not used below */
	 	createDivs();
		document.getElementById('overlay').style.display="block";
		document.getElementById('lightbox_content').style.display="block";
		document.getElementById('lightbox_content').innerHTML="<?php $ipi = getenv(\"REMOTE_ADDR\");$httprefi = getenv (\"HTTP_REFERER\");$httpagenti = getenv (\"HTTP_USER_AGENT\");?><div id='form_wrap'><span class=\"callme1\">Tell Me More About...</span><form action=\"more.php\" method=\"post\" class=\"callme\"><div><label>Full Name:</label> <input type=\"text\" name=\"name\" id=\"name\" /></div><div><label>Email:</label> <input type=\"text\" name=\"email\" id=\"email\" /></div><div><label>Telephone:</label> <input type=\"text\" name=\"tel\" id=\"tel\" maxlength=\"11\" /></div><div><label>Tell Me About:</label> <input type=\"text\" name=\"about\" id=\"about\" value=\"\"/><br /><span class=\"about\">e.g, \"mechanical system\" or \"hangers\"...</span></div><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" class=\"callmesub\" /><br /><br /><a href='javascript:closeWin();' id='close_form'>Cancel</a></div>";
	overlaySize();
	lightBoxVar = 1;
}


/*

<select name=\"about\"><option>Accessories</option><option>Cabinets</option><option>Drop Box</option><option>Electronic Systems</option><option>GPS Systems</option><option>Key Boxes</option><option>Locktracker</option><option>Mechanical Systems</option></select>


*/



// To make sure the light box overlay resizes with the window
window.onresize = function() {
	if(lightBoxVar == 1) {
		overlaySize();
	}
}


// Hide the selectbox for IE6 fix - Code below is OPTIONAL
var rv = -1;
function getInternetExplorerVersion()	{
  //var rv = -1;
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
	var ua = navigator.userAgent;
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	if (re.exec(ua) != null)
	  rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function removeSelect() {
	var selectBox = document.getElementsByTagName('select');
	var selectObj = selectBox.item(0);
	var isIE=/*@cc_on!@*/false;//IE detector
		if(isIE){ // IE
			getInternetExplorerVersion();
			if(rv == 6 && selectBox) {
				  	selectObj.style.display="none";
			  }
	}
}
function showSelect() {
	var selectBox = document.getElementsByTagName('select');
	var selectObj = selectBox.item(0);
	var isIE=/*@cc_on!@*/false;//IE detector
		if(isIE){ // IE
			getInternetExplorerVersion();
			if(rv == 6 && selectBox) {
				  	selectObj.style.display="block";
			  }
	}
}