var usingIOS = false;
if ( navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null || navigator.userAgent.match(/iPod/i) != null ) usingIOS = true;

function setStyle (elementId, styleName, styleValue) {
	
	var element = document.getElementById(elementId);
	element.style[styleName] = styleValue;
	
}

function changeState (newState) {

	var mainContainer = document.getElementById('main-container');
	
	mainContainer.className = newState;
	
	window.location.hash = newState.replace("state-", "");
	
}

function resolveHash () {

	if (window.location.hash != "") changeState("state-" + window.location.hash.replace("#", ""));

	
}

function main() {
	
	if (usingIOS) {

		setStyle('flash', 'visibility', 'hidden');
		setStyle('no-flash', 'visibility', 'inherit');
		setStyle('twitter', 'visibility', 'inherit');

		
	} else {
	
		setTimeout ("setStyle ('twitter', 'visibility', 'inherit')", 10700);
	
	}
	
	$(function() { $('.scroll-pane').jScrollPane({showArrows: true}); });
	
	$(function(){
		var spt = $('span.mail-karene');
		var at = / at /;
		var dot = / dot /g;
		var addr = $(spt).text().replace(at,"@").replace(dot,".");
		var contact = 'Send Email';
		$(spt).after('<a href="mailto:'+addr+'" title="Send Email" class="address">'+ contact +'</a>').hover(function(){window.status="Send a letter!";}, function(){window.status="";});
		$(spt).remove();
	});
	
	$(function(){
		var spt = $('span.mail-us');
		var at = / at /;
		var dot = / dot /g;
		var addr = $(spt).text().replace(at,"@").replace(dot,".");
		var contact = 'Contact Us';
		$(spt).after('<a href="mailto:'+addr+'" title="Send Email" class="address">'+ contact +'</a>').hover(function(){window.status="Send a letter!";}, function(){window.status="";});
		$(spt).remove();
	});

	resolveHash();
	
}

