//
// ------------------------------------------------------------------------------------------------
// waulk_init.js
// dreas1@me.com
// March 2011
// ------------------------------------------------------------------------------------------------
//
var int_web_fonts_live_var

$(document).ready(function() {
				
	if (get_environment() == "ios"){
		window.addEventListener('orientationchange', position_items, false);
	}
	
	$(window).resize(function() {
		/*					  
		$( "#logotype_marker" ).fadeOut('fast');
		$( "#page_content" ).fadeOut('fast');
		*/
		position_items();
	
	});
	
	//$("#debug").append("<br>f:" + $("h1").css('font-family'));
	
	
	//----------------------------------------
	var custom_font = ['Droid+Sans'];

	WebFontConfig = {
		google: {families: [ custom_font[0] ]
		},
		loading: function() {
	
		// do something
		},
		fontloading: function(fontFamily, fontDescription) {
		// do something
		},
		fontactive: function(fontFamily, fontDescription) {
		// do something
			//position_items();
		},
		fontinactive: function(fontFamily, fontDescription) {
		// do something
		// Currently IE takes full advantage of this function
		//
			//$("#debug").append("<br>Font Fail f:" + $("h1").css('font-family'));
			
			window.clearInterval(int_web_fonts_live_var);
			
			custom_font = ['Verdana'];
			int_web_fonts_live_var = window.setInterval("int_web_fonts_live('"+custom_font[0]+"')",300);
			//position_items();
		},
		active: function() {
			
			//position_items();
			
			//$("#debug").append("<br>f:" + $("h1").css('font-family'));
	
		},
		inactive: function() {
		// do something
		}
	};

	
	//----------------------------------------

	var wf = document.createElement('script');
	
	wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
	'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
	
	wf.type = 'text/javascript';
	wf.async = 'true';
	
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(wf, s);

	//----------------------------------------

	position_items();
	
	int_web_fonts_live_var = window.setInterval("int_web_fonts_live('"+custom_font[0]+"')",300);
	
});

//
// ------------------------------------------------------------------------------------------------
//
function position_items(){
	
	//$("#debug").append("p");
	

	$( "#page_content" ).position({
		of: $( "#background" ),
		my: 'center' + " " + 'center',
		at:  'center' + " " + 'center',
		offset: '0'
	});

	$( "#logotype_marker" ).position({
		of: $( "#page_content" ),
		my: 'center center',
		at:  'left top',
		offset: '0'
	});
	/*
	$( "#logotype_marker" ).fadeIn('fast');
	$( "#page_content" ).fadeIn('fast');
	*/
	
};
//
// ------------------------------------------------------------------------------------------------
//
/*
function position(){
	
	$( "#page_content" ).position({
		of: $( "#background" ),
		my: 'center' + " " + 'center',
		at:  'center' + " " + 'center',
		offset: '0'
	});

};
*/
//
// ------------------------------------------------------------------------------------------------
//
/*
function get_screen_size(){
	var screen_width = $(window).width();
	var screen_height = $(window).height();
	var screen_array =[screen_width,screen_height];
	return screen_array;
}
*/
//
// ------------------------------------------------------------------------------------------------
//
function int_web_fonts_live(custom_font){
	
	//$("#debug").append("<br>f:" + $("h1").css('font-family'));
	
	var h1_font_family = $("h1").css('font-family');
	
	if(h1_font_family.indexOf(custom_font[0]) != -1){
		
		//$("#debug").append("<br>ok:" + $("h1").css('font-family'));
		
		position_items();
		
		window.clearInterval(int_web_fonts_live_var);
		
	}else{
		//$("#debug").append("<br>no:" + $("h1").css('font-family'));
	};
	
}
//
// ------------------------------------------------------------------------------------------------
//
function get_environment(){
	
	var browser_input = navigator.userAgent;
	//
	if ((browser_input.indexOf('iPhone') != -1) || (browser_input.indexOf('iPod') != -1) || (browser_input.indexOf('iPad') != -1)) {
		
		return("ios");
		
	}else{
		
		return("other");
	};
	
};
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
//
// ------------------------------------------------------------------------------------------------
//
