function emptySearchBoxValue() {
	var searchBox = document.getElementById('q');
	if (searchBox.value == 'Search for a game') {
		searchBox.value = '';
	}
}

function fillSearchBox(value) {
	var searchBox = document.getElementById('q');
	searchBox.value = value;
	var resultElm = document.getElementById('livesearch_results');
	resultElm.innerHtml = '';
	resultElm.style.display = 'none';
}

function toggleResultsVisible(visible) {
	var resultElm = document.getElementById('livesearch_results');
	var searchBox = document.getElementById('q');
	if (searchBox.value.length>0) {
		resultElm.style.display = visible ? 'block' : 'none';
	} else {
		resultElm.style.display = 'none';
	}
}

function getWinHeight() {
   var myHeight = 0;
   if( typeof (window.innerWidth ) == 'number') {
      myHeight = window.innerHeight;
   } else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      myHeight = document.documentElement.clientHeight;
   } else if (document.body && ( document.body.clientWidth || document.body.clientHeight)) {
      myHeight = document.body.clientHeight;
   }
   return (myHeight);
}

window.onload = function() {
	var col1 = document.getElementById('col1');
	var col2 = document.getElementById('col2');
	
	var col1Height = col1.offsetHeight;
	col2.style.height = col1Height + 'px';
	
    var links = document.getElementsByTagName('a');
    for (var i=0;i < links.length;i++) {
        if (links[i].className == 'new-window') {
            links[i].onclick = function() {
                window.open(this.href);
                return false;
            };
        }
    }
    
	var winHeight = getWinHeight();
	var elm = document.getElementById('wrapper');
	var contentHeight = elm.offsetHeight;
	
	if (contentHeight < winHeight) {
		contentHeight = winHeight;
	}
	elm.style.height = ''+contentHeight+'px';
};

