Image1= new Image(150,20)
Image1.src = "/gfx/search_loading.gif"

//Break out of iframes (from other sites)
if (top.location != location) {
	top.location.href = document.location.href ;
}

function confirmPopup(confirmUrl, confirmMessage) {
	if (confirm(confirmMessage)) {
		document.location = confirmUrl;
	}
}

function url(obj)
{
 if (obj.selectedIndex>-1)
 {
self.location.href=obj.options[obj.selectedIndex].value
 }
}


function bookmarksite(title, url){
	if (document.all)
	{
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(title, url, "");
	}
}

function enter_pressed(e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	return (keycode == 13);
}

function jsSearch()
{
	var searchBox = document.getElementById('top_search_box');
	if (searchBox.value == "Search")
	{
		searchBox.value = '';
	}
}


var state = 'none';

function showhide(layer_ref) {

if (state == 'none') {
state = 'block';
}
else {
state = 'none';
}
document.getElementById(layer_ref).style.display=state;
}

var state4='none';

function showhide4(layer_ref) {

if (state4 == 'none') {
state4 = 'block';
}
else {
state4 = 'none';
}
document.getElementById('themeForm').style.display='none';
state5='none';
document.getElementById(layer_ref).style.display=state4;
}

var state5='none';

function showhide5(layer_ref) {

if (state5 == 'none') {
state5 = 'block';
}
else {
state5 = 'none';
}
document.getElementById('passwordForm').style.display='none';
state4='none';
document.getElementById(layer_ref).style.display=state5;
}

var state6='none';

function showhide6(layer_ref) {

if (state6 == 'none') {
state6 = 'block';
}
else {
state6 = 'none';
}
document.getElementById(layer_ref).style.display=state6;
}


var xmlHttp

function sqlSearch(str, oldsearch, genre)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Unfortunately your (old?) web browser does not support AJAX and we cannot show any dynamic searches for you. Try updating your browser or switch to an alternate browser, like Firefox. http://www.firefox.com");
		return;
	}
	var searchText='<img src="/gfx/search_loading.gif" />';
	document.getElementById("search_loading").innerHTML=searchText;
	var url="/includes/getsearch.php";
	url=url+"?q="+encodeURIComponent(str);
	url=url+"&sid="+Math.random();
	if (oldsearch==2)
	{
		url=url+"&oldsearch=2";
	}
	if (genre!= '')
	{
		url=url+"&searchGenre="+genre;
	}
	var minLengthText = '<div class="left_top"></div><div class="left_middle"><span class="left_head">Keep typing</span><br />Minimum length is 2 letters</div><div class="left_bottom"></div>';
	if (str.length > 1)
	{
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else if (str != '')
	{
		document.getElementById("txtHint").innerHTML=minLengthText;
		document.getElementById("search_loading").innerHTML='';
	}
	else
	{
		document.getElementById("txtHint").innerHTML='';
		document.getElementById("search_loading").innerHTML='';
	}
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
document.getElementById("search_loading").innerHTML='';
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
