/* KPF.COM */

// tell cufon to replace fonts
Cufon.replace('h3.projectname', {fontFamily: 'The Sans Light Caps'});
Cufon.replace('h3.projectsubname', {fontFamily: 'The Sans Light Caps'});
Cufon.replace('h3.catname', {fontFamily: 'The Sans Light Plain'});
Cufon.replace('h5', {fontFamily: 'The Sans Light Plain'});
Cufon.replace('h5 .postnom', {fontFamily: 'The Sans Light Caps'});
Cufon.replace('h6', {fontFamily: 'The Sans Light Plain'});
Cufon.replace('.contact-subhead', {fontFamily: 'The Sans Light Caps'});
Cufon.replace('.bottomprojecttype', {fontFamily: 'The Sans Light Plain', hover: true, hoverables: { a:true }});




// jquery things to do
jQuery(document).ready(function(){ 

	// remove "noscript" class from body
	$("body").removeClass("noscript");
	
	// IF THE LANGUAGE IS MANDARIN, set sizes for the sliding submenus
	if ($('body').hasClass('mandarin')==true) {
		//highlist "chinese" in the footer
		$("#footer #languages #chinese a").addClass("active");
		
		// toggle "Projects" subnav (mandarin)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"93px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (mandarin)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"400px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is mandarin and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for chinese characters
		if ($('body').hasClass('pagetype-typelist')==true) {
			$('.typelist .corporate a').html('');
			$('.typelist .culture a').html('');
			$('.typelist .education a').html('');
			$('.typelist .government a').html('');
			$('.typelist .health a').html('');
			$('.typelist .hospitality a').html('');
			$('.typelist .interiors a').html('');
			$('.typelist .masterplan a').html('');
			$('.typelist .mixeduse a').html('');
			$('.typelist .office a').html('');
			$('.typelist .repositioning a').html('');
			$('.typelist .residential a').html('');
			$('.typelist .retail a').html('');
			$('.typelist .supertall a').html('');
			$('.typelist .transport a').html('');
		}
		
		if ($('body').hasClass('pagetype-regionlist')==true) {
			$('.typelist .americas a').html('');
			$('.typelist .asia a').html('');
			$('.typelist .europe a').html('');
			$('.typelist .middleeast a').html('');
		}
		
	}
	
	// OTHERWISE the language is not set to mandarin, so use default widths
	else {
		// highlight "English" in the footer
		$("#footer #languages #english a").addClass("active");
		
		// if it is not the chinese version, use cufon on project category lists
		Cufon.replace('.typelist li a, .loclist li a', {fontFamily: 'The Sans Light Plain', hover: true, hoverables: { li: true, a:true }});
	
		// toggle "Projects" subnav (default)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"95px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (default) (360px actual width)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"365px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
	}
	
	

	// OTHER STUFF
	
	// preload images from css files
	$.preloadCssImages();
	
	// initialize tooltips
	$(".hastooltip").tooltip({ 
		tip: '.tooltip', effect: 'fade', fadeInSpeed: 200, fadeOutSpeed: 100, predelay: 0, position: "bottom center", relative: true, offset: [-3, -424] 
	});
				
	// initialize scrollables (for project thumbnails)
	$("#project-thumbnails").scrollable({clickable: false}).mousewheel(); 
	$("#awards").scrollable({size: 4}).navigator().mousewheel(); 
	
	// get height of elements in project sidebar, then set project text scroller height
	$remainingheight = 500 - (($("#projectdata").height() + 22));
	$(".scroll-pane").css({ height: $remainingheight}); 
	
	// initialize jscrollpane (for project descriptions)
	$('.scroll-pane').jScrollPane({
		scrollbarWidth:10, scrollbarMargin:10, dragMaxHeight:75, dragMinHeight:25, topCapHeight: 0, bottomCapHeight: 50
	});
	
});




// highlights thumbs/project names on project list pages
function highlightOn (id) {
if ($("#img"+id+"")){$("#img"+id+"").addClass("highlightonimg");}
if ($("#cap"+id+"")){$("#cap"+id+"").addClass("highlightoncap");}
if ($("#prname"+id+"")){$("#prname"+id+"").addClass("highlightonname");}
//if ($("#catname"+id+"")){$("#catname"+id+"").addClass("active");}
if ($("#li"+id+"")){$("#li"+id+"").addClass("active");}
}

function highlightOff (id) {
if ($("#img"+id+"")){$("#img"+id+"").removeClass("highlightonimg");}
if ($("#cap"+id+"")){$("#cap"+id+"").removeClass("highlightoncap");}
if ($("#prname"+id+"")){$("#prname"+id+"").removeClass("highlightonname");}
//if ($("#catname"+id+"")){$("#catname"+id+"").removeClass("active");}
if ($("#li"+id+"")){$("#li"+id+"").removeClass("active");}
}
