
	
		
function showItem(el){
  if($(el).next("li").size() == 1) //stop the recursion?
      $(el).fadeIn(250, function() {showItem($(el).next("li"))});
  else
      $(el).fadeIn(250);     
  }
  
function mainmenu(){
$(" #nav1 ul li ul ").css({display: "none"}); // Opera Fix
$(" #nav1 ul li").hover(function(){
		jQuery(this).find('a:first').css({color: "#33b9cc"});
		
		jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(200);
		},function(){
		jQuery(this).find('a:first').css({color: "#33b9cc"});
		
		jQuery(this).find('a').css({color: "#ffffff"});
		jQuery(this).find('ul:first').css({visibility: "hidden"});
		});
}

//////////////////////////////////////////
$(function() {
	
	mainmenu();
$("#m-feature a").colorbox({iframe:true,innerWidth:"622px",innerHeight:"349px", scrolling:false });	
$("#bm-feature a").colorbox({iframe:true,innerWidth:"622px",innerHeight:"349px", scrolling:false });	
var slideTimeout = null;
	
	$(window).resize(function () {
		
		
		clearTimeout(slideTimeout);
		
		function slide() {
			clearTimeout(slideTimeout);
			if($('#main').hasClass('animating')) { } else {
				$('#main').addClass('animating');
				$('#carousel #rotate').animate({'left': -ox }, 'slow', function(){
					var theLI = $('#carousel #rotate li:first').html();
					$('#carousel #rotate').append('<li style="width: ' + ox + 'px; height: ' + oy + 'px;">' + theLI + '</li>');
					$('#carousel #rotate li:first').remove();
					$('#carousel #rotate').css({'left': '0'});
					$('#main').removeClass('animating');
				});
			}
			slideTimeout = setTimeout(function () {
				slide();
			}, 8000);
		};
		
		function resetSlide() {
			clearTimeout(slideTimeout);
			slideTimeout = setTimeout(function () {
				slide();
			}, 8000);
		}
		
		var ox = $(document).width();
		var oy = $(window).height();

		
		$('#main #rotate img').each(function () {
			var self = this;
			var img = new Image();
			img.onload = function () {
				var cx = this.width;
				var cy = this.height;

				$(self).parent().css({
					'width': ox,
					'height': oy
				});

				var noItems = $(self).parent().parent().find('li').length;
				$(self).parent().parent().css({
					'width': ox * noItems,
					'height': oy
				});

				$(self).parent().parent().parent().css({
					'width': ox,
					'height': oy
				});

				if (ox / oy > cx / cy) {
					$(self).css({
						'width': ox,
						'height': (ox * cy / cx),
						'left': 0,
						'top': 0,
						//'top': 0 * (oy - (ox * cy / cx)),
						'position': 'relative'
					});

				} else {
					$(self).css({
						'width': oy * cx / cy,
						'height': oy,
						'top': 0,
						'left': 0,
						//'left': 0 * (ox - (oy * cx / cy)),
						'position': 'relative'
					});
				}
			}
			img.src = $(self).attr('src');
		});
		
		$('#img1a img').each(function () {
			
			var self1 = this;
			var img1 = new Image();
			img1.onload = function () {
				var x = this.width;
				var y = this.height;

				$(self1).css({
					'width': x,
					'height': y
				});
			}
			
		});
	
		
		
		$('#carousel-nav li.next').die('click').live('click', function() {
			if($('#main').hasClass('animating')) { } else {
				$('#main').addClass('animating');
				$('#carousel #rotate').animate({'left': -ox}, 'slow', function(){
					var theLI = $('#carousel #rotate li:first').html();
					$('#carousel #rotate').append('<li style="width: ' + ox + 'px; height: ' + oy + 'px;">' + theLI + '</li>');
					$('#carousel #rotate li:first').remove();
					$('#carousel #rotate').css({'left': '0'});
					$('#main').removeClass('animating');
				});
			}
			resetSlide();
			return false;
		});
		
		$('#carousel-nav li.prev').die('click').live('click', function() {
			if($('#main').hasClass('animating')) { } else {
				$('#main').addClass('animating');
				var theLI = $('#carousel #rotate li:last').html();
				$('#carousel #rotate').prepend('<li style="width: ' + ox + 'px; height: ' + oy + 'px;">' + theLI + '</li>');
				$('#carousel #rotate li:last').remove();
				$('#carousel #rotate').css({'left': -ox});
				$('#carousel #rotate').animate({'left': '0'}, 'slow', function(){
					$('#main').removeClass('animating');
				});
			}
			resetSlide();
			return false;
		});
		
		$('#rotate .panel .button').mouseover(function() {
			clearTimeout(slideTimeout);
		}).mouseout(function() {
			resetSlide();
		});
		
		if($('#rotate li').length > 1) {
			resetSlide();
		}
	

	}).trigger('resize');
	
	$('#mid1').live('mouseover', function() {
	
	$('.close1').click(function(){
	$('#mid1').hide(500);
	$('.reveal').css({visibility: "visible",display: "none"}).show(200);
	$('#h-testimonial').delay(400).fadeOut("slow");
});
$('.reveal').click(function(){
	$('#mid1').css({visibility: "visible",display: "none"}).show(500);
	$('.reveal').hide(100);
	$('#h-testimonial').delay(400).fadeIn("slow");
});
		
	});

	
});

//////////////////////////////////////////
