/*	var result = document.createElement("div");
	result.style.backgroundColor = "#F3E8CC";
	result.style.position = "absolute";
	result.id = "result";

	result.style.left = getXpos(document.getElementById("search"))+"px";

	result.style.top  = getYpos(document.getElementById("search"))+20+"px";
	result.style.border="1px solid #000000";

	result.onmousedown = mDown;

	result.onmouseup = mUp;

	document.body.appendChild(result);
	document.onmousemove = mouseMove;
	document.getElementById("search").onkeyup = Gaseste;*/

function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'

    var histogram = {}, histogram_r = {}, code = 0, str_tmp = [];
    var ret = str.toString();
    
    // The histogram is identical to the one in urlencode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
 
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        tmp_arr = ret.split(search); // Custom replace
        ret = tmp_arr.join(replace);   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);

    return ret;
}
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                                     
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}
var url = window.location;
	url = urldecode(url.toString());
	if(url.indexOf("search")!=-1){
		var key_word = url.substr(url.indexOf("search=")+7);
		
		var str;
		//var add = "/(\<a href\=\"[a-z0-9_\.]+\"\>)("+key_word+")(\<\\/a\>)/gi";
		//var add = "/[^\/]+"+key_word+"([^\.]+)|([^\/]+)/gi";
		var add="/"+key_word+"/gi";
		if(!document.all){
			str= document.body.innerHTML;
			
			if (str.match(eval(add)))
			{
				document.body.innerHTML = str.replace(eval("/" + key_word + "/gi"),"<span style='background-color:#9999FF;color:#FFFFFF;'>"+key_word+"</span>");
				str = document.body.innerHTML;
			}
			if(str.match(eval("/%3Cspan\%20style\=\%27background\-color\:\#0000FF\;color\:\#FFFFFF\;\%27\%3E"+key_word+"%3C\\/span\%3E/i")))
				document.body.innerHTML = str.replace(eval("/%3Cspan\%20style\=\%27background\-color\:\#9999FF\;color\:\#FFFFFF\;\%27\%3E"+key_word+"%3C\\/span\%3E/gi"),key_word);
			//var pat = "/^(/<span[^>]+>)("+key_word+")(<\\/span>)"/i";
			//document.documentElement.childNodes[1].innerHTML = str.replace(eval(pat), "$2");

			/*if (str.match(eval(add)))
			{
				//alert("");
				document.body.innerHTML=str.replace(eval(add), "$1<span style='background-color:#0000FF;color:#FFFFFF;'>"+key_word+"</span>$3");
			}*/
//			document.body.innerHTML = str.replace(eval("/"+key_word+"/gi"),"<span style='background-color:#0000FF;color:#FFFFFF;'>"+key_word+"</span>");
		}else{
			str= document.documentElement.childNodes[1].innerHTML;
			//alert(str);
			if (str.match(eval(add))){
				document.documentElement.childNodes[1].innerHTML = str.replace(eval(add),"<span style='background-color:#9999FF;color:#FFFFFF;'>"+key_word+"</span>");
				str= document.documentElement.childNodes[1].innerHTML;
				//alert(str);
				//var pat = "/^(/<span[^>]+>)("+key_word+")(<\\/span>\/)"/i";
				//document.documentElement.childNodes[1].innerHTML = str.replace(eval(pat), "$2");
				//document.documentElement.childNodes[1].innerHTML = str.replace(eval("/%3Cspan%20style=%27background-color:#0000FF;color:#FFFFFF;%27%3E"+key_word+"%3C/span%3E/gi"),key_word);
			}
			if(str.match(eval("/<span\%20style\=\'background\-color\:\#0000FF\;color\:\#FFFFFF\;\'\>"+key_word+"<\\/span\>/i")))
			//	alert("ura");
				document.documentElement.childNodes[1].innerHTML = str.replace(eval("/<span\%20style\=\'background\-color\:\#9999FF\;color\:\#FFFFFF\;\'\>"+key_word+"<\\/span\>/gi"),key_word);
		}
		
	}
