

function trim(s)
{
	if ((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/^\s+/,'').replace(/\s+$/,'')
}


function isNumber (obj)
{
	if (obj.value.match (/^\d+$/))
		return true;
		
	alert ("Number only.");
	obj.value = 1;
	return false;
}

function isIE ()
{
	if (navigator.appVersion.indexOf ("MSIE") != -1)
		return true;
				
	return false;
}

function lostFocus (obj)
{
	if (obj.value == "") 
		obj.style.backgroundImage = 'url(http://www.google.com/coop/images/google_custom_search_watermark.gif)';

}

function dropMenu (obj)
{
	if (!document.getElementById ('dropMenu'))
	{
	var bodyRef = document.getElementsByTagName ("body").item(0);
	var surround1 = document.getElementById ('surround1');
	var surround2 = document.getElementById ('surround2');
	
	surround1.style.zIndex = 50;
	surround1.style.height = "185px";
	surround2.style.zIndex = 50;
	surround2.style.height = "185px";
	
	surround1.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";	// IE
	surround1.style.opacity = 0.0;														// Standard
	surround1.style.MozOpacity = 0.0;													// Firefox
	surround2.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";	// IE
	surround2.style.opacity = 0.0;														// Standard
	surround2.style.MozOpacity = 0.0;													// Firefox
	
	var menuDIV = document.createElement ("div");
	menuDIV.setAttribute ("id", "dropMenu");
	//menuDIV.setAttribute ("style", "display:block; width:76px; height:30px; background-color:#FFFFFF;");
	obj.focus();
	// For IE, IE doesn't work with setAttribute() style
	menuDIV.style.display = "block"; 
	menuDIV.style.position = "absolute";
	menuDIV.style.width = "74px"; 
	menuDIV.style.height = "30px"; 
	//menuDIV.style.zIndex = 100;
	//obj.style.zIndex = 80;
	
	var top = parseInt(obj.style.top) + parseInt(obj.style.height);
	var left = parseInt(obj.style.left);
	menuDIV.style.top = top  - 3 + "px";
	menuDIV.style.left = 0 + "px";
	menuDIV.style.backgroundColor = "#FFFFFF";
	menuDIV.style.borderRight = "1px solid black";
	menuDIV.style.borderLeft = "1px solid black";
	menuDIV.style.borderBottom = "1px solid black";
	
	var englishDIV = document.createElement ("div");
	var newTextNode = document.createTextNode ("ENGLISH");
	englishDIV.setAttribute ("style", "padding:0px 0px 0px 2px");
	englishDIV.style.padding = "0px 0px 0px 2px";
	englishDIV.innerHTML = "<font style = \"font-size:xx-small; color:#000000;\">ENGLISH</a>";
	englishDIV.onmouseover = function () {this.style.backgroundColor = '#B2B4C1'; this.style.cursor = 'default';}
	englishDIV.onmouseout = function () {this.style.backgroundColor = '#FFFFFF'; this.style.curosr = 'auto';}
	englishDIV.onclick = function () {removeDropDown(); window.location = "http://www.brekeke.com/index.php";}
		
	var japaneseDIV = document.createElement ("div");
	var newTextNode = document.createTextNode ("JAPANESE");
	japaneseDIV.setAttribute ("style", "padding:0px 0px 0px 2px");
	japaneseDIV.style.padding = "0px 0px 0px 2px";
	japaneseDIV.innerHTML = "<font style = \"font-size:xx-small; color:#000000;\">JAPANESE</a>";
	japaneseDIV.onmouseover = function () {this.style.backgroundColor = '#B2B4C1'; this.style.cursor = 'default';}
	japaneseDIV.onmouseout = function () {this.style.backgroundColor = '#FFFFFF'; this.style.curosr = 'auto';}
	japaneseDIV.onclick = function () {removeDropDown(); window.location = "http://www.brekeke.com/index-j.php";}
	//japaneseDIV.appendChild (newTextNode);
	
	//menuDIV.onmouseout = function () {obj.removeChild(menuDIV);}
	//obj.setAttribute ("onblur", "obj.removeChild(menuDIV)");
	//obj.onblur = function () {alert ('hi');var main = document.getElementById ('dropDownMenu'); var menu = document.getElementById ('dropMenu'); main.removeChild (menu); }
	
	// Append new drop down menu to obj
	menuDIV.appendChild (englishDIV);
	menuDIV.appendChild (japaneseDIV);
	obj.appendChild (menuDIV);
	}
}

function removeDropDown()
{

	if (document.getElementById ('dropMenu'))
	{
		var main = document.getElementById ("dropDownMenu");
		main.removeChild (document.getElementById ('dropMenu'));
		
		var surround1 = document.getElementById ('surround1');
		var surround2 = document.getElementById ('surround2');
	
		surround1.style.zIndex = 0;
		surround1.style.height = "20px";
		surround2.style.zIndex = 0;
		surround2.style.height = "20px";
	}
}

function searchBrekeke ()
{	
	var qryString = document.getElementById("searchString").value;
	document.getElementById("searchString").value = "";
	document.getElementById("searchString").style.backgroundImage = 'url(http://www.google.com/coop/images/google_custom_search_watermark.gif)';
	
	window.location = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=" + qryString + "&btnG=Search$domains=www.brekeke.com&sitesearch=www.brekeke.com";
	
}

function searchWiki ()
{
	var qryString = document.getElementById("searchString").value;
	document.getElementById("searchString").value = "";
	document.getElementById("searchString").style.backgroundImage = 'url(http://www.google.com/coop/images/google_custom_search_watermark.gif)';
	
	window.location = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=" + qryString + "&btnG=Search$domains=www.brekeke.com&sitesearch=wiki.brekeke.com/wiki/";
}

