/* suckerfish */
sfHover = function() {
	var sfEls = document.getElementById("globalNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// detect iOS
var isIphone = navigator.userAgent.indexOf("iPhone") != -1 ;
var isIpod = navigator.userAgent.indexOf("iPod") != -1 ;
var isIpad = navigator.userAgent.indexOf("iPad") != -1 ;

// now set one variable for all iOS devices
var isIos = isIphone || isIpod || isIpad ; 
if (isIos && !Cookie.read("iosPrompt")) {
	var myCookie = Cookie.write('iosPrompt', '1');
	window.location = "/ios.html";
}

window.addEvent('domready', function(){	
	
	
	if (document.getElement('.share')) {
		$$('.share').each(function(share) {
			
			var button = share.getElement('.share-btn');
			button.addEvent('click', function(event) {
				
				event.preventDefault();
				$$('.share-box:not(this)').each(function(shareBox) {
					shareBox.hide();
				});
				
				
				
				var permalink = this.getAttribute('data-permalink');		
				var shareBox = share.getElement('.share-box');
				shareBox.show();
				
				
				var tweetDiv = shareBox.getElement('.tweet-button');
				var likeDiv = shareBox.getElement('.like-button');
				var shortlink = shareBox.getElement('.shortlink');
				shortlink.focus();
				shortlink.select();
					
			});
			
			
		});
		
		document.addEvent('mousedown', function(e) {
			if (!$(e.target).getParent('.share-box')) {
				$$('.share-box').each(function(shareBox) {
					shareBox.hide();
				});
			}
		});
	}		
});	
