var oldbg = "";

function createContentFrame(title, html, width, height, halign, calign, cvalign){
	printCfTop(title, width, height, halign, calign, cvalign);
    document.write(html);
	printCfBot();
}

function createContentFrame2(name, title, html, width, height, halign, calign, cvalign){
	printCfTop(title, width, height, halign, calign, cvalign);
    document.write(html);
    printCfBot();
}

function printCfTop(title, width, height, halign, calign, cvalign){
    var style = "";

    if (width > 0 || width != '') {
        style = "width:" + width + ";";
    }
    if (height > 0) {
        style += "height:" + height + ";";
    }

	document.write("<table class=\"contentFrame\" style=\"" + style + "\" cellSpacing=\"0\" cellPadding=\"0\">");
    document.write("<tr>");
    document.write("<td class=\"bar_top_left\"></td>");
    document.write("<td class=\"bar_top_bg\" align=\"" + halign + "\">" + title + "</td>");
    document.write("<td class=\"bar_top_right\"></td>");
    document.write("</tr>");
    document.write("<tr>");
    document.write("<td class=\"bar_mid_left\"></td>");
    document.write("<td align=\"" + calign + "\" valign=\"" + cvalign + "\">");
}

function printCfBot(){
	document.write("</td>");
    document.write("<td class=\"bar_mid_right\"></td>");
    document.write("</tr>");
    document.write("<tr>");
    document.write("<td class=\"bar_bot_left\"></td>");
    document.write("<td class=\"bar_bot_bg\"></td>");
    document.write("<td class=\"bar_bot_right\"></td>");
    document.write("</tr>");
    document.write("</table>");
}

function showurl(url){
	parent.location = url;
}

function changeMainFrame(url){
	parent.main.location=url;
}

function OpenWindow(url, w, h, x, y){
	window.open(url,"mywindow","width=" + w + ",height=" + h + ";status=no,resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,left=" + x + ",top=" + y);
}

function OpenFixedWindow(url, w, h, x, y){
	window.open(url,"mywindow","width=" + w + ",height=" + h + ";status=no,resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes,left=" + x + ",top=" + y);
}

function CreateWindow(title, content, w, h, x, y) {
	top.consoleRef=window.open('','newwindow',
	'width=' + w + ',height=' + h
	+',menubar=0'
	+',toolbar=0'
	+',status=0'
	+',scrollbars=1'
	+',resizable=1'
	+',left=' + x
	+',top=' + y)
	top.consoleRef.document.writeln(
	'<html><head><title>' + title + '</title></head>'
	+'<body bgcolor=white onLoad="self.focus()">'
	+content
	+'</body></html>'
 )
 top.consoleRef.document.close()
}

function CreateFixedWindow(title, content, w, h, x, y) {
	top.consoleRef=window.open('','newwindow',
	'width=' + w + ',height=' + h
	+',menubar=0'
	+',toolbar=0'
	+',status=0'
	+',scrollbars=1'
	+',resizable=0'
	+',left=' + x
	+',top=' + y)
	top.consoleRef.document.writeln(
	'<html><head><title>' + title + '</title></head>'
	+'<body topmargin="0" leftmargin="0" bgcolor=white onLoad="self.focus()">'
	+content
	+'</body></html>'
 )
 top.consoleRef.document.close()
}

function setfocus(obj){
	f = document.getElementById(obj);
	if(f)
		f.focus();
}

function changeBg(obj, color){
	oldbg = obj.style.backgroundColor;
	obj.style.backgroundColor=color;
}

function changeBgBack(obj){
	obj.style.backgroundColor=oldbg;
}

function padBefore(str, len, chr)
{

    if(typeof(chr)=="undefined")
        chr = " ";

    str = str + ""; //<< convert to string trick
    slen = str.length;
    if(slen < len){
        for (i=slen;i<len;i++)
        {
            str = chr + str;
        }
    }
    return str;
}

function highlightRow(checkbox)
{
    // Parameters -
    // checkbox - reference to checkbox
    // noselclass - class to use if not selected
    var tr;
    var trclass = "";

    if (checkbox.parentNode) {
       tr = checkbox.parentNode;
       while (tr.nodeName.toLowerCase() != 'tr')
            tr = tr.parentNode;
    }
    else if (checkbox.parentElement) {
        tr = checkbox.parentElement;
        while (tr.tagName.toLowerCase() != 'tr')
            tr = tr.parentElement;
    }

    /*var altclass = tr.getAttribute("altclass");
    if (!altclass) {
        tr.setAttribute("altclass", tr.className);
    }*/

    if(checkbox.checked){
        tr.className = "selectedTableItem";}
    else{
        trclass = tr.getAttribute("altclass");

        if (trclass == null)
            trclass = "tableItem";

        tr.className = trclass;

        }
}