function get_http()
{
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new 
                ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function proc_url(url)
{
    if (!this.http)
    {
        this.http = get_http();
        this.working = false;
    }
    document.getElementById('info').innerHTML = '<img src="load.gif" />&nbsp;Getting Info...';
    par = 'q='+encodeURIComponent(url);
    this.http.open("POST", 'ddl.php', true);
    this.http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    this.http.setRequestHeader("Content-length", par.length);
    this.http.setRequestHeader("Connection", "close");
    this.http.onreadystatechange = function() {
        if (http.readyState == 4) {
            r = eval("("+http.responseText+")");
            if (r.err==0) {
		if (typeof(r.url) == 'object') {
		    content = '<div class="dtitle">' + r.title + '</div><div class="ddl">Direct Download Links:<br />';
		    for(i = 0; i < r.url.length; i++) {
			content += r.url[i].desc + ': <a target="_blank" href="' + r.url[i].url + '">&gt;&gt; DOWNLOAD! &lt;&lt;</a><br />';
		    }
		    content += "</div>";
		} else {
		    content = '<div class="dtitle">' + r.title + '</div><div class="ddl">Direct Download Link: <a target="_blank" href="' + r.url + '">&gt;&gt; DOWNLOAD! &lt;&lt;</a></div>';
		}
		document.getElementById('info').innerHTML = content;
	    } else if (r.err==1) {
		document.getElementById('info').innerHTML = 'Search string entered. Performing search...';
		document.location = 'http://youddl.com/search?'+par;
	    } else if (r.err==2) {
		document.getElementById('info').innerHTML = 'Now we are fixing the engine. Please come back later.';
	    } else if (r.err==3) {
		document.getElementById('info').innerHTML = 'This is the streaming video. It cannot be saved as a file.';
	    } else {
		document.getElementById('info').innerHTML = 'Video not found. Please check your input or try again later!';
	    }
            this.working = false;
        }
    }
    this.working = true;
    this.http.send(par);
}

function popupinfo()
{
    newwindow = window.open('list', 'Video Download', 'left=150,top=150,width=565,height=335');
    if (window.focus) { newwindow.focus() }
    return false;
}

function popupprivacy()
{
    newwindow = window.open('privacy', 'Privacy Policy', 'left=150,top=150,width=550,height=550');
    if (window.focus) { newwindow.focus() }
    return false;
}
