/*
Site-wide JS
*/

$(document).ready(function(){
	showFullScreen();
	Cufon.replace('#header ul#udm li:not(.last) a', {fontFamily: 'Whitney HTF', hover:{color: "#2e1f17"}});
	Cufon.replace('ul#home_menu li a', {fontFamily: 'Whitney HTF'});
	Cufon.replace('#section_nav li a:not(#japaneseButton), #sibling_nav li a:not(#japaneseButton), #category_list li a', {fontFamily: 'Whitney HTF', hover:{color: "#fff"}});
	Cufon.replace('#content h1', {fontFamily: 'HeveticaThinExtended'});
	Cufon.replace('h2:not(.japanese)', {fontFamily: 'HeveticaLightExtended2'});
	$('#header #fullscreen_btn img').hover(function(){
		$(this).css('top', '-14px');
	},function(){
		$(this).css('top', '0px');
	})
	$("#header #fullscreen_btn").click(function(){ 
		if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
		 if (top.screenX>0 || top.screenY>0) top.moveTo(0,0);
		 if (top.outerWidth < screen.availWidth)
				top.outerWidth=screen.availWidth;
		 if (top.outerHeight < screen.availHeight) 
				top.outerHeight=screen.availHeight;
		}
		else {
		 top.moveTo(-4,-4);
		 top.resizeTo(screen.availWidth+8,screen.availHeight+8);
		}
	 }

	 var isSafari = navigator.userAgent.toLowerCase().indexOf("safari") != -1

		if(isSafari){
		self.resizeTo(screen.availWidth, screen.availHeight);
	 }
			// $("#content").each(function() {this.sendToActionscript()});
	});
	showFullScreen();
	if(document.title == 'Japanese | Peter Vincent Architects'){
		console.log(document.title );
		$(".udm li.currentSection").removeClass('currentSection');
		$(".udm li a.currentSection").removeClass('currentSection');
		
		$(".udm li.last").addClass('currentSection');
	}
	// custom scrolling for iDevices
	// fixes the bottom footer issues
	if (console) {
		console.log(WebKitDetect.isMobile());
	}
	if(WebKitDetect && WebKitDetect.isMobile()){
		$('body').addClass('header-top');
		/* Removed scrolling fix on Mobile Safari
		myScroll = new iScroll('content');
		// need some additional padding on the bottom of the content to accomodate footer
		$('#content').css('padding-bottom', 300);
		*/
	}
});

var changeLogo = function(logoNum){
	$('#header h1 span').css('background-image');
	$('#header h1 span').css({'background-image':'url("/media/img/logo'+logoNum+'.gif")'});
	$('#header h1 span').css('background-image');
	
}
var setLocation = function(loc_object){
	window.location.hash = "#"+$.param(loc_object);
};

var showFullScreen = function() {
	$("#header #fullscreen_btn").show();	
}

var hideFullScreen = function() {
	$("#header #fullscreen_btn").hide();	
}
