function theRotator() {
	//Set the opacity of all images to 0
	$('.new_carous_li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('.new_carous_li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 2000 = change to next image after 2 seconds
	rotate();
	setInterval('rotate()',2000);
}

function rotate() {	
	//Get the first image
	var current = ($('.new_carous_li.show')?  $('.new_carous_li.show') : $('.new_carous_li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('.new_carous_li:first') :current.next()) : $('.new_carous_li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
}

function openPopup(selector){
		$(selector).show()
				   .appendTo('#overlay')
				   .parent() //that's basically #overlay
				   .fadeIn('fast');
		$('html').css({'overflow':'hidden'});
   }
   
$(document).ready(function() {		
	//Load the slideshow
	var vertTimer = 0;
	
	theRotator();
	$('.vert_ul').hide();
	$('.having_vert_menu').hoverIntent(function(){
			//$(this).children('ul').css({'display':'block'});
			$(this).children('.vert_ul').slideDown(100);
		},function(){
			//$(this).children('ul').css({'display':'none'});
			$(this).children('.vert_ul').slideUp(100);
			
		});
	
	$('.vert_ul_li').hover(function(){
			$(this).children('.vert_sec_ul').show();
		},function(){
			
			$(this).children('.vert_sec_ul').hide();
			});
	
	$('.vert_ul').hover(function(){ 
			$(this).parent('.having_vert_menu').find('.qL_li_a').addClass('vertHover');
		},function(){
			$(this).parent('.having_vert_menu').find('.qL_li_a').removeClass('vertHover');
		});   //these 2 functions are used in this way inorder to remove flicker from IE
	
	$('.vert_sec_ul').hover(function(){
			$(this).parent('.vert_ul_li').find('.vert_ul_li_a').addClass('vertHover');
		},function(){
			$(this).parent('.vert_ul_li').find('.vert_ul_li_a').removeClass('vertHover');
		});  //these 2 functions are used in this way inorder to remove flicker from IE
	
	$('.description_sp').css({'opacity':0.75});
	$('#leftBillboard').jCarouselLite({
		visible:1,
		btnPrev: ".prev",
		btnNext: ".next",
                auto: 5000,
		speed: 500,
		easing: 'easeOutElastic'
		});
	
/*	$('#popup').css({'height':0,'display':'block'}).animate({'height':'300px'},'normal');*/
	openPopup('#popup');
	$('.closePop').click(function(){
			$(this).parents('#overlay').remove();
			$('html').css({'overflow':'auto'});
			return false;
		});
	$('#blanket').css({'opacity':0.75}).click(function(){
		$(this).parents('#overlay').remove();
		$('html').css({'overflow':'auto'});
		});
	
	$('#txtEmail').data('default',$('#txtEmail').val())
                    .addClass('inactive')
                    .focus(function(){
                            $(this).removeClass('inactive');
                            if($(this).val() == $(this).data('default') || ''){
                                $(this).val('');
                            }
                        })
                    .blur(function(){
                            var default_val = $(this).data('default');
                            if ($(this).val() == ''){
                                $(this).addClass('inactive');
                                $(this).val($(this).data('default'));
                            }
                        });
});
