//========================================================================================
//                LastVisitProducts.js
//  §state        public
//----------------------------------------------------------------------------------------
//  §description  Cookiehandling und Ajax
//
//  §class        id2cookie
//  §class        ajax        
//========================================================================================
//  §created      23.09.2010 markus goetz
//========================================================================================

//========================================================================================
//  §Class        id2cookie
//  §state        public
//----------------------------------------------------------------------------------------
//  §description  Cookiehandling
//
//  §example      var cookiehandling = new id2cookie( int shopID );
//                  // liest die Cookievariablen shopID_10 bis shopID_20 aus und gibt sie
//                  // als Array zurück
//========================================================================================
//  §created      23.09.2010 markus goetz
//========================================================================================

id2cookie = function (shop)
{
  var products = new Array();
  var cookie = document.cookie;
  var productidname = 'iclvp' + shop + '=';
  var cookiestring = '';

  this.readcookie = function()
  {
    if (cookie.indexOf(productidname) > -1) {
	    cookiestring = cookie.substring((cookie.indexOf(productidname) + (productidname.length)), cookie.length); 
	    if(cookiestring.indexOf(";") > -1)
	    {
	      cookiestring = cookiestring.substring(0, cookiestring.indexOf(";"));
	    }
    
	    products = cookiestring.split(',');
    
	    return products;
    }
    return new Array();
  }
}

//========================================================================================
//  §Class        ajax
//  §state        public
//----------------------------------------------------------------------------------------
//  §description  Ajax
//
//  §example      var ajax = new ajax( string url );
//                  // url: Anfrage URL
//                var ajaxantort = ajax.requestsync();
//                  // synkrone Antwort der Anfrage wird zurück gegeben
//========================================================================================
//  §created      23.09.2010 markus goetz
//========================================================================================

function ajax(requrl)
{
  this.aj_datei = requrl;

  this.http = null;
  var glob_this = this;

  this.requestsync = function()
  {
    if (window.XMLHttpRequest)
    {
      this.http = new XMLHttpRequest();
    } else if (window.ActiveXObject) 
    {
    this.http = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
    if (this.http != null) 
    {
      this.http.open("GET", this.aj_datei, false);
      this.http.send(null);
      return glob_this.http.responseText;
    }
  }
}

