$(document).ready(function(){
Cufon.replace('.head h2', { fontFamily: 'Gotham Book', hover: true });
Cufon.replace('.box .head h2', { fontFamily: 'Gotham Book', hover: true });
Cufon.replace('.entry h3', { fontFamily: 'Gotham Book',  });
	
	$(".slider-carousel").jcarousel({
		scroll:1,
		//auto:0,
		wrap:"both",
        itemFirstInCallback: mycarousel_itemFirstInCallback,
        initCallback: mycarousel_initCallback,
        start: 1
       	
	});

	//Hiding all tabs
	$(".tab").hide();
	$(".tabs a").removeClass("active");
	
	// Showing First Tab
	$(".tabs-content .tab").eq(0).show().addClass("active");
	$(".tabs a").eq(0).addClass("active");
	
	$(".tabs a").click(function(){
		$(".tabs a").removeClass("active");
		$(this).addClass("active");
		
		$(".tabs-content .active").removeClass("active").hide();
		$($(this).attr("href")).addClass("active").fadeIn();
		
		return false;
	});
	
	 $(function(){
            $('.blink').
                focus(function() {
                    if(this.title==this.value) {
                        this.value = '';
                    }
                }).
                blur(function(){
                    if(this.value=='') {
                        this.value = this.title;
                    }
                });
        });
	 
	 $("#navigation ul li").hover(function(){
			$(".dd", this).show();
			$("a:eq(0)", this).addClass("hover");
		}, function(){
			$(".dd", this).hide();
			$("a", this).removeClass("hover");
		});

	 
	 $("#contact_form").submit(function(){		 
		 if(!validate_form('#contact_form'))
		 {
		   return false;
		 }
		 if(!$("#contact_form textarea").val())
		 {
			alert("Please enter your Message");
			return false; 
		 }
		 if(!checkmail($("#subsribe-form-email-address").val()))
		 {
		   return false;
		 }
		 
	 });
	 
	 $("#signup_form").submit(function(){		 
		 if(!validate_form('#contact_form'))
		 {
		   return false;
		 }
		 if($("#sign").val() == 'Your Name')
		 {
			alert("Please enter Your Name");
			return false; 
		 }
		 if(!checkmail($("#subsribe-form-email-address").val()))
		 {
		   return false;
		 }
		 
	 });
	 
	 $("#subscriptions_form").submit(function(){		 
		 if(!validate_form('#subscriptions_form'))
		 {
		   return false;
		 }
		 if(!$("#subscriptions_form input[type=checkbox]:checked").length)
		 {
			alert("Please check any programs or issues that you would like to receive updates");
			return false; 
		 }
		 if(!checkmail($("#subsribe-form-email-address").val()))
		 {
		   return false;
		 }
		 
	 });
	
});

function checkmail(value) {
	reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
	if (!value.match(reg)) {alert("invalid e-mail");
	document.getElementById('subsribe-form-email-address').value=""; return false; }
	return true;
	}

function validate_form(id) {
	var i = 0;
	$(id + " input").each(function(){
	  if(!$(this).val() && !$(this).hasClass('nr'))
	  {
		i++;  
		alert('Please enter your ' + $(this).attr('title'));
		return false;
	  }
	});
	if(i > 0)
	{
		return false;
	}
	else
	{
		return true;	
	}
}


function mycarousel_initCallback(carousel) {
    $('.slider-nav a').bind('click', function() {
        carousel.scroll($.jcarousel.intval($(this).text()));
        return false;
    });	        
};
	
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	$('.slider-nav a').removeClass('active');
	$('.slider-nav a').eq(idx-1).addClass('active');
};


