function popupShow(){
	var arrayPageSize = this.getPageSize();
	document.getElementById("popupbg").style.width=arrayPageSize[0]+"px";
	document.getElementById("popupbg").style.height=arrayPageSize[1]+"px";
	document.getElementById("popup").style.top=parseInt(document.documentElement.scrollTop+((screen.height/2)-300))+"px";
	document.getElementById("trigger").style.top=document.documentElement.scrollTop+"px";
	document.getElementById("popup").style.left=((arrayPageSize[0]/2)-145)+"px";
	
	$('popupbg').appear({ duration: 0.1 ,to: 0.9 });
	self.setTimeout("Effect.SlideDown('popup')", 100);
	return false;
}

function popupHide(){
	$('popupbg').hide();
	$('popup').hide();
	return false;
}

function getPageSize() {
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function show(id){
  	var e=document.getElementById(id);
  	if(e){e.style.display='';}
	return false;
}
function hide(id){
	var e=document.getElementById(id);
	if(e){e.style.display='none';}
	return false;
}

var XHRObj = false;
	
if (window.XMLHttpRequest) {
	XHRObj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
	XHRObj = new ActiveXObject("Microsoft.XMLHTTP");
}

function sendQuote() {
	if(!checkString(document.frm.name,"'Your Name'")){return false;}
	if(!checkEmail(document.frm.email)){return false;}
	
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;	
	if (XHRObj) {	
		XHRObj.open("POST", "popup.php", true);
		XHRObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		XHRObj.onreadystatechange = function() {
			if ((XHRObj.readyState == 4) && (XHRObj.status == 200)) {
				var messageObj = document.getElementById("quote-result");
				var xmlDocument = XHRObj.responseXML;
				
				quotes = xmlDocument.getElementsByTagName("quote");
				if(quotes[0].getAttribute("result")=="1") {
					messageObj.style.padding = "5px";
					messageObj.style.margin = "5px";
					messageObj.style.border = "1px solid #FF0000";
					messageObj.style.background = "#FDF1F1";
					messageObj.innerHTML = "Your quote has been received. We will get back to you as soon as possible.";
					document.getElementById("name").value="";
					document.getElementById("email").value="";
					document.getElementById("phone").value="";
				}
			}
		}
		XHRObj.send("name="+name+"&email="+email);
	}
}

function getscrollTop() {
	//alert(document.body.scrollTop);
	if (document.body.scrolltop!= null) return alert(document.body.scrolltop);
	if (window.pageYOffset!= null) return alert(window.pageYOffset);
	//return (null); 
}



checked=false;
function checkedAll(frm) {
	if (checked == false){
		checked = true;
   }else{
		checked = false;
	}
	for (var i =0; i < aa.elements.length; i++) {
		frm.elements[i].checked = checked;
	}
}

