﻿
// IMAGE ROLLOVERS

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

//Print out a page
function printPage() {
    window.print();
    return false;
}

function openEmailPopup(url, height, width, top, left) {
    return openPopup(url, height, width, top, left, "email_popup");
}

function openFaqPopup(url, height, width, top, left) {
    return openPopup(url, height, width, top, left, "faq_popup");
}

// POP UP NEW WINDOW and RESIZE TO DEFINED WIDTH and HEIGHT
function openPopup(url, height, width, top, left, windowName) {
    var windowFeatures = "resizable=1,height=" + height + ",width=" + width
	        + ",top=" + top + ",left=" + left + ",location=0,toolbar=0,scrollbars=1";

    var popup = window.open(url, windowName, windowFeatures);

    //The page needs to be reloaded in IE.
    if (navigator.appVersion.indexOf("MSIE") != -1)
        popup.location.reload();

    popup.focus();

    return false;
}


// FORM INPUT TEXT CLEAR (Currently used on Booking Widget, Service Finder Widget)
function textClear(theText) {
    if (theText.value == theText.defaultValue) {
        theText.value = ""
    }
}


// SHOW/HIDE FUNCTIONALITY

// Currently used for Windowshading Functionality and on Media Player to swap out Media Types

function shn_showtool(id) {
    var elm = document.getElementById(id)
    elm.style.display = "block"
}


function shn_hidetool(id) {
    var elm = document.getElementById(id)
    elm.style.display = "none"
}

function shn_hide_all(prefix, offset) {
    var cnt_div = offset;

    while (document.getElementById(prefix + cnt_div) != null) {
        document.getElementById(prefix + cnt_div).style.display = "none";
        cnt_div++;
    }
}

function shn_show_all(prefix, offset) {
    var cnt_div = offset;

    while (document.getElementById(prefix + cnt_div) != null) {
        document.getElementById(prefix + cnt_div).style.display = "";
        cnt_div++;
    }
}

function shn_change_class(id, newClass) {
    var elm = document.getElementById(id)
    elm.className = newClass;
}


function check_uncheck(ctrlID) {
    for (var j = 0; j < document.forms[0].elements.length; j++) {
        if (document.forms[0].elements[j].type == "checkbox") {
            var chkd = document.getElementById(ctrlID.id);
            if (chkd.checked) {
                if (document.forms[0].elements[j].id.indexOf("chkListALLCategories") != -1)
                    document.forms[0].elements[j].checked = true;
            }
            else {
                document.forms[0].elements[j].checked = false;
            }
        }
    }
} // function

function UnCheckMain(ctrlID, selectedCtrlID) {
    for (var j = 0; j < document.forms[0].elements.length; j++) {
        var chkd = document.getElementById(ctrlID.id);
        var childCtrl = document.getElementById(selectedCtrlID.id);
        if (!childCtrl.checked)
            chkd.checked = false;
        else
            chkd.checked = false;
    }
} // function


function trackIt(pn, p1, exitLink, url)
//pn is used for Page Name
//p1 is used  for Section  name
{
    //	alert("pn: " + pn + "\n p1: " + p1);
    if (typeof (s) != "undefined") {
        s.pageName = pn;
        s.channel = p1;
        if (!exitLink) {
            void (s.t());
        }
    }
}

