﻿// by Daniel Ng, County of Lambton
// Copyright 4th December 2008

var oZoomLevel = null;
var oMap = null;
var oScaleBar = null;

// Function to launch a pop up window displaying detailed information
function OpenPopup(strOpen)
{
    var s = strOpen.split("=");
    if(s[1]!=null && s[1]!=''){
        window.open(strOpen,'Info','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=384,height=500,left=50,top=50,titlebar=yes');
    } else {
        alert("Unable to retrieve detailed information due to invalid record ID.");
    };
}

// Function to launch a pop up window displaying all results
function OpenPopup2(strOpen)
{
    try {
        window.open(strOpen,'Results','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=400,left=50,top=50,titlebar=yes');
    } catch(err) {
        alert('Sorry! Your browser do not support this operation.');
        return false;
    }
}

// Function to print a web page
function PrintPage()
{
    try {
        if (window.print) {window.print();};
    } catch(err) {
        alert('Sorry! Your browser do not support this operation.');
        return false;
    }
}

// Function to show the processing dialog box
function ShowProcessing(){
    window.status = "Processing... Please wait.";
    var divtag = document.getElementById("dv-loading");
    if (divtag) {
        var screenY = document.body.offsetHeight;
        var screenX = document.body.offsetWidth;
        var ew = 200;   // width of the div tag
        divtag.style.left = (screenX - ew)/2 + 'px'; 
        divtag.style.top = '300px'; 
        divtag.style.visibility = "visible"; 
    };
}

// Function to hide the processing dialog box
function HideProcessing(){
    window.status = "Done";
    var divtag = document.getElementById("dv-loading");
    if (divtag) {divtag.style.visibility = "hidden";};
    return true;
}

// Function to hide div element
function HideDiv(id){
    divtag = document.getElementById(id);
    if (divtag) {
        divtag.style.visibility = "hidden"; 
        divtag.style.display = "none";
    };
    return true;
}

// Function to display floating panel element on the center of the screen
function ShowFloatingPanel(id){
    paneltag = document.getElementById(id);
    if (paneltag) {
        if (paneltag.style.visibility != "visible"){
            var screenY = document.body.offsetHeight;
            var screenX = document.body.offsetWidth;
            var ew = paneltag.style.width.replace("px","");     // width of the panel tag
            var hw = paneltag.style.height.replace("px","");    // height of the panel tag
            paneltag.style.position = 'absolute';
            paneltag.style.left = (screenX - ew)/2 + 'px'; 
            paneltag.style.top = '260px'; //(screenY - hw)/2 + 'px'; 
            paneltag.style.zindex = 100;
            paneltag.style.display = "block";
            paneltag.style.visibility = "visible"; 
        } else {
            paneltag.style.display = "block";
        };
    };
    return true;
}

// Function to find any HTML element on a page. Returns Left and Top position.
function FindElementPosition(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}