$(document).ready(function(){

//INDEX.PHP ====================

var check = $('#tagline').attr('src');//check to see if the image is index.php
if(check == 'images/tagline.png'){

	//Insert loading screen
	$('body').prepend('<div id="loading"><div id="loadingC"><p>loading</p><img src="images/loading.gif"/></div></div>');
		
	//Index.php animation prep	
	$('#nav, #tagline, #splashtxt1, #splashtxt2, #splashtxt3,#splashlink').hide();
	$('#logo').css('top','-150px');

}else{
	$('#content').hide().fadeIn();
}//end index.php check

//PORTFOLIO.PHP ====================

//Greybox
var gbOptions = {
	gbWidth: 1200,
	gbHeight: 600,
	captionHeight: 22,
	ffMacFlash: true
	};
$('.popup').livequery(function(){$(this).greybox(gbOptions);});

//Portfolio Thumbnails
$('.pitem1, .pitem2').livequery(function(){
	$(this).hover(
		function(){
			$(this).animate({width:'+=30px',height:'+=30px'},200);
		},function(){
			$(this).animate({width:'-=30px',height:'-=30px'},200);
		});//end hover
});//end livequery

//ALL PAGES ====================

//Enhanced Page Nav Rewrite
$('.navLink').livequery('click',function(evt){
	var target = $(this).attr('href');
	var check2 = $('#tagline').attr('src');//check to see if the image is index.php
	
	if(check2 == 'images/tagline.png'){ //if the index
		$('#content').fadeOut(400, function(){
			$('#featured').load('includes/'+target,function(){
				$('#tag').hide().css('margin-left','350px').show().animate({marginLeft:'0px'},800);
				$('#window').hide().wait(400).slideDown(500);
			});//end load callback
		});
	}else{
		$('#window').slideUp(500);
		$('#content').wait(500).fadeOut(0,function(){
			$('#featured').load('includes/'+target,function(){
				$('#tag').hide().css('margin-left','350px').show().animate({marginLeft:'0px'},800);
				$('#window').hide().wait(400).slideDown(500);
			});//end load callback
		});
	}

	evt.preventDefault();
});//end navLink click

});//end ready

//Close loading screen once page is fully loaded
window.onload = function(){

	//check to see if the image is index.php
	var check = $('#tagline').attr('src');
	if(check == 'images/tagline.png'){
	
		//remove the loading screen
		$('#loading').fadeOut(400,function(){

			//Home Animation as loading screen fadeOut callback
			$('#logo').wait(500).animate({top:'78px'},1500,function(){
				//page animation as logo animate callback
				$('#tagline').fadeIn(1000);
				$('#splashtxt1, #splashtxt2').wait(700).fadeIn();
				$('#splashtxt3, #splashlink').wait(1200).fadeIn(1500);
				$('#nav').wait(1550).slideDown();
			});	//end animation 

		});//end loading callback  

	}//end index check
	
};//end window.onload
