﻿
var bannerCount = 6;
var activeBanner = 1;


//jquery functionality
$(document).ready(function() {
    
    $(function() {
        $(".link")
            .mouseover(function() { 
                $(this).addClass('link_over');
            })
            .mouseout(function() {
                $(this).removeClass('link_over');
            });
    });
    
    var IsActive = false;
    
    $(function() {
        $(".banner_control")
            .mouseover(function() { 
                
                if ($(this).attr('src') == "Images/" + $(this).attr('id') + "_active.png")
                {
                    IsActive = true;
                }
                else
                {
                    IsActive = false;
                    $(this).attr('src', "Images/" + $(this).attr('id') + "_active.png");
                }
            })
            .mouseout(function() {
                if(!IsActive)
                {
                    $(this).attr('src', "Images/" + $(this).attr('id') + ".png");
                }
            })
            .click(function() {
                activeBanner = parseInt($(this).attr('id').replace("btn", ""));
                $(this).attr('src', "Images/" + $(this).attr('id') + "_active.png");
                IsActive = true
                RotateBanner(false);
            });
    });
   
   
});

RotateBanner(true);

function RotateBanner(recall)
{    
    $(".banner_control").each(function() { 
        $(this).attr('src', "Images/" + $(this).attr('id') + ".png");
    });
    
    $("#btn" + activeBanner).attr('src', "Images/btn" + activeBanner + "_active.png");
    $("#banner").attr('src', "Images/banner" + activeBanner + ".jpg");
    
    if (activeBanner == 6)
    {
        activeBanner = 1;
    }
    else
    {
        activeBanner = activeBanner + 1;
    }
    
    if(recall)
    {
        setTimeout("RotateBanner(true);", 10000);
    }
}


function SubmitContact() 
{
    var sName = $("#txtName").val();
    var sTel = $("#txtTel").val();
    var sEmail = $("#txtEmail").val();
    var sMessage = $("#txtMessage").val();
    
    $('#contactSent').show();
    
    $.ajax({
        type: "POST",
        url: "Handlers/Contact/SendContactEmail.ashx",
        data: "Name=" + sName + "&Tel=" + sTel + "&Email=" + sEmail + "&Message=" + sMessage,
        success: function(xml) {
            $('#contactSent').attr("innerHTML","Your message has been sent.");
            setTimeout("$('#contact').dialog('close');", 1000);
        }
    });
}
