/*
This is a simple javascript to deal with multiple clicks on a
button or a link.  When invoked, only the first click will be
processed.  Subsequent clicks within a pre-defined interval
after the first click will be ignored.  The time interval is
configurable by the "timeInterval" value (in milliseconds) below.

	for a form - use onSubmit event

		<form.......onSubmit="return checkFirst()">

	for a link - use onClick event

		<a........onClick="return checkFirst()">
*/
	// time interval to reset the lock....30 seconds for now
	var timeInterval = 30000;

	var iCount = 0;
	var clickTime = 0;
	var againTime = 0;
	var timeDiff = 0;

	function checkFirst() {

		if (iCount==0) {
			iCount++;
			var now = new Date();
			clickTime = now.getTime();
			return true;

		} else {

			iCount++;
			var now = new Date();
			againTime = now.getTime();

			if (clickTime != 0) {
				timeDiff = againTime - clickTime;
				if (timeDiff > timeInterval) {  // release the lock
					clickTime = againTime;
					return true;
				}
				else {
					return false;
				}
			}
			return false;
		}
	}

/* script to go to the dropdown url */
function changePage(newLoc)
 {
   nextPage = newLoc.options[newLoc.selectedIndex].value

   if (nextPage != "")
   {
      document.location.href = nextPage
   }
 }

/* open a new window */
function popWindow(windowName, fileName, winX, winY, menuY)
    {

			var params = "width=" + winX + ",height=" + winY + ",menubar=" + menuY + ",resize=no,scrollbars=yes";
			newWin = window.open(fileName, windowName, params);
			newWin.creator=self;
			newWin.focus();

      //eval(windowName +' = window.open("' + fileName + '", "'+ windowName +'", "width=' + winX + ',height=' + winY + ',menubar=' + menuY + ',resize=no,scrollbars=yes");');
      //eval(windowName + '.creator=self;');
    }

function MM_openBrWindow(theURL,winName,features) { //v2.0
        newWin = window.open(theURL,winName,features);
        newWin.focus();
      }

function ClosePop(sendTo) {
	  if(sendTo) { window.opener.location = sendTo; }
	  window.close(); }


function PopQuiz(popPage) {
if(!popPage) { popPage = "/harl/empty.htm"; }
var popName = "quiz"; // target=quiz in form
var popSize = "width=450,height=600,resizable,scrollbars";
popWindow = window.open(popPage,popName,popSize);
if(!popWindow.opener) { popWindow.opener = window; }
popWindow.focus();
if(document.quiz) { document.quiz.submit(); } }


function pollPopper() {
var popPage = "http://poll.eharlequin.com/blank.htm";
var popName = "popper";
var popSize = "width=450,height=500,resizable,scrollbars"
var pop = open(popPage,popName,popSize);
pop.focus(); }


/* --- Script for More than Words Begin ---*/
if(document.images)
{
 nav_about_a = new Image(); nav_about_a.src = "/images/charity/about_2.jpg";
 nav_about_i = new Image(); nav_about_i.src = "/images/charity/about_1.jpg";

 nav_submit_a = new Image(); nav_submit_a.src = "/images/charity/submit_2.jpg";
 nav_submit_i = new Image(); nav_submit_i.src = "/images/charity/submit_1.jpg";

 nav_story_a = new Image(); nav_story_a.src = "/images/charity/story_2.jpg";
 nav_story_i = new Image(); nav_story_i.src = "/images/charity/story_1.jpg";

 nav_contribute_a = new Image(); nav_contribute_a.src = "/images/charity/contribute_2.jpg";
 nav_contribute_i = new Image(); nav_contribute_i.src = "/images/charity/contribute_1.jpg";

 nav_getinv_a = new Image(); nav_getinv_a.src = "/images/charity/getinvolve_2.jpg";
 nav_getinv_i = new Image(); nav_getinv_i.src = "/images/charity/getinvolve_1.jpg";

 nav_faq_a = new Image(); nav_faq_a.src = "/images/charity/faq_2.jpg";
 nav_faq_i = new Image(); nav_faq_i.src = "/images/charity/faq_1.jpg";

}

function switchImages (ImageName2BChanged, objImage,   objInfoImage){
  if (document.images){
  	window.document[ImageName2BChanged].src=objImage.src;
  	}
}

function OpenWindow(s)
    {
		msgWindow=window.open(s, "contactWindow", "toolbar=no,width=375,height=500,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
		msgWindow.focus();
	}

/* --- Script for More than Words End ---*/
var popPage = "";

function PopWindow(popPage) {
var popName = "new";
popWindow = window.open(popPage,popName);
popWindow.focus(); }

function popQuizzes(popPage) {
if (popPage == "aomquiz.htm")
{
	popPage = "/harl/books/alcove/quiz/aomquiz.htm";
	var popName = "quiz"; // target=quiz in form
	var popSize = "width=450,height=600,resizable,scrollbars";
	popWindow = window.open(popPage,popName,popSize);
	if(!popWindow.opener) { popWindow.opener = window; }
		popWindow.focus();
	if(document.quiz) { document.quiz.submit(); }
}
else
{
	var popPage = "http://poll.eharlequin.com/cgi-bin/tallies.cgi?quiz=" + popPage + "&proceed=proceed";
	var popName = "quiz";
	var popSize = "width=450,height=550,resizable,scrollbars";
	popWindow = window.open(popPage,popName,popSize);
	if(!popWindow.opener) { popWindow.opener = window; }
		popWindow.focus();
}
}


function PopThesaurus() {
var popPage = "/harl/books/readingroom/thesaurus/20thes11.htm";
var popName = "thesaurus";
var popSize = "width=400,height=400,resizable,scrollbars";
popWindow = window.open(popPage,popName,popSize);
if(!popWindow.opener) { popWindow.opener = window; }
popWindow.focus();}

function PopCard(popPage) {
var popName = "card";
var popSize = "width=530,height=550,resizable,scrollbars";
popWindow = window.open(popPage,popName,popSize);
popWindow.focus(); }


function popvideo(desturl,winw,winh) {
var sWin;
  if (!((winw)&&(winh))) {
   winw = 640;
   winh = 480;
  }
  var scrw = 640;
  var scrh = 480;
  if ((document.layers)||(document.all)) {
    scrw = screen.width;
    scrh = screen.height;
  }
  winx = (scrw-winw)/2;
  winy = (scrh-winh)/2;
  if ((sWin) && (!sWin.closed)) { sWin.close(); }
  sWin = window.open(desturl,"_blank","toolbar=no,location=no,directories=no,resizable=no,scrollbars=no,status=yes,menubar=no,width="+winw+",height="+winh+",screenX="+winx+",screenY="+winy+",left="+winx+",top="+winy);
  return false;
}

function new_win(src) {

   window.open(src, "mywin", "width=550,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes");

}

function PopDaily(popPage)
{
		var popName = "card";
		var popSize = "width=400,height=550,resizable,scrollbars";
		popWindow = window.open(popPage,popName,popSize);
		popWindow.focus();
}
