function checkSearch() {
	if ( document.getElementById( 'cmsContentSearch_text' ).value != '' ) {
		document.getElementById( 'searchForm' ).action = '/products/%20search::' + document.getElementById( 'cmsContentSearch_text' ).value;
		document.getElementById( 'searchForm' ).submit();		
	} else {
		alert( 'Please enter some search text.' );
		return false;
	}
}

function setTall() {
	if ( document.getElementById ) {
		var divs = new Array( 
			new Array( 
				new Array( document.getElementById('lhs'), document.getElementById('contentArea'))
			)
		);
		for (var i = 0; i < divs.length; i++) {
			var maxHeight = 0;
			for (var j = 0; j < divs[i][0].length; j++) {
				if (divs[i][0][j].offsetHeight > maxHeight) {
					maxHeight = divs[i][0][j].offsetHeight;
				}
			}
			for (var j = 0; j < divs[i][0].length; j++) {
				divs[i][divs[i].length-1][j].style.height = maxHeight + 'px';
				if (divs[i][0][j].offsetHeight > maxHeight) {
					divs[i][divs[i].length-1][j].style.height = ( parseInt(divs[i][divs[i].length-1][j].style.height) - (divs[i][0][j].offsetHeight - maxHeight)) + 'px';
				}
			}
		}
	}
}

if ( document.getElementById('lhs') ) {
	window.onload = setTall;
}



var showLoginOnLoad = false;
var submitLoginForm = false;

function initLogin() {
	// Initialize the temporary Panel to display while waiting for external content to load
	document.getElementById('loginPopup').style.display = '';
	loginBox = 
			new YAHOO.widget.Panel("loginPopup",  
											{ width:"302px", 
											  height:"204px", 
											  fixedcenter:true, 
											  close:false, 
											  draggable:false, 
											  modal:true,
											  visible:false,
											  underlay:"none",
											  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.5}
											} 
										);

	loginBox.render(document.body);
	if( showLoginOnLoad )
		loginBox.show();
}

YAHOO.util.Event.addListener(window, "load", initLogin);

function hideLogin() {
	// Show the Panel
	if( typeof loginBox != "undefined" )
		loginBox.hide();
	submitLoginForm = false;
}

function showLogin() {
	// clear the password field
	document.getElementById('clientLogin_password').value = '';
	// Show the Panel
	if( typeof loginBox != "undefined" )
		loginBox.show();
	else
		showLoginOnLoad = true
}

function onPopupSubmit() {
	// if we are submitting to form
	if( submitLoginForm ){
		// ensure we have username and password
		var validate = new validateForm();
		validate.checkText( 'clientLogin_username', 'Username' );
		validate.checkText( 'clientLogin_password', 'Password' );
		if( validate.numberOfErrors() > 0 ) {
			validate.displayErrors();
			// we have errors
			submitLoginForm = false;
		}
	}
	
	return submitLoginForm;
}

function inputBoxFocus( input, defaultText, passwordField ) {
	if( typeof( passwordField ) != 'undefined' ) {
		document.getElementById( passwordField ).style.display = '';
		document.getElementById( passwordField+'_text' ).style.display = 'none';
		document.getElementById( passwordField ).focus();
	} else {
		if( input.value == defaultText ) {
				input.value = '';
		} else {
		}
	}
}

function inputBoxBlur( input, defaultText, passwordField ) {
	if( input.value == '' ) {
		if( typeof( passwordField ) != 'undefined' ) {
			document.getElementById( passwordField ).style.display = 'none';
			document.getElementById( passwordField+'_text' ).style.display = '';
		} else {
			input.value = defaultText;
		}
	}
}
