/*function scrollUp(){
    var totalLines = CountLines();     
    var topLine = 0;
    var visibleLines = 17;
    var finalStr = "";
    topLine = MoveThroughText(topLine,'up',totalLines);
    finalStr = GetDisplayText(topLine,totalLines);
    RenderText(finalStr,'up',topLine,totalLines);
}

function loopUp(repetition, line){
    var totalLines = CountLines();     
    var topLine = 0;
    var finalStr = "";
    topLine = MoveThroughText(topLine,'up',totalLines);
    finalStr = GetDisplayText(topLine,totalLines);
    RenderThis(finalStr);
}

function scrollDown(){
    var totalLines = CountLines();     
    var topLine = 0;
    var finalStr = "";
    topLine = MoveThroughText(topLine,'down',totalLines);
    finalStr = GetDisplayText(topLine,totalLines);    
    RenderText(finalStr,'down',topLine,totalLines);   
}

function loopDown(){
    var totalLines = CountLines();     
    var topLine = 0;
    var finalStr = "";
    topLine = MoveThroughText(topLine,'down',totalLines);
    finalStr = GetDisplayText(topLine,totalLines);
    RenderThis(finalStr);
}

function stopScroll(){   
   return false;
}

function CountLines(){
    var storedTextElement = document.getElementById("maincontentleft");
    var storedText = storedTextElement.innerHTML;
    var arr1 = storedText.split("<BR>");
    
    return arr1.length;
}
    
function MoveThroughText(topLine,scrollDirection,lineCount){
    if(scrollDirection == "down"){
        if((topLine+1) <= lineCount){
            topLine++;
        }
    }else{ //up
        if((topLine-1) > 0){
            topLine--;
        }
    }
    return topLine;
}   

function GetDisplayText(startLineIndex,numLines){
    var compileStr = "";
    var cnt = CountLines(); 
    if(startLineIndex == 0){    //up
        compileStr += GetLine(numLines-1);
        for(m=1;m<(numLines-1);m++){
            compileStr += GetLine(m);
        }
    }else{      //down
        var tLine = "";
        for(m=startLineIndex;m<numLines;m++){
            
            tLine = GetLine(startLineIndex + m);
            compileStr += tLine;         
        }
        tLine = GetOtherLines(startLineIndex+1);
        compileStr += tLine;
    }
    //remove last separator
    compileStr = compileStr.substring(0,compileStr.length-4);
    return compileStr;
}      

function GetLine(num){
    var storedTextElement = document.getElementById("maincontentleft");
    var storedText = storedTextElement.innerHTML;
    var arr = storedText.split("<BR>");
    if( (arr[(num-1)] + "").indexOf("undefined")!=-1){
        return "";
    }
    return arr[(num-1)] + "<BR>";
}

function GetOtherLines(chopLineNum){
    var hiddenLinesStr = "";
    for(a=1;a<=chopLineNum;a++){
        hiddenLinesStr += GetLine(a);
    }
    return hiddenLinesStr;
}

function GetTopLineIndex(){
    var indexresult=1;    
    var storedText = document.getElementById("contentcopy");
    var activeText = document.getElementById("maincontentleft");
    var activeArr = activeText.innerHTML.split("\n");
    var storedArr = storedText.innerHTML.split("\n");
    for(x=0;x<storedArr.length;x++){
        if(storedArr[x] == activeArr[0]){
            indexresult = x;
        }
    }
    return indexresult+1;
}

function RenderText(strHTML,direction,lineNumber,numLines){
    var activeDiv = document.getElementById("maincontentleft");
    activeDiv.innerHTML = strHTML;    
    //alert(numLines + ":" + lineNumber);
    Repeat(10,direction,lineNumber);   
}

function RenderThis(strHTML){
    var activeDiv = document.getElementById("maincontentleft");
    activeDiv.innerHTML = strHTML;    
}

function Repeat(times, dir, lineNumber){
    for(i=0;i<times;i++){
        if(dir=="down"){
            window.setTimeout("loopDown()",(i*100));
        }else{
            window.setTimeout("loopUp()",(i*100));
        }
    }
}
*/
function SetLayers(){
    var scrollingDiv = document.getElementById("maincontentleft");
    //var parentDiv = document.getElementById("maincontent");
    //parentDiv.style.zIndex = 10;
    alert(scrollingDiv.id);
    //scrollingDiv.style.zIndex = parentDiv.style.zIndex+1;
    
}

function scrollUp(){
    SetLayers();
    GoUp();
}

function scrollDown(){
    SetLayers();
    GoDown();
}

function stopScroll(){   
   return false;
}

function GoUp(){
    var elevator = document.getElementById("scrollElevator");
    DecreaseHeight(elevator);
    Repeat(20,"up");   
}
    

function GoDown(){
    var elevator = document.getElementById("scrollElevator");
    IncreaseHeight(elevator);
    Repeat(20,"down");   
}
function Repeat(times, dir){
    for(i=0;i<times;i++){
        if(dir=="down"){
            window.setTimeout("LoopDown()",(i*50));
        }else{
            window.setTimeout("LoopUp()",(i*50));
        }
    }
   }
function LoopUp(){
    var elevator = document.getElementById("scrollElevator");
    DecreaseHeight(elevator);  
}

function LoopDown(){
    var elevator = document.getElementById("scrollElevator");
    IncreaseHeight(elevator);  
}

function DecreaseHeight(el){
    el.style.height = (parseInt(el.style.height.replace("px",""))-5) + "px";
    
}
function IncreaseHeight(el){
    el.style.height = (parseInt(el.style.height.replace("px",""))+5) + "px";
  
}
function Swap(sectStr,onOff){
			var navImg = document.getElementById(sectStr);
            if(onOff == "on"){
                navImg.src = navImg.src.replace("off","on");
            }else if(onOff == "off"){
                navImg.src = navImg.src.replace("on","off");
            }
        }
        
        //' Pops up a new window at the upper left of screen
function PopIt(page, widthVal, heightVal){ 
    var newWnd = window.open( page, 'popupWindow', 'status,resizable,scrollbars,width=' + widthVal + ',height=' + heightVal + ',left=' + screen.availLeft + ',top=' + screen.availTop + '', true ); 
    newWnd.focus(); 
}

function PreviewNews(url){
	    //' Opens a new window 
			var newWnd1 = window.open( url, 'popupWindow1', 'resizable,scrollbars,width=650,height=500', false ); 
			newWnd1.focus();
			newWnd1.name = "popupWindow2";
	}