
$(function() {
	
	// to prevent MooTools issues
	
	jQuery.noConflict();
	
	// render the separators correctly
	
	jQuery('.menuMain ul.menu span.separator, .choose ul.menu span.separator').empty().parent().addClass('separator');
	
	// menu & nutrition menu functionality
	
	jQuery('.sortby a').click(function() {
		var elLI = jQuery(this).parent();
		if (!elLI.hasClass('active')) {
			jQuery('li.'+strCurrentSort).slideUp();
			strCurrentSort = elLI.attr('id');
			jQuery('li.'+strCurrentSort).slideDown();
			jQuery('.sortby .active').removeClass('active');
			elLI.addClass('active');
		}
		return false;
	});
	jQuery('li.'+strCurrentSort).show();
	jQuery('li.sortby #'+strCurrentSort).addClass('active');
	
	// css fix - ticker
	jQuery('.divNewsFeed td').each(function() {
		if (jQuery(this).html().length < 1) {
			jQuery(this).html('&nbsp;');
		}
	});
	
	// Mini-Stages (autoscroll)
	
	// fill the screen if not full
	var intTotalWidth = 0;
	jQuery('.gallery li').each(function() {
		intTotalWidth += (jQuery(this).width() + parseInt(jQuery(this).css('padding-right')));
	});
	var intVisibleWidth = jQuery('.gallery').width() - parseInt(jQuery('.gallery').css('padding-left'));
	if (intTotalWidth < intVisibleWidth) {
		var intSlides = jQuery('.gallery li').size();
		while (intTotalWidth < intVisibleWidth) {
			for (var i = 0; i < intSlides; i++) {
				jQuery('.gallery li:eq(' + i + ')').clone().insertAfter(jQuery('.gallery li:last'));
				intTotalWidth += (jQuery('.gallery li:eq(' + i + ')').width() + parseInt(jQuery('.gallery li:eq(' + i + ')').css('padding-right')));
			}
		}
	}
	
	slideRotate = function(blnAuto, strDir) {
		if (!blnSlideInMotion && (blnAutoRotate || !blnAuto)) {
			blnSlideInMotion = true;
			if (strDir == 'ltr') {
				var elToSlide = jQuery('.gallery li:last');
				var widthToSlide = elToSlide.width() + parseFloat(elToSlide.css('padding-right'));
				elToSlide.clone().insertBefore(jQuery('.gallery li:first')).css('margin-left', '-' + widthToSlide + 'px');
				jQuery('.gallery li:first').animate({
					'margin-left': ('+=' + widthToSlide)
					}, 1000, function() {
						blnSlideInMotion = false;
						jQuery('.gallery li:last').remove();
				});
			} else {
				var elToSlide = jQuery('.gallery li:first');
				var widthToSlide = elToSlide.width() + parseFloat(elToSlide.css('padding-right'));
				elToSlide.clone().insertAfter(jQuery('.gallery li:last'));
				jQuery('.gallery li:first').animate({
					'margin-left': ('-=' + widthToSlide)
					}, 1000, function() {
						blnSlideInMotion = false;
						jQuery('.gallery li:first').remove();
						if (blnAutoRotate) {
							rotate = setTimeout("slideRotate('auto', 'rtl')", 3000);
						}
				});
			}
		}
	}
	
	jQuery('a.previous').click(function() {
		blnAutoRotate = false;
		slideRotate(false, 'rtl');
		return false;
	});
	jQuery('a.next').click(function() {
		blnAutoRotate = false;
		slideRotate(false, 'ltr');
		return false;
	});
	
	var rotate = setTimeout("slideRotate(true, 'rtl')", 3000);
// ****************************Scrollable Div for Homepage************************************

/***************************** Top Right Carousel ********************/
			jQuery(document).ready(function(){
				jQuery('#slideshow').cycle({ 
			    fx:     'scrollHorz',
				speed:  'slow',
				prev:    '#prev',
                next:    '#next'
				});
				
//Homepage text
//jQuery('.home_logo').mouseover(function() {
//    jQuery('.home_over').show("slow");
//});
//jQuery('.home_logo').mouseout(function() {
//    jQuery('.home_over').hide("slow");
//});
//Wow main box over
jQuery(".main-box").each(function (i) {
	  jQuery(this).addClass("box-bg"+i);
   jQuery(".box-bg"+i+" .more").click(function(){
//      jQuery(".box-bg"+i+" .wow-text").slideToggle(500);
		   jQuery(".box-bg"+i+" .wow-text").show();
		   jQuery(".box-bg"+i+" .more").hide();
		   jQuery(".box-bg"+i+" .less").show();
		jQuery('.scroll-pane').jScrollPane({showArrows: true});

   });
      jQuery(".box-bg"+i+" .less").click(function(){
		   jQuery(".box-bg"+i+" .wow-text").hide();
		   jQuery(".box-bg"+i+" .more").show();
		   jQuery(".box-bg"+i+" .less").hide();
	     jQuery('.scroll-pane').jScrollPane({showArrows: true});
 

   });
    jQuery(".box-bg"+i).mouseover(function() {
        jQuery(".box-bg"+i+" "+".box-bg").show();
    });	
	jQuery(this).mouseout(function() {
         jQuery(".box-bg"+i+" "+".box-bg").hide();
    });
 });
//jQuery('#scroll-content').jScrollPane({showArrows:true});
}); //document ready
			
});// end global function 
var slideRotate = null;
var blnAutoRotate = true;
var blnSlideInMotion = false;

/***************************** Top Right Carousel ********************/
function displayWowExternalAjax(category){
	//var url = "/index.php?option=com_ajaxcalls&view=articles&tmpl=component&pageSizeSelect=8&categorySelect=" + category;
	//callUrl(url, category);
	jQuery("#menuCategory").val(category);
	document.forms["dailyFormMenu"].submit();
	
}

