﻿// JavaScript Document
var xmlhttp=false;
    try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
function gotoFlipCard(rID) {
    varSRC = "flashcard.asp?rowid=" + rID;
    document.searchform.action = varSRC;
    document.searchform.method = "post";
    document.searchform.submit();
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function gotoFlipCard3(aref, rID) {
    varSRC = "flashcard.asp?rowid=" + rID;
    aref.href = varSRC;
}
function gotoEdit2(frmname, rID) {
    var form1 = eval("document." + frmname);
    varSRC = "addword.asp?rowid=" + rID;
    form1.action = varSRC;
    form1.method = "post";
    form1.submit();
}
function showLoginAlert(inAlert) {
    alert(inAlert);
}
// 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 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 getIEFix() {
    objects = document.getElementsByTagName("object");
    for (var i = 0; i < objects.length; i++)
    {
        objects[i].outerHTML = objects[i].outerHTML;
    }
}
function saverelevance(rowID, varVal) {
	if (xmlhttp) {
		str1 = "?rowid=" + rowID + "&status=" + varVal ;

		url = "addrelevance.asp" + str1;
		xmlhttp.open("GET", url);
		xmlhttp.onreadystatechange=function() {
		   if (xmlhttp.readyState==4) {
		        if (xmlhttp.responseText.length > 0) {
		            //alert("test" + xmlhttp.responseText);
		            alert("there was a problem setting the words relevance rating.  Please notify the webmaster if this continues.");
		        } else {
		        	
		        	if (varVal == 'good') {
						if (document.getElementById("imgThumbU")) {
							document.getElementById("imgThumbU").src="pageimages/thumb_upon.gif";
						}
		        		document.getElementById("imgThumbD").src="pageimages/thumb_down.gif";
		        	} else if (varVal == 'bad') {
		        		if (document.getElementById("imgThumbU")) {
			        		document.getElementById("imgThumbU").src="pageimages/thumb_up.gif";
						}
		        		document.getElementById("imgThumbD").src="pageimages/thumb_downon.gif";
		        	}
		        	
		        	varTemp = document.getElementById('divMessage').innerHTML
		            document.getElementById('divMessage').innerHTML = varTemp + "<strong>The current word has been marked as: <font size=+1>" + varVal + "</font></strong>. <br>We appreciate user input like this. Please do it often.<BR>";
		        }
		   }
		}  
		xmlhttp.send(null);
	}
}
function saverelevance2(rowID, varVal, inComment, inImage, inSecondImage) {
   var xmlhttp=false;

// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
str1 = "?rowid=" + rowID + "&status=" + varVal ;
url = "addrelevance.asp" + str1;
xmlhttp.open("GET", url);
xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
        if (xmlhttp.responseText.length > 0) {
            //alert("test" + xmlhttp.responseText);
            alert("there was a problem setting the words relevance rating.  Please notify the webmaster if this continues.");
        } else {
        	
        	if (varVal == 'good') {
				if (document.getElementById(inImage)) {
					document.getElementById(inImage).src="pageimages/thumb_upon.gif";
				}
        		document.getElementById(inSecondImage).src="pageimages/thumb_down.gif";
        	} else if (varVal == 'bad') {
        		if (document.getElementById(inImage)) {
	        		document.getElementById(inImage).src="pageimages/thumb_downon.gif";
				}
        		document.getElementById(inSecondImage).src="pageimages/thumb_up.gif";
        	}
        	
        	varTemp = document.getElementById(inComment).innerHTML
            document.getElementById(inComment).innerHTML = varTemp + "<strong>The current word has been marked as: <font size=+1>" + varVal + "</font></strong>. <br>We appreciate user input like this. Please do it often.<BR>";
        
        }
   }
}  
xmlhttp.send(null);
}
function buttonMouseOver(obj) {
obj.style.cursor= "pointer"; 
obj.style.border= "solid 1px rgb(80,80,80)"; 
obj.style.background= "rgb(220,220,220)"; 
obj.style.color= "rgb(80,80,80)";
}
function buttonMouseOut(obj) {
obj.style.background= "rgb(235,235,235)"; 
obj.style.color= "rgb(150,150,150)";
}
function gotoregister() {
	//txtLoginID = document.getElementById("uid");
	form1 = document.getElementById("formlogin");
	form1.action = "register.asp";
	form1.submit();
}
function saveWord(rowID, varVal, varList_ID, divcomment, divimage) {
   var xmlhttp=false;
	var varNewName=(arguments.length>5)?arguments[5]:"";
	//alert("varNewName: " + varNewName);
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
str1 = "?rowid=" + rowID + "&status=" + varVal + "&listid=" + varList_ID + "&newname=" + varNewName;
url = "addSaved.asp" + str1;
//alert ("url: " + url);
xmlhttp.open("GET", url);
xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
        if (xmlhttp.responseText.length > 0) {
            alert("error: " + xmlhttp.responseText+"  there was a problem saving this word.  Please notify the webmaster if this problem continues to happen.");
        } else {
        	if (varVal == "add") {
	        	varTemp = document.getElementById(divcomment).innerHTML
	            document.getElementById(divcomment).innerHTML = varTemp + "<strong>This Word has been added to the selected list.</strong>";
	            document.getElementById(divimage).src="pageimages/lock_add.gif";
        	} else if (varVal == "copy") {
        		varTemp = document.getElementById(divcomment).innerHTML
	            document.getElementById(divcomment).innerHTML = varTemp + "<strong>This list has been copied to your own list set.</strong>";
	            document.getElementById(divimage).src="pageimages/lock_add.gif";
        	} else {
        		varTemp = document.getElementById(divcomment).innerHTML
	            document.getElementById(divcomment).innerHTML = varTemp + "<strong>This Word has been deleted from your General Personal Word List.</strong>";
	            document.getElementById(divimage).src="pageimages/tick_red.gif";
        	}
        }
   }
}  
xmlhttp.send(null);
}
function gotoPrevious(currentID) {
	pageform = document.getElementById("flipcardform");
	pageform.action = "flashcard.asp?gotoprevious=" + currentID;
	pageform.submit();
}
function saverating(rowID, varVal, tagname, tagnameoff1, tagnameoff2) 
{
	str1 = "?rowid=" + rowID + "&rating=" + varVal ;
	varValString = "";
	if (varVal == 1) varValString = "easy";
	if (varVal == 2) varValString = "medium";
	if (varVal == 3) varValString = "hard";
	url = "addrating.asp" + str1;
	xmlhttp.open("GET", url);
	xmlhttp.onreadystatechange=function() {
	   if (xmlhttp.readyState==4) {
	        if (xmlhttp.responseText.length > 0) {
	            //alert("test" + xmlhttp.responseText);
	            alert("there was a problem saving your ratings.  Please notify the webmaster if this continues.");
	        } else {
	        	varTemp = document.getElementById('divMessage').innerHTML
	            document.getElementById('divMessage').innerHTML = varTemp + "<strong>You have rated this word with a difficulty level of: " + varValString + "</strong><BR>";

	        }
	   }
	}
	var_showans = document.getElementById(tagname);
	var_showans.style.border = "1px solid red"
	var_showans = document.getElementById(tagnameoff1);
	var_showans.style.border = ""
	var_showans = document.getElementById(tagnameoff2);
	var_showans.style.border = ""
	xmlhttp.send(null);
}
function setPageHeight() {
}
function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
function SetCookie(cookieName,cookieValue) {
var nDays = 60;
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function popup(URL, ww, wh) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ww+",height="+wh+",left = 40,top = 40');");
}
function docollapse(thingstring) {
   thing = document.getElementById(thingstring);

   if (thing.style.height == '') {
	   thing.style.visibility = 'hidden';
	   thing.style.height = '0px';
	   thing.style.display = 'none';
   } else {
	   thing.style.visibility = 'visible'
	   thing.style.height = '';
	   thing.style.display = 'block';
   }
}