/* Author:

*/


$(document).ready(function(){
	
	// Run Matt Kersley's jQuery Responsive menu plugin (see plugins.js)
	if ($.fn.mobileMenu) {
		$('ol#id').mobileMenu({
			switchWidth: 768,                   // width (in px to switch at)
			topOptionText: 'Choose a page',     // first option text
			indentString: '&nbsp;&nbsp;&nbsp;'  // string for indenting nested items
		});
	}

	// Run Mathias Bynens jQuery placeholder plugin (see plugins.js)
	if ($.fn.placeholder) {
		$('input, textarea').placeholder();		
	}
});



// This script applies a different class to every third letter so that different styles can be applied

var processTextNodes = function(element, fn) {
	var children = element.childNodes;
	for (var i = children.length; i --> 0;) {
		var node = children[i];
		var type = node.nodeType;
		if (type == 1) processTextNodes(node, fn);
		if (type == 3) fn.call(this, node);
	}
}

$(function() {
  $('H1').each(function () {
	processTextNodes(this, function(node) {
	  var txt = node.nodeValue.split('');
	  var spans = [];
	  while (txt.length) {
		var tempAr = [];
		tempAr[tempAr.length] = txt.shift();
		var charsFound = (tempAr[tempAr.length - 1] !== " ");
		while (txt[0] === " ") {
		  tempAr[tempAr.length] = txt.shift();
		}
		if (!charsFound) {
		  tempAr[tempAr.length] = txt.shift();
		}
		spans[spans.length] = tempAr.join("");
	  }
	  var parent = node.parentNode;
	  for (var i = 0, len = spans.length; i < len; i++ ) {
		var span = spans[i];
		parent.insertBefore($('<span class="added">' + span + '</span>')[0], node);
	  }
	  parent.removeChild(node);
	});
	$("span.added", this).each(function(index) {
	  $(this).addClass("span_" + (index % 3));
	});
  });

$('H1 SPAN:even').addClass('drop');

$('H1 SPAN.space').removeClass('added');

});



//ipad and iphone fix; from http://blog.0100.tv/2010/05/fixing-the-hover-event-on-the-ipadiphoneipod/
$(document).ready(function(){
	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
	    $("TD[title]").click(function(){
	        //we just need to attach a click event listener to provoke iPhone/iPod/iPad's hover event
	        //strange
	    });
	}
	
});
