// Java Document

// cookie code

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

// end cookie code


// Poll Pop-up start

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=100;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-310;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

// Poll pop-up end


function downloadfile() {
	
	if(document.URL.indexOf("download3.html") >= 0){ 
		setTimeout("window.location.href='http://www.teachers-pet.org/dl/TeachersPet_installer.exe';",1800);
	}
	
/*	var survey_done=getCookie("survey_done");
	
	if (survey_done!=null && survey_done!=""){
	  	//alert("The cookie exists!"); 
		//DO NOTHING
	} else { 
		//if (document.URL.indexOf("vocabulary_word_list_public_places_flashcards.html") >= 0){ 
		setTimeout("popup('popUpDiv');",900);
		//}
	}*/

	
}


function checkForm() {
	word = document.getElementById("q").value;
	if (word == "") {
		alert('You have not entered a search word. Please try again.');
		return false;
	}
		return true;
	}

// Firefox Search Plugin Start

function addEngine(name, ext)
{
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
    window.sidebar.addSearchEngine(
      "http://mycroft.mozdev.org/external.php/" + name + ".src",
      "http://mycroft.mozdev.org/external.php/" + name + "."+ ext, "", "");
  } else {
    alert("You will need a browser which supports Sherlock to install this plugin.");
  }
}

function addOpenSearch(name,ext,meth)
{
  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
    } else {
      window.external.AddSearchProvider(
        "http://mycroft.mozdev.org/externalos.php/" + name + ".xml");
    }
  } else {
    alert("You will need a browser which supports OpenSearch to install this plugin.");
  }
}

// Firefox Search Plugin End

function display_google_search_radiobuttons(){
	document.getElementById('radiobuttons').style.display == "inline";
	}

function displayThisHideOthers(num, menuCount) {
	
	if(document.getElementById('menu'+num).style.display == "inline") {
		var menuOpen = 1;
	}
	
	for (i=1; (i<=menuCount); i++) {
		document.getElementById('menu'+i).style.display="none";
	}
	
	for (i=1; (i<=menuCount); i++) {
		document.getElementById('icon_across'+i).style.display="inline";
		document.getElementById('icon_down'+i).style.display="none";
	}
		
	if(menuOpen == 1) {
		document.getElementById('menu'+num).style.display="none";
		document.getElementById('icon_across'+num).style.display="inline";
		document.getElementById('icon_down'+num).style.display="none";
	} else {
		document.getElementById('menu'+num).style.display="inline";
		document.getElementById('icon_down'+num).style.display="inline";
		document.getElementById('icon_across'+num).style.display="none";
	}
					
}

function fieldCheck() {
	if (( document.getElementById('name').value == '' ) || ( document.getElementById('email').value  == '' ) || ( document.getElementById('message').value == '' ) || ( document.getElementById('code').value == '' )) {
		alert('Please complete all the required fields!');
		return false;
	}
}

function fieldCheck_getcode() {
	if (( document.getElementById('ref_num').value == '' ) || ( document.getElementById('name').value  == '' ) || ( document.getElementById('email').value == '' ) || ( document.getElementById('version').value == '' )) {
		alert('Please complete all the required fields!');
		return false;
	}
}

function fieldCheck_addlink() {
	if (( document.getElementById('name').value == '' ) || ( document.getElementById('email').value  == '' ) || ( document.getElementById('title').value  == '' ) || ( document.getElementById('description').value  == '' ) || ( document.getElementById('category').value  == '' ) || ( document.getElementById('url').value  == '' ) || ( document.getElementById('code').value == '' ) || ( document.getElementById('recipurl').value == '' )) {
		alert('Please complete all fields!');
		return false;
	}
}

function returntomerchant_alert() {
		alert('You will now be transferred to PayPal. When the payment is complete, you must click on the \'Return to Merchant\' link to generate your activation code.');
}

function returntomerchant_alert_sch() {
		alert('You will now be transferred to PayPal. When the payment is complete, you must click on the \'Return to Merchant\' link to complete the process.');
}

function toggleInfobox(myid) {
        o=document.getElementById(myid).style;

        if (o.display == "inline") o.display="none";
        else {
                o.display="inline";
        }
}

function bookmarksite(title,url){
	if (window.sidebar) // firefox
			window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} 
	else if(document.all)// ie
			window.external.AddFavorite(url, title);
}

//code for left menu

function MM_MyPreloadimages(images) { //v3.0
MM_preloadimages(images);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//END code for left menu

function showhide(areaid, areaid2) {
        o=document.getElementById(areaid).style;
		p=document.getElementById(areaid2).style;
        o.display="inline";
        p.display="none";
}

function show(areaid) {
        o=document.getElementById(areaid).style;
        o.display="inline";
}

function hide(areaid) {
        o=document.getElementById(areaid).style;
        o.display="none";
}



