var hTimer;
jQuery(document).ready(function() {		

	jQuery("ul.dropdown li ul li:last-child").addClass("last-child");	

	jQuery("#rotatorNav li").click(function(){ 		
		var id = jQuery(this).find('a').attr("rel");	
		if (jQuery(this).is(".active")) { return false;	} else {		
			clearTimeout(hTimer);
			jQuery('#rotatorDescription .active').hide().removeClass('active');																		
			jQuery('#rotatorDescription #desc_'+id).show().css('opacity', 0).animate({opacity:1}).addClass('active');			
			jQuery('#rotatorImage div').css('z-index', 9700);
			jQuery('#rotatorImage div.active').css('z-index', 9800);
			var img = jQuery('#rotatorImage #img_'+id).css('z-index', 9801).addClass('active');			
			jQuery(img).find('img').css('margin-left', '200px').css('opacity', 0).animate({opacity:1, marginLeft:0},250);				
			hTimer = setTimeout(hRotateNext,8500);
			
		}		
		jQuery("#rotatorNav li").removeClass('active');
		jQuery(this).addClass('active');
		return false;		
	});		
	jQuery("#rotatorNav li:first").trigger('click');	
	
});

function hRotateNext(){
	var next = jQuery('#rotatorNav li.active').next();
	if(next.length == 1){ jQuery(next).trigger('click'); }else{	jQuery("#rotatorNav li:first").trigger('click');}	
}

jQuery(document).ready(function() {
	jQuery("#videopopup").fancybox({
	
		'width'				: 585,
	
		'height'			: 860,
	
		'autoScale'			: false,
		
		'padding'			: 0,		
	
		'transitionIn'		: 'none',
	
		'transitionOut'		: 'none',
	
		'type'				: 'iframe'
	
	});
	jQuery("#videopopup_homepage").fancybox({
	
		'width'				: 585,
	
		'height'			: 860,
	
		'autoScale'			: false,
		
		'padding'			: 0,		
	
		'transitionIn'		: 'none',
	
		'transitionOut'		: 'none',
	
		'type'				: 'iframe'
	
	});
	jQuery("#gallery a").fancybox();
});

jQuery(document).ready(function() {
	jQuery("#content").prepend("<div id=\"plusone\"><g:plusone></g:plusone></div>");
	contentPosition = jQuery('#content').position();
	helpformOffset = contentPosition.left - 200;
//	alert(contentPosition.left);
	jQuery("#online_help").css('left', helpformOffset+'px');	
	jQuery("#online_help_more").css('left', helpformOffset+'px');
	
	formSubmit = window.location.search.substring(1);
	if(formSubmit&&(formSubmit.indexOf("thanks")||formSubmit.indexOf("error"))){
		show('online_help_more');hide('online_help');
	} 

});

