$(document).ready(function(){
	
	/*---------------------------------------------------
	Nav
	---------------------------------------------------*/
	
	$("#nav a.current-cat, #nav a.current_page_ancestor").each(function (i) {

		var bradar = $(this).siblings();
		bradar.show();
		
		var rand = Math.ceil(3*Math.random());
		bradar.parent().addClass('expand' + rand);
	
	});
	

	
	
	$("#nav .open > a").each(function (i) {

		var bradar = $(this).parent().parent();
		
		var rand = Math.ceil(3*Math.random());
		$(this).parent().addClass('expand' + rand);
	
	});
	
	
	/*$("#nav a.last-cat, #nav a.current_page_item").each(function (i) {

		var bradar = $(this).parent().siblings();
		
		if ($(this).parent().parent().is('ul'))
			bradar.hide();
		
	});*/
	
	
	$('#nav > li > a').not('.intact a').each(function() {
		
		$(this).click( function(event) {
			event.preventDefault();
		});
	
		$(this).addClass('weak');
		
	});

	$("#nav a").hover(
	function(){
		
		var unkles = $(this).parent().siblings();
		
		$(this).siblings('ul').show();
		$(this).siblings('ul').children('li').show();
		
		unkles.find('ul').hide();	
		
		unkles.removeClass('expand1 expand2 expand3');
		unkles.find('li').removeClass('expand1 expand2 expand3');
		
	},
	function(){ 
	});
	
	
	$("#header li:has(ul)").children('a').hover(
	function(){
		
		var dad = $(this).parent();
		
		var rand = Math.ceil(3*Math.random());
		var has = dad.attr("class");
				
		if ( has.indexOf('expand') < 0 ) dad.addClass('expand' + rand);
		
	},
	function(){ 
		
		//$(this).parent().removeClass('expand1 expand2 expand3');
	
	});
	
	/*
	$("#nav").hover(
	function(){
			
	},
	function(){ 
		
		$(this).find("ul").hide();
		$(this).find("li").removeClass('expand1 expand2 expand3');
	
	});*/
	
	
	
	/*---------------------------------------------------
	Wheel
	---------------------------------------------------*/
	leadingZeros = function(num, totalChars, padWith) {
		num = num + "";
		padWith = (padWith) ? padWith : "0";
		if (num.length < totalChars) {
			while (num.length < totalChars) {
				num = padWith + num;
			}
		} 

		return num;
	}
	
	
	shuffle = function(o){ //v1.0
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	WheelSpin = function() {
		var src = $("#more img").attr("src");
		var temp = new Array();	temp = src.split('wheel-')

		var rand_no = Math.random();
		rand_no = rand_no * 4;
		rand_no = Math.ceil(rand_no);

		$("#more img").attr("src",temp[0] + 'wheel-'  + leadingZeros(rand_no,2) + '.png');

	}
	
	var refreshId = 0;
	refreshId = setInterval("WheelSpin()", 4000); 
	
	

	
	var images = shuffle([ 1, 2, 3, 4 ]);
	

	
	
	$("#more img").hover(
	function(){
		$(this).css("background-position","left -113px");
	},
	function(){ 
		$(this).css("background-position","top left");
	});



	/*---------------------------------------------------
	Home
	---------------------------------------------------*/
	var gotime = new Array(1,1);

		$("#content.home .safe .holder").hover(
		function(){ 

				$(this).animate({marginLeft: 0}, "medium");

		},
		function(){ 

				$(this).animate({marginLeft: "-260px"}, "medium");

		});	

		
				



	
});
