$(document).ready(function(){
	
	/* User Sitemap */

	
	$("a#ShowUserSitemap").fancybox({
		'hideOnContentClick': true,
		'type': 'inline',

		'onComplete': function(){
			$('#UserSitemap').masonry({
				// options
				itemSelector : '.FirstLevel',
				columnWidth : 240,
				gutterWidth : 20
				});
			}
	});
	
	


	
	var Col3Height = $("#col3").height() -20;
	$("#col2_content").css("min-height", Col3Height + "px");
													 
/*
	* jQuery.fn.rand();
	*
	* Return a random, but defined numbers of elements from a jQuery Object.
	* $('element').rand(); // returns one element from the jQuery Object.
	* $('element').rand(4); // returns four elements from the jQuery Object.
	*
	* Version 0.8.5
	* www.labs.skengdon.com/rand
	* www.labs.skengdon.com/rand/js/rand.min.js
	*
	* And:
	* http://phpjs.org/functions/array_rand:332
	*/
	(function($){$.fn.rand=function(number){var array_rand=function(input,num_req){var indexes=[];var ticks=num_req||1;var checkDuplicate=function(input,value){var exist=false,index=0;while(index<input.length){if(input[index]===value){exist=true;break;};index++;};return exist;};while(true){var rand=Math.floor((Math.random()*input.length));if(indexes.length===ticks){break;};if(!checkDuplicate(indexes,rand)){indexes.push(rand);}};return((ticks==1)?indexes.join():indexes);};if(typeof number!=='number')var number=1;if(number>this.length)number=this.length;var numbers=array_rand(this,number);var $return=[];for(var i=0;i<number;i++){$return[i]=this.get(numbers[i]);};return $($return);};}(jQuery));
	
	
	function ShowRandomElements() {
		$('.ContainerAnimationPane ul li').removeClass("Visible");
		if($("body").hasClass("Tab36") || $("body").hasClass("Tab184") || $("body").hasClass("Tab138")) { $('.ContainerAnimationPane ul li').rand(3).addClass("Visible");} else { $('.ContainerAnimationPane ul li').rand(5).addClass("Visible");}
		
		//$('body.Tab91 .ContainerAnimationPane ul li, body.Tab225 .ContainerAnimationPane ul li, body.Tab179 .ContainerAnimationPane ul li').rand(3).addClass("Visible");
		$(".Visible").fadeIn(2000).delay(5000);
		$(".Visible:first").queue(function() { HideRandomElements(); $(this).dequeue(); });
	}
	
	function HideRandomElements() {
		$(".Visible").fadeOut(1000).delay(0);
		$(".Visible:first").queue(function() { ShowRandomElements(); $(this).dequeue(); });
	}
	
	
	ShowRandomElements();
	
	
	
	/*function GetRandomElements(){
		$(".ContainerAnimationPane ul li.Visible").fadeOut(3000, function() {
			$(this).removeClass();
			$('.ContainerAnimationPane ul li').rand(3).addClass("Visible");	 /* fade in 3 random home boxes *
			$(".Visible").fadeIn(2000, function() {
					window.setTimeout(function() { GetRandomElements(); }, 3000);/* .fadeOut(3000, function(){ $(".Visible").removeClass("Visible");GetRandomElements();});*														
			});
		});

	}*/
	
	//$('.ContainerAnimationPane ul li').rand(3).addClass("Visible").fadeIn(2000, function() { GetRandomElements(); });
	

});





/*** Library ***/
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function TwoSIC_AlignLayer(theDiv,h,v,hPx,vPx,blnTopLeftStop){
 var obj,fun,dw,dh,lw,lh,x,y;
 fun = (document.getElementById) ? "document.getElementById" : "MM_findObj";
 obj = (document.getElementById) ? document.getElementById(theDiv) : MM_findObj(theDiv);
 if(obj){
  if(document.all){dw = document.body.clientWidth;dh = document.body.clientHeight;}
  else{dw = innerWidth;dh = innerHeight;}
  if(document.layers){
   lw = obj.clip.width;lh = obj.clip.height;
   if(lw == 0) lw = hPx; 
   if(lh == 0) lh = vPx;
  }else{
  lw = obj.style.width.replace("px","");lh = obj.style.height.replace("px","");}
  x = (document.layers) ? ".left" : ".style.left";
  y = (document.layers) ? ".top" : ".style.top";
  if(h == "l"){eval(fun+"('"+theDiv+"')"+x+"="+hPx);}
  if(h == "c"){eval(fun+"('"+theDiv+"')"+x+"="+dw+"/2-"+lw+"/2");}
  if(h == "r"){eval(fun+"('"+theDiv+"')"+x+"="+dw+"-"+lw+"-"+hPx);}
  if(v == "t"){eval(fun+"('"+theDiv+"')"+y+"="+vPx);}
  if(v == "m"){eval(fun+"('"+theDiv+"')"+y+"="+dh+"/2-"+lh+"/2");}
  if(v == "b"){eval(fun+"('"+theDiv+"')"+y+"="+dh+"-"+lh+"-"+vPx);}
   if(blnTopLeftStop) {
    if(eval(fun+"('"+theDiv+"')"+x).toString().indexOf("-") == 0) eval(fun+"('"+theDiv+"')"+x+"=0");
    if(eval(fun+"('"+theDiv+"')"+y).toString().indexOf("-") == 0) eval(fun+"('"+theDiv+"')"+y+"=0");
   }
 }
}


