/* 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 }});
Cufon.replace('.community-column .title', {fontFamily: 'The Sans Light Plain'});




// jquery things to do
jQuery(document).ready(function(){ 

	// remove "noscript" class from body
	$("body").removeClass("noscript");
	
	
	// IF THE LANGUAGE IS MANDARIN
	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)     when News moved to top  nav change 466px to 435px
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"435px"}, 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 || $('body').hasClass('pagetype-regionlist')==true) {
			$('.typelist a').html('');
		}	
	}
	
	
	// IF THE LANGUAGE IS KOREAN
	else if ($('body').hasClass('korean')==true) {
		//highlist "korean" in the footer
		$("#footer #languages #korean a").addClass("active");
		
		// toggle "Projects" subnav (korean)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"85px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (korean)  when News moved to top  nav change 401 to 370
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"370px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is korean and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for korean characters
		if ($('body').hasClass('pagetype-typelist')==true || $('body').hasClass('pagetype-regionlist')==true) {
			$('.typelist a').html('');
		}
	}
	
	
	// IF THE LANGUAGE IS JAPANESE
	else if ($('body').hasClass('japanese')==true) {
		//highlist "japanese" in the footer
		$("#footer #languages #japanese a").addClass("active");
		
		// toggle "Projects" subnav (japanese)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"121px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (japanese)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"440px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is japanese and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for japanese characters
		if ($('body').hasClass('pagetype-typelist')==true || $('body').hasClass('pagetype-regionlist')==true) {
			$('.typelist a').html('');
		}
		
	}
	
	
	// IF THE LANGUAGE IS SPANISH
	else if ($('body').hasClass('spanish')==true) {
		//highlist "spanish" in the footer
		$("#footer #languages #spanish a").addClass("active");
		
		// toggle "Projects" subnav (spanish)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"180px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (spanish)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"390px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is spanish and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for spanish characters
		if ($('body').hasClass('pagetype-typelist')==true || 
			$('body').hasClass('pagetype-regionlist')==true ||
			$('body').hasClass('pagetype-projectlist')==true) {
			$('.typelist .corporate a, .pagetype-regionlist .listingthumb #cap4, h3.corporate').html('Corporativo');
			$('.typelist .culture a, .pagetype-regionlist .listingthumb #cap2, h3.culture').html('Cultural + Entretenimiento');
			$('.typelist .education a, .pagetype-regionlist .listingthumb #cap3, h3.education').html('Educación');
			$('.typelist .government a, .pagetype-regionlist .listingthumb #cap1, h3.government').html('Gubernamental');
			$('.typelist .health a, .pagetype-regionlist .listingthumb #cap5, h3.health').html('Sanidad + Ciencia');
			$('.typelist .hospitality a, .pagetype-regionlist .listingthumb #cap7, h3.hospitality').html('Hoteles');
			$('.typelist .interiors a, .pagetype-regionlist .listingthumb #cap13, h3.interiors').html('Inreriores');
			$('.typelist .masterplan a, .pagetype-regionlist .listingthumb #cap6, h3.masterplan').html('Urbanismo');
			$('.typelist .mixeduse a, .pagetype-regionlist .listingthumb #cap8, h3.mixeduse').html('Uso mixto');
			$('.typelist .office a, .pagetype-regionlist .listingthumb #cap9, h3.office').html('Oficinas');
			$('.typelist .repositioning a, .pagetype-regionlist .listingthumb #cap15, h3.repositioning').html('Reposicionamiento + Transformación');
			$('.typelist .residential a, .pagetype-regionlist .listingthumb #cap10, h3.residential').html('Residencial');
			$('.typelist .retail a, .pagetype-regionlist .listingthumb #cap11, h3.retail').html('Comercial');
			$('.typelist .supertall a, .pagetype-regionlist .listingthumb #cap14, h3.supertall').html('Rascacielos');
			$('.typelist .transport a').html('Transporte +<br />Infraestructura');
			$('.pagetype-regionlist .listingthumb #cap12, h3.transport').html('Transporte + Infraestructura');
			
			$('.typelist .americas a, h3.americas').html('América');
			$('.typelist .asia a, h3.asia').html('Asia pacífico');
			$('.typelist .europe a, h3.europe').html('Europa');
			$('.typelist .middleeast a, h3.middleeast').html('Medio Oriente + África');
			
			Cufon.replace('.typelist li a, .loclist li a', {fontFamily: 'The Sans Light Plain', 
				hover: true, hoverables: { li: true, a:true }});
			Cufon.replace('h3', {fontFamily: 'The Sans Light Plain'});
		}
		
		/* Replace text on the "Contact" page */
		if ($('body').hasClass('pagetype-contact')==true)  {
			$('.contact-subhead:contains(New York)').html('Nueva York');
			$('.contact-subhead:contains(London)').html('Londres');
			$('.contact-subhead:contains(Shanghai)').html('Shanghái');
			$('.contact-subhead:contains(Seoul)').html('Seúl');
			$('.contact-subhead:contains(Abu Dhabi)').html('Abu Dabi');
			$('#inquiries-column .label:contains(General Information)').html('Información general');
			$('#inquiries-column .label:contains(Press Inquiries)').html('Consultas de prensa');
			$('#inquiries-column .label:contains(Career Opportunities)').html('Oportunidades laborales');
			$('#inquiries-column .label:contains(New Business)').html('Nuevos negocios<br />David Niles<br />Marketing Director');
			
			Cufon.replace('.contact-subhead', {fontFamily: 'The Sans Light Caps'});
		}
	}
	
	// IF THE LANGUAGE IS FRENCH
	else if ($('body').hasClass('french')==true) {
		//highlist "french" in the footer
		$("#footer #languages #french a").addClass("active");
		
		// toggle "Projects" subnav (french)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"95px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (french)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"520px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is french and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for french characters
		if ($('body').hasClass('pagetype-typelist')==true || 
			$('body').hasClass('pagetype-regionlist')==true ||
			$('body').hasClass('pagetype-projectlist')==true) {
			$('.typelist .corporate a, .pagetype-regionlist .listingthumb #cap4, h3.corporate').html('Immeuble de bureaux');
			$('.typelist .culture a, .pagetype-regionlist .listingthumb #cap2, h3.culture').html('Culture et loisirs');
			$('.typelist .education a, .pagetype-regionlist .listingthumb #cap3, h3.education').html('Enseignement');
			$('.typelist .government a, .pagetype-regionlist .listingthumb #cap1, h3.government').html('Administration');
			$('.typelist .health a, .pagetype-regionlist .listingthumb #cap5, h3.health').html('Santé + Recherche');
			$('.typelist .hospitality a, .pagetype-regionlist .listingthumb #cap7, h3.hospitality').html('Hôtel');
			$('.typelist .interiors a, .pagetype-regionlist .listingthumb #cap13, h3.interiors').html('Intérieurs');
			$('.typelist .masterplan a, .pagetype-regionlist .listingthumb #cap6, h3.masterplan').html('Urbanisme');
			$('.typelist .mixeduse a, .pagetype-regionlist .listingthumb #cap8, h3.mixeduse').html('Usage mixte');
			$('.typelist .office a, .pagetype-regionlist .listingthumb #cap9, h3.office').html('Bureaux');
			$('.typelist .repositioning a, .pagetype-regionlist .listingthumb #cap15, h3.repositioning').html('Restructuration + Transformation');
			$('.typelist .residential a, .pagetype-regionlist .listingthumb #cap10, h3.residential').html('Résidentiel');
			$('.typelist .retail a, .pagetype-regionlist .listingthumb #cap11, h3.retail').html('Commerce');
			$('.typelist .supertall a, .pagetype-regionlist .listingthumb #cap14, h3.supertall').html('Grande Hauteur');
			$('.typelist .transport a, .pagetype-regionlist .listingthumb #cap12, h3.transport').html('Transport + Infrastructure');
			
			$('.typelist .americas a, h3.americas').html('Amériques');
			$('.typelist .asia a, h3.asia').html('Asie / Pacifique');
			$('.typelist .europe a, h3.europe').html('Europe');
			$('.typelist .middleeast a, h3.middleeast').html('Moyen-Orient / Afrique');
			
			Cufon.replace('.typelist li a, .loclist li a', {fontFamily: 'The Sans Light Plain', 
				hover: true, hoverables: { li: true, a:true }});
			Cufon.replace('h3', {fontFamily: 'The Sans Light Plain'});
		}
		
		/* Replace text on the "Contact" page */
		if ($('body').hasClass('pagetype-contact')==true)  {
			$('.contact-subhead:contains(London)').html('Londres');
			$('.contact-subhead:contains(Shanghai)').html('Shanghai');
			$('.contact-subhead:contains(Seoul)').html('Séoul');
			$('#inquiries-column .label:contains(General Information)').html('Informations Générales');
			$('#inquiries-column .label:contains(Press Inquiries)').html('Presse');
			$('#inquiries-column .label:contains(Career Opportunities)').html('Opportunités de carrière');
			$('#inquiries-column .label:contains(New Business)').html('Nouveaux Projets<br />David Niles<br />Marketing Director');
			
			Cufon.replace('.contact-subhead', {fontFamily: 'The Sans Light Caps'});
		}
	}
	
	
	// IF THE LANGUAGE IS PORTUGUESE
	else if ($('body').hasClass('portuguese')==true) {
		//highlist "portuguese" in the footer
		$("#footer #languages #portuguese a").addClass("active");
		
		// toggle "Projects" subnav (portuguese)
		$("#topnav-projects").toggle(function() { $("#topnav-projects-subnav").animate({width:"100px"}, 200);
		}, function() { $("#topnav-projects-subnav").animate({width:"0px"}, 200); });
		
		// toggle "Profile" subnav (portuguese)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"410px"}, 200);
		}, function() { $("#topnav-firm-subnav").animate({width:"0px"}, 200);});
		
		// if language is portuguese and page is the type or location list, replace default of 
		// list items as empty so that background images can be used for portuguese characters
		if ($('body').hasClass('pagetype-typelist')==true || 
			$('body').hasClass('pagetype-regionlist')==true ||
			$('body').hasClass('pagetype-projectlist')==true) {
			$('.typelist .corporate a, .pagetype-regionlist .listingthumb #cap4, h3.corporate').html('Empresarial');
			$('.typelist .culture a, .pagetype-regionlist .listingthumb #cap2, h3.culture').html('Cultural + Divertimento');
			$('.typelist .education a, .pagetype-regionlist .listingthumb #cap3, h3.education').html('Educação');
			$('.typelist .government a, .pagetype-regionlist .listingthumb #cap1, h3.government').html('Governamental');
			$('.typelist .health a, .pagetype-regionlist .listingthumb #cap5, h3.health').html('Ciencia + Saude');
			$('.typelist .hospitality a, .pagetype-regionlist .listingthumb #cap7, h3.hospitality').html('Hotéis');
			$('.typelist .interiors a, .pagetype-regionlist .listingthumb #cap13, h3.interiors').html('Interiores');
			$('.typelist .masterplan a, .pagetype-regionlist .listingthumb #cap6, h3.masterplan').html('Urbanismo');
			$('.typelist .mixeduse a, .pagetype-regionlist .listingthumb #cap8, h3.mixeduse').html('Uso Misto');
			$('.typelist .office a, .pagetype-regionlist .listingthumb #cap9, h3.office').html('Escritório');
			$('.typelist .repositioning a, .pagetype-regionlist .listingthumb #cap15, h3.repositioning').html('Reposicionamento + Transformação');
			$('.typelist .residential a, .pagetype-regionlist .listingthumb #cap10, h3.residential').html('Residencial');
			$('.typelist .retail a, .pagetype-regionlist .listingthumb #cap11, h3.retail').html('Comercial');
			$('.typelist .supertall a, .pagetype-regionlist .listingthumb #cap14, h3.supertall').html('Arranha-céu');
			$('.typelist .transport a').html('Transporte + <br />Infra-estrutura');
			$('.pagetype-regionlist .listingthumb #cap12, h3.transport').html('Transporte + Infra-estrutura');
			
			$('.typelist .americas a, h3.americas').html('Americas');
			$('.typelist .asia a, h3.asia').html('Asia Pacifico');
			$('.typelist .europe a, h3.europe').html('Europa');
			$('.typelist .middleeast a, h3.middleeast').html('Oriente Medio + Africa');
			
			Cufon.replace('.typelist li a, .loclist li a', {fontFamily: 'The Sans Light Plain', 
				hover: true, hoverables: { li: true, a:true }});
			Cufon.replace('h3', {fontFamily: 'The Sans Light Plain'});
		}
		
		/* Replace text on the "Contact" page */
		if ($('body').hasClass('pagetype-contact')==true)  {
			$('.contact-subhead:contains(New York)').html('Nova York');
			$('.contact-subhead:contains(London)').html('Londres');
			$('.contact-subhead:contains(Shanghai)').html('Xangai');
			$('.contact-subhead:contains(Seoul)').html('Seul');
			$('.contact-subhead:contains(Abu Dhabi)').html('Abu Dabi');
			$('#inquiries-column .label:contains(General Information)').html('Informações Gerais');
			$('#inquiries-column .label:contains(Press Inquiries)').html('Informações para a imprensa');
			$('#inquiries-column .label:contains(Career Opportunities)').html('Oportunidades de Carreira');
			$('#inquiries-column .label:contains(New Business)').html('Novos Negócios<br />David Niles<br />Marketing Director');
			
			Cufon.replace('.contact-subhead', {fontFamily: 'The Sans Light Caps'});
		}
		
	}
	
	// OTHERWISE the language is not set to anything, 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) (436px actual width)  (without news in subnav: 405px)
		$("#topnav-firm").toggle(function() { $("#topnav-firm-subnav").animate({width:"405px"}, 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] 
	});*/
	$(".hastooltip, .tooltip").hover(
	  function () { $('.tooltip').show(); }, 
	  function () { $('.tooltip').hide(); }
	);
				
	// 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
	});
	
	// initialize overlay for google maps
	$(function() {
		$("#data-location span[rel]").overlay({effect: 'apple', onLoad: function(){initializemap();}});
	});
});








// HIGHLIGHT 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");}
};








// stuff for STREET VIEW
var toggleStreetView = false;

function openStreetView() {
	if (toggleStreetView==false) {
		toggleStreetView = true;
		
		// fade out default elements
		$('#project-mainimagetemp').fadeOut(400);
		$('#project-thumbnails').fadeOut(400);
		$('.caption').fadeOut(400);
		$('#projecttext').slideUp(400);
		//$('.project-bottomleftcolumn').slideUp(400);
		
		// add street view stuff
		$('#streetview-map').delay(100).fadeIn(400);
		$('#streetview-text').slideDown(400);
		
		window.setTimeout(initializemap, 300);

	} else {
		closeStreetView();
	}
};

function closeStreetView() {
	// remove street view stuff
	$('#streetview-map').fadeOut(400);
	$('#streetview-text').slideUp(400);

	// fade in default elements
	$('#project-mainimagetemp').delay(100).fadeIn(400);
	$('#project-thumbnails').delay(100).fadeIn(400);
	$('.caption').delay(100).fadeIn(400);
	$('#projecttext').delay(100).slideDown(400);
	//$('.project-bottomleftcolumn').slideDown(400);
	
	toggleStreetView = false;
	
	// if using google maps api v2, uncomment the following line
	GUnload();
};
