/**
 * @author apipkin
 */

 
$().ready(function(){
	
	$('#search form .text').focus(function(){
		if($(this).val() == 'Search') $(this).val('');
	}).blur(function(){
		if($(this).val() == '') $(this).val('Search');
	});

	var footHeight = (parseFloat($('#foot').height()) + parseFloat($('#footWrapper').css('padding-top')) + parseFloat($('#footWrapper').css('padding-bottom')));
	$('#footWrapper').css('margin-top',-footHeight);
	$('#bodyWrapper').css('padding-bottom',footHeight);
	
	
 	/*
	height_fix();
	$(window).bind('resize',function(){ height_fix();});
	$(document).bind('resize',function(){ height_fix();});
	//*/
 });
function height_fix()
{
	var pH = parseFloat(('#headWrapper').height()) + parseFloat($('#bodyWrapper').height());
	$('#pageLeft').height(pH);
	$('#pageRight').height(pH);
	$('#page').height(pH);
	
	// record scroll height
	var curScroll = getScroll();
	
	// reset
//	$('#footWrapper').css('position','');
//	$('#page').css('padding-bottom','')
//	          .css('height','');
	
/*
	var wH = $(window).height();
	var pH = parseFloat($('#page').height()) + parseFloat($('#page').css('padding-top')) + parseFloat($('#page').css('padding-bottom'));  
 
	if(wH >= pH)
	{
		$('#footWrapper').css('position','absolute');
		$('#page').css('padding-bottom','0')
		          .css('height','100%');
	}else{
		$('#footWrapper').css('position','absolute');
		$('#page').css('padding-bottom',(parseFloat($('#footWrapper').height()) + parseFloat($('#footWrapper').css('padding-top')) + parseFloat($('#footWrapper').css('padding-bottom'))))
		          .css('height','auto');
	}
	//*/
	setScroll(curScroll);
}

function getScroll() {
	var sy = 0;
	if(typeof(window.pageYOffset) == 'number') {
		sy = window.pageYOffset;
	}else if(document.body && document.body.scrollTop) {
		sy = document.body.scrollTop;
	}else if(document.documentElement && document.documentElement.scrollTop) {
		sy = document.documentElement.scrollTop;
	}
	
	return sy;
}

function setScroll(sy) {
	window.scrollTo(0,sy);
}

