function toggleDefaultText(input) {
	input.focus(function() {
	        if (this.value == this.defaultValue) {
	        	this.value = '';
	    	}
	        if (this.value != this.defaultValue) {
		    	this.select();
	        }
		});
		
	input.blur(function() {
	        if (this.value == ''){
	        	this.value = (this.defaultValue ? this.defaultValue : '');
	    	}				
		});
}

$(document).ready(function(){

	if ($('#subscribe .email').length > 0) {
		toggleDefaultText($('#subscribe .email'));
	}
		
	/* blue box */
	if ($('.rollover').length > 0) {
		$('.rollover').hover(function(){
		
			var siblings = $(this).siblings('.rollover');

			$(this).children('p').stop().animate({opacity: 1, height: '35px'}, 200);

			$(siblings).each(function(index) {
			    var summary = $(this).children('p');
			    if ($(summary).is(':visible')) {
			    	$(this).children('p').stop().animate({opacity: 0, height: '0'}, 200);
			    }
			});
		});
	}
    
    if ($('#country').length > 0) {
		$('#country').bind('submit', function(){
		
			// Get the index of the selected option
			var idx = $('#countryUrl option').index($('#countryUrl option:selected'));
			
			if (idx > 0) { // Only execute this code if the first option is not selected
			
				// Get the url
				var url = $('#countryUrl').val();
				// Redirect
				window.location = url;
				
			}
			// Stop form submission
			return false;
		});    
    }

    var $feature = $('.home_v2 #feature ol');
    
    if ($feature.length > 0) {
    
		$feature.cycle({ 
		    fx:     'scrollHorz', 
		    speed:   300, 
		    timeout: 8000, 
		    next:   '#feature .next',
		    prev:   '#feature .prev',
			pager:  '#feature .pager'
		});    	
    
    }
    
    var $news = $('.home_v2 .slider .columns');
    
    if ($news.length > 0) {
    
		$news.cycle({ 
		    fx:     'scrollHorz', 
		    speed:   300, 
		    timeout: 0, 
		    next:   '.slider .next',
		    prev:   '.slider .prev',
			pager:  '.slider .pager'
		});
    }
});
