function getRadioVal()
{
for (var i=0; i < document.myform.numlistyn.length; i++)
   {
   if (document.myform.numlistyn[i].checked)
      {
      return document.myform.numlistyn[i].value;
      }
   }
}



function ajaxFunction(n){
//var progress_bar = new Image();
//progress_bar.src = 'images/load.gif';
document.getElementById('content_new').innerHTML='<div align="center"><img src = "images/load.gif"  border="0" alt="Loading..." /></div>';
	var http;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		http = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
var def = encodeURIComponent(document.getElementById('p1').value);
var url = "modules/test.inc.php";
if(n == 0)
  var params = "par1=" + def + "&numlist=" + document.getElementById("numlist").checked + "&alpha=" + document.getElementById("alpha").checked +"&numlistyn=" + getRadioVal() + "&max=" +  document.getElementById("max").value + "&random=" + document.getElementById("random").checked+ "&check=0"+"&partof=" + document.getElementById("partof").checked; 
else
  var params = "par1=" + def + "&numlist=" + document.getElementById("numlist").checked + "&alpha=" + document.getElementById("alpha").checked +"&numlistyn=" + getRadioVal() + "&max=2" + "&random=" + document.getElementById("random").checked + "&check=1"+"&partof=" + document.getElementById("partof").checked; 


http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		document.getElementById('content_new').innerHTML = http.responseText;
	}
}
http.send(params);
}




//synonmys and flashcards
function ajaxFunction3(str,b,rl){
//var progress_bar = new Image();
//progress_bar.src = 'images/load.gif';
if(str == "Syn")
	document.getElementById('content_here').innerHTML='<div align="center"><img src = "images/load.gif"  border="0" alt="Loading..." /></div>';
else if (str != "flal")
	document.getElementById('temploader').innerHTML='Loading...';
else
	document.getElementById('temploader2').innerHTML='Loading...';
	var http;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		http = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
var def = encodeURIComponent(document.getElementById('p1').value);
if(str =="Syn")
	var url = "modules/syn.inc.php";
else if(str == "syn")
	var url = "modules/make_synonyms.inc.php";
else
	var url = "modules/make_flashcards.inc.php";
	
var para = "par1=" + def + "&numlist=" + document.getElementById("numlist").checked + "&random=" + document.getElementById("random").checked + "&check=" + document.getElementById("numlist").checked + "&alpha=" + document.getElementById("alpha").checked +"&numlistyn=" + getRadioVal() + "&max=" +  document.getElementById("max").value + "&partof=" + document.getElementById("partof").checked +"&ht=" + b; 


http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", para.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		if(str =="Syn" || str == "quiz")
			document.getElementById('content_here').innerHTML = http.responseText;
		else if(str != 'flal'){
			document.getElementById('temploader').innerHTML='';
			location.replace('?p=' + rl);
			}
		else{
			document.getElementById('temploader2').innerHTML ='';
			location.replace('?p=' + rl);
		}
		    
		
	}
}
http.send(para);
}






function quiz(str){
//var progress_bar = new Image();
//progress_bar.src = 'images/load.gif';
//if(str == "Syn")
	document.getElementById('content_here').innerHTML='<div align="center"><img src = "images/load.gif"  border="0" alt="Loading..." /></div>';

	var http;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		http = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
var def = encodeURIComponent(document.getElementById('p1').value);
if(str =="quiz1" || str =="quiz2"  || str =="quiz3" )
	var url = "modules/make_flashcards.inc.php";
else
	var url = "modules/make_synonyms.inc.php";
	
var para = "par1=" + def + "&numlist=" + document.getElementById("numlist").checked + "&random=" + document.getElementById("random").checked + "&check=" + document.getElementById("numlist").checked + "&alpha=" + document.getElementById("alpha").checked +"&numlistyn=" + getRadioVal() + "&max=" +  document.getElementById("max").value + "&partof=" + document.getElementById("partof").checked +"&ht=0"; 


http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", para.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		if(str =="Syn" || str == "quiz")
			document.getElementById('content_here').innerHTML = http.responseText;
		else if(str != 'flal'){
			document.getElementById('temploader').innerHTML='';
			location.replace('?p=' + rl);
			}
		else{
			document.getElementById('temploader2').innerHTML ='';
			location.replace('?p=' + rl);
		}
		    
		
	}
}
http.send(para);
}








function ajaxFunction2(){
document.getElementById('conf').innerHTML='<div align="center"><img src = "images/ajax-loader.gif"  border="0" alt="Loading..." /></div>';
	var http;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		http = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
var to = encodeURIComponent(document.getElementById('to').value);
var url = "modules/email.inc.php";
var params = "to=" + to ;
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		document.getElementById('conf').innerHTML = http.responseText;
	}
}
http.send(params);
}



function ajaxFunction4(){
	var http;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		http = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
var url = "modules/update.inc.php";
var params = "hi=2";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

	if(http.readyState == 4 && http.status == 200) {
http.onreadystatechange = function() {//Call a function when the state changes.
	}
}
http.send(params);
}




function modalClose (dialog) {
	dialog.data.fadeOut('fast', function () {
		dialog.container.slideUp('fast', function () {
				dialog.overlay.fadeOut('fast', function () {
		        $.modal.close(); 
		      });

		});
	});
}

function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.slideDown('fast', function () {
			dialog.data.fadeIn('fast');
		});

});
}
