﻿// JScript File

$(document).ready(function() {
    $('div.loginbox, ul.list3, ul.list2').hide();

    $('a.loginlink').toggle(function() {
        $(this).parent().addClass('login_on');
    }, function() {
        $(this).parent().removeClass('login_on');
    });

    $('a.loginlink').click(function() {
        $('div.loginbox').slideToggle(200);
        $('#newsScroller').toggle(200);
    });

    $('.tabs a:contains("Details")').click(function() {
        $(this).parent().siblings('div:eq(2), div:eq(3)').hide();
        $(this).parent().siblings('div:eq(4)').show();
    }, function() {
        $(this).parent().siblings('div:eq(4), div:eq(3)').hide();
        $(this).parent().siblings('div:eq(2)').show();
    });

    $('.tabs a:contains("Contact")').click(function() {
        $(this).parent().siblings('div:eq(2), div:eq(4)').hide();
        $(this).parent().siblings('div:eq(3)').show();
    }, function() {
        $(this).parent().siblings('div:eq(3), div:eq(4)').hide();
        $(this).parent().siblings('div:eq(2)').show();
    });

    $(".officeMapMenu").show();
    $(".officeMapMenuOpen").hide();

    $("#showOffices").click(function() {
        $(".officeMapMenuOpen").slideToggle(500);
    });

    //$(div.breadcrumb ul li).
    var show = false;
    $(".showhide").click(function() {
    if (!show) {
            $(".showhide").text("Show new boats");
            $("#newboat_results").fadeOut(500);
            show = true;
        } else {
            $(".showhide").text("Hide new boats");
            $("#newboat_results").fadeIn(500);
            show = false;
        }
    });

});
    
    
    
function ShowBigImg(src,alt,id)
{
    $(".thumbs").children("img").removeClass("selected");
    $("#"+id).addClass("selected");
    $("#FullImage").html("<img src='"+src+"' alt='"+alt+"'>");        
}

function ShowBigImgWithDescription(src,alt,id,description)
{
    $(".thumbs").children("img").removeClass("selected");
    $("#"+id).addClass("selected");
    
    if(description!="")       
        $("#FullImage").html("<img src='"+src+"' alt='"+alt+"'><br>"+description); 
    else
        $("#FullImage").html("<img src='"+src+"' alt='"+alt+"'>"); 
        
}


function textMaxLength(obj, maxLength, evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    var max = maxLength - 0;
    var text = obj.value;
    if (text.length > max) {
        var ignoreKeys = [8, 46, 37, 38, 39, 40, 35, 36];
        for (i = 0; i < ignoreKeys.length; i++) {
            if (charCode == ignoreKeys[i]) {
                return true;
            }
        }
        return false;
    }
    else {
        return true;
    }
}
function textCounter(maxlimit, textBox, div) {
    var text = textBox.value;
    if (text.length > maxlimit) // if too long...trim it!
    {
        textBox.value = text.substring(0, maxlimit);
        document.getElementById(div).innerHTML = "max " + maxlimit + " characters <span>(0 remaining)</span>";
    }
    else if (text.length < maxlimit) {
        var textLength = text.length;
        var charsLeft = maxlimit - textLength;
        document.getElementById(div).innerHTML = "max " + maxlimit + " characters <span>(" + charsLeft + " remaining)</span>";
    }
}
    