<!--
/***
Ajax mein Fahrradladen
***/

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();
var http2 = createRequestObject();
var httpClick = createRequestObject();

function getPic(pid,size) {
	var imgData; 
	var shop = document.getElementById('shop').innerHTML;
	if((http.readyState == 0) || (http.readyState == 4)){
		var anfrage = '/ajax/picture.php?pid='+pid+'&size='+size+'&shop='+shop;
		http.open('get', anfrage);
      	http.onreadystatechange = function(){
			if(http.readyState == 4){
   				imgData = http.responseText;
   				document.getElementById('product_pic').src = imgData;
	   		}
      	};
      http.send(null);
	}
}

function showInfo() {
	if(document.getElementById('product_pic') && document.getElementById('smallInfos') && document.getElementById('layer')) {
		/*Bigger Picture + Layer */
		var shoplink = document.getElementById('shoplink').href;
		var bigPic = document.getElementById('produktID').innerHTML;
		getPic(bigPic,730);
		document.getElementById('product_pic').style.width = "730px";
		document.getElementById('layer').className = "overlayPic";
		document.getElementById('smallInfos').className = "overlaySmallInfos";
		document.getElementById('moreInfoLink').className = "other smallText";
		document.getElementById('moreInfoLink').innerHTML = 'ihre Optionen:<br /><img src="/static_picture/arrow_in.png" alt="" style="width:10px;height:10px" /> <a class="cursor" onclick="javascript:undoPage()">mehr Informationen zu diesem Produkt</a><br /><img src="/static_picture/feed.png" alt="" style="width:10px;height:10px" /> <a href="http://feeds.feedburner.com/MeinFahrradladen" class="cursor">das Angebot des Tages im RSS-Feed</a><br /><img src="/static_picture/find.png" alt="" style="width:10px;height:10px" /> <a href="http://www.mein-fahrradladen.de/suche/" class="cursor">ein anderes Angebot suchen</a><br /><img src="/static_picture/cart.png" alt="" style="width:10px;height:10px" /> <a href="'+shoplink+'" class="cursor">zu fahrrad.de &amp; diesen Artikel kaufen</a>';
		document.getElementById('layer').innerHTML = '<a class="cursor" onclick="javascript:modifyPage()"><img src="/static_picture/bullet_toggle_minus.png" alt="schlie&szlig;en" title="schlie&szlig;en" /></a>';
	}	
}

function modifyPage() {
	/* Modify Page-Layout */
	if(document.getElementById('teaserText')) {
		/*Hide more Infos*/
		document.getElementById('teaserText').style.display = "none";
	}
	if(document.getElementById('product_pic') && document.getElementById('smallInfos') && document.getElementById('layer')) {
		/*Bigger Picture*/
		var bigPic = document.getElementById('produktID').innerHTML;
		getPic(bigPic,730);
		document.getElementById('product_pic').style.width = "730px";
		document.getElementById('layer').className = "overlayPic2";
		document.getElementById('smallInfos').className = "hide";
		document.getElementById('layer').innerHTML = '<a class="cursor" onclick="javascript:showInfo()"><img src="/static_picture/bullet_toggle_plus.png" alt="&ouml;ffnen" title="&ouml;ffnen" /> Informationen zum Produkt</a><br /><img src="/static_picture/arrow_in.png" alt="" style="width:10px;height:10px" /> <a class="cursor" onclick="javascript:undoPage()">Bild verkleinern</a>';
	}	
}

function undoPage() {
	/* Modify Page-Layout */
	if(document.getElementById('teaserText')) {
		/*Show more Infos*/
		document.getElementById('teaserText').style.display = "block";
	}
	if(document.getElementById('product_pic') && document.getElementById('smallInfos') && document.getElementById('layer')) {
		/*Smaller Picture*/
		var shoplink = document.getElementById('shoplink').href;
		var bigPic = document.getElementById('produktID').innerHTML;
		getPic(bigPic,430);
		document.getElementById('product_pic').style.width = "430px";
		document.getElementById('layer').className = "hide";
		document.getElementById('smallInfos').className = "noajax";
		document.getElementById('moreInfoLink').className = "other smallText";
		document.getElementById('moreInfoLink').innerHTML = 'ihre Optionen:<br /><img src="/static_picture/arrow_out.png" alt="" style="width:10px;height:10px" /> <a class="cursor" onclick="javascript:modifyPage()">gr&ouml;&szlig;eres Bild</a><br /><img src="/static_picture/feed.png" alt="" style="width:10px;height:10px" /> <a href="http://feeds.feedburner.com/MeinFahrradladen" class="cursor">das Angebot des Tages im RSS-Feed</a><br /><img src="/static_picture/find.png" alt="" style="width:10px;height:10px" /> <a href="http://www.mein-fahrradladen.de/suche/" class="cursor">ein anderes Angebot suchen</a><br /><img src="/static_picture/cart.png" alt="" style="width:10px;height:10px" /> <a href="'+shoplink+'" class="cursor">zu fahrrad.de &amp; diesen Artikel kaufen</a>';
	}	
}

function setCookie(name, wert, domain, expires, path, secure){
   var cook = name + "=" + unescape(wert);
   cook += (domain) ? "; domain=" + domain : "";
   cook += (expires) ? "; expires=" + expires : "";
   cook += (path) ? "; path=" + path : "";

   cook += (secure) ? "; secure" : "";
   document.cookie = cook;
}

function getCookie(name) {
   var i=0;  //Suchposition im Cookie
   var suche = name + "=";
   while (i<document.cookie.length) {
      if (document.cookie.substring(i, i + suche.length) == suche) {
         var ende = document.cookie.indexOf(";", i + suche.length);
         ende = (ende > 1) ? ende :
         document.cookie.length;
         var cook = document.cookie.substring(i + suche.length, ende);
         return unescape(cook);
      }
      i++;
   }
   return "";
}

function statistikTool() {      
        if((http2.readyState == 0) || (http2.readyState == 4)) {
                var referer = encodeURIComponent(document.referrer);
                var webseite = encodeURIComponent(document.URL);
                
                setCookie("Cookietest","ok");
                if (!getCookie("Cookietest")) {
                        var theURL = '/ajax/setajax.php?url='+webseite+'&amp;ref='+referer+'&amp;nocookie=true';
                } else {
                        var theURL = '/ajax/setajax.php?url='+webseite+'&amp;ref='+referer;
                }
                http2.open('get', theURL);
                http2.onreadystatechange = function(){
                        if(http2.readyState == 4 && http2.status == 200){ 
                        }
                };
                http2.send(null);
        }
}

function start() {
	/* start default applications if browser ready*/
	if (http) {
		undoPage();
	}
}
// -->
