	function goBack() {
		
		href = document.referrer;
		
		var pattern = new RegExp("(http|ftp|https)://(.*?)/.*$");
		parsed = href.match(pattern);

		if( parsed == null )
			window.location ='http://edno.bg';

		if( parsed[2] == 'edno.bg' )
			history.go(-1);
		else
			window.location = 'http://edno.bg';
	}

// check if hover image exists
	function isFile(str){
	    var ajax = Ajax();
	    if(!ajax) return false;
	    try
	    {
	        ajax.open("HEAD", str, false);
	        ajax.send(null);

	        if( (ajax.status>=200 && ajax.status<300) || (ajax.status == 304) || (ajax.status == 1223) || (Prototype.Browser.Safari && ajax.status == undefined) ) {
	        	return true;
	        } else {
		        return false;
	        }
	    }
	    catch(er)
	    {
	        return false;
	    }
	}
	function Ajax()
	{
	    var obj;
	    if (window.XMLHttpRequest)
	    {
	        obj = new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject)
	    {
	        try
	        {
	            obj = new ActiveXObject('MSXML2.XMLHTTP.3.0');
	        }
	        catch(er)
	        {
	            obj = false;
	        }
	    }
	    return obj;
	}

	// replace old image name and check if the new one exists
	function HoverImgOf(filename)
	{
		var re = new RegExp("(.+)\\.(gif|png|jpg|jpeg)", "g");
		fn = filename.replace(re, "$1_hover.$2");
		if( isFile(fn) )
			return fn;
		else
			return filename;
	}
	
	function NormalImgOf(filename)
	{
	   var re = new RegExp("(.+)_hover\\.(gif|png|jpg)", "g");
	   return filename.replace(re, "$1.$2");
	}

	// replace old image source + move search element
	document.observe('dom:loaded', function(){
		h = $('headerText').getHeight() + 20;
		height = h + 'px';
		$('ednoSearch').setStyle({ 
			'position': 'absolute', 
			'top': height, 
			'right': '64px' 
		});
		z=$$('.ednoBWtoColor img');
		z.each(function(n) {
		    n.observe('mouseover', function() {
		    	n.src = HoverImgOf(n.src);
		    });
		    n.observe('mouseout', function(){
		    	n.src = NormalImgOf(n.src);
		    });
		});
	});