
var player_obj = null;
var slideshow = null;
var inners = null;
$(function (){

        // init and stop the inner slideshows
        inners = $('.grouping').cycle().cycle('stop');

        slideshow = $('#featured').cycle({
    	    fx:    'fade', 
    	    speed: 500,
    	    timeout: 7500,
    	 	cleartype : 1,
    	 	pause : 1,
            prev: '.prev',
            next: '.next',
    	 	startingSlide : Math.round(Math.random() * 4), // 5 groups
    	 	onPrevNextEvent : function (isNext, zeroBasedSlideIndex, slideElement){
                $(slideElement).find('.feature-detail').show();
    	 	},
    	 	after: function (currSlideElement, nextSlideElement, options, forwardFlag){
    	 	    $(currSlideElement).find('.feature-detail').hide();
    	 	},
            before: function(cs) {
                $(this).cycle({
                    fx: 'fade',
                    random: 1,
                    pause : 1,
                    cleartype : 1,
                    autostop: true
                }).cycle('pause');
            }
});

    
    $('input[name=email]').focus(function (){ var obj = $(this); if(obj.attr('value')=='Please enter a valid email.')obj.attr('value','').css({'color':'black'}) })
    
    function email_form_submitted(){
        var email = $('input[name=email]').val();
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        if(reg.test(email)){
            $('#signup').submit();   
        }else{
            $('input[name=email]').attr('value','Please enter a valid email.').css({'color':'red'})
            return false;
        }
    }
    
    $('#submit-box').click(email_form_submitted);
    //$('#signup').submit(email_form_submitted);

	$('.feature-detail').slideUp();
	
	var active = false;
	$('#featured').mouseenter(function (){
		active = true;
		//$('#featured').cycle('pause');
		
		$('.feature-detail').each(function (){
    		if($(this).parent().is(':visible')){
    			$(this).slideDown();
    		}		    
		})
	})
	
	$('#featured').mouseleave(function (){
		active = false;
		setTimeout(function (){			
		    if(!active){
    		    $('.feature-detail').each(function (){
        			if($(this).parent().is(':visible')){
        				$(this).slideUp(function (){
        				});
        			}
    		    })
    		}
		},750);		
	})
	
	
	var hght = $('#news').height()
	$('#recent').css({'min-height': hght})
	$('#signupcol').css({'min-height':hght})
	$('#news').css({'min-height':hght})


	$('.news-text-body').autolink();
})
