﻿// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006 www.cryer.co.uk
function IncludeJavaScript(jsFile) {
    document.write('<script type="text/javascript" src="'
    + jsFile + '"></script>');
}
/***********************************************
* DHTML Window Widget- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
IncludeJavaScript('windowfiles/dhtmlwindow.js');
IncludeJavaScript('modalfiles/modal.js');

function loginPopup(siteId) 
{
    loginWindow = dhtmlmodal.open('loginbox', 'iframe', 'login.aspx?action=update&siteId='+siteId.toString(), 'Confirmation', 'width=550px,height=250px,resize=0,scrolling=0,center=1', 'recal');
    loginWindow.onclose = function(success, results) 
    {
        if (success) 
        {
            location.href = '/updateSite.aspx?siteId=' + siteId.toString();
        }
        return true;
    }
}

function mappingPopup(hiddenControl, locationControl) {
    ctrlHidden = document.getElementById(hiddenControl);
    ctrlLocation = document.getElementById(locationControl);

    mappingWindow = dhtmlmodal.open('mappingbox', 'iframe', 'mapping.aspx?edit=1&locationString=' + ctrlHidden.value, 'Maps', 'width=685px,height=550px,resize=0,scrolling=0,center=1', 'recal');
    mappingWindow.onclose = function(success, results) {
        if (success) {
            ctrlHidden.value = results;
            if (results == "") {
                ctrlLocation.innerHTML = 'No Results Found';
            }
            else {
                ctrlLocation.innerHTML = 'Long: ' + results.replace(' ', ', Lat: ');
            };
        }
        return true;
    }
}

function mappingViewPopup(locationValue) {
    mappingWindow = dhtmlmodal.open('mappingbox', 'iframe', 'mapping.aspx?edit=0&locationString=' + locationValue, 'Maps', 'width=665px,height=530px,resize=0,scrolling=0,center=1', 'recal');
    mappingWindow.onclose = function(success, results) {
        if (success) {
        }
        return true;
    }
} 
function deadlinkPopup(siteId) {
    deadlinkWindow = dhtmlmodal.open('loginbox', 'iframe', 'login.aspx?action=delete&siteId=' + siteId.toString(), 'Confirmation', 'width=550px,height=250px,resize=0,scrolling=0,center=1', 'recal');
    deadlinkWindow.onclose = function(success, results) 
    {
        history.go(0);
        return true;
    }
}

function reviewPopup(siteId) 
{
    reviewWindow = dhtmlmodal.open('reviewbox', 'iframe', 'reviews.aspx?siteId=' + siteId.toString(), 'Reviews', 'width=600px,height=450px,resize=0,scrolling=0,center=1', 'recal');
    reviewWindow.onclose = function(success, results) 
    {
        if (success) 
        {
            history.go(0);
        }
        return true;
    }
}

function getWidth() {
    var myWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
    }
    return myWidth;
}

function getHeight() {
    var myHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.body.offsetHeight //document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight * 2;
}
