$(document).ready(function() {
	$('#f_name').autofill({
		value: 'Name (required)',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
	$('#f_phone').autofill({
		value: 'Phone',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
	$('#f_email').autofill({
		value: 'E-mail (required)',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
		
	$( "a#[id^='resize_']" ).click(function(){
		var ourText      = $('#right > *:not("#tools")');
		
		if( ourText.length < 1 )
			ourText = $('#no_leftmenu > *:not("#tools")');
		
		//console.log(ourText);
		
		var currFontSize = ourText.css('fontSize');
		var finalNum     = parseFloat(currFontSize, 10);
		var stringEnding = currFontSize.slice(-2);
		
//		var ourH1        = $('#right > h1:first');
//		var currH1Size 	 = ourH1.css('fontSize');
//		var finalH1Num 	 = parseFloat(currH1Size, 10);
//		var H1Ending     = currH1Size.slice(-2);
		
		var currLineHeight = parseInt( ourText.css('line-height') );
		if(this.id == 'resize_large') {
			finalNum *= 1.2;
			//finalH1Num *= 1.2;
			currLineHeight += 3;
		}
		else if (this.id == 'resize_small'){
			finalNum /=1.2;
			//finalH1Num /=1.2;
			currLineHeight -= 3;
		}
		ourText.css('fontSize', finalNum + stringEnding);
		//ourH1.css('fontSize', finalH1Num + H1Ending);
		ourText.css('line-height', currLineHeight + 'px' );
		
		return false;
		
	});
	
	$( '.submit_button' ).click(function(){
		$( this ).parents( 'form:first' ).submit();
		return false;
	});

});

//$(document).ready(function(){
//	  // Reset Font Size
//	  var originalFontSize = $('html').css('font-size');
//	    $(".resetFont").click(function(){
//	    $('html').css('font-size', originalFontSize);
//	  });
//	  // Increase Font Size
//	    $( "a#resize_large").click(function(){
//	    var currentFontSize = $('html').css('font-size');
//	    var currentFontSizeNum = parseFloat(currentFontSize, 10);
//	    var newFontSize = currentFontSizeNum*1.2;
//	    $('html').css('font-size', newFontSize);
//	    alert(currentFontSize);
//	    return false;
//	  });
//	  // Decrease Font Size
//	  $(".decreaseFont").click(function(){
//	    var currentFontSize = $('html').css('font-size');
//	    var currentFontSizeNum = parseFloat(currentFontSize, 10);
//	    var newFontSize = currentFontSizeNum*0.8;
//	    $('html').css('font-size', newFontSize);
//	    return false;
//	  });
//	});

function log( whatToLog ){
	console.log( whatToLog );
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

