function select(id, optval) {
  	if(optval.length > 0){
         var options = document.getElementById(id).options;
         for(var i = 0; i < options.length; i++) {
			if(options[i].value == optval){
				options[i].selected = true;
				break;
			}
			            	
		} 
	}
}

function changeMenuImage(event) {
	var target = YAHOO.util.Event.getTarget(event);
	var menuImageSrc = target.attributes['menuImage'];
	if(menuImageSrc != null){
		document.getElementById('menuImage').src = menuImageSrc.value;
	}
} 

function translate_page(lang) {
	var page =  typeof document.baseURI=="undefined"||!document.baseURI ? window.location.href : document.baseURI;
	if(lang == "en")
	{
		top.window.location.href =page;
	}else{
		window.location.href='http://translate.google.com/translate_c?hl=en&ie=UTF-8&u='+escape(page)+'&sl=en&tl='+lang+'&history_state0=';
	}
}

function trim(str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function open_text_window(txt){
	var w = (window.screen.width/2) - (75 + 10);
	var h = (window.screen.height/2) - (100 + 50);
	var win = window.open("", "win", "width=600,height=500,left=" + w + ",top=" + h + ",screenX=" + w + ",screenY=" + h + ",menubar=1");
	with (win.document) {
	  open("text/plain", "replace");
	  write(txt);
	  close();
	}
	win.focus();
}

