//Ajax functions
//w3schools.com
function GetXmlHttpObject(){
	var xmlHttp=null;
  	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
  	catch (e){
    // Internet Explorer
		try{
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
    	catch (e){
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
    }
  	
	return xmlHttp;
} 

function genSC4(){
	
	var sc1 = document.getElementById("sc1").value; 
	var sc2 = document.getElementById("sc2").value;
	var sc3 = document.getElementById("sc3").value;
	
	if (sc3 == 0){ 
		
		document.getElementById("sc4_here").innerHTML="<span id='sc4_here'></span>";

		document.getElementById("sc4").value= 0;
		
		return;
  	}
	
		document.getElementById("sc4_here").innerHTML="<span id='sc4_here'></span>";
		
		document.getElementById("sc4").value= 0;
		
		
	xmlHttpx=GetXmlHttpObject();
	if (xmlHttpx==null){
  		alert ("Your browser does not support AJAX! \nThis page may not work properly.");
  		return;
  	} 
	
	var url="gen_sc4_cat.php";
	url=url+"?sc2="+sc2;
	url=url+"&sc1="+sc1;
	url=url+"&sc3="+sc3;
	url=url+"&sid="+Math.random();
	xmlHttpx.onreadystatechange=function() { 
		if (xmlHttpx.readyState==4){ 
			document.getElementById("sc4_here").innerHTML=xmlHttpx.responseText;
		}
	};
	xmlHttpx.open("GET",url,true);
	xmlHttpx.send(null);
	
}

