var http = createRequestObject();
var field;
function createRequestObject() {
	var xmlhttp;
	try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) {
	try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	catch(f) { xmlhttp=null; }
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}

function getLink() {
	url = encodeURIComponent(document.getElementById('url').value);
	action = encodeURIComponent(document.getElementById('action').value);
	http.open('POST', 'index.php');
	field = 'link_download';
	document.getElementById(field).innerHTML = "<center><img src='images/ajax-loader.gif'> Fetching video link</center>";
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponse;
	http.send('action='+action+'&url='+url);
	return false;
}

function handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			response = http.responseText;
			document.getElementById(field).innerHTML = response;
		}
  	}
	catch(e){}
	finally{}
}