var found=false
var current = new Array()
var NumUnique=3  //The number of unique numbers required
var Count=0
var current = new Array(NumUnique)

  function GetUnique(max_value)  {
    for (i=0;Count<NumUnique;Count++) {
      found=false
      var rndValue = get_random(max_value)
      var j=0
      for (j=0;j<current.length;j++)
      {
        if (current[j] == rndValue)
        {
          found=true
          break
        }
      }
      if (found)
      {
        Count--
      } else {
        current[Count]=rndValue
      }
    }
  }
  function get_random(max_value) {
    var ranNum= Math.round(Math.random()*max_value);
    return ranNum;
  }

$(document).ready(function() {
	var bodyclass = $('body').attr("id");
	if (bodyclass == 'single'){
		// $('#apps').html(data);
		GetUnique($("#apps li").size()-1);			
		$("#apps li").hide();
		$("#apps li").eq(current[0]).show();
		$("#apps li").eq(current[1]).show();
		$("#apps li").eq(current[2]).show();
		
	}
	
	//$.get('_apps.html', function(data) {	
	//	var bodyclass = $('body').attr("id");
  //
	//	if (bodyclass == 'single'){
	//		$('#apps').html(data);
	//		GetUnique($("#apps li").size()-1);			
	//		$("#apps li").hide();
	//		$("#apps li").eq(current[0]).show();
	//		$("#apps li").eq(current[1]).show();
	//		$("#apps li").eq(current[2]).show();
	//		
	//	}else {
	//		$('#apps').html(data);
	//	}
  //
	//  // alert('Load was performed.');
	//});
	
 
	$('#filters a').click(function () {
		$("#filters a").parent().removeClass("selected");
		$(this).parent().addClass("selected");	
		
		var item = $(this).attr("href").replace("#", ".");
		if (item == ".") item = "";
		
		if(item){
			$("#apps li").hide().filter(item).show();
		}else {
			$("#apps li").show();
		}

	  return false;
	});

	// Colorbox implementation
	// Syntax for individual image slideshows
	$("a[rel='colorbox']").colorbox({initialWidth: "473",initialHeight: "354"});
	
	// Syntax for embedded youtube videos
	$('.video').colorbox({initialWidth: "480",initialHeight: "390", inline:true, href:"#video"});
	
	
	$("#toystory2_vid").colorbox({initialWidth: "480",initialHeight: "390", inline:true, href:"#toystory2"});
	$("#toystory3_vid").colorbox({initialWidth: "480",initialHeight: "390", inline:true, href:"#toystory3"});
	
	
});
