
jQuery(document).ready(function($) {
	var pageHeight = $('#wrap').height();
	$('#menu ul li:last-child').addClass('last');
	var footerAlign = 10;
	
//	$('#main').click(function(){alert("Page Items: "+pageItems+" Page: "+$(window).height()+ "Footer Offset: "+footStretch)});


// Align the Menu to the Middle
	var menuSize = 0;
	$('#menu ul li').each(function(){
		menuSize = menuSize + $(this).outerWidth();
	});
//	alert(menuSize);
	$('#menu ul').css({width: menuSize});

// Set the Content to stretch to full Page size
	if( $('#sidebar-right').height() >= $('#main').height() ){
		$('#main').css({height: $('#sidebar-right').height()});
		var mainHeight = $('#sidebar-right').outerHeight(true);
	}else{
		var mainHeight = $('#main').outerHeight(true);
	}
	var pageItems = $('#header').outerHeight(true) + $('#menu').outerHeight(true) + mainHeight + $('#footer').outerHeight(true) + $('#page').outerHeight(true);
	var footStretch = $(window).height() - (pageItems + footerAlign);
	if (footStretch >=1){
		$('#footer').css({top: footStretch});
	}
	
	inputFocus($('form.wpcf7-form input[type="text"]'));// Activate Default Input Magic.
// Setting the wrapper to full screen height
	if( $(window).height() >= $('#wrap').height() ){
		$('#wrap').css({height: $(window).height()});
	}
// Reseting the wrapper to new size after screen is resized
	$(window).resize(function() {
		footStretch =  $(window).height() - (pageItems + footerAlign);
		if ($(window).height() >= pageItems){
			$('#footer').css({top: footStretch});
		}
		if ( $(window).height() >= pageHeight ){
			$('#wrap').css({height: $(window).height()});
		}
	});

	$('#menu ul li').each(function(){
		$(this).addClass('selected');
		$(this).removeClass('selected');
	});
});

////////////////////////////////////////////

function inputFocus(thisTag){
	

	thisTag.each(function()
	{

		$(this).focus(function() {
    	$(this).addClass("focus");alert('fired.');
	});
	$(this).blur(function() {
		$(this).removeClass("focus");
	});
		var default_value = $(this).value;
		$(this).focus(function()
		{
			if($(this).value == default_value)
			{
				$(this).value = '';
			}
		});
		$(this).blur(function()
		{
			if($(this).value == '')
			{
				$(this).value = default_value;
			}
		});
	});
}
