
function ajaxLoadObject (url, divID) {
	makeHttpRequest ( url, 'fadeDiv', false, divID );
}

function ajaxLoadObjectNoFade (url, divID) {
	makeHttpRequest ( url, 'noFadeDiv', false, divID );
}

function makeHttpRequest(url, callback_function, return_xml, divID)
{
   var http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly your browser doesn\'t support this feature.<br/> Please upgrade to <a href="http://www.mozilla.com">Mozilla</a>.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML,divID)' );
               } else {
                   eval(callback_function + '(http_request.responseText,divID)' );
               }
           } else {
               document.getElementById('ERROR_BOX').innerHTML =  'There was a problem with the request.(Code: ' + http_request.status + ') URL:' + url;
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}

function fadeDiv (response, divID) {
	obj = document.getElementById(divID);
	setOpacity(obj,0);
	obj.innerHTML = response;
	fadeIn(divID,0);
}

function noFadeDiv (response, divID) {
	obj = document.getElementById(divID);
	obj.innerHTML = response;
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.KHTMLOpacity = opacity/100;
  obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 20;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function emailWindow(emailID) {
	var load = window.open('emailForm.php?emailID='+emailID,'','scrollbars=yes,menubar=no,height=550,width=720,resizable=yes,toolbar=no,location=no,status=no');	
}

function deleteConfirmation()
{
	if (confirm("Are you really sure you want to delete this?\n\nOnce deleted it will be gone forever.  We will not store a backup of it, so once you delete it, if you made a mistake, you will have to come back and type it in all over again. And any ways, what you probably really want to do - if you meant to hit the delete button in the first place - is just set the status of this record to inactive."))
	{ return true; }
	else { return false; }
}

function membersOnly()
{
	if (confirm('This feature is available only for Pro-Members. Would you like to subscribe now?')) {
		window.location='/register.php';
	} else {
		void(0);
	}
}

function addAttachmentForm (num) {
	var thisAttachmentForm = document.getElementById('attachment'+num);
	var newNum = num + 1;
	var attachmentsSpan = document.getElementById('attachmentSpan'+num);
	if (thisAttachmentForm.value != '') {
		attachmentsSpan.innerHTML = '<input type="file" name="attachment'+newNum+'" id="attachment'+newNum+'" onChange="javascript:addAttachmentForm('+newNum+');" style=\"margin-bottom:4px;\" /><br/><span id="attachmentSpan'+newNum+'"></span>';
	}
}

function playSound(soundname) {
	try {
		soundname.Stop();
		soundname.Rewind();
	} catch (e) {
	}
	
	try {
	soundname.DoPlay();
} catch (e) {
	soundname.Play();
	}
}

function stopSound(soundname) {
	try {
		soundname.Stop();
		soundname.Rewind();
	} catch (e) {
	}
}

function flashCardsDropDown () {
	var flashCardsLink = document.getElementById('flashCardsLink');
	var flashCards = document.getElementById('flashCards');
	flashCards.style.display = 'block';
}

function gamesDropDown () {
	var gamesLink = document.getElementById('gamesLink');
	var games = document.getElementById('games');
	games.style.display = 'block';
}

function audioImmersionDropDown () {
	var audioImmersionLink = document.getElementById('audioImmersionLink');
	var audioImmersion = document.getElementById('audioImmersion');
	audioImmersion.style.display = 'block';
}

function referenceDropDown () {
	var  referenceLink = document.getElementById('referenceLink');
	var  reference = document.getElementById('reference');
	reference.style.display = 'block';
}

function cookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}

function translationControl (action) {
	if (action == 'hide') {
		cookie('showTranslation','hide',90);
		document.getElementById('english').className='translationHidden';
		document.getElementById('translationControl').innerHTML='Show Translation';
		document.getElementById('translationControl').href="javascript:translationControl('show');";
	} else if (action == 'show') {
		cookie('showTranslation','show',90);
		document.getElementById('english').className='translationShown';
		document.getElementById('translationControl').innerHTML='Hide Translation';
		document.getElementById('translationControl').href="javascript:translationControl('hide');";
	}
}

