//New js file.  is what this file is.  I love files.  

/*This is the function for the NEW posts slider on the index page.  Note: when x is less than -810 the que is at it's end.  When x is 0 it is at it's beginning.  The que moves 90px at each click*/
/*
UPDATE: THIS IS NOW OBSOLETE AS I HAVE REMOVED FROM THE HOME PAGE AND REPLACED WITH THUMBS + PLAIN TEXT
$(document).ready(function(){
	var x = -90; 
	$('#index_new_arrow_left').click(function(){
	if (x<0)
	{
		x += 90; 
		$('#new_inner_hidden').animate({left:''+x+'px'},200,'easeOutQuad');
	}
	else {
		return; 
	}
	});
	$('#index_new_arrow_right').click(function(){
		if (x>-720)
		{
			x -= 90; 
			$('#new_inner_hidden').animate({left:''+x+'px'},200,'easeOutQuad');
		}
	});
});*/

//Here are fucntions for the about section on the index page. 
/*
$(document).ready(function() {
	$('#about_img').click(function() {
		$('#about_p').toggle(2000); 
	});
});*/

//All the rollover functions in one!!!
$(document).ready(function(){
rollOver($('#sub_slider_arrow_left, #sub_slider_arrow_right, #about_img, #index_new_arrow_right, #index_new_arrow_left, .nav_img')); 

function rollOver(image) 
{
	image.hover(function() 
	{
		$(this).attr('src',$(this).attr('src').split('_off').join('_on'))
	},
	function() 
	{
		$(this).attr('src',$(this).attr('src').split('_on').join('_off'))
	});
}
});

//This function determines how many sections there are in the sub-page galleries and 
//sets the width of the sliding div... thingy
var newWidth; 
$(document).ready(function() {
	var numberDivs = $('#sub_slider_inner').children().size(); 
	newWidth = numberDivs*440; 
	$('#sub_slider_inner').css('width',newWidth+'px'); 
});

//And this ol' function-erino slides it left and right at your every whim (it's whimsical)
//AND, it shows or hides the MOR and BAK bttnz if the time is right (you know it is)
$(document).ready(function(){
	var x = 0; 
	if (newWidth <= 440) 
	{
		$('#sub_slider_arrow_right').hide(); 
	}
	$('#sub_slider_arrow_left').click(function(){
	if (x<0)
	{
		x += 440; 
		$('#sub_slider_inner').animate({left:''+x+'px'},200,'easeOutQuad');
		showOrHideBtns(); 
	}
	else {
		showOrHideBtns(); 
		return; 
	}
	});
	$('#sub_slider_arrow_right').click(function(){
		if (x>-newWidth+440)
		{
			x -= 440; 
			$('#sub_slider_inner').animate({left:''+x+'px'},200,'easeOutQuad');
			showOrHideBtns(); 
		}
		else {
			showOrHideBtns(); 
			return; 
		}
	});
	function showOrHideBtns()
	{
//		alert(x +'AND'+-newWidth+440 )
		if (x == 0 )
		{
			$('#sub_slider_arrow_left').hide(); 
			$('#sub_slider_arrow_right').show(); 
		}
		else if (x == -newWidth+440) 
		{
			$('#sub_slider_arrow_right').hide(); 
			$('#sub_slider_arrow_left').show(); 
		}
		else if (0 > x > -newWidth+440)
		{
			$('#sub_slider_arrow_right').show(); 
			$('#sub_slider_arrow_left').show(); 
		}
	}
});

//Jquery FancyBox function.  

$(document).ready(function() {
	$(".sub_slider_thumbs").fancybox({
		'titleShow'		: true,
		'titlePosition'	: 'inside', 
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic', 
		'overlayOpacity' : '0.5', 
		'overlayColor' : '#111' 
	});
});

//This function takes the current default thumbnail and replaces it with the correct one
//NOTE: the naming scheme is important here.  The thumbnail must be uploaded during the same month or wordpress will place it in a different folder (ideally just do them both at the same time) 
//AND it must have the exact same name with '_thumb' @ the end.  ONLY jpeg images will be accepted.  If no image is found, you're fucked, so it has to work.  I tried writing a function that checks whether or not the thumbnail exists, and if not filling in a default thumb, but the file_exists() method was a boner (tee hee).  

$(document).ready(function() {
	$('.sub_slider_thumbs').each(function() {
		var new_url = $(this).attr('href').split('.jpg').join('_thumb.jpg'); 
		$(this).find('img').attr('src',new_url); 
	}); 

  //Inserts the year into the footer: 
	var theYear = (new Date).getFullYear();
	$('#footer p').append(theYear); 

  // Hover animation for home page nav. 
	$('.nav_img_home').hover(function() {
		$(this).animate({right:'-15px'}); 
	} , function(){
		$(this).animate({right:'0px'}); 
	});

  //Hide and show the about section on the index page.
	$("#index_about").fancybox({
		'autoDimensions'	: false, 
		'width'			: '400px', 
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic', 
		'titleShow'		: false, 
		'titlePosition'	: 'inside', 
		'opacity'		: true, 
		'overlayOpacity' : '0.5', 
		'overlayColor' : '#111' 
	});


  //The following function transforms the hidden divs into drop shadows for IE
	if ($.support.opacity == false) {
		var theId = $('#shadow_container').siblings().attr('id');
		var newHeight = $('#'+theId).height();
		$('#IE_wrapper_shadow').attr({'style':'filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius="7", MakeShadow="false", ShadowOpacity="0.40");'});
		$('#IE_wrapper_shadow').height(newHeight);
		$('#IE_wrapper_shadow').css('display','block');
	}

  //Dinosaur script for "don't press the red button" blog post
  $('#naughty_button').click(function(){
    console.log('this is dinoz bitch!'); 
    
    var img = "http://ronaldvwilliams.com/common/images/dino_angry.png"; 
    var txt = "YOU'RE ABOUT TO GET EEEAAATEN!!! AAAAAAH!"; 
    var t; 
    var styles1 = {'position':'absolute', 'top':'100px', 'right':'-700px', 'width':'1000px', 'height':'500px'}; 
    var styles2 = {'float':'right'}; 
    var styles3 = {'float':'left', 'width':'500px', 'height':'100%' , 'font-size':'100px', 'font-family' : 'helvetica', 'text-wrap':'unrestricted', 'font-weight':'bolder'}; 
    $('body').append(
      $('<div>').attr('id' , 'dino_angry').css(styles1).append(
        $('<img>').attr('src',img).css(styles2)
      ).append(
        $('<div>').attr('id', 'dino_angry_text').text(txt).css(styles3)
      )
    );
    $('#dino_angry').animate({'right':'0px'}, function(){
      t = setInterval(function(){
        var rgb = 'rgb(' + random() + ',' + random() + ',' + random() + ')'; 
        $('#dino_angry_text').css('color',rgb)
      }, 200)
    }); 
    function random() {var x = Math.floor(Math.random() * 255); return x}; 
  
  }); 
  // End of dinosaur script

// End of document.ready functions
});



