/* 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();		
	}
	
  // Tabs - JQUery UI - Added by Claw - 15/10/2011
  if( $('.tabs').length ) {
		$(".tabs").tabs({
	    fx: { opacity: 'toggle', duration:'fast'},
		 	select: function(event, ui) {
		     $(this).css('height', $(this).height());
		     $(this).css('overflow', 'hidden');
			},
	    show: function(event, ui) {
	       $(this).css('height', 'auto');
	       $(this).css('overflow', 'visible');
	    }   
	  });	
	}

	//Set the width of the closed toolbar tab with tabWidth
	if ($(window).width() > 767) {		
		$('.promo').stickyBar({tabWidth:49});  	
	}
   

	// Listen for change to content editable
	var currentText = '';
	$('[contenteditable="true"]').each(function() {
		
		var editRegion = $(this).attr('data-editregion');
		if(cookieObj.readCookie(editRegion)) {
			$(this).text(cookieObj.readCookie(editRegion))
		}
		
		$(this).focus(function() {
			currentText = $(this).text();		
		});

		$(this).blur(function() {
			if ($(this).text() != currentText) {
				var region = $(this).attr('data-editregion')
				var updatedText = $(this).text();
				$.post("insert.php", { area: region, changedtext: updatedText} );	
				cookieObj.createCookie(region, updatedText, '365');
			}			
		})
		
		
		

	})
	
	

	
});








