<!--


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(random_key) {
	var youtube_url = document.getElementById('q').value;
	if(youtube_url.length>8){

		// disable both text and button field
		document.getElementById("q").disabled = true;
		document.getElementById("b").disabled = true;
		
		// display loading things
		loading();
		
		// okay, send request to starfleet
		http.open('get', 'robot.php?key='+random_key+'&url='+youtube_url);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
	else{
		// yeah, at least please tell me what to download :P
		alert('Please enter video URL you wish to download.');
	}
}
function handleResponse() {
    if(http.readyState == 4){
       	var response = http.responseText;
        
		document.getElementById("result").innerHTML = response;
		
		// undisabled all disabled items
		document.getElementById("q").disabled = false;
		document.getElementById("b").disabled = false;
		document.getElementById("q").value = '';
        return false;
        //}
    }
}

function loading(){
	document.getElementById("result").innerHTML = "<p><img src='img/o.gif' alt='loading..' /></p>";
	return false;
}


// this is a hack for IE T_T
var newdiv = document.createElement("div");
var container = document.getElementById("result");
container.appendChild(newdiv);

-->

