/************************************************************************************************************
(C) www.dhtmlgoodies.com, March 2006

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Version:
	1.0	Released	March. 3rd 2006

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/
logging = true;
xsltdebug = true;
var url_long = '/cgi-bin/CiXbase/brewis/CiXbase_search';
var url_long2 = '/styles/long-ger-js.xml';
var ajaxObjects = new Array();
var ajaxObjects2 = new Array();

var url_removeProductFromBasket = '/removeProduct.php';
var shopping_cart_div = false;
var currentProductDiv = false;

var http = null;
if (window.XMLHttpRequest) {
   http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
   http = new ActiveXObject("Microsoft.XMLHTTP");
}

function laden(productId,peid,id,la,cid,hitnr,exemplar) {
	if (la == "") var la="DE";
   if (http != null) {
	if (!exemplar) {var kommentar = '&Hitnr='+hitnr+'&keinExemplar=1';}else{var kommentar = '&Hitnr='+hitnr+'&'+exemplar;}
   	var agent = navigator.userAgent.toLowerCase();
//   	if (agent.indexOf('safari')>-1||(agent.indexOf('konqueror')>-1)||(agent.indexOf('omniweb')>-1)) {  
//  		parent.location.href = '/cgi-bin/CiXbase/brewis/CiXbase_search?act=peid&peid='+peid+'&CID='+cid+'&XML_STYLE=/styles/cns-long-DE.xml&LAN='+la+kommentar; 
//   	}else{  
   		var productRow = document.getElementById(id+productId);
		productRow.parentNode.removeChild(productRow);
		var div = document.createElement('div');
	 	div.setAttribute('id',id+productId);
	 	div.setAttribute('class','content');
		document.getElementById('content'+productId).insertBefore(div, document.getElementById('rssfeed'+productId));
		div.innerHTML = '<p><img src="/images/ajax-loader.gif"/></p>';							   								   									   
	    http.open('GET','/cgi-bin/CiXbase/brewis/CiXbase_search?act=peid&peid='+peid+'&CID='+cid+kommentar,true);
	 if (agent.indexOf('safari')>-1||(agent.indexOf('konqueror')>-1)||(agent.indexOf('omniweb')>-1)) {
	    http.onreadystatechange = function(){ ausgeben(productId,id,'/styles/merge-long-'+la+'.xml');};
	}else{
	http.onreadystatechange = function(){ ausgeben(productId,id,'/styles/cns-long-'+la+'-js.xml');};
		}
		setTimeout('',2000);
	    http.send(null);
//	}
   }
}

function laden2(productId,peid,id,la,cid) {
	if (la == "") var la="DE";
   if (http != null) {
	var agent = navigator.userAgent.toLowerCase();
	var productRow = document.getElementById(id+productId);
	productRow.parentNode.removeChild(productRow);
	var div = document.createElement('div');
 	div.setAttribute('id',id+productId);
 	div.setAttribute('class','content');
	document.getElementById('content'+productId).insertBefore(div, document.getElementById('rssfeed'+productId));
	div.innerHTML = '<p><img src="/images/ajax-loader.gif"/></p>';							   								   									   
    http.open('GET','/cgi-bin/CiXbase/brewis/CiXbase_search?LOG=NOLOG&act=peid&peid='+peid+'&CID='+cid,true);
    if (agent.indexOf('safari')>-1||(agent.indexOf('konqueror')>-1)||(agent.indexOf('omniweb')>-1)) {
    	http.onreadystatechange = function(){ ausgeben(productId,id,'/styles/merge-short-'+la+'.xml');};
    }else{
    	http.onreadystatechange = function(){ ausgeben(productId,id,'/styles/cns-short-'+la+'-js.xml');};
    }
	setTimeout('',2000);
    http.send(null);
   }
}


function ausgeben(productId,id,style) {
   if (http.readyState == 4) {
      var daten = http.responseXML;
	  var productRow = document.getElementById(id+productId);
	  productRow.parentNode.removeChild(productRow);
	  var div = document.createElement('div');
 	  div.setAttribute('id', id+productId);
 	  div.setAttribute('class','content');
	  document.getElementById('content'+productId).insertBefore(div, document.getElementById('rssfeed'+productId));							   
	  if (window.ActiveXObject) {
         var xsl = loadXMLDoc(style);
         var template = new ActiveXObject("MSXML2.XSLTemplate");
         template.stylesheet = xsl;
         var process = template.createProcessor();
         process.input = daten;
         process.transform();
         div.innerHTML = process.output;
       } else if (window.XSLTProcessor) {
         var xsl = loadXMLDoc(style);
         var process = new XSLTProcessor();
         process.importStylesheet(xsl);
   		 ergebnis = process.transformToFragment(daten, document);
         div.appendChild(ergebnis);
      }
   }
}

function el(id) {
  return document.getElementById(id);
}

function loadXMLDoc(fname){
	var xmlDoc;
	
	try //Internet Explorer 
    { 
        xmlDoc=new ActiveXObject("MSXML2.FreeThreadedDOMDocument"); 
        xmlDoc.async=false; 
        xmlDoc.load(fname); 
    } 
    catch(e) 
    { 
        try //Firefox, Mozilla, Opera, etc. 
        { 
            xmlDoc=document.implementation.createDocument("","",null); 
            xmlDoc.async=false; 
            xmlDoc.load(fname); 
        } 
        catch(e) 
        { 
            try //Google Chrome 
            { 
                var xmlhttp = new window.XMLHttpRequest(); 
                xmlhttp.open("GET",fname,false); 
                xmlhttp.send(null); 
                xmlDoc = xmlhttp.responseXML.documentElement;
            } 
            catch(e) 
            { 
            error=e.message; 
            } 
        } 
    } 
    return xmlDoc; 

}

