var trAPP="Translat";
//Browser capablilities
navigator.di=typeof(document.images)!='undefined';
navigator.dl=typeof(document.layers)!='undefined';
navigator.da=typeof(document.all)!='undefined';
navigator.w3c=((typeof(GEBI)!='undefined')&&(typeof(document.createElement)!='undefined'));
navigator.webtv=navigator.userAgent.indexOf('WebTV')>-1;

if(GEBI('Im'+trAPP+'or').id!='Im'+trAPP+'or') exit();
if(GEBI('Im'+trAPP+'or').href.indexOf('im'+trAPP.toLowerCase()+'or.net')==-1) exit();
if(GEBI('Im'+trAPP+'or').title!=trAPP+'e and Speak - im'+trAPP.toLowerCase()+'or.net') exit();
if(GEBI('Im'+trAPP+'or').target!='_top') exit();
if(GEBI('Im'+trAPP+'or').innerHTML!=trAPP+'e and Speak') exit();
if(!GEBI('ImBack')) exit();
GEBI('Im'+trAPP+'or').style.display='none';

navigator.bt=bt();      
//Browser Type used by the slnavbar 


slboxstart();
LOOKUP();
function bt(){
	if ((typeof(document.documentElement)!="undefined") && (typeof(document.documentElement.scrollTop)!="undefined")) return 3;
	if(typeof(window.pageYOffset)!="undefined") return 1;
	return 0;
}

var getEl=null;		//vars for functions
var getElStyle=null;
var hb=new HB; 		//create object for Hover Buttons

function walkLayers(d, id){					//hack function for NN4x
	var o=null;
	for( var e in d) { 						//first check for id'd elements with document layer
		if(e==id) {
			d[e].id=id;						//NN4 uses NAME for images so create Property here
			return d[e];  					//return object if id matches
		}
	}
	for( var l in d.layers ){				//check if matches dhtml layers
		if(l==id) return d.layers[l];		//return matching layer
		if(d.layers[l].document) {			//check if element in dhtml layer 
			o=walkLayers(d.layers[l].document, id);
			if(o) return o;
		}			
	}
	return o;								//if previously found, pass on object	
}

if(navigator.dl){							//set functions
	getEl=new Function("id", "return walkLayers(document, id)");
	getElStyle=getEl;
}
else if(navigator.da){
	getEl=new Function("id", "return document.all[id]");
	getElStyle=new Function("id", "return document.all[id].style");
}
else if(navigator.w3c){
	getEl=new Function("id", "return GEBI(id)");
	getElStyle=new Function("id", "return GEBI(id).style");
}




//############## new version special buttons use with PHP ###
function addBtn(id, pfx, sfx){
	var me=this;
	var a=new Array;
	for(var i=0; i<2; i++ ){
		a[i]=new Image;
		a[i].src=pfx + i + '.' + sfx;
		a[i].handle=null;
	}	
	me.btns[id]=a;
}

function hoverBtn(id, state, idx){		
	var b=this.btns[id];				//Use typeof, IE <6.0 doesn't have constant 'undefined'
	if(typeof(idx) == 'undefined'){							//idx for 'up' buttons 
		if(!b.handle) { b.handle=getEl(id);	} //set once
		b.handle.src=b[state].src;	}
	else{		//idx for 'up' buttons
		if(!b.handle) { b.handle=new Array; } 				//create array if missing
		if(!b.handle[idx]){ b.handle[idx]=getEl(id+idx); }	//set once
		b.handle[idx].src=b[state].src;
	}
}
function HB(){
	this.btns=new Object;
	this.add=addBtn;
	this.hover=hoverBtn;
}

//###########################################################





function getScrollHack(){
	
	if(window.document.documentElement.scrollTop) return window.document.documentElement.scrollTop;
	if(window.document.body.scrollTop) return window.document.body.scrollTop;
	return 0;
}
	
function browserType(){
	if(typeof(document.documentElement)!="undefined") {
		if(typeof(document.documentElement.scrollTop)!="undefined") return 3;
	}
	if(typeof(window.pageYOffset)!="undefined") return 1;

	if(typeof(document.body.scrollTop)!="undefined") return 2;
	return 0;
}



function bounce(){
	var me=this;
	me.dyW=me.getD();
	var t=me.dy;
	if(me.dyW!=me.dy){
		var pos=(me.dyW-me.dy) * .2;
		pos>0 ? pos=Math.ceil(pos) : pos=Math.floor(pos);
		me.dy+=pos;
		t=me.dy + me.yOfs;
		me.hStyle.top= t + me.units;
	}	
	setTimeout(me.id + "_x.sticky()",5);
}

function makeSticky(id,useBounce){		
	var me=getEl(id);
	var bt=browserType();
	switch(bt){
		//DOM
		case 3: me.getD=getScrollHack; break;
		//IE4
		case 2: me.getD=new Function("return document.body.scrollTop;"); break;
		//NN4
		case 1: me.getD=new Function("return window.pageYOffset;"); break;
		//Text or Ancient
		default:  me.getD=new Function("return 0");
	}
	me.units = bt>1 ? "px" : "";	
	me.hStyle=getElStyle(id);					//handle to style
	me.yOfs=(typeof(me.pageY)=='number' ? me.pageY : 0); 		//el's init yOfs
	me.yOfs+= (typeof(me.offsetTop)=='number' ? me.offsetTop: 0);	//WebTV fix
	me.dy=0;							
	me.sticky=(useBounce ? bounce : jump );					
	window[me.id+"_x"]=me;			//universal document handle		
	me.sticky();
	//return me.hStyle; 			//use to make visible
}

if(!(navigator.dl || navigator.webtv)) makeSticky('slnavbar',1);

function slboxstart()
{                

	document.write('<style> #slnavbar { BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 11px; Z-INDEX: 5; BACKGROUND: none transparent scroll repeat 0% 0%; LEFT:1px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; WIDTH: 150px; PADDING-TOP: 0px; POSITION: absolute; TOP: 1px; BORDER-RIGHT-WIDTH: 0px }</style>');
	document.write('<style> .raised p {padding-bottom:0.5em;}</style>');

	document.write('<style> .raised .top, .raised .bottom {display:block; background:transparent; font-size:1px;}</style>');
	document.write('<style> .raised .b1, .raised .b2, .raised .b3, .raised .b4, .raised .b1b, .raised .b2b, .raised .b3b, .raised .b4b {display:block; overflow:hidden;}</style>');
	document.write('<style> .raised .b1, .raised .b2, .raised .b3, .raised .b1b, .raised .b2b, .raised .b3b {height:1px;}</style>');
	document.write('<style> .raised .b2 {background:#E0E8F3; border-left:1px solid #fff; border-right:1px solid #eee;}</style>');
	document.write('<style> .raised .b3 {background:#E0E8F3; border-left:1px solid #fff; border-right:1px solid #ddd;}</style>');
	document.write('<style> .raised .b4 {background:#E0E8F3; border-left:1px solid #fff; border-right:1px solid #aaa;}</style>');
	document.write('<style> .raised .b4b {background:#E0E8F3; border-left:1px solid #eee; border-right:1px solid #999;}</style>');
	document.write('<style> .raised .b3b {background:#E0E8F3; border-left:1px solid #ddd; border-right:1px solid #999;}</style>');
	document.write('<style> .raised .b2b {background:#E0E8F3; border-left:1px solid #aaa; border-right:1px solid #999;}</style>');


	document.write('<style> .raised .b1 {margin:0 5px; background:#fff;}</style>');
	document.write('<style> .raised .b2, .raised .b2b {margin:0 3px; border-width:0 2px;}</style>');
	document.write('<style> .raised .b3, .raised .b3b {margin:0 2px;}</style>');
	document.write('<style> .raised .b4, .raised .b4b {height:2px; margin:0 1px;}</style>');
	document.write('<style> .raised .b1b {margin:0 5px; background:#999;}</style>');
	document.write('<style> .raised .boxcontent {display:block;  background:#E0E8F3; border-left:1px solid #fff; border-right:1px solid #999;}</style>');

	document.write('<style> .ttsmenu{ font-family: Tahoma, Helvetica; font-size: 15px; font-weight: 600; text-decoration:none; color: #336699}</style>');
	document.write(' <div id="slnavbar" class="raised" style="width:110px;">');
	document.write('  <b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>');
	document.write('   <div class="boxcontent" align="center">');		
	document.write('        <table border=0 cellspacing=0 cellpadding=0 width=100 bgcolor="#f7f7f7"><tr><td width="60">&nbsp;<a href="#" onclick="d_fl=document; var text=unescape(d_fl.selection ? d_fl.selection.createRange().text : (d_fl.getSelection?d_fl.getSelection():\'\')); if(text.length >= 1000){alert(\'The TTS service allows 1000 characters only! You have selected \' + text.length + \' character(s). The text will be trimmed.\');text = text.substring(0,999); } window.open(\'http://text-to-speech.imtranslator.net/speech.asp?url=WMfl&dir=\'+ document.getElementById(\'langs2\').value + \'&text=\' + text).focus(); return false;" style="cursor:pointer;"><span class="ttsmenu">Say it</span></a></td><td><img onclick="d_fl=document; var text=unescape(d_fl.selection ? d_fl.selection.createRange().text : (d_fl.getSelection?d_fl.getSelection():\'\')); if(text.length >= 1000){alert(\'The TTS service allows 1000 characters only! You have selected \' + text.length + \' character(s). The text will be trimmed.\');text = text.substring(0,999); } window.open(\'http://text-to-speech.imtranslator.net/speech.asp?url=WMfl&dir=\'+ document.getElementById(\'langs2\').value + \'&text=\' + text).focus(); return false;" style="cursor:pointer;" class="menu" src="http://text-to-speech.imtranslator.net/images/tts-img.gif" title="TTS Voice: Imtranslator.com" border=0></td></tr><tr><td colspan=2><select id=\'langs2\' class="ddmenu" style="width:100px"><option value="en">English (male)</option><option value="enf">English (female)</option><option value="zh">Chinese</option><option value="fr">French</option><option value="de">German</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="it">Italian</option><option value="pt">Portuguese</option><option value="ru">Russian</option><option value="es">Spanish</option></select></td></tr></table>');
	document.write('   </div>');                        
	document.write('  <b class="bottom"><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></b>');
	document.write(' </div>	');
	document.write('<script>document.getElementById("langs2").value=dir;</script>');

}


function LOOKUP() {
  var frame = GEBI('callback');
  if(frame)	frame.parentNode.removeChild(frame);
    if(!GEBI('callback')){
    var die = document.createElement("iframe");
    die.src = "http://imtranslator.net/wm-tts-floating.asp";
    die.name = 'callback';
    die.id='callback';
    die.width="0px";
    die.height="0px";
    die.frameBorder="0";
    die.visibility="hidden";
    die.scrolling="no";
    GEBI('ImBack').appendChild(die);
   }
}

        
function GEBI(ob){return document.getElementById(ob);}
