var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest();
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}



var http = httprequest;
function savedata(div) // Start Function
{ 	
	var page= 'getdata.php';
	if (http){
	var obj = document.getElementById('target');
	obj.innerHTML=' ';
	var postString = 'text1=' + document.getElementById('csshandler').value;
	http.open("POST",page,true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    http.setRequestHeader("Content-length", postString.length); 
    http.setRequestHeader("Connection", "close"); 
	http.send(postString);
	http.onreadystatechange = function()
	
	
		{
			if (http.readyState == 4 && 
			http.status == 200){
				obj.innerHTML = http.responseText;
			}
			
	}

	}
	
}

function altered(){
var obj=document.getElementById('target');
	obj.innerHTML="<font color='red'> The file has been edited, but not saved. </font>";
}//End Function 



function getInfo(active) // Start Function
{
	if (http){
		var obj = document.getElementById('rightColContent');
		http.open("GET","classes/getdata.php?action=getcontent&active="+active ,true);
		http.onreadystatechange = function()
		
		{
			if (http.readyState == 4 && 
			http.status == 200){
				obj.innerHTML = http.responseText;
			}
				
	}
	http.send(null);
	} 
}

function getCables(cat) {
	if (http){
		var proddiv = document.getElementById('prodtl');

		http.open("GET","classes/getdata.php?action=getcables&cat="+cat ,true);
		proddiv.innerHTML = "";
		http.onreadystatechange = function()
	
		{
			if (http.readyState == 4 && 
			http.status == 200){
				obj.innerHTML = http.responseText;
			}
				
	}
	http.send(null);
	} 
}
function product(product){
	if (http){
		var obj = document.getElementById('prodtl');
		http.open("GET","classes/getdata.php?action=getproduct&prod="+product ,true);
		http.onreadystatechange = function()
		
		{
			if (http.readyState == 4 && 
			http.status == 200){
				obj.innerHTML = http.responseText;
			}
				
	}
	http.send(null);
	} 
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=200,height=200');");
}
function popUpGoo(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=900,height=450');");
}

function submitcontact()
{ 	
	if (document.getElementById('txtMessage') != "" && document.getElementById('txtName') != ""){
	
	var page= 'classes/submitform.php';
	if (http){
	var obj = document.getElementById('contactForm');
	var postString = 'name=' + document.getElementById('txtName').value + '&howheard=' + document.getElementById('ddlHowHeard').value + '&text=' + document.getElementById('txtMessage').value + '&email=' + document.getElementById('txtEmail').value;
	http.open("POST",page,true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    http.setRequestHeader("Content-length", postString.length); 
    http.setRequestHeader("Connection", "close"); 
	http.send(postString);
	http.onreadystatechange = function()
	
	
		{
			if (http.readyState == 4 && 
			http.status == 200){
				obj.innerHTML = http.responseText;
			} else {
				obj.innerHTML = "Sending...";
			}
			
	}

	}
	}
	else{
document.getElementById('target').innerHTML = "<font color='red'>Please check all required fields </font>";	
	}

}



		function isemail(email) {
if (http){
		document.getElementById('submitbutton').disabled=true;
		var obj = document.getElementById('target');
		http.open("GET","classes/submitform.php?checkemail&email=" +email);
		http.onreadystatechange = function()
		
		{
			if (http.readyState == 4 && 
			http.status == 200){
				if (http.responseText != 'false'){
					submitcontact();
				} else
				obj.innerHTML="<font color='red'>The E-mail address you provided is not valid.</font>";
				document.getElementById('submitbutton').disabled=false;
				
				}
				
	}
	http.send(null);
	} 
   
 


}


				
	
