//Set ready state
$(document).ready(function(){//Start Ready
		



// For Flickr Gallery & Lightbox
if($('body').hasClass('bodypress')){
	jQuery(function(){   
		jQuery("#gallery-flickr").flickr({     
			api_key: '0080589dd9543bfdce2ed9d5f47abf65', 
			type: 'photoset',
			photoset_id: '72157615219849326',
			per_page: 40, 
			callback: liteboxCallback 
		}); 
// For Integrating Litebox with Flickr Gallery
function liteboxCallback(el){
  			$(".gallery").litebox({
			nz:	'1em', 
			sw: 0.6,
			sh: 0.6,
			count: false
		});
		}
}); 

}

// For Flickr Gallery & Lightbox
if($('body').hasClass('bodypress')){
	jQuery(function(){   
		jQuery("#gallery-flickr2").flickr({     
			api_key: '0080589dd9543bfdce2ed9d5f47abf65', 
			type: 'photoset',
			photoset_id: '72157615191667971',
			per_page: 40, 
			callback: liteboxCallback 
		}); 
// For Integrating Litebox with Flickr Gallery
function liteboxCallback(el){
  			$(".gallery").litebox({
			nz:	'1em', 
			sw: 0.6,
			sh: 0.6,
			count: false
		});
		}
}); 

}


//  $(".jqAlbumParser").jqAlbumParser({
//		showDesc: true,
//        pluginExec : function(){
//            $(this).jqGalViewII();
//        }
//    }).click();
//	
//	$("#thumbs a").click(function(event){
//		$("#thumbs .on").removeClass();
//		$(this).find("img").addClass("on");
//		var showdiv_show = $(this).attr("href");
//		$('.show').removeClass('show').hide();
//		$(showdiv_show).fadeIn('slow').addClass('show');
//		event.preventDefault();
//	});
//	
//	$('#flashcontent div').hide();
//	$("#thumbs a:first").click();
	
					   

//Begin Functions for Comment Form
						   
//Clear Comment Field
$(".comment").focus(function() {
		    if(this.value == "Type comment here!"){
				this.value = "";
				}
		});
$(".comment").blur(function() {
		    if(this.value == ""){
				this.value = "Type comment here!";
				}
		});

$(".poplink").click(function(event){ //Triggers all pops from 'a' elements with class of 'poplink'
		var popdiv_show = $(this).attr("href");  
		$(popdiv_show).fadeIn('slow');
		event.preventDefault();
		$('#playerContainer').hide().parent().prepend('<img src="img/player.jpg" />')
		$('#youtube img').fadeIn('slow');
		popDiv();
	});

$(".tooltip a").click(function(event){ //Triggers all tooltips from 'a' elements with class of 'tooltip'
		var popdiv_show = $(this).attr("href");  
		$(popdiv_show).toggle('slow');
		event.preventDefault();
	});
$(".pop .close").click(function(event){ //Triggers close of pop div from 'a' elements with class of 'close' and clicking on overlay background
   		closePopDiv();
		event.preventDefault();
		$('#youtube').find('img').remove()
		$('#playerContainer').show();
	});

$(".poptip .close").click(function(event){ //Triggers close of tooltips from 'a' elements with class of 'close'
   		closePopTip();
		event.preventDefault();
	});

//Query (requires jquery.query.js)
	if($('body').hasClass('bodycontact')){
	var cat = $.query.get('cat');
	}
	if(cat == "thankyou"){
		$("#thankyou").fadeIn('slow');
		popDiv();
	}
	if(cat == "nogo"){
		$("#nogo").fadeIn('slow');
		popDiv();
	}
	// validate signup form on keyup and submit
	if($('body').hasClass('bodycontact')){
		$(".contactform").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			comment: "required"
		},
		messages: {
			name: "Please enter your name.",
			email: "Please enter a valid email address.",
			comment: "Please ask your question or leave a comment."
		}
	});
	}
		


//Twitter Cleanup
$('#twitter_update_list li:last').css("border", "0");
	




});//End Ready

//Sets offset for popup divs from top of browser window
function popDiv() {
		getHeight();
		if($.browser.msie){
		$(".pop").css("top", document.documentElement.scrollTop+50+'px');
		$('#content select').hide();
		}
		else {
		$(".pop").css("top", window.pageYOffset+100+'px');
		}
		$("#overlay").show();
}

function closePopDiv(){
	$(".pop").fadeOut('slow');
	$("#overlay").hide();
	if($.browser.msie) {
 		$('#content select').show();
		$("#footer").css("height", "200px");
 		}
	return false;
}


// Sets height for Overlay
function getHeight(){
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  		wind = window.innerWidth;
  		wind = window.innerHeight;
 		}
 		if($.browser.msie) {
  		wind = document.body.offsetWidth;
  		wind = document.body.offsetHeight;
 		}
	}
	var divh = document.getElementsByTagName('body')[0].offsetHeight;
	var lock = document.getElementById('overlay');
	if (divh >= wind){
	lock.style.height = divh +"px";
	}
	else {lock.style.height =wind +"px";}
}
