﻿$ektron(document).ready(function() { swapValues = []; $ektron(".swap_value").each(function(i) { swapValues[i] = $ektron(this).val(); $ektron(this).focus(function() { if ($ektron(this).val() == swapValues[i]) { $ektron(this).val("") } }).blur(function() { if ($ektron.trim($ektron(this).val()) == "") { $ektron(this).val(swapValues[i]) } }) }) });
$ektron(document).ready(function() {
    $ektron(".wmark").each(function(i) {
        $ektron(this).focus(function() { $ektron(this).addClass("black"); $ektron(this).removeClass("wmark"); });
        $ektron(this).blur(function() { $ektron(this).removeClass("black"); $ektron(this).addClass("wmark"); })
    });
    $ektron(".swmark").each(function (i) {
        $ektron(this).focus(function () { $ektron(this).addClass("black"); $ektron(this).removeClass("swmark"); });
        $ektron(this).blur(function () { $ektron(this).removeClass("black"); $ektron(this).addClass("swmark"); })
    });
    $ektron(".lwmark").each(function (i) {
        $ektron(this).focus(function () { $ektron(this).addClass("black"); $ektron(this).removeClass("lwmark"); });
        $ektron(this).blur(function () { $ektron(this).removeClass("black"); $ektron(this).addClass("lwmark"); })
    });

});

$ektron(document).ready(function () { $ektron('#SlideShow').cycle({ timeout: 5000 }); });

$ektron(document).ready(function () {

    $ektron('.submit').click(function () {
        $ektron('#aspnetForm').attr("action", "http://visitor.constantcontact.com/d.jsp");
        $ektron('#aspnetForm').submit(); 

    });
});


function recenterModal(modalIdStr) {
    var modal = document.getElementById(modalIdStr);
    var modalWidth = modal.clientWidth;
    var modalHeight = modal.clientHeight;
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();

    var modalLeftVal = (arrayPageSize[2] - 20 - modalWidth) / 2;
    var modalLeft = (modalLeftVal < 0) ? window.pageXOffset + "px" : (window.pageXOffset + modalLeftVal) + "px";

    var modalTopVal = (arrayPageSize[3] - modalHeight) / 2;
    var modalTop = (modalTopVal < 0) ? window.pageYOffset + "px" : (window.pageYOffset + modalTopVal) + "px";

    modal.style.left = modalLeft;
    modal.style.top = modalTop;
}
function showModal(modalIdStr) {
    // to prevent overlay showing twice on a double click
    if (document.getElementById('overlay')) {
        return;
    }

    //create overlay
    var $overlay = $(document.createElement('div'));
    $overlay.addClass('jqmOverlay').css({ 'height': '100%', 'width': '100%', 'position': 'fixed', 'left': '0pt', 'top': '0pt', 'z-index': '499', 'opacity': '0.5' }).attr('id', 'overlay');
    $overlay.prependTo('body');

    var modal = document.getElementById(modalIdStr);

    $(modal).show();
    var modalWidth = modal.clientWidth;
    var modalHeight = modal.clientHeight;
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();


    var modalLeftVal = (arrayPageSize[2] - 20 - modalWidth) / 2;
    var modalLeft = (modalLeftVal < 0) ? window.pageXOffset + "px" : (10 + modalLeftVal) + "px";

    var modalTopVal = (arrayPageSize[3] - modalHeight) / 2;
    var modalTop = (modalTopVal < 0) ? window.pageYOffset + "px" : (0 + modalTopVal) + "px";



    modal.style.left = modalLeft;
    modal.style.top = modalTop;

    $(modal).css({ 'z-index': '500' });


}
function hideModal(modal) {
    var modal = document.getElementById(modal);
    $(modal).css({ 'z-index': '0' }).hide();
    $('.jqmOverlay').remove();

}




//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//

function getPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        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
        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 = windowWidth;
    } else {
        pageWidth = xScroll;
    }


    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll() {

    var yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }

    arrayPageScroll = new Array('', yScroll)
    return arrayPageScroll;
}



