// JavaScript Document
var t;
function isUrl(s)
    {
    var regexp = /(ftp|http|https):\/\/([_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+)(([_a-zA-Z\d\-\\\.\/]+[_a-zA-Z\d\-\\\/])+)*/
  	return regexp.test(s);
    }
function clearerror(what)
    {
    document.getElementById(what).innerHTML = "";
    }
function changevalue(what,to)
    {
    document.getElementById(what).innerHTML = to;
    }
function checklink(wname,wlink,report,func)
    {
    clearTimeout(t);
    name = document.getElementById(wname).value;
    link = document.getElementById(wlink).value;
    document.getElementById(func).focus();
    var error = "";
    var warn = "";
    if (name == "" && link == ""){return false;}
    document.getElementById(report).innerHTML = "";
    if (name == "")
        {
        error = error + "Web site name is blank" + "<br />";
        }
    if (name.length > 15)
        {
        warn = warn + "Web site name will appear as " + name.substr(0,14) + "<br />"
        }
    if (link == "")
        {
        error = error + "URL link address is blank" + "<br />"
        }
    if (isUrl('http://' + link))
        {
        warn = warn + "URL is correctly formed" + "<br />";
        if (error == "")
            {
            warn = warn + "URL http://" + link + " will be added and named " + name.substr(0,14);
            changevalue(func,'Add Link');
            }
        }
    else
        {
        warn = warn + "URL is misformed" + "<br />";
        }
    document.getElementById(report).innerHTML = error + warn;
    t = setTimeout("clearerror('linkerror')", 10000);
    }
function gotopage(where)
    {
    popnewwin(where,'_blank',800,600);
//    document.location.href=where;
    }
function popnewwin(what,winname,xwidth,yheight)
    {
    attrib = "width=" + xwidth + ", height=" + yheight + ", resizable=yes,scrollbars=yes";
    calopen = window.open(what, winname, attrib);
    }
function changegcell(cell,gr,gc)
    {
    x = cell.split("-", 2);
    findghood(x[0], x[1], "#bbbbbb",gr,gc);
    changegtext(cell, "#ffffff",gr,gc);
    }
function changegtext(cell,color,gr,gc)
    {
    x = cell.split("-", 2);
    if(Number(x[0])>0 && Number(x[0])<=gr && Number(x[1])>0 && Number(x[1])<=gc)
        {
        document.getElementById(cell).style.color = color;
        }
//    else
//        {
//        alert(cell + "-" + color + "-" + gr + "-" + gc);
//        }
    }
function changegback(cell,gr,gc)
    {
    x = cell.split("-", 2);
    findghood(x[0], x[1], "gray",gr,gc);
    changegtext(cell,"gray",gr,gc);
    }
function findghood(row, col, color,gr,gc)
    {
    x1 = Number(row) - 1;
    x2 = Number(row) + 1;
    y1 = Number(col) - 1;
    y2 = Number(col) + 1;
    changegtext(row+"-"+y1, color,gr,gc);
    changegtext(row+"-"+y2, color,gr,gc);
    changegtext(x1+"-"+col, color,gr,gc);
    changegtext(x2+"-"+col, color,gr,gc);
    }
function addlink(wname,wlink,wclass,report,func)
    {
    document.getElementById(report).innerHTML = "Function disabled at this web site";
    t = setTimeout("clearerror('linkerror')", 10000);

    }
