function cauta(ce) {
	if( ce.length < 3 ) {
		alert('Minim 3 caractere!')
		return false;
	} 
	ce = ce.toLowerCase(); 
	//ce = ce.replace(/\s+/g, '');
	ce = ce.replace(/[^a-z0-9/]/gi, '-');
	var final = 'cauta-referate-'+ce+'.html';
	window.location = final;
}

function makeCookie(name,value) {
	var date = new Date();
	date.setTime(date.getTime()+(3600*24*1000));
	var expires = ";expires="+date.toGMTString();
	document.cookie = name+"="+value+expires+"; path=/";
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return false; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function handleEnter(inField, e) {
    var charCode;    
    if(e && e.which){
        charCode = e.which;
    }else if(window.event){
        e = window.event;
        charCode = e.keyCode;
    }

    if(charCode == 13) {
		if( inField.value.length < 3 ) {
			alert('Minim 3 caractere!')
			return false;
		} else {
	        cauta(inField.value);
		}
    }
}

function goTo(url,type,a) {
	if( type == 'doc' ) window.location = url+'x/doc.php?id='+a;
	if( type == 'pdf' ) window.location = url+'x/pdf.php?id='+a;	
}