/**
 * User: prussell
 * Date: 16-Sep-2011
 * Time: 8:05:13 AM
 */

var aDiv = new Object();
var aImg = new Array();
var aMenu =
    [{
        label:'Welcome',
        page:'welcome',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "Welcome to the web site of the Sackville Cobequid PC Assocation!<br /><br />"+
                    "We are the party of choice for"+
                    "<ul>"+
                        "<li>Responsible Government</li>"+
                        "<li>Keeping Promises</li>"+
                        "<li>Promoting Business and our Province</li>"+
                        "<li>Managing the Debt</li>"+
                        "<li>Keeping Taxes in line</li>"+
                    "</ul>"+
                    "<br />"+
                    "We are working hard at"+
                    "<ul>"+
                        "<li>Supporting Your Family</li>"+
                        "<li>Supporting Your Community</li>"+
                        "<li>Supporting Your Future</li>"+
                    "</ul>"+
                    "<br /><br />"+
                    "New: On November 23, from 7:30pm until 9:00pm, we are having a Christmas Social. "+
                        "This will be at the Knights Of Columbus Hall, 252 Cobequid Road.<br /><br />"+
                        "The cost of admission is: A donation for the food bank.";
        }
    },{
        label:'Meetings',
        page:'meetings',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "Our meetings are typically on the third Wednesday of each month at 7pm.<br /><br />"+
                    "We hold them at the Knights of Columbus Hall, 252 Cobequid Road<br /><br />"+
                    '<iframe width="425" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=252+cobequid+road,+lower+sackville,+ns&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=38.22949,79.013672&amp;vpsrc=6&amp;ie=UTF8&amp;hq=&amp;hnear=252+Cobequid+Rd,+Lower+Sackville,+Nova+Scotia+B4C+1Z8,+Canada&amp;t=m&amp;ll=44.763738,-63.657146&amp;spn=0.010665,0.018239&amp;z=15&amp;iwloc=A&amp;output=embed"></iframe>';
        }
    },{
        label:'Upcoming Events',
        page:'events',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "We regularly have extra events through the year, and we welcome you to them.<br /><br />"+
            "<table border=0>"+
                    "<tr><td>Jan 18, 2012</td><td></td><td>Executive Meeting</td></tr>"+
                    "<tr><td>Feb 10-12, 2012</td><td></td><td>Provincial AGM (Halifax Marriott)</td></tr>"+
                    "<tr><td>Feb 22, 2012</td><td></td><td>Sackville Cobequid AGM (Knights Of Columbus)</td></tr>"+
                    "<tr><td>Mar 21, 2012</td><td></td><td>Executive Meeting</td></tr>"+
                    "<tr><td>Apr 18, 2012</td><td></td><td>Executive Meeting</td></tr>"+
                    "<tr><td>May 16, 2012</td><td></td><td>Sackville Cobequid Spring Dinner (Lion's Den)</td></tr>"+
                    "<tr><td>Jun 20, 2012</td><td></td><td>Executive Meeting</td></tr>"+
                    "<tr><td>Summer, 2012</td><td></td><td>Summer BBQ (Knights Of Columbus)</td></tr>"+
                    "<tr><td>Sep 19, 2012</td><td></td><td>General Meeting</td></tr>"+
                    "<tr><td>Oct 17, 2012</td><td></td><td>Executive Meeting</td></tr>"+
                    "<tr><td>Nov 11, 2012</td><td></td><td>Remembrance Day (Cenotaph)</td></tr>"+
                    "<tr><td>Nov 21, 2012</td><td></td><td>General Meeting</td></tr>"+
                    "<tr><td></td><td>&nbsp;&nbsp;</td><td></td></tr>"+
            "</table>"
        }
    },{
        label:'Membership',
        page:'membership',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "We are always interested in any help that you can bring to the table, as a party member, a supporter, a volunteer, and as a friend.<br /><br />" +
                    "As valuable as all of these are, however, there are some distinct advantages to buying a membership in the party:" +
                    "<ul>"+
                        "<li><i>Voting privileges</i> at party and association meetings</li>"+
                        "<li>Work on a committee or the executive, and help <i>set the direction</i></li>"+
                        "<li>Regular party and association <i>news</i></li>"+
                        "<li><i>Attendance</i> at association general meetings</li>"+
                    "</ul>"+
                    "We invite you to become a member of the PC Party of Nova Scotia.<br /><br />"+
                    "Please <a href='http://pcparty.ns.ca/userfiles/mem_form.pdf' target='_new'>download the membership form</a> and drop it off with the association or mail it in to the party.<br /><br />"+
                    "Membership is only $10 per year.";
        }
    },{
        label:'Donate!',
        page:'donate',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "We are working to make a positive difference in our community and our province, and we need your help.<br /><br />" +
                        "As much as we rely on and appreciate our volunteers, we need funds to help us continue to operate and grow. <br /><br />"+
                        "There are a few different ways that you can donate and help our association.<br /><br />" +
                        "The most helpful of these is a small monthly donation that is automatically applied to your credit card or comes out of your bank account. "+
                        "This small amount can be split between a donation to the provincial organization and a donation to the Sackville Cobequid association.<br /><br />"+
                        "In addition, all donations (up to $1,000 annually) have a 75% tax refund. " +
                        "If you donate $400 through the year, you receive a tax credit for $300 and so the actual cost to you is only $100. "+
                        "The party and the association benefit, and it doesn't cost you that much to help!<br /><br />"+
                        "Please contact us directly at sackvillecobequid@gmail.com or by calling Paul Russell at (902) 830-5043 if you are interested in donating to the association.";
        }
    },{
        label:'Your Help',
        page:'volunteer',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "We welcome you to join us as a volunteer, a supporter, or a party member.<br /><br />"+
                    "Please contact us through the form below or by contacting our President at:<br /><br />"+
                    "Paul Russell<br />"+
                    "(902) 830-5043<br />" +
                    "sackvillecobequid@gmail.com<br /><br />"+
                            "<form name='frmHelp' method='POST' action=''>"+
                            "<table border=0 cellpadding=0 cellspacing=0>"+
                            "<tr><td>First Name</td><td>&nbsp</td><td><input name='txtFirstName' id='txtFirstName' type='text' size=20 maxlength=20 /></td></tr>"+
                            "<tr><td>Last Name</td><td>&nbsp</td><td><input name='txtLastName' id='txtLastName' type='text' size=20 maxlength=20 /></td></tr>"+
                            "<tr><td>E-mail Address</td><td>&nbsp</td><td><input name='txtEmail' id='txtEmail' type='text' size=40 maxlength=60 /></td></tr>"+
                            "<tr><td>Phone Number</td><td>&nbsp</td><td><input name='txtPhone' id='txtPhone' type='text' size=20 maxlength=20 /></td></tr>"+
                            "<tr><td>I would like to help as</td><td>&nbsp</td><td>"+
                            "<select name='selJoinType' id='selJoinType'>"+
                                "<option selected value='PC Party Member'>PC Party Member</option>"+
                                "<option value='Supporter'>Supporter</option>"+
                                "<option value='Volunteer'>Volunteer</option>"+
                                "<option value='I just want information'>I just want information</option>"+
                            "</select></td></tr>"+
                            "<tr><td>I would like to donate</td><td></td><td><input type='checkbox' name='chkDonate' id='chkDonate' /></td></tr>"+
                            "<tr><td>I would like information on</td><td>&nbsp;</td><td><textarea name='txtMoreInformation' id='txtMoreInformation' cols=40 rows=6></textarea></td></tr>"+
                            "<tr><td colspan='3'><input type='button' name='cmdSubmit' value='Please Contact Me' onclick='SubmitHelpForm();' /></td></tr>"+
                            "</table>"+
                            "</form>";
            document.frmHelp.txtFirstName.focus();
        }
    },{
        label:'Facebook Page',
        page:'facebooksackcob',
        type:'website',
        site:'http://www.facebook.com/pages/Sackville-Cobequid-PC-Association/177589952313923'
    },{
        label:'PC Party of NS',
        page:'pcpartyns',
        type:'website',
        site:'http://pcparty.ns.ca/'
    },{
        label:'Contact Us',
        page:'contact',
        type:'js',
        fn:function()
        {
            aDiv.divRightFrame.innerHTML =
                    "We welcome any comments or concerns that you have about our community, the province, the association, and the party.<br /><br />"+
                    "We are here to try and help make life better for those in and around Lower Sackville, and also for the broader community across Nova Scotia.<br /><br />"+
                    "Please contact us through the President of our Association:<br /><br />"+
                    "Paul Russell<br />"+
                    "(902) 830-5043<br />" +
                    "sackvillecobequid@gmail.com";
        }
    }];
var aEvent;
var intLogoWidth = 205;
var intLogoHeight = 105;
var intSeparatorHeight = 16;
var intMenuWidth = 140;
var intMenuItemHeight = 20;
var intMenuHeightMargin = 2;
var intMenuWidthMargin = 6;
var binShowError = false;

function Resize()
{
    try
    {
        var intHeight = window.innerHeight;
        var intWidth = window.innerWidth;
        if (! intHeight)
        {
            intHeight = screen.height;
            intWidth = screen.width;
        }
        var intPageWidth = Math.min(intWidth,740);
        var intLeft = Math.round((intWidth - intPageWidth)/2);
        aDiv.divTopFrame.style.left = px(intLeft);
        aDiv.divTopFrame.style.width = px(intPageWidth);
        aDiv.divTopContent.style.left = px(intLogoWidth);
        aDiv.divTopContent.style.width = px(intPageWidth - intLogoWidth);
        aDiv.divSeparator.style.left = px(intLeft);
        aDiv.divSeparator.style.width = px(intPageWidth);
        aDiv.divSeparatorCenter.style.left = px(4);
        aDiv.divSeparatorCenter.style.width = px(intPageWidth - (parseInt(aDiv.divSeparatorLeft.style.width) + parseInt(aDiv.divSeparatorRight.style.width)));
        aDiv.divSeparatorRight.style.left = px(intPageWidth - parseInt(aDiv.divSeparatorRight.style.width));
        aDiv.divLeftFrame.style.left = px(intLeft);
        aDiv.divLeftFrame.style.height = px(intHeight - (parseInt(aDiv.divTopFrame.style.height) + parseInt(aDiv.divBottomFrame.style.height)));
        aDiv.divRightFrame.style.left = px(intLeft + parseInt(aDiv.divLeftFrame.style.width));
        aDiv.divRightFrame.style.width = px(intPageWidth - parseInt(aDiv.divLeftFrame.style.width));
        aDiv.divRightFrame.style.height = px(intHeight - (parseInt(aDiv.divTopFrame.style.height) + parseInt(aDiv.divSeparator.style.height) + parseInt(aDiv.divBottomFrame.style.height)));
        aDiv.divBottomFrame.style.left = px(intLeft);
        aDiv.divBottomFrame.style.width = px(intPageWidth);
        aDiv.divBottomFrame.style.top = px(intHeight - parseInt(aDiv.divBottomFrame.style.height));
        var intMenuCount;
        for (intMenuCount = 0; intMenuCount < aMenu.length; intMenuCount++)
        {
            //aMenu[intMenuCount].div.style.left = px((intWidth - intPageWidth)/2);
        }
    }
    catch (err)
    {
        if (binShowError)
        {
            alert(err.message);
        }
    }
}
window.onload = function()
{
    try
    {
        //LoadImageToArray("2011_PC_Logo_small.png");
        aDiv.divTopFrame = document.getElementById("divTopFrame");
        aDiv.divTopFrame.style.height = px(intLogoHeight);
        aDiv.divSeparator = document.getElementById("divSeparator");
        aDiv.divSeparatorLeft = document.getElementById("divSeparatorLeft");
        aDiv.divSeparatorCenter = document.getElementById("divSeparatorCenter");
        aDiv.divSeparatorRight = document.getElementById("divSeparatorRight");
        aDiv.divSeparator.style.top = px(intLogoHeight);
        aDiv.divSeparator.style.height = px(intSeparatorHeight);
        aDiv.divSeparatorLeft.style.height = px(7);
        aDiv.divSeparatorCenter.style.height = px(7);
        aDiv.divSeparatorRight.style.height = px(7);
        aDiv.divTopContent = document.getElementById("divTopContent");
        aDiv.divTopContent.style.height = px(intLogoHeight);
        aDiv.divLeftFrame = document.getElementById("divLeftFrame");
        aDiv.divLeftFrame.style.top = px(intLogoHeight + intSeparatorHeight);
        aDiv.divLeftFrame.style.width = px(intMenuWidth);
        aDiv.divRightFrame = document.getElementById("divRightFrame");
        aDiv.divRightFrame.style.top = px(intLogoHeight + intSeparatorHeight);
        aDiv.divBottomFrame = document.getElementById("divBottomFrame");
        aDiv.divBottomFrame.style.height = px(20);
    }
    catch (err)
    {
        if (binShowError)
        {
            alert(err.message);
        }
    }
    DrawMenu();
    Resize();
    MenuCall('welcome');
};
window.onresize = function()
{
    setTimeout("Resize();",50);
};
function DrawMenu()
{
    try
    {
        var intMenuCount;
        var strHTML = '';
        for (intMenuCount = 0; intMenuCount < aMenu.length; intMenuCount++)
        {
            strHTML += "<div id='divMenu" + intMenuCount + "' class='divMenu'>" + aMenu[intMenuCount].label + "</div>";
        }
        aDiv.divLeftFrame.innerHTML = strHTML;
        for (intMenuCount = 0; intMenuCount < aMenu.length; intMenuCount++)
        {
            aMenu[intMenuCount].div = document.getElementById("divMenu" + intMenuCount);
            aMenu[intMenuCount].div.MenuPage = aMenu[intMenuCount].page;
            aMenu[intMenuCount].div.style.height = px(intMenuItemHeight);
            aMenu[intMenuCount].div.style.top = px(intMenuCount * (intMenuItemHeight + intMenuHeightMargin));
            aMenu[intMenuCount].div.style.width = px(intMenuWidth - intMenuWidthMargin);
            aMenu[intMenuCount].div.onclick = function() {MenuCall(this.MenuPage);};
        }
    }
    catch (err)
    {
        if (binShowError)
        {
            alert(err.message);
        }
    }
}
function LoadImageToArray(strFilename)
{
    var strImageFile = "images/" + strFilename;
    var imgNew = new Image();
    imgNew.src = strImageFile;
    var intImage = 0;
    if (aImg)
    {
        intImage = aImg.length;
    }
    aImg[intImage] = {name:strFilename, src:strImageFile, img:imgNew, height:imgNew.height, width:imgNew.width};
}
function SubmitHelpForm()
{
    var txtFirstName = trim(document.frmHelp.txtFirstName.value);
    var txtLastName = trim(document.frmHelp.txtLastName.value);
    var txtEmail = trim(document.frmHelp.txtEmail.value);
    var txtPhone = trim(document.frmHelp.txtPhone.value);
    var txtJoinType = document.frmHelp.selJoinType.value;
    var binDonate = document.frmHelp.chkDonate.checked;
    var txtMoreInformation = trim(document.frmHelp.txtMoreInformation.value);
    if ((txtFirstName == '' && txtLastName == '') || (txtEmail == '' && txtPhone == ''))
    {
        alert("At least your name, and either your phone number or e-mail address, are required.");
        return;
    }
    var txtSubmit = '&first=' + HTTPEncode(txtFirstName);
    txtSubmit += '&last=' + HTTPEncode(txtLastName);
    txtSubmit += '&email=' + HTTPEncode(txtEmail);
    txtSubmit += '&phone=' + HTTPEncode(txtPhone);
    txtSubmit += '&join=' + HTTPEncode(txtJoinType);
    txtSubmit += '&donate=' + (binDonate ? 'yes' : 'no');
    txtSubmit += '&moreinfo=' + HTTPEncode(txtMoreInformation);
    Execute("page=inforequest" + txtSubmit);
    alert("Your information has been sent. Thank you for contacting us. We will be in touch shortly.");
    MenuCall('welcome');
}
function MenuCall(strMenuCall)
{
    var intMenuItem = -1;
    var intMenuCount;
    for (intMenuCount = 0; intMenuCount < aMenu.length && intMenuItem == -1; intMenuCount++)
    {
        if (aMenu[intMenuCount].page == strMenuCall) {intMenuItem = intMenuCount;}
    }
    for (intMenuCount = 0; intMenuCount < aMenu.length && intMenuItem == -1; intMenuCount++)
    {
        if (aMenu[intMenuCount].label == strMenuCall) {intMenuItem = intMenuCount;}
    }
    for (intMenuCount = 0; intMenuCount < aMenu.length; intMenuCount++)
    {
        if (intMenuCount == intMenuItem)
        {
            aMenu[intMenuCount].div.style.backgroundColor = "#99FFFF";
            aMenu[intMenuCount].div.innerHTML = '<span class="fontSelectedMenu">' + aMenu[intMenuCount].label + '</span>';
        }
        else
        {
            aMenu[intMenuCount].div.style.backgroundColor = "#ffffff";
            aMenu[intMenuCount].div.innerHTML = '<span class="fontUnselectedMenu">' + aMenu[intMenuCount].label + '</span>';
        }
    }
    switch (aMenu[intMenuItem].type)
    {
        case 'js':
            aMenu[intMenuItem].fn();
            break;
        case 'website':
            if (confirm("The " + aMenu[intMenuItem].label + " web site will be opened in a new window. This may not work if you have popups disabled."))
            {
                window.open(aMenu[intMenuItem].site,aMenu[intMenuItem].page);
            }
            break;
    }
}
