// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07


jQuery(document).ready(

	/*
	This function gets loaded when all the HTML, not including the portlets, is
	loaded.
	*/

	function() {	
		styleButtons();
	}
);

Liferay.Portlet.ready(

	/*
	This function gets loaded after each and every portlet on the page.

	portletId: the current portlet's id
	jQueryObj: the jQuery wrapped object of the current portlet
	*/

	function(portletId, jQueryObj) {
		
	}
);

jQuery(document).last(

	/*
	This function gets loaded when everything, including the portlets, is on
	the page.
	*/

	function() {				
		fillthescreen();	
	}
);

function windowHeight(){
	var alto= 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		alto= window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		alto= document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		alto= document.body.clientHeight;
	}
	return alto;
};

function fillthescreen(){	
	winH = windowHeight();
	wrapperElem = document.getElementById('left-maincol');
	footerTop = document.getElementById('footer_top');	
	wrapperH = wrapperElem.offsetHeight + footerTop.offsetHeight;
	heightNeeded = winH - wrapperH; 
	if(heightNeeded  > 0) {				
		document.getElementById('footer_bottom').style.height = heightNeeded + 'px';							
	}		
};

function styleButtons() {	
	var inputList = document.getElementsByTagName('input');
	for(i=0; i < inputList.length; i++) {
		var input = inputList[i];

		/* we'll change just liferay inputs */
		if(input.className == null || input.className == "") {
			switch(input.type) {
				case "submit":
				case "button":
				case "reset":
	
					input.setAttribute('id','right_arrow_btn_blue_content');
					var parent = input.parentNode;										
	
					var table = document.createElement('table');
					table.setAttribute('cellpadding','0');
					table.setAttribute('cellspacing','0');
					table.setAttribute('id','btn_table');																				
																				
					var leftCell = document.createElement('td');	
					var centerCell = document.createElement('td');	
					var rightCell = document.createElement('td');	
						
					leftCell.setAttribute('id','right_arrow_btn_blue_left');										
					centerCell.setAttribute('id','right_arrow_btn_blue_center');										
					rightCell.setAttribute('id','right_arrow_btn_blue_right');
					
					var row = document.createElement('tr');					
					row.appendChild(leftCell);
					row.appendChild(centerCell);
					row.appendChild(rightCell);
	
					var body = document.createElement('tbody');
					body.appendChild(row);	
					
					table.appendChild(body);																				
					parent.replaceChild(table,input);					
					
					centerCell.appendChild(input);										
					break;
				default: break;
			}
		}
	}	

}
