//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 GetXmlHttpObject(){ 
    var objXMLHttp = null;
    
    if (window.XMLHttpRequest){
        try{
            objXMLHttp = new XMLHttpRequest();
        }catch (e){
            objXMLHttp = false;
        }
    }else if (window.createRequest){
        try{
            objXMLHttp = new window.createRequest();
        }catch (e){
            objXMLHttp = false;
        }
    }else if (window.ActiveXObject){
        try {
            objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            try {
                objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }catch (e){
                objXMLHttp = false;
            }
        }
    }
    
    return objXMLHttp;
}

function genAtt(){
	
	var att = document.getElementById("att").value;
	
	
	if (att == 0){ 
		toCat = "<select name='att_val' id='att_val'><option value='0'>Select Value</option></select>";
	
		document.getElementById("att_here").innerHTML="<span id='att_here'>"+toCat+"</span>";
		return;
  	}
		toCat = "<select name='att_val' id='att_val'><option value='0'>Select Value</option></select>";
	
		document.getElementById("att_here").innerHTML="<span id='att_here'>"+toCat+"</span>";
	
	xmlHttpx=GetXmlHttpObject()
	if (xmlHttpx==null){
  		alert ("Your browser does not support AJAX! \nThis page may not work properly.");
  		return;
  	} 
	
	var url="gen_att2.php";
	url=url+"?att="+att;
	url=url+"&sid="+Math.random();
	xmlHttpx.onreadystatechange=function() { 
		if (xmlHttpx.readyState==4){ 
			document.getElementById("att_here").innerHTML=xmlHttpx.responseText;
		}
	};
	xmlHttpx.open("GET",url,true);
	xmlHttpx.send(null);
	
}

