var suspend_reload = 0;






function changeFont(intFontSize)
	{
	document.getElementById('article_body').style.fontSize = intFontSize + 'em';
	document.getElementById('article_body').style.lineHeight = '1.2em';
	document.getElementById('textbefore').style.fontSize = intFontSize + 'em';
	document.getElementById('textbefore').style.lineHeight = '1.2em';
	document.getElementById('textafter').style.fontSize = intFontSize + 'em';
	document.getElementById('textafter').style.lineHeight = '1.2em';
	}





function toggleLayerOn(whichLayer)
    {
    if (document.getElementById)
        {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
        }
    else if (document.all)
        {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
        }
    else if (document.layers)
        {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
        }
    }

function toggleLayerOff(whichLayer)
    {
    if (document.getElementById)
        {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"none";
        }
    else if (document.all)
        {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"none";
        }
    else if (document.layers)
        {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"none";
        }
    }






/*function changediv(div_id, el_count, delay_ms, div_counter)
    {
    for (i = 0; i < el_count; i++)
        {
        i2 = i + 1;
        var div_off = div_id + i2;
        document.getElementById(div_off).style.display = "none";
        }
    
    div_counter++;
    
    if (div_counter > el_count)
        {
        div_counter = 1;
        }
    
    var div_on = div_id + div_counter;
    
    document.getElementById(div_on).style.display = "block";
    
    window.setTimeout('changediv(\'' + div_id + '\',' + el_count + ',' + delay_ms + ',' + div_counter + ')', delay_ms);
    }
*/




var timeout_handler = [];

function changediv(div_id, el_count, delay_ms, div_counter, kill_id, resume_ms)
    {
    /*
    PURPOSE: To toggle visibility of two or more divs
    div_id: the divs' ID without the numeric value
    el_count: number of total divs to toggle; named [div_id][#]
    delay_ms: number of milliseconds to delay the toggle
    div_counter: keeps track of how many times the div is run so it can loop
    kill_id: ID number of selected div; allows an event to trigger a pause in the toggle
    resume_ms: number of milliseconds after killing the previous setTimeout
    */
    for (i = 0; i < el_count; i++)
        {
        i2 = i + 1;
        var div_off = div_id + i2;
        document.getElementById(div_off).style.display = "none";
        }

    div_counter++;

    if (div_counter > el_count)
        {
        div_counter = 1;
        }

    if ((!kill_id) || (kill_id == 0))
        {
        var div_on = div_id + div_counter;
        if (resume_ms > 0)
            {
            delay_ms = resume_ms;
            resume_ms = 0;
            }
        }
    else
        {
        var div_on = div_id + kill_id;
        clearTimeout(timeout_handler[div_id]);
        }
    
    if (!resume_ms)
        {
        resume_ms = 0;
        }

    document.getElementById(div_on).style.display = "block";
    
    if ((!kill_id) || (kill_id == 0) || (resume_ms > 0))
        {
        timeout_handler[div_id] = window.setTimeout('changediv(\'' + div_id + '\',' + el_count + ',' + delay_ms + ',' + div_counter + ', 0,' + resume_ms + ')', delay_ms);
        }
    }







function togvis(block_id, block_type)
    {
    block_vis = document.getElementById(block_id).style.display;
    if (block_vis == 'none')
        {
        document.getElementById(block_id).style.display = block_type;
        }
    else
        {
        document.getElementById(block_id).style.display = 'none';
        }
    }





        
function check_url()
    {
    hoststring = window.location.host;
    pathstring = window.location.pathname;
    searchstring = window.location.search
    
    if (hoststring == 'wdt.net' || hoststring == 'www.wdt.net' || hoststring == 'wdweb.sv.publicus.com')
        {
        window.location = "http://www.watertowndailytimes.com" + pathstring + searchstring;
        }
    }






function set_reload(tval)
    {
    if (suspend_reload != 1)
        {
        if (tval >= 0)
            {
            timeoutset = setTimeout("window.location=window.location", tval);
            }
        }
    }

function clear_reload()
    {
    clearTimeout(timeoutset);
    }










function formtext_focus(basetext)
    {
    if (document.storysearchform.crit.value == basetext)
        {
        document.storysearchform.crit.value = '';
        document.storysearchform.crit.style.color = '#003366';
        }
    }

function formtext_blur(basetext)
    {
    if (document.storysearchform.crit.value == '')
        {
        document.storysearchform.crit.value = basetext;
        document.storysearchform.crit.style.color = '#666666';
        }
    }

function search_submit(basetext)
    {
    if (document.storysearchform.crit.value == basetext)
        {
        document.storysearchform.crit.value = '';
        storysearchform.submit();
        }
    }
    
    
    



function frames_remove()
    {
    if (top.location != self.location)
        {
        top.location = self.location;
        }
    }





function findandreplace(id, needle, replacement)
    {
    var haystack = document.getElementById(id).innerHTML;
    var match = new RegExp(needle, "ig");
    var replaced = haystack.replace(match, replacement);
    document.getElementById(id).innerHTML = replaced;
    }




    
function set_commenttext(el,aid)
    {
    var com_div = 'commentsbody' + aid;
    if (document.getElementById(com_div).style.display == 'none')
        {
        el.innerHTML = 'SHOW COMMENTS';
        }
    else
        {
        el.innerHTML = 'HIDE COMMENTS';
        }
    clear_reload();
    suspend_reload = 1;
    }








