$(document).ready(function () {

    if ($("#ecards2010").length > 0) {
        $(".extra-fields").hide();
        $(".hidefields").hide();

        $(".addmore .showfields").click(function (event) {
            event.preventDefault();
            $(".extra-fields").slideDown("fast");
            $(".showfields").hide();
            $(".hidefields").show();
        });

        $(".hidefields").click(function (event) {
            event.preventDefault();
            $(".extra-fields input[@type=text]").each(function () {
                $(this).val("");
            });
            $(".extra-fields").slideUp("fast");
            $(".showfields").show();
            $(".hidefields").hide();
        });
    }

    if ($(".dform-info-box").length > 0) {
        goFormHelp();
    }

    if ($("#talk-box").length > 0) {
        doTalkExpand();
    }

    if ($(".searchInp").length > 0) {
        $(".searchInp").focus(function () {
            emptyMe(this);
        });
    }
    if ($(".talk-to-us").length > 0) {
        $(".talk-to-us").focus(function () {
            emptyMe(this);
        });
    }
    if ($(".inlineSearchInp").length > 0) {
        $(".inlineSearchInp").focus(function () {
            emptyMe(this);
        });
    }
    if ($(".zebra-table").length > 0) {
        $(".zebra-table tr:even").addClass("alt");
    }

    if ($(".datepicker").length > 0) {
        $(".datepicker").datepicker({
            showOn: 'button'
		    , buttonImage: strThemeDir + '/img/icons/calendar.png'
		    , buttonImageOnly: true
		    , dateFormat: 'dd/mm/yy'
		    , minDate: '2d'
		    , onSelect: function (dateText) {
		        document.all ? $(this).get(0).fireEvent("onchange") : $(this).change();
		    }
        });
    }

});

function goFormHelp(){
	
	$(".dform-info-box").hide();
	$(".dform-info-box:first").show();
	
	$(".donation-form input[type=text],.donation-form input[type=checkbox],.donation-form select,.donation-form textarea").bind('focus', function() {

		var fieldId = $(this).attr("id");
		var boxId = "#dynamicid-" + fieldId;
		var parentRow = $(this).parents(".dform-row");

		$(".dform-info-box").hide();
		$(".dform-row").removeClass("activerow");
		$(parentRow).toggleClass("activerow");
		$(boxId).show();
	});

}

function doTalkExpand(){		
		var talkHid = $("#talk-box-hidden");
		var talkHidInput = $("#talk-box-hidden input");
		var talkText = $("#talk-box textarea");
		$(talkHid).hide();
		
		$(talkText).focus(function() {
			$(talkHid).slideDown("normal");
			$(talkHidInput).css({ color:"#3e4043"});
			$(talkText).css({ color:"#3e4043"});
		});
	}


function emptyMe (target){
	$(target).attr("value","");
}

$(document).ready(function() {
if($("#homeNewsTicker").length > 0){						   
    var options = {
        newsList: "#homeNewsTicker",
        startDelay: 10,
        placeHolder1: " _",
        tickerRate: 80
    }
    $().newsTicker(options);
}
});

/* Clear Form Labels */

$(document).ready(function() {
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('').addClass('focused');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');	
			}
		});
	});
});
