// JavaScript Document


function playSound(soundname) {
 var sound = eval("document." + soundname);

 // make an effort to stop and rewind any playback
 // already in progress so that the sound starts over.
 // Otherwise this call has no effect when the sound
 // is already in progress. You can remove these lines
 // if you don't like this behavior.
 try {
  sound.Stop();
  sound.Rewind();
 } catch (e) {
  // A player that doesn't support
  // Stop and Rewind
 }

 try {
  // For RealPlayer-enabled browsers.
  // Some versions of RealPlayer do not
  // offer a Play() function and will
  // fail to play sound if we try to
  // call Play().
  sound.DoPlay();
 } catch (e) {
  // If DoPlay doesn't work, call Play.
  // This works for all other audio
  // plug-ins.
  sound.Play();
 }
}

function gotoFlipCard(rID) {
    varSRC = "index.asp?rowid=" + rID;
    document.searchform.action = varSRC;
    document.searchform.method = "post";
    document.searchform.submit();


}



// Pop-Up Embedder Script by David Battino, www.batmosphere.com; Object tag implementation by Mark Levitt, http://digitalmedia.oreilly.com
var UniqueID = 314 // Make each link open in a new window.
var newWinOffset = 0 // Position of first pop-up
function PlayerOpen(soundfiledesc,soundfilepath) {

PlayWin = window.open('',UniqueID,'width=320,height=190,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
PlayWin.focus(); 
var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE></HEAD><BODY bgcolor='grey'>";
winContent += "<B style='font-size:18px;font-family:Verdana,sans-serif;line-height:1.5'>" + soundfiledesc + "</B>";

winContent += "<OBJECT width='300' height='42'>";
winContent += "<param name='SRC' value='" +  soundfilepath + "'>";
winContent += "<param name='AUTOPLAY' VALUE='true'>";
winContent += "<param name='CONTROLLER' VALUE='true'>";
winContent += "<param name='BGCOLOR' VALUE='grey'>";
winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='grey'></EMBED>";
winContent += "</OBJECT>";

winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='"+soundfilepath+"'>Download this file</a> <SPAN style='font-size:10px'>(right-click or Option-click)</SPAN></p>";

winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onClick='javascript:window.close();'></DIV></FORM>";
winContent += "</BODY></HTML>";
PlayWin.document.write(winContent);
PlayWin.document.close(); // "Finalizes" new window
UniqueID = UniqueID + 1
newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower.
}


rowcount=1;
function toggleDivIndex(divName) {
    answerDiv = document.getElementById("answer");
        
    if (answerDiv.style.visibility == "hidden") {
        answerDiv.style.visibility = "visible";
        document.getElementById('button2').value='Hide Answer';
    }
    else {
        answerDiv.style.visibility = "hidden";
        document.getElementById('button2').value='View Answer';
    }
    document.flipcardform.btnNext.focus();
}

function showdiv(div1, type) {
    div = document.getElementById(div1);
    div.style.visibility = "visible";
    if (type == 1) div.style.display = "inline";  
    if (type == 2) div.style.display = "none"; 
    if (type == 3) div.style.display = "block"; 
}

function hidediv(div1, type) {
    div = document.getElementById(div1);
    div.style.visibility = "hidden";
    if (type == 1) div.style.display = "inline";  
    if (type == 2) div.style.display = "none"; 
    if (type == 3) div.style.display = "block";    
}

function fncShowTextBoxAgain()
{
    answerDiv = document.getElementById("answer");
    answer1Div = document.getElementById("answer1");
    typedDiv = document.getElementById("txtAnswer");
    txthidden = document.getElementById("hiddenans");
    txttest = document.getElementById("answerTxtBox");
    txttest.style.visibility = "visible";
    txttest.style.display = "block";
    varAnswer = txthidden.value;

    answer1Div.style.visibility = "hidden";
    answer1Div.style.display = "none";
    answerDiv.style.visibility = "hidden";
        answerDiv.style.display = "none";
        document.getElementById('button1').value='View Answer';
}

function toggleDivAndCount() {
    answerDiv = document.getElementById("answer");
    answer1Div = document.getElementById("answer1");
    typedDiv = document.getElementById("txtAnswer");
    txthidden = document.getElementById("hiddenans");
    txttest = document.getElementById("answerTxtBox");
    txttest.style.visibility = "hidden";
    txttest.style.display = "none";
    varAnswer = txthidden.value;
   <!--  document.flipcardform.nextbutton.focus(); -->
    if (!(varAnswer.indexOf(typedDiv.value) == -1) && typedDiv.value.length > 0) 
    {
        inpcountRight = document.getElementById("countRight");
        temp = inpcountRight.value
        if (temp != "") {
            count = parseInt(temp) + 1;
            inpcountRight.value = count;
        }
        else
        {
            inpcountRight.value = 1;
        }
        answerDiv.style.color = "black";
    }    
    else 
    {
        inpcountWrong = document.getElementById("countWrong");
        temp = inpcountWrong.value
        if (temp != "") {
            count = parseInt(temp) + 1;
            inpcountWrong.value = count;
        }
        else
        {
            inpcountWrong.value = 1;
        }
        answerDiv.style.color = "red";
    }
    
    if (answer1Div.style.visibility == "hidden") {
        answer1Div.style.visibility = "visible";
        answer1Div.style.display = "block";
    }
    else {
        answer1Div.style.visibility = "hidden";
        answer1Div.style.display = "none";
    }
    if (answerDiv.style.visibility == "hidden") {
        answerDiv.style.visibility = "visible";
        answerDiv.style.display = "block";
        document.getElementById('button1').value='Hide Answer';
        showexample("img2","example2");
    }
    else {
        answerDiv.style.visibility = "hidden";
        answerDiv.style.display = "none";
        document.getElementById('button1').value='View Answer';
    }
}

function showexample(Div1,Div2) 
{
    divImage = document.getElementById(Div1);
    divText = document.getElementById(Div2);
    divText.style.visibility = "visible";
    divText.style.display = "inline";
    divImage.style.display = "none";

}

function fncChangeForSave() {
    btnNext = document.getElementById("nextbutton");
    btnNext2 = document.getElementById("btnNext");
    btnNext3 = document.getElementById("nextbutton2");
    btnNext.value = "Save Word";
    btnNext2.value = "Save Word";
    btnNext3.value = "Save and Go To Next Word";
}

function hideSideBar() {
    SideBar = document.getElementById("divSideBar");
    count = document.getElementById("sidebarCount");
    btnDisplay = document.getElementById("btnhidesidebar");
    
    if (count.value == "1") {
        SideBar.style.visibility = "hidden";
        SideBar.style.display = "none";
        btnDisplay.value = "Show Sidebar"
        count.value = 2;
   } else {
        SideBar.style.visibility = "visible";
        SideBar.style.display = "inline";
        btnDisplay.value = "Hide Sidebar"
        count.value = 1;
   }
}

function toggleDivVerb(divName, Answer) {
    placesDiv = document.getElementById("places" + divName);
    answerDiv = document.getElementById("answer" + divName);
    checkansDiv = document.getElementById("hiddenans" + divName);
    imagestag = document.getElementById("images" + divName);
    if (placesDiv) {
        if (answerDiv.style.visibility == "hidden" || answerDiv.style.visibility == "") {
            if (placesDiv.value != checkansDiv.value) {
                answerDiv.style.color = "red";
            }
            answerDiv.style.visibility = "visible";
            answerDiv.style.display = "inline";
            placesDiv.style.visibility = "hidden";
            placesDiv.style.display = "none";
            imagestag.src = "pageimages/hidesmall.jpg";
            
        }
        else {
            answerDiv.style.color = "black";
            answerDiv.style.visibility = "hidden";
            answerDiv.style.display = "none";
            placesDiv.style.visibility = "visible";
            placesDiv.style.display = "inline";
            imagestag.src = "pageimages/answersmall.jpg";
            
        }
    }
    else {
        alert("Error: Could not locate div with id: " + divName);
    }
}


function allcheckVerb(varSet)  {
    for (var i = 0; i < 17; i++) {
        increment = i + varSet
        placesDiv = document.getElementById("places" + increment);
        answerDiv = document.getElementById("answer" + increment);
        checkansDiv = document.getElementById("hiddenans" + increment);
        if (placesDiv) {
            if (placesDiv.value != checkansDiv.value) {
                answerDiv.style.color = "red";
            } else {
                answerDiv.style.color = "black";
            }
            answerDiv.style.visibility = "visible";
            answerDiv.style.display = "inline";
            placesDiv.style.visibility = "hidden";
            placesDiv.style.display = "none";
        }
    }

}

function allonVerb(varSet)  {
    for (var i = 0; i < 17; i++) {
        increment = i + varSet
        placesDiv = document.getElementById("places" + increment);
        answerDiv = document.getElementById("answer" + increment);
        imagestag = document.getElementById("images" + increment);
    
        if (placesDiv) {
            answerDiv.style.color = "black";
            answerDiv.style.visibility = "visible";
            answerDiv.style.display = "inline";
            placesDiv.style.visibility = "hidden";
            placesDiv.style.display = "none";
            imagestag.src = "pageimages/hidesmall.jpg";
        }
    }

}
function alloffVerb(varSet)  {
    for (var i = 0; i < 17; i++) {
        increment = i + varSet
        placesDiv = document.getElementById("places" + increment);
        answerDiv = document.getElementById("answer" + increment);
        imagestag = document.getElementById("images" + increment);
    
        if (placesDiv) {
            answerDiv.style.visibility = "hidden";
            answerDiv.style.display = "none";
            answerDiv.style.color = "black";
            placesDiv.style.visibility = "visible";
            placesDiv.style.display = "inline";
            imagestag.src = "pageimages/answersmall.jpg";
        }
    }

}
function toggleTenseVerb(varSet) {
    imgimagestense = document.getElementById("imagestense" + varSet);
    varSRC = imgimagestense.src;
    for (var i = 1; i < 5; i++) {
        increment = i + (varSet - 1) * 4;
        
        placesDiv = document.getElementById("places" + increment);
        answerDiv = document.getElementById("answer" + increment);
        checkansDiv = document.getElementById("hiddenans" + increment);
        imagestag = document.getElementById("images" + increment);
        if (placesDiv) {
            if (!(varSRC.indexOf("answer") == -1)) {
                if (placesDiv.value != checkansDiv.value) {
                    answerDiv.style.color = "red";
                }
                answerDiv.style.visibility = "visible";
                answerDiv.style.display = "inline";
                placesDiv.style.visibility = "hidden";
                placesDiv.style.display = "none";
                imagestag.src = "pageimages/hidesmall.jpg";
                imgimagestense.src = "pageimages/hidesmall.jpg";
                
            }
            else {
                answerDiv.style.color = "black";
                answerDiv.style.visibility = "hidden";
                answerDiv.style.display = "none";
                placesDiv.style.visibility = "visible";
                placesDiv.style.display = "inline";
                imagestag.src = "pageimages/answersmall.jpg";
                imgimagestense.src = "pageimages/answersmall.jpg";
                
            }
        }
        
    }
    
}