var IE=(navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.indexOf("Opera")==-1?1:0);
var click_block=0;
function ById(id){return document.getElementById(id)}
function getsearchtxt(){
	hidesearchbox();
	if (click_block){
		click_block=0;
		return;
	}
	if (!IE){
		t = document.getSelection();
		addsearchtxt(t);
	}
	else {
		t = document.selection.createRange();
		if(document.selection.type == 'Text' && t.text != ''){
			//document.selection.empty();
			addsearchtxt(t.text);
		}
	}
}
function addsearchtxt(text){
	while (text.substr(text.length-1,1)==' ') text=text.substr(0,text.length-1)
	while (text.substr(0,1)==' ') text=text.substr(1)
	if (text > ''){
		var text = text.replace(/:/i, " - ");
        var text = text.replace(/\//i, " ");
		var text = text.replace(/  /i, " ");
		document.getElementById('seltext').value = text;
		showsearchbox();
	}
	else {
		hidesearchbox();
	}
}
function hidesearchbox() {
	var id = "searchfield";
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function showsearchbox() {
	//safe function to show an element with a specified id
	var id = "searchfield";
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


function searchdesc(id, txt) {
	document.getElementById("searchsite").innerHTML = txt + "&nbsp;";
    document.getElementById("selsite").value = id;
    if (txt == '') document.getElementById(id).src = "images/" + id + "_bw.png";
    else {
        document.getElementById(id).src = "images/" + id + ".png";
        opacity(id);
    }
     
}
	
function opacity(id) {
	opacStart = 25;
	opacEnd = 100;
	millisec = 800;
 //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
