function random_santa(){
  var xmas_images = new Array();

	//Specify random images below. You can have as many as you wish [Please note! Images must be in the "skin1/images/custom/" folder!]
  xmas_images[1]="santa_01.png";
  xmas_images[2]="santa_02.png";
	xmas_images[3]="santa_03.png";

  var r=Math.floor(Math.random()*xmas_images.length);

  if (r==0)
     r=1;
 
	$("#catrootmenu").css({"background-image":"url\(" + xmas_dir + "images/" + xmas_images[r] + "\)"});
}

if (is_snowfall == "Y"){

	var snowFlake = "*";
  var num = 20;
	snowDistance = snowDistance ? snowDistance : 140;

	var w = 800, h = 600, i = 0;

	var x = new Array();
	var y = new Array();
	var sfs = new Array();
	var currStep = new Array();
	var fall = new Array();
	var step = new Array();
	var theFlakes = new Array();

	function windowSize(){
		w = getWindowWidth() - 30;
		return w;	
	}

	h = snowDistance ? snowDistance : 300;

	function snowMaker() {

		var dy,dx;

			for (i = 0; i < num; i++){

			 dy = fall[i];
			 dx = fall[i] * Math.cos(currStep[i]);

			 y[i]+=dy;
			 x[i]+=dx; 

			 if (x[i] >= w || y[i] >= h){
				y[i] = 20; 	
				x[i] = Math.round(Math.random() * w);
				fall[i] = (sfs[i] == 1)?
				Math.round(2 + Math.random() * 2): Math.round(3 + Math.random() * 2);
				step[i] = (sfs[i] == 1)?
				0.05 + Math.random() * 0.1 : 0.05 + Math.random() * 0.05 ;
			 }

			 theFlakes[i].top = y[i] + "px";
			 theFlakes[i].left = x[i] + "px";
			 currStep[i]+=step[i];

			}
		
		snowtimer = setTimeout(snowMaker, 60);

		return y;
	}

	function initSnowfall(){
		for (i = 0; i < num; i++){
			theFlakes[i] = document.getElementById("dot"+(i)).style;
			theFlakes[i].fontSize = 14 + Math.floor(Math.random()*5) + "px";

			sfs[i] = Math.round(1 + Math.random() * 1);

			y[i] = Math.round(Math.random()*h);
			x[i] = Math.round(Math.random()*w);
		}
		y = snowMaker();
	}

	function snowFalling () {

		for (i = 0; i < num; ++ i) {  

			$(document.body).append("<div class=\"snowflake\" id=\"dot"+ i +"\">" + snowFlake + "<\/div>");

			currStep[i] = 0;
			fall[i] = (sfs[i] == 1)?
			Math.round(2 + Math.random() * 2): Math.round(3 + Math.random() * 2);
			step[i] = (sfs[i] == 1)?
			0.05 + Math.random() * 0.1 : 0.05 + Math.random() * 0.05 ;
		}
			
			windowSize();

			initSnowfall();
	}

} //endif is_snowFall

$(document.body).ready(function(){

	if (is_flyout == "Y"){
		
		random_santa();

		$(".fancycat-icons-scheme ul li ul").append("<li class=\"xmas-cell\"><img src=\"" + images_dir + "/spacer.gif\" alt=\"\" /></li>");

		var _tmp_src = "";
		$(".fancycat-icons-scheme a.icon-link").hover(
			function(){
				_tmp_src = $(this).find("img").attr("src");
				$(this).find("img").attr({src:images_dir + "/spacer.gif"}).css({"background":"transparent url\(" + xmas_dir + "images/cap.gif" + "\) no-repeat center"});
			},
			function(){
				$(this).find("img").attr({src:_tmp_src}).css({"background":"transparent none"});
			}
		);

		if (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32") {
			var _tmp_li = $(".fancycat-icons-scheme ul li ul");
			var _tmp_width = _tmp_li.outerWidth() - 2;
			
			$("li.xmas-cell").replaceWith("<li class=\"xmas-cell\" style=\"width:" + _tmp_width + "px !important; background-color:" + _tmp_li.find('li').css('background-color') + "!important;\"><img src=\"" + images_dir + "/spacer.gif\" alt=\"\" /></li>");

		}


	}
		snowFalling();
});

$(window).resize(function(){
	windowSize();
});
