
		
	jQuery.noConflict()(function(){
				
		
		jQuery.fn.infiniteCarousel = function () {
		
		    function repeat(str, num) {
		        return new Array( num + 1 ).join( str );
		    }
		  
		    return this.each(function () {
		    	
		        var $wrapper = jQuery('> div', this).css('overflow', 'hidden'),
		            $slider = $wrapper.find('> ul'),
		            $items = $slider.find('> li'),
		            $single = $items.filter(':first'),
		            
		            singleWidth = $single.outerWidth(), 
		            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
		            currentPage = 1,
		            pages = Math.ceil($items.length / visible);            
		
		
		        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
		        if (($items.length % visible) != 0) {
		            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
		            $items = $slider.find('> li');
		        }
		
		        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
		        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
		        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
		        $items = $slider.find('> li'); // reselect
		        
		        // 3. Set the left position to the first 'real' item
		        $wrapper.scrollLeft(singleWidth * visible);
		        
		        // 4. paging function
		        function gotoPage(page) {
		            var dir = page < currentPage ? -1 : 1,
		                n = Math.abs(currentPage - page),
		                left = singleWidth * dir * visible * n;
		            
		            $wrapper.filter(':not(:animated)').animate({
		                scrollLeft : '+=' + left
		            }, 500, function () {
		                if (page == 0) {
		                    $wrapper.scrollLeft(singleWidth * visible * pages);
		                    page = pages;
		                } else if (page > pages) {
		                    $wrapper.scrollLeft(singleWidth * visible);
		                    // reset back to start position
		                    page = 1;
		                } 
						
		                currentPage = page;
		            });                
		            
		            return false;
		        }
		        
		        $wrapper.after('<div class="next arrow"><a href="#">Next</a></div><div class="previous arrow"><a href="#">Previous</a></div>');
		        
		        // 5. Bind to the forward and back buttons
		        jQuery('div.previous a', this).click(function () {
		            return gotoPage(currentPage - 1);                
		        });
		        
		        jQuery('div.next a', this).click(function () {
		            return gotoPage(currentPage + 1);
		        });
		        
		        // create a public interface to move to a specific page
		        jQuery(this).bind('goto', function (event, page) {
		            gotoPage(page);
		        });
		    });  
		};
	
	});

	var $j = jQuery.noConflict();
	
	$j(function(){
		Site.init();
	});

	var Site = {
		menuIndex: 1000,
		menudelay: false,
		init: function() {
		
			$j('.multibox').each(function(){
				Site.multiBox.init(this);
				Site.multiBox.select($j('.upcoming:first',$j(this)));
				Site.multiBox.auto($j('.upcoming:first',$j(this)));
			});
			
			$j('.carousel').infiniteCarousel();
			
			$j('.carouselsml').each(function(){
				var $c = $j(this);
				var $w = $j('.wrapper',$c);
				
				$c.css({
					position: 'relative'
				});
				$w.css({
					position: 'absolute',
					top: 0,
					height: '300px',
					width: '300px',
					overflow: 'hidden'
				});
				
				if ($j('li',$c).length > 6) {
				
					$w.after('<div class="next"><a href="#">Next</a></div><div class="previous"><a href="#">Previous</a></div>');
					
					var $n = $j('.next a',$c);
					var $p = $j('.previous a',$c);
					
					var maxClick = $j('li',$c).length / 6;
					$j('ul',$c).attr('curclick',0).attr('maxclick',maxClick);
					
					$n.click(function(){
						var $ul = $j(this).parents('.carouselsml').find('ul').not(':animated');
						
						if (parseInt($ul.attr('curclick')) < parseInt($ul.attr('maxclick'))) {
							
							$ul.attr('curclick',parseInt($ul.attr('curclick')) + 1).animate({
								marginTop: '-=300px'
							},800);
							if (parseInt($ul.attr('curclick')) < parseInt($ul.attr('maxclick'))) {
								$j(this).parents('.carouselsml').find('.next a').fadeTo('fast',1);
							} else {
								$j(this).parents('.carouselsml').find('.next a').fadeTo('fast',0.5);
							}
							$j(this).parents('.carouselsml').find('.previous a').fadeTo('fast',1);
						}
						
						return false;
					}).fadeTo('fast',1);
					
					$p.click(function(){
						var $ul = $j(this).parents('.carouselsml').find('ul').not(':animated');
						
						if (parseInt($ul.attr('curclick')) > 0) {
							
							$ul.attr('curclick',parseInt($ul.attr('curclick')) - 1).animate({
								marginTop: '+=300px'
							},800);
							
							if (parseInt($ul.attr('curclick')) > 0) {
								$j(this).parents('.carouselsml').find('.previous a').fadeTo('fast',1);
							} else {
								$j(this).parents('.carouselsml').find('.previous a').fadeTo('fast',0.5);
							}
							$j(this).parents('.carouselsml').find('.next a').fadeTo('fast',1);
							
						}
						return false;
					}).fadeTo('fast',0.5);
				
				}
			});
			
			$j('#menu li').mouseover(function(){
				$j(this).addClass('hover');
				$j(this).children('ul').show();
			}).mouseout(function(){
				$j(this).removeClass('hover');
				$j(this).children('ul').hide();
			});
			
			/*
			
			$j('li.dropmenu').mouseover(function(){
			//	$j('ul.dropmenu:visible').hide();
			});
			
			$j('.level1 ul').hide();
			$j('.level1,.level1 *').mouseover(function(){
				clearTimeout(Site.menudelay);
				$j(this).siblings('li').find('ul').fadeOut(80);
				$j(this).css('zIndex',Site.menuIndex);
				Site.menuIndex++;
				$j(this).children('ul:hidden').slideDown(150);
				
				//check to see if its last item
				
				if ($j(this).is('li') && $j(this).hasClass('level1')) {
					var $l = $j(this);
				} else {
					var $l = $j(this).parents('li.level1');
				}
				
				
				if ($l.hasClass('last')) {
					$j('ul',$l).each(function(){
						var nl = 0 - (parseInt($j(this).width()) - parseInt($l.width()) + 1); //1 for border
						$j(this).css('left',nl+'px');
					});
				} 
				
			}).mouseout(function(){
				var xx = this;
				clearTimeout(Site.menudelay);
				Site.menudelay = setTimeout(function(){
					$j(xx).children('ul:visible').fadeOut(80);
				},500);
			});
			
			*/
		},
		multiBox: {
			speed: 7000,
			timers: [],
			init: function(e) {
				var $e = $j(e);
				var id = $j(e).attr('id');
				
				var $imgbox = $j('.upcomingmain',$e);
				var $links = $j('.upcoming',$e);
				
				$links.mouseover(function(){
					Site.multiBox.select(this);
				}).click(function(){
					var link = $j('a',$j(this)).attr('href');
					window.location = link;
				}).mouseout(function(){
					Site.multiBox.auto(this);
				});
				
			},
			select: function(e) {
				$j(e).parents('.multibox:first').find('.on').removeClass('on');
				$j(e).addClass('on');
				
				var id = $j(e).parents('.multibox:first').attr('id');
				var $parent = $j(e).parents('.multibox:first');
				
				clearTimeout(Site.multiBox.timers[id]);
				
				var rel = $j('a',$j(e)).attr('rel');
				var curimg = $parent.find('.upcomingmain img:first');
				
				$parent.find('.upcomingmain img:gt(0)').remove();
				
				$j(curimg).css({
					zIndex: 70,
					position: 'absolute'
				});
				
				$j(curimg).clone().attr('src',rel).css({
					position: 'absolute',
					zIndex: 60,
					opacity: 1
				}).appendTo($j('.upcomingmain',$parent)).show();
				
				
				$j(curimg).fadeOut(500,function(){
					$j(this).remove();
				});
			},
			auto: function(e) {
				var id = $j(e).parents('.multibox:first').attr('id');
				
				Site.multiBox.timers[id] = setTimeout(function(){
					Site.multiBox.autoScroll(e);
				},Site.multiBox.speed);
			},
			autoScroll: function(e) {
			
				var $parent = $j(e).parents('.multibox:first');
				var id = $parent.attr('id');
				
				clearTimeout(Site.multiBox.timers[id]);
				
				var $links = $j('.upcoming',$parent);
				var current = $j('.on',$parent);
				var index = $links.index(current);
				
				var next = index + 1;
				
				if (next >= $links.length) {
					next = 0;
				}
				
				Site.multiBox.select($j('.upcoming:eq('+next+')',$parent));
								
				Site.multiBox.timers[id] = setTimeout(function(){
					Site.multiBox.autoScroll(e);
				},Site.multiBox.speed);
			}
			
		}
		
	};
	

