﻿var win = null;
var ScreenWidth = null;
var ScreenHeight = null;

function openWindow(mypage, myname) {
    { ScreenWidth = 900 }
    { ScreenHeight = 700 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=yes,directories=no,fullscreen=no,status=yes,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function smallWindow(mypage, myname) {
    { ScreenWidth = 640 }
    { ScreenHeight = 480 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=yes,directories=no,fullscreen=no,status=no,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function imageWindow(mypage, myname) {
    { ScreenWidth = 600 }
    { ScreenHeight = 600 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=yes,directories=no,fullscreen=no,status=no,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function encodeName(name) {
    name = name.replace(/\+/g, "");
    name = name.replace(/\./g, "");
    name = name.replace(/\-/g, "");
    name = name.replace(/\//g, "");
    name = name.replace(/\?/g, "");
    name = name.replace(/\=/g, "");
    name = name.replace(/\&/g, "");
    return escape(name);
}

function newsletterSubscribe() {
    var myForm = document.getElementById('aspnetForm');
    var myAction = myForm.action;

    myForm.target = '_blank';
    myForm.action = 'http://ui.constantcontact.com/d.jsp';

    myForm.submit();

    myForm.action = myAction;
    myForm.target = '_self';
}