﻿var winHeight = $(window).height();
var winWidth = $(window).width();


// **********************************************
// Increase the height of the main-content-area 
// based on the height of the browser to move the
// footer to the bottom of the page
// **********************************************
function moveFooter() {
    var h = $(window).height() - 200;
    var containerHeight = $("#container").css('height').replace('px', '');
    var headerHeight = $("header").css('height').replace('px', '');
    var footerHeight = $("footer").css('height').replace('px', '');
    var h1 = $("#sectionBody").css('height').replace('px', '');
    if (h > h1) {
        $("#sectionBody").css('height', h);
    } else {
        $("#sectionBody").css('height', h1);
    }

    if ($("#designCentreImage1").length) {
        $("#designCentreImage1").css('height', $("#container").height());
    };
    if ($("#designCentreImage2").length) {
        $("#designCentreImage2").css('height', $("#container").height());
    };
};
// **********************************************

$(window).load(function () {
    moveFooter();
});

$(document).ready(function () {
   
    $("#personQuoteText").hide();

    $('a[rel="external"]').attr({
        target: "_blank",
        title: "This link will open in a new window"
    })
	.append(' <img src=\"/SiteResources/Corporate/Site/nw.gif\" width=\"16\" height=\"12\" alt=\"New Window Icon\" />');

    
    $(window).resize(function () {
        $.doTimeout('moveFooter', 250, function () {
            moveFooter();
        });
    });

    $('#campaignEnquiryForm').submit(function () {

        return isCampaignEnquiryValid();
    });


});


    



function isCampaignEnquiryValid() {

    var isValid = true;

    //    Firstname
    if ($("#FirstName").val() == "") {

        $("#firstnamerequired").attr("class", "enquiryrowerrorlableshow");
        $("#FirstName").attr("class", "errortextbox");
        isValid = false;
    }
    else {

        $("#firstnamerequired").attr("class", "enquiryrowerrorlablehide");
        $("#FirstName").attr("class", "textbox");
    }

    //    Surname
    if ($("#LastName").val() == "") {

        $("#lastnamerequired").attr("class", "enquiryrowerrorlableshow");
        $("#LastName").attr("class", "errortextbox");
        isValid = false;
    }
    else {

        $("#lastnamerequired").attr("class", "enquiryrowerrorlablehide");
        $("#LastName").attr("class", "textbox");
    }

    //    Email
    if ($("#Email").val() == "") {

        $("#emailrequired").attr("class", "enquiryrowerrorlableshow");
        $("#Email").attr("class", "errortextbox");
        isValid = false;
    }
    else {

        $("#emailrequired").attr("class", "enquiryrowerrorlablehide");
        $("#Email").attr("class", "textbox");
    }

    //    Phone
    if ($("#Phone").val() == "") {

        $("#phonenorequired").attr("class", "enquiryrowerrorlableshow");
        $("#Phone").attr("class", "errortextbox");
        isValid = false;
    }
    else {

        $("#phonenorequired").attr("class", "enquiryrowerrorlablehide");
        $("#Phone").attr("class", "textbox");
    }

    if (!isValid)
        $(".errortext").show();
    else
        $(".errortext").hide();

    return isValid
}












    

//function galleria() {
//    $(".gallery-container").galleria({
//        width: 900,
//        autoplay: true,
//        height: 600,
//        showImagenav: false,
//        showCounter: false,
//        showInfo: false,
//        thumbnails: false,
//        transitionSpeed:400,
//        showImagenav:true
//    });
//};



//    function LoadGallery() {

//    var url = "/Corporate/Media/Gallery";
//  //  var jsonString = "{\"PersonnelID\":" + JSON.stringify(personnelID) + "}";

//    
//    $.ajax({
//        type: "POST",
//        url: url,
//        dataType: "html",
//      //  data: jsonString,
//        contentType: "application/json; charset=utf-8",

//        success: function (result) {

//            $("#mediaGalleryBox").html("");
//            $("#mediaGalleryBox").html(result);


//            
//            galleria();
//            Galleria.ready(function () {
//                this.bind('idle_enter', function (e) {
//                    this.play();
//                });
//            });

//        },
//        error: function (request, error) {
//            
//        }
//    })

//}
