(function($) {
  var cache = [];
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
	
		$(document).ready(function(){
			
			var aloc = null;
			var bloc = null;
			var cloc = null;
			var dloc = null;
			var eloc = null;
			var floc = null;
			var gloc = null;
			
			$(window).scroll(function () {
			aloc = $(document).scrollTop()+"px";
			bloc = 48+$(document).scrollTop()+"px";
			cloc = 96+$(document).scrollTop()+"px";
			dloc = 144+$(document).scrollTop()+"px";
			eloc = 192+$(document).scrollTop()+"px";
			floc = 240+$(document).scrollTop()+"px";
			gloc = 288+$(document).scrollTop()+"px";
				
				$('#floatMenu .a').animate({top:aloc},{duration:1400,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .b').animate({top:bloc},{duration:1300,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .c').animate({top:cloc},{duration:1200,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .d').animate({top:dloc},{duration:1100,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .e').animate({top:eloc},{duration:1000,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .f').animate({top:floc},{duration:900,queue:false,easing:'easeOutQuint'});
				$('#floatMenu .g').animate({top:gloc},{duration:800,queue:false,easing:'easeOutQuint'});
							});
		
		});
		
		$(document).ready(function(){
			var name = "#optionspace";
			var menuYloc = null;
			menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
			$(window).scroll(function () { 
				offset = menuYloc+$(document).scrollTop()+"px";
				$(name).animate({top:offset},{duration:600,queue:false,easing:'easeOutQuint'});
									});
		}); 
		
		$(document).ready(function() {
	
			$('.thumbs img').hover(function() {
			var p = $(this).parent(); // parent tag
			$(this).stop().animate({opacity:1}, {duration:1000,queue:false,easing:'easeOutQuint'});
			$("#moused").html(p.attr("title"));
			$("#moused").stop().animate({opacity:.7, marginRight: '12px'}, {duration:400,queue:false,easing:'easeOutQuint'});
			}, function() {
			$(this).stop().animate({opacity:.5}, {duration:800,queue:false,easing:'easeInCubic'});
			$("#moused").stop().animate({opacity:0, marginRight: '-240px'}, {duration:800,queue:false,easing:'easeInCubic'});
		}
	);
	
			$('.poptions').hover(function() {
			$(this).animate({opacity:1}, {duration:600,queue:false,easing:'easeOutQuint'});
			$(this).animate({paddingTop: '30px'}, {duration:600,queue:false,easing:'easeOutQuint'});
		}, function() {
			$(this).animate({opacity:.3}, {duration:800,queue:false,easing:'easeInCubic'});
			$(this).animate({paddingTop: '12px'}, {duration:600,queue:false,easing:'easeOutQuint'});
		}
	);
	
		$('#floatMenu a').hover(function() {
			$(this).stop().animate({marginRight: 0}, {duration:200,queue:false,easing:'easeOutQuint'}).animate({opacity:1, width: '148px', paddingRight: '12px'}, {duration:400,queue:false,easing:'easeOutQuint'});
			$(this).children('span').stop().animate({marginLeft: 0}, {duration:800,queue:false,easing:'easeOutQuint'});
		}, function() {
			$(this).css('paddingRight', 0).css('marginRight', '12px').stop().animate({opacity:.4, width: '36px'}, {duration:800,queue:false,easing:'easeOutQuint'});
			$(this).children('span').stop().animate({marginLeft: '300px'}, {duration:1600,queue:false});
		}
	);

		$('h1').hover(function() {
			$(this).stop().animate({opacity:1}, {duration:1200,queue:false,easing:'easeOutCubic'});
		}, function() {
			$(this).stop().animate({opacity:.7}, {duration:2400,queue:false,easing:'easeOutQuint'});
		}
	);
	

	$('#corner').stop().animate({opacity:1}, {duration:6600,queue:false,easing:'easeOutQuint'});
	$('h1').stop().animate({opacity:.7});
	$('.poptions').stop().animate({opacity:.3});
	$('#moused').animate({opacity:0});
});

jQuery.preLoadImages("/photo/bg_photo.gif", "/pro/bg_pro.gif", "/about/bg_about.gif", "/graphic/bg_graphic.gif");
		
Shadowbox.init({
    language: "en",
    players: ["img","iframe","swf"],
	overlayColor: "#000",
	overlayOpacity: .9,
	autoDimensions: true
});

function fadeInRandom(){ 
var numElements = $(".thumbs").children().length;
var randomElem = Math.floor(Math.random()*(numElements));
var randomPoster = $(".thumbs").children()[randomElem].href;
var randomTitle = $(".thumbs").children()[randomElem].title;
var randomGall = $(".thumbs").children()[randomElem].rel.substring(10,12);
if (randomPoster.indexOf(".jpg") != -1) {var playerType = "img"; var widthSize = ""; var heightSize = "";}
if (randomPoster.indexOf(".html") != -1) {var playerType = "iframe"; var widthSize = "597"; var heightSize = "600";}
if (randomPoster.indexOf(".swf") != -1) {var playerType = "swf"; var widthSize = ""; var heightSize = "";}
if (randomPoster.indexOf(".php") != -1) {var playerType = "iframe"; var widthSize = ""; var heightSize = "";}
if (randomPoster.indexOf("ss.php") != -1) {var playerType = "iframe"; var widthSize = "700"; var heightSize = "600";}

Shadowbox.open({
        content: randomPoster,
        player: playerType,
        title: randomTitle,
        width: widthSize,
        height: heightSize,
        gallery: randomGall
    });
}

function fadeOpen(){
var numElements = Shadowbox.gallery.length + 1;
var randomElem = Math.floor(Math.random()*(numElements));
Shadowbox.change(randomElem);
}
