/*

Object Adjective, LLC
650 Delancey St.
Unit 220
San Francisco, CA 94107 US
415-756-5198
http://www.objectadjective.com


I Correct > common.js

.......................................................*/


//Set ready state.......................................

$(document).ready(function() {

$('.slideshow p').cycle({
		fx: 'fade'
	});
	
$(".magnify img").hide().load(function(){

	$(this).magnify().fadeIn("fast");
	
});

$('a[rel=nofollow], a[rel=pdf]').attr('target','new');


setupLightbox();
enablePlaceholder();

    
});

//End Ready.............................................



/*------------- Set Up Tabs ----------------------------------*/

/* Setup Lightbox Trigger Links */
function setupTabs(){
	$('.tab-content').hide();
    $('.tabs a').click(function(event) {
    	$('.tab-content').hide();
    	$(this).parents('.lightbox').find('.current').removeClass('current');
    	$(this).parent().addClass('current');
        var el_show = $(this).attr("href");
        $(el_show).show();
        event.preventDefault();
    });
	$('.tabs a[href=#all]').click();
}


/*------------- Set Up Lightboxes -----------------------------*/

/* Setup Lightbox Trigger Links */
function setupLightbox(){
	$('body').append('<div id="overlay"></div>')
    $('.fadein').click(function(event) {
        var el_show = $(this).attr("href");
        $(el_show).hide().css('left', '50%').fadeIn('slow');
        event.preventDefault();
        popDiv();
    });
}

/* Position and Event Handlers for Lightboxes */
function popDiv() {
	$('#overlay').show();
	getHeight();
	if($.browser.msie) {
	    $(".lightbox").css("top", document.documentElement.scrollTop + 30 + 'px');
	}
	else if($.browser.opera) {
	    $('.lightbox').css('top', document.body.scrollTop + 30 + 'px');
	}
	else {
	    $(".lightbox").css("top", window.pageYOffset + 30 + 'px');
	}
    $(".lightbox .close, .lightbox .cancel, #overlay").click(function(event){
		closePopDiv();
		event.preventDefault();
	});

}


function closePopDiv(){
    $(".lightbox").fadeOut('slow');
    $("#overlay").hide();
}


/* Overlay Set Up */
function getHeight(){
	if (parseInt(navigator.appVersion)>3) {
 		if($.browser.msie) {
  		wind = document.body.offsetWidth;
  		wind = document.body.offsetHeight+200;
 		}
		else {
  		wind = window.innerWidth;
  		wind = window.innerHeight;
 		}
	}
	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";}
}
    
/*------------- /Set Up Lightboxes -----------------------------*/


/*------------- Enable Placeholder -----------------------------*/

function enablePlaceholder(){

	if(!Modernizr.input.placeholder){
		$("input").each(
		function(){
			if($(this).val()=="" && $(this).attr("placeholder") != null){
				$(this).val($(this).attr("placeholder"));
			}
			if ($(this).attr("placeholder") != null) {  
				$(this).focus(function(){
					if($(this).val()==$(this).attr("placeholder")) $(this).val("");
				});
				$(this).blur(function(){
					if($(this).val()=="") $(this).val($(this).attr("placeholder"));
				});
			}
		});
	
	}



}

