// site specific javascript

$(function(){
		   

	
	//CALLS THE BIND BEHAVIOR FUNCTION
	behavior_binder();
	
});

/*
Binds behaviors
** can be re-run whenever there are DOM changes
*/
function behavior_binder(){

	$('.section_heading').drawFont();
	$('#footer_links li a').drawFont();
	$('#page_title').drawFont();
	$('#page_subtitle').drawFont();
	$('#return_index').drawFont();
	$('#site_password').drawFont();

/* ADD FIRST/LAST TO LI
		adds a class 'first' to the first LI, and a 'last' to the last LI and 'first last' to a single LI
	*/
	$('ul').each(function(i){
		$(this).children('li:first').addClass('first');
		$(this).children('li:last').addClass('last');
	});
	$('ul#nav a').bind('click',function(e){nav_click(e)});
	var loc=window.location.pathname+window.location.search;
	var found=false;
	
	if($('ul#nav a.selected').length){
		$('ul#nav a').each(function(){
			if($('.selected',$(this).parent()).length){
				$(this).addClass('hitarea');
				$('>ul',$(this).parent()).css('display','block');
			}

		});
	}

}

function nav_click(e){
	var parent_ul=$(e.target).parent();
	if($('ul',parent_ul).length){
		e.preventDefault();
		if($(e.target).hasClass('hitarea')){
			close_nav(parent_ul);
		}
		else{
			open_nav(parent_ul);
		}
		$(e.target).addClass('hitarea');
	}
	
}
function close_nav(item){
	var curr=item;
	$('ul',item).slideUp('fast',function(){
		if(curr){
			$('a',curr).removeClass('hitarea');
			
		}
		
	});
	
	
}
function open_nav(item){
	$('>a',item).addClass('hitarea');
	$('>ul',item).slideDown('fast');
	
}
$(document).ready(function(){
$('.photoassetlink').bind('click',function(e){popwindow(e)});
});
function popwindow(e){
e.preventDefault();
var href=$(e.target).parent().attr('href');
window.open(href,'','menubar=1,toolbar=0,width=440,height=450');
};