﻿$(function() {
    $(".textField").focus(function() {
        $(this).addClass("focus").attr("value", "");
    }).blur(function() {
        $(this).removeClass("focus");
    });

    $(".tab").click(function(e) {
        var slideHeight = 0
        $("*").stop(true, true);
        e.preventDefault();
        var selectedtab = $(".on").parent().attr("class");
        var target = $(this).attr("rel").toLowerCase();

        if (target == selectedtab) return;

        $(".tab").removeClass("on");
        $(this).addClass("on");

        $(".tabContent").customFadeOut(500);
        if (target == "tab1") { matchTab = "tab1"; } else { matchTab = "tab2"; }
        var $matchContainer = $("#" + matchTab).parent();
        var contentHeight = $("#" + matchTab).outerHeight(true);
        //alert(contentHeight);
        //alert($matchContainer.height());

        if (matchTab == "tab1") {

            if ($("#" + matchTab).children(":first").hasClass('tweet_list')) {
                contentHeight += $("#" + matchTab).children(":first").children().length * 20;
            }
        }
		else {
        contentHeight += 20;
		}
        $matchContainer.animate({ height: contentHeight }, 500);
        $("#" + target).animate({ opacity: 1.0 }, 500).customFadeIn(350);
    });
    $("body select").msDropDown();
    
    $(".enquiry-button").hover(
        function() {
            $(this).attr("src", "/images/contact-button-hover.png")
        },
        function() {
            $(this).attr("src", "/images/contact-button.png")
        }
     );
             
    Watermark(".Email", "Your email address");
    Watermark(".Firstname", "Your first name");
    Watermark(".Surname", "Your surname");
    Watermark(".enquiry", "What's on your mind?");
    Watermark(".SearchBox", "Type keyword...");
    Watermark(".CommentText", "Enter your comment...");
});

function Watermark(selector, value) {
    var watermark = value;
    $(selector).each(function(){
        if ($(this).val() == "") {
            $(this).val(watermark);
        }
    });

    $(selector).focus(function() {
        if (this.value == watermark) {
            this.value = "";
        }
    }).blur(function() {
        if (this.value == "") {
            this.value = watermark;
        }
    });
}