
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 load_next_video(url) {
    var http = get_http();
    if (http) {
        http.open("GET", url+'&counter='+counter+'&videos='+videos, true);
        http.onreadystatechange = function() {
            if (http.readyState == 4) {
                if(http.status == 200){
                    resp = http.responseText;
                    res_arr = resp.split('|||');
                    counter++;
                    if(trim(res_arr[0])!='noexist'){
                    	showed++;
	                    document.getElementById('page-heading').innerHTML = res_arr[0];
	                    document.getElementById("AdotubePlayerDiv").innerHTML = res_arr[1];
	                    // document.getElementById('recipe_details').innerHTML = res_arr[2];
					} else {
                    	videos++;
                    	load_next_video(url);
					}
                   	
                }
            } else {
                // document.getElementById(id).innerHTML = '<img src="ajax-loader.gif" />';
            }
        }
        http.send(null);
    }
    if(!http){
        alert('Your browser is not support AJAX!')
    }
}

function trim(string) { 
	return string.replace(/(^\s+)|(\s+$)/g, "");
}

