function highlightTableRows(tableId) {
    var previousClass = null;
    var table = document.getElementById(tableId); 
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
        rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
        rows[i].onmouseout = function() { this.className=previousClass };
        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            if (cell.getElementsByTagName("a").length > 0) {
                var link = cell.getElementsByTagName("a")[0];
                if (link.onclick) {
                    call = link.getAttributeValue("onclick");
                    // this will not work for links with onclick handlers that return false
                    eval(call);
                } else {
                  location.href = link.getAttribute("href");
                }
                this.style.cursor="wait";
            }
        }
    }
}

// Show the document's title on the status bar
window.defaultStatus=document.title;

//window.onload = StyleSheetSwitcher.initialize();


// Perform a rollover action on a div / span or whatever that emulates a action tag rollover
function rollOver(id, newClass) {

    var element = document.getElementById(id);

    if (element.useMap != newClass) {
        element.useMap = element.className;
        element.className = newClass;
    }

}

function rollOut(id) {

    var element = document.getElementById(id);
    if (element && element.useMap != null) {
        element.className = element.useMap;
    }
    
}

//******************************************************************************************


//    function setLoadFocus(field) {
//        $(field).focus();
//    }


function showImage(target, ctx, source, size, captionTarget, caption) {

    var smallSource = source.replace(".", "."+size+".");
    var largeSource = source.replace(".", ".600.");

    smallSource = smallSource.replace(".JPG", ".jpg");
    largeSource = largeSource.replace(".JPG", ".jpg");

    document.getElementById(captionTarget).innerHTML = caption;
    
    document.getElementById(target).href = largeSource;
    document.getElementById(target).innerHTML = "<img src='"+smallSource+"' alt='"+caption+"' />";

}


function increaseTextSize(target) {

    var curSize = document.getElementById(target).style.fontSize;
    var curLineHeight = document.getElementById(target).style.lineHeight;
                
    if (curSize.length < 1) {

        curSize = 12;
        curLineHeight = 1.7;

    } else {
        curSize = curSize.substring(0, curSize.indexOf("px"));
        curSize++;
        curLineHeight = Number(curLineHeight) + 0.1;
    }

    document.getElementById(target).style.fontSize = curSize + "px";
    document.getElementById(target).style.lineHeight = curLineHeight;

}


function decreaseTextSize(target) {

    var curSize = document.getElementById(target).style.fontSize;
    var curLineHeight = document.getElementById(target).style.lineHeight;

    if (curSize.length < 1) {

        curSize = 10;
        curLineHeight = 1.5;

    } else {
        curSize = curSize.substring(0, curSize.indexOf("px"));
        curSize--;
        curLineHeight = Number(curLineHeight) - 0.1;
    }

    document.getElementById(target).style.fontSize = curSize + "px";
    document.getElementById(target).style.lineHeight = curLineHeight;

}


function doSearch(ctx, id, lang) {

    var searchString = document.getElementById(id).value;
	//alert(lang);
	if (lang=="")
	{
		this.location.href=ctx+'/search.jsp?search=' + searchString;
	}else{
	    this.location.href=ctx+'/search.jsp?search=' + searchString+'&lang='+lang;
	}

}


function clearInputBox(id) {
    document.getElementById(id).value = '';
}

function checkForEnterKey(ctx, id, lang) {

    if (window.event.keyCode == 13) {
        doSearch(ctx, id, lang);
    }
                                  
}


function pop_close(){
	document.getElementById('popup').style.display="none";
}

function pop_redirect(){
	window.location = "http://www.google.com/";
}

var testing = 150;

function pop_fade(){
	
	document.getElementById('popup').style.filter = "alpha(Opacity="+testing+")";
	document.getElementById('popup').style.opacity = testing/100;
	if (testing>0)
	{
		testing = testing-1;
		var t = setTimeout('pop_fade()', 50);
		//clearTimeout(t);
	}else{
		document.getElementById('popup').style.display="none";
	}
}



