// JavaScript Document
function entrySpot(obj){
	var top = Math.floor(Math.random()*550) + 50;
	var left = Math.floor(Math.random()*950) + 50;
	$(obj).css("top", top + 'px').css("left", left + 'px');
}

function moveShy(){
	var myLeft = Math.floor(Math.random()*370);
	var topAbs = Math.floor(Math.random()*15);
	var myTop = (-1)*(topAbs + 45);
	var eyeLeft = Math.floor(Math.random()*11) + 13;
	var eyeTop = Math.floor(Math.random()*16) + 6;
	$("#mrShy").css("left", myLeft + "px");	
	$("#mrShy").css("top", myTop + "px");
	$("#shyEyes").css("left", eyeLeft + "px");	
	$("#shyEyes").css("top", eyeTop + "px");
}

function shyInit(){
	entrySpot('#lilShy');
	entrySpot('#lilShy2');
	entrySpot('#lilShy3');
	entrySpot('#lilShy4');
	entrySpot('#lilShy5');
	moveShy();
	if ( $("#comics").length > 0 ) { 
	$('#comics').galleryView({
			panel_width: 900,
			panel_height: 600,
			frame_width: 90,
			frame_height: 60, 
			show_captions: true,
			transition_speed: 600,
			transition_interval: 0,
			nav_theme: 'light',
			filmstrip_position: 'top', 
			background_color: '#F5560A', 

		});
	}
	if ( $("#random").length > 0 ) { 
	$('#random').galleryView({
			panel_width: 600,
			panel_height: 400,
			frame_width: 100,
			frame_height: 100, 
			nav_theme: 'light',
			background_color: 'black',
			overlay_color: 'white',
			overlay_text_color: '#232323',
			overlay_font_size: '12px'
			
		});
	}
	$("#lilShy").everyTime(940, "shymove", function() { 
			var currTop = $(this).css("top");
			var tTop = parseInt(currTop);
			var curLeft = $(this).css("left");
			var tLeft = parseInt(curLeft);
			var vert = Math.floor(Math.random()*200) - 100;			
			var newTop = tTop + (vert);
			var horz = Math.floor(Math.random()* 200) - 100;
			var newLeft = tLeft + (horz);
			$(this).animate( { top:newTop }, { queue:false, duration:800 } )
         .animate( { left:newLeft }, { queue:false, duration:800 } );});						
	$("#lilShy2").everyTime(960, "shymove2", function() { 
			var currTop = $(this).css("top");
			var tTop = parseInt(currTop);
			var curLeft = $(this).css("left");
			var tLeft = parseInt(curLeft);
			var vert = Math.floor(Math.random()*200) - 100;			
			var newTop = tTop + (vert);
			var horz = Math.floor(Math.random()* 200) - 100;
			var newLeft = tLeft + (horz);
			$(this).animate( { top:newTop }, { queue:false, duration:800 } )
         .animate( { left:newLeft }, { queue:false, duration:800 } );});						
	$("#lilShy3").everyTime(980, "shymove3", function() {  
			var currTop = $(this).css("top");
			var tTop = parseInt(currTop);
			var curLeft = $(this).css("left");
			var tLeft = parseInt(curLeft);
			var vert = Math.floor(Math.random()*200) - 100;			
			var newTop = tTop + (vert);
			var horz = Math.floor(Math.random()* 200) - 100;
			var newLeft = tLeft + (horz);
			$(this).animate( { top:newTop }, { queue:false, duration:800 } )
         .animate( { left:newLeft }, { queue:false, duration:800 } );});
	$("#lilShy4").everyTime(1000, "shymove4", function() { 
			var currTop = $(this).css("top");
			var tTop = parseInt(currTop);
			var curLeft = $(this).css("left");
			var tLeft = parseInt(curLeft);
			var vert = Math.floor(Math.random()*200) - 100;			
			var newTop = tTop + (vert);
			var horz = Math.floor(Math.random()* 200) - 100;
			var newLeft = tLeft + (horz);
			$(this).animate( { top:newTop }, { queue:false, duration:800 } )
         .animate( { left:newLeft }, { queue:false, duration:800 } );});
	$("#lilShy5").everyTime(1010, "shymove5", function() { 
			var currTop = $(this).css("top");
			var tTop = parseInt(currTop);
			var curLeft = $(this).css("left");
			var tLeft = parseInt(curLeft);
			var vert = Math.floor(Math.random()*200) - 100;			
			var newTop = tTop + (vert);
			var horz = Math.floor(Math.random()* 200) - 100;
			var newLeft = tLeft + (horz);
			$(this).animate( { top:newTop }, { queue:false, duration:800 } )
         .animate( { left:newLeft }, { queue:false, duration:800 } );});
	$(".lilPix").draggable({start: function() {$(this).stop().stopTime();}});
	$(".lilPix").bind('dragstop', function() {$(this).everyTime(940, "shymoveAgain", function() { var currTop = $(this).css("top");var tTop = parseInt(currTop);var curLeft = $(this).css("left");var tLeft = parseInt(curLeft);var vert = Math.floor(Math.random()*200) - 100;	var newTop = tTop + (vert);var horz = Math.floor(Math.random()* 200) - 100;var newLeft = tLeft + (horz);$(this).animate( { top:newTop }, { queue:false, duration:800 } ).animate( { left:newLeft }, { queue:false, duration:800 } );});});
	
}

