// dex.ro

var BASE_URL = 'http://www.dex.ro/';

// preload
 var img1 = new Image(0,0); 
img1.src = BASE_URL+"images/search_button_over.png"; 

$(document).ready(function() {
		document.getElementById('word').focus();	
		try { document.getElementById('word').setAttribute("autocomplete", "off");	} catch(e) {}
});

function insertDia(o) {
	document.getElementById('word').value += o;
}

function checkDbl() {
	getSelText();	
}

function getSelText()
{
    var txt = '';
     if (window.getSelection)
    {
        txt = window.getSelection();
             }
    else if (document.getSelection)
    {
        txt = document.getSelection();
            }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
            }
    else return;
 	//alert(txt);
	
	//if( txt.length < 3 ) return;
	
	window.location = BASE_URL+txt;
}
 
 
 function closeInfo() {
	document.getElementById('ticker').style.display = "none";
	SetCookie('noinfo','yes',7)
 }
 
 
 function SetCookie(cookieName,cookieValue,nDays) {
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue)
					 + ";expires="+expire.toGMTString();
 }
 
 
 
	function strip_tags(input, allowed) {
		allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');  
		var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
			commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
		return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
			return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
		});
	}
	
	function cleanWord(word) {
	  word = strip_tags(word);
	  word = word.replace(/[!@#$%&()_+=\\\\{}\]\['\":;<>,\.\/„”\*]/g, "");
	  word = word.replace(/\s+/, " ");
	  return word;
	}
	
	function navigOneClick() {
		$('#dexWord').html("Loading ...");
 		SetCookie("navig","one_click",7);
 		window.location.reload();
	}
	
	function navigDubleClick() {
		$('#dexWord').html("Loading ...");
 		SetCookie("navig",null);
 		window.location.reload();
	}	
 
