function clearText(field) {
	if (field.defaultValue == field.value) field.value = '';
}

function restoreText(field) {
	if (field.value == '') field.value = field.defaultValue;
}

jQuery(document).ready(function(){
	$ = jQuery;
	$("#sidebar").extendLeftSide();
	//$("#page").append('<div id="sidebar-left-filling"></div>');
});

(function($){
var EXTRA_TOP_OFFSET = 29;
var methods = {
	init:function(){
		return this.each(function(){
			var offset = $(this).position();
			var width = offset.left;
			var top = parseInt($(this).css('top').replace('px',''),10) + EXTRA_TOP_OFFSET;
			/*******************
			**** QUICK FIX *****
			********************/
			if(window.navigator.userAgent.match(/WebKit/) !== null) {
				top = offset.top + EXTRA_TOP_OFFSET;
			}
			var height = $(this).height() - EXTRA_TOP_OFFSET;
			var style = 'width:'+width+'px; height:'+height+'px; top:'+top+'px; left:0; background-color:#1d1d1d; position:fixed;';
			//console.log(style);
			$("#page").append('<div id="sidebar-left-filling" style="'+style+'"></div>');
			$(window).resize(function(){
				$('#sidebar-left-filling').css('width',$('#sidebar').position().left+'px');
			});
		});
	}
} // end methods


$.fn.extendLeftSide = function(method){
	if(methods[method]){
		return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
	}
	else if( typeof method === 'object' || ! method ){
		return methods.init.apply( this, arguments );
	}
	else{
		$.error( 'Method ' +  method + ' does not exist on swipeAndDrag' );
	}    
}	

})(jQuery); // end swipe

