/**
* @var integer Viewport variable height
*/
var iDeltaV;
/**
* @var integer Viewport variable width
*/
var iDeltaW;

/**
* @var integer Bodycontainer div variable height
*/
var iDeltaC;

/**
* @var integer Subsection navigation div variable height
*/
var iDeltaS;

/**
* @var integer top margin top div constant height
*/
var iTopMargin;

/**
* @var integer top div variable height
*/
var iDeltaT;

/**
 * Resizing height/width of divs elements (navigation menu, content-block and background element)
 * when window resizes.
 *
 * @return void
 */
function adaptViewConteinerHeight(){
	/**
	* @var integer Temporary variable value container.
	*/
	var iResizeTo;
	
	iTopMargin = 16;
	iDeltaT = $('body_top').getHeight();
	
	iDeltaV= document.viewport.getHeight();
	
	iDeltaW = document.viewport.getWidth();
	
	// Resizing for homepage only.
	if($('home_module_container')){
		if(iDeltaV >= $('home_module_container').getHeight())
		{
			$('home_module_container').style.height = (iDeltaV-iDeltaT)+'px';
		}
		else
		{
			$('home_module_container').style.height = '468px';
		}
	}
	
	// Resizing for everywhere behalf the homepage
	if($('module_container') && $('subsection_navigation'))
	{
		// Re-sizing anywhere then the homepage
		iDeltaC= $('module_container').getHeight();
		iDeltaS= ($('navigation_menu').getHeight() + $('sfeer_block').getHeight() + 25);
		
		if( ( iDeltaV >= (iDeltaS+iDeltaT+iTopMargin) ) && ( iDeltaV >= (iDeltaC+iDeltaT) ) )
		{
			// View container always taller than subsection-navigation and text-container.
			iResizeTo = iDeltaV-iDeltaT;
			$('subsection_navigation').style.height = (iResizeTo-iTopMargin)+'px';
			$('body_container').style.height		= (iResizeTo+iDeltaT)+'px';
			$('body_sticky_bottom').style.height	= iResizeTo+'px';
		}
		else if( (iDeltaV <= (iDeltaS+iDeltaT+iTopMargin) ) && (iDeltaV <= (iDeltaC+iDeltaT)) )
		{
			// View container always shorter than subsection-navigation and text-container.
			if( (iDeltaS+iTopMargin) >= iDeltaC ){
				iResizeTo = iDeltaS+iTopMargin;
			} else {
				iResizeTo = iDeltaC;
			}
			$('subsection_navigation').style.height = (iResizeTo-iTopMargin)+'px';
			$('body_container').style.height		= (iResizeTo+iDeltaT)+'px';
			$('body_sticky_bottom').style.height	= iResizeTo+'px';
			
		}
		else
		{
			if( ( iDeltaV <= (iDeltaS+iTopMargin+iDeltaT) ) && (iDeltaC <= (iDeltaS+iTopMargin) ) )
			{
				// Content div <= Navigationmenu block
				iResizeTo = iDeltaS+iTopMargin;
			}
			else if( ( iDeltaV < (iDeltaC+iDeltaT)) && ( (iDeltaS+iTopMargin) <= iDeltaC )) 
			{
				// Navigationmenu block <= content div
				iResizeTo = iDeltaC;
			}
			$('subsection_navigation').style.height = (iResizeTo-iTopMargin)+'px';
			$('body_container').style.height		= (iResizeTo+iDeltaT)+'px';
			$('body_sticky_bottom').style.height	= iResizeTo+'px';
		}
	}
	else
	{
		// Re-sizing in the homepage
		$('body_sticky_bottom').style.minHeight = ($('body_container').getHeight()-iDeltaT)+"px";
		$('body_sticky_bottom').style.height	= (iDeltaV-iDeltaT)+"px";
	}
	
	/* Always to execute */
	$('body_top').style.width			= iDeltaW+'px';
	$('body_top').style.minWidth		= $('body_sticky_bottom').style.minWidth = ( 970+$('ziglogo').getWidth() )+'px';
	$('body_sticky_bottom').style.width = iDeltaW+'px';
	
	/*
	if((navigator.appVersion).indexOf('MSIE 7.0',0) > -1)
	{
		$('body_container').style.height = ($('body').getHeight()-20)+'px';
	}
	*/
}

/**
 * Make an object's value empty
 *
 * @return void
 */
function reset_field(obj){
	obj.value = "";
}

function resetDefaultForm()
{
   var form = $('defaultForm'); 
   
   form.reset(); 
}


/* Registering events during page loading */
Event.observe(window, 'load',	adaptViewConteinerHeight);
Event.observe(window, 'resize', adaptViewConteinerHeight );
