/**
 * @author terry
 */
//Trigger winodws's print function
function printpage(){
	window.print();
}

function closeWindow(){
	window.close();
}

/**
 * Popup Window
 * @param {Object} link
 * @param {Object} title
 */
function openPopUpWindow(link) {

	var iMyWidth;
	var iMyHeight;
	var window_height = 500;
	var window_width = 700;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (75 + 10);
	
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (100 + 50);
	
	//Open the window.
	var popup = window.open(link,"test",
							"status=no,height="+window_height+",width="+window_height
							+ ",resizable=yes, left=" + iMyWidth + ",top=" + iMyHeight 
							+ ",screenX=" + iMyWidth
							+ ",screenY=" + iMyHeight 
							+ ",scrollbars=1");
	popup.focus();
}
$(function() {
    $('#gallery a').lightBox();
});

function getXMLHTTP() { //fuction to return the xml http object
	var xmlhttp=false;	
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)	{		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1){
				xmlhttp=false;
			}
		}
	}
	 	
	return xmlhttp;
}

function getLocationArea(districtId) {		
	
	var strURL="../../helpers/findLocationArea.php?district_id="+districtId;
	var req = getXMLHTTP();
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('locationAreaDiv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}
