var rotate = true;
$(document).ready(function(){
//Setup the main rotater on the home page
$('#divSimpleSlider').cycle({
			speed:       500,
			timeout:     9000,
			autoSlideInterval: 5000,
			pagerEvent: 'mouseover',
			fastOnEvent: false
});
var numImg = 25;
var varRandProfile = Math.round(Math.random()*(numImg));
if(varRandProfile == 0)
{
		varRandProfile = 1;
		$('.profile').hide();
		$('#cont'+varRandProfile).animate({ opacity: 1}, 100);
		$('#cont'+varRandProfile).show();
}

$('.profile').hide();
$('#cont'+varRandProfile).animate({ opacity: 1}, 100);
$('#cont'+varRandProfile).show();
$('#menu ul li').hover(function(){
$('#divSimpleSlider').cycle('pause');
$('.billboard').hide();
$('#menu ul li').removeClass('active');
$(this).addClass('active');
$('#'+$(this).children('a').attr('rel')).animate({ opacity: 1}, 100);
$('#'+$(this).children('a').attr('rel')).stop(true,true).fadeIn();
},function(){});

$('.next').click(function(){
   if(rotate)
				randFunc(varRandProfile,numImg);
   });
});

function randNum(numImg){
   return Math.round(Math.random()*(numImg));
}

function statt() {
   if( typeof statt.counter == 'undefined' ) {
       statt.counter = 0;
   }
   statt.counter++;
   return statt.counter;
}

function stattt() {
   if( typeof stattt.counter == 'undefined' ) {
       stattt.counter = 0;
   }
   stattt.counter++;
   return stattt.counter;
}

var num = new Array();
function randFunc(varRandProfile,numImg){
			var count = statt();
						var flag = 0;
			var i;
			var varRand = Math.round(Math.random()*(numImg));
			num[0] = varRandProfile
			num[count] = varRand;
			for(i=0;i<count;i++){
						if(varRand == num[i]){
									flag = 1;
									randFunc(varRandProfile,numImg);
									break;
							}else{
														flag = 0; 
									   }
		}			
		if(flag == 0){
					$('.profile').hide();
					$('#cont'+varRand).fadeIn(700);
					counts = stattt();
		}
		if(counts == numImg){
					document.getElementById('innerval').innerHTML = 'You have seen all Profiles...';
					rotate = false;
		}
		count ++;
}
