﻿// master JS client-side script functions.
// copyright Next6Exits

function a(str) { //quick alert
    alert(str);
}

function d(id) { //get DOM element by id independently
    var ie = (document.all);
    var ns4 = document.layers ? true : false;
    var dom = document.getElementById && !document.all ? true : false;

    if (dom) return document.getElementById(id);
    else if (ie) return document.all[id];
    else if (ns4) return document.layers[id];

}

function imgPop(isStage,imgRef,w,h) { //n6e image viewer
    window.open(isStage+"/n6e/imageViewer.aspx?id=" + imgRef, "imgPop", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h);
    return false
}

function n6e(pgeName) { //the onload event, leave empty if not required
    //used to initialise jquery etc
    switch(pgeName) {
        case "index":
            onLoadHome(); // loads home function
            break;
        case "news": // loads generic news page function
            onLoadNews();
            break;
    }
}

function onLoadHome() {
    var $ = jQuery.noConflict(); 
    $(document).ready(function(){ 	
        $(".img-slide").click(function(){
            $("#divPanel").slideToggle("slow");
            return false;
        });
    });
}
function onLoadNews() {
    var $ = jQuery.noConflict();
    $(document).ready(function () {
        $(".img-slide").click(function () {
            $("#divPanel").slideToggle("slow");
            return false;
        });
        $('p.newsMonthHeading').click(function () {
            //$(".display").not($(this).next()).slideUp();
            var $this = $(this);
            var elID = $this.attr("id").replace("newsMonthHeading_", "newsMonthWrap_");
            var $el = $('#' + elID);
            if ($el.is(':visible')) {
                $el.slideUp(500);
            } else {
                $el.slideDown(500);
            }
            return false;
        });
        $('p.newsYearHeading').click(function () {
            //$(".display").not($(this).next()).slideUp();
            var $this = $(this);
            var elID = $this.attr("id").replace("newsYearHeading_", "newsYearWrap_");
            var $el = $('#' + elID);
            if ($el.is(':visible')) {
                $el.slideUp(500);
            } else {
                $el.slideDown(500);
            }
            return false;
        });
    });
}

function emailFormValidate() { //called from an email form when validation active.
    alert("N6E Email Form Validation");
    //return false;
}

function n6eTextArea(id) {
    if (d(id).value == 'Please enter...') { d(id).value = ''; }
}
