﻿
var xmlhttp1 = null;
var xmlhttp2 = null;
var xmlhttp3 = null;


function getData(count, kunde, cat)
{
xmlhttp1=GetXmlHttpObject();
xmlhttp2=GetXmlHttpObject();
xmlhttp3=GetXmlHttpObject();

if (xmlhttp1==null & xmlhttp2==null & xmlhttp3==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
    //News
    var urlnews = "http://www.yallaa.de/reader/news_reader.aspx";
    urlnews = urlnews +"?count="+count;
    urlnews = urlnews +"&kunde="+kunde;
    urlnews = urlnews +"&cat="+cat;
    xmlhttp1.onreadystatechange=stateChanged;
    xmlhttp1.open("GET",urlnews,true);
    xmlhttp1.send(null);
    
    //Coupons
    var urlcoupons = "http://www.yallaa.de/reader/coupons_reader.aspx";
    urlcoupons = urlcoupons +"?count="+count;
    urlcoupons = urlcoupons +"&kunde="+kunde;
    urlcoupons = urlcoupons +"&cat="+cat;
    xmlhttp2.onreadystatechange=stateChanged;
    xmlhttp2.open("GET",urlcoupons,true);
    xmlhttp2.send(null);
    
    //Gewinnspiele
    var urlspiel = "http://www.yallaa.de/reader/gewinnspiele_reader.aspx";
    urlspiel = urlspiel +"?count="+count;
    urlspiel = urlspiel +"&kunde="+kunde;
    urlspiel = urlspiel +"&cat="+cat;
    xmlhttp3.onreadystatechange=stateChanged;
    xmlhttp3.open("GET",urlspiel,true);
    xmlhttp3.send(null);
}

function stateChanged()
{
  if (xmlhttp1.readyState==4)
  {
  document.getElementById("news").innerHTML=xmlhttp1.responseText;  
  }
  
  if (xmlhttp2.readyState==4)
  {  
  document.getElementById("coupons").innerHTML=xmlhttp2.responseText;
  }
  
  if (xmlhttp3.readyState==4)
  {  
  document.getElementById("gewinnspiele").innerHTML=xmlhttp3.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


