/*
http://www.thesocialnetwork-movie.com/iphone/scripts/iphone.js
http://www.thesocialnetwork-movie.com/iphone/scripts/gallery_slide.js
*/


function ignoreAccidentalClicks() {
	//Fix stupid bug with links getting clicked without want...
	$("a").each(function(){
		if($(this).attr('target') == '_blank') {
			//Replace value in href for value in rel
			var href = $(this).attr('href');
			$(this).attr('href','#').attr('target','_self').attr('rel',href);
			$(this).bind(clickEvent,function(e){
				e.preventDefault();
				clearInterval(dumbLoop);
				var where = $(this).attr('rel');
				window.open(where);
			});
		} else if($(this).attr('target') == '_self' || $(this).attr('rel')=='external') {
			var href = $(this).attr('href');
			$(this).attr('href','#').attr('rel',href);
			$(this).bind(clickEvent,function(e){
				e.preventDefault();
				clearInterval(dumbLoop);
				var where = $(this).attr('rel');
				document.location.href = where;
			});
		}
	});	
}

clickEvent = null;
isTouchEnabled = false;

if((navigator.userAgent.match(/iPhone/i)) || 
   (navigator.userAgent.match(/iPod/i)) || 
   (navigator.userAgent.match(/iPad/i))) {
	clickEvent = 'tap';
	isTouchEnabled = true;
}
 else
{
	clickEvent = "click";
}

if ( isTouchEnabled )
{

	var jQT = new $.jQTouch({
		fixedViewport: false	
	});
}

$(window).load( function() { 

	if ( isTouchEnabled ) ignoreAccidentalClicks();	

	if( !$.fontAvailable('GothamBook') && !$.fontAvailable('Gotham-Book') && !$.fontAvailable('Gotham Book')) {
		
		Cufon.replace('#navigation ul li a', {fontFamily: "Gotham Book"});
		Cufon.replace("#navigation ul li ul li a", {fontFamily: "Gotham Book"});
		Cufon.replace("ul.collection-gallery li span.label", {fontFamily: "Gotham Book"});
		Cufon.replace('a.button', {fontFamily: "Gotham Book"});
	}
	if( !$.fontAvailable('GothamLight') && !$.fontAvailable('Gotham-Light') && !$.fontAvailable('Gotham Light')) {
			
		Cufon.replace("h3", {fontFamily: "Gotham Light"});
		Cufon.replace('.text-content p', {fontFamily: "Gotham Light"});
		Cufon.replace("h4", {fontFamily: "Gotham Light"});
	}
});
