var updatescript= "/rss/index.php";
var xhttp;              
var myParamForAjax 	= '';
var globalmessage 	= "";
var mydebug	        = "";
//////////////////////////////////////////////////////
function sendRequest(YourParams) {
//////////////////////////////////////////////////////    
    if (!xhttp) {
        alert("An Error occured when trying to initialize XMLHttpRequest!");
        return; // exit
    }
 //   YourParams = "&dummy=0&"+YourParams;
// 		Wir nehmen den Post, damit wir das Feedback vom Server bekommen
//    	xhttp.open("GET",updatescript+"?"+YourParams,false);
//    	xhttp.onreadystatechange=sendRequest_callback;
//    	xhttp.send();
    xhttp.open("POST",updatescript,false);
    xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhttp.setRequestHeader("Content-length", YourParams.length);
    xhttp.setRequestHeader("Connection", "close");
    xhttp.send(YourParams);
    if(xhttp.status == 200)
    	globalmessage = xhttp.responseText;

}

//////////////////////////////////////////////////////
function sendGetRequest(YourParams) {
//////////////////////////////////////////////////////
	xhttp.open("GET",updatescript+"?"+YourParams,true);
	xhttp.onreadystatechange=sendRequest_callback;
	xhttp.send();
}
//////////////////////////////////////////////////////
function sendRequest_callback() {
//////////////////////////////////////////////////////
  // alert ( xhttp.readyState);
    if (xhttp.readyState==4 && xhttp.status==200){
    	var rueckgabe =  xhttp.responseText;
    	document.getElementById("xmlresult").innerHTML = xhttp.responseText;
    	globalmessage = rueckgabe;
    }
}
//////////////////////////////////////////////////////
function init() {
//////////////////////////////////////////////////////
    createXMLHttpRequest();
    }
	//window.onload=init;

//////////////////////////////////////////////////////    
function createXMLHttpRequest() {
//////////////////////////////////////////////////////
   if (window.ActiveXObject) { 
        try { 
                   // IE 6 and higher
            xhttp = new ActiveXObject("MSXML2.XMLHTTP");
        } catch (e) {
        try {
                        // IE 5
             xhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                xhttp=false;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        try {
            // Mozilla, Opera, Safari ...
            xhttp = new XMLHttpRequest();
            } catch (e) {
            xhttp=false;
            }
        }
}
////////////////////////////////////////////////////////
function MakeJason(YourStringToJason){
////////////////////////////////////////////////////////
    	globalmessage = globalmessage.replace(/&#39;/g,"'");
	globalmessage = globalmessage.replace(/&#34;/g, '"');
	globalmessage = globalmessage.replace(/&quot;/g, '"');
	globalmessage = globalmessage.replace(/&lt;/g, '>');
	globalmessage = globalmessage.replace(/&gt;/g, '>');	
	myjsondata = eval('(' + globalmessage + ')');
        return (myjsondata);
}


////////////////////////////////////////////////////////
function rss2pdfmakepdf(YourForm){
////////////////////////////////////////////////////////
if((YourForm.strurl.value.length) == 0){
    alert("Enter a RSS-Feed before submitting");
    return;
}
var output = YourForm.outputpdf.value;
var strurl = YourForm.strurl.value;
var params = "&rss[tm]=rss2pdf&rss[output]="+output+"&rss[strurl]="+strurl;
sendRequest(params);
myjsondata = MakeJason();
window.location = myjsondata.web;
}

////////////////////////////////////////////////////////
function rss2pdfmakepdfLink(YourParams){
sendRequest(YourParams);
myjsondata = MakeJason();
window.location = myjsondata.web; 
}
////////////////////////////////////////////////////////

