var storefront = false;
var q6content = false;
var last_action = '';

function Ratenkalkulator(calc_win_url) {
	var calc_win;
	calc_win = window.open(calc_win_url, "calculator", "width=564,height=566,toolbar=no,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizeable=0");
    	calc_win.opener=self;
    	calc_win.focus();
}

// general function for getting cookie value

function getCookieValue(name) {
	if(name == '')
		return('');
	name_index = document.cookie.indexOf(name + '=');
	if(name_index == -1)
		return('');
	cookie_value =  document.cookie.substr(name_index + name.length + 1, document.cookie.length);
	end_of_cookie = cookie_value.indexOf(';');
	if(end_of_cookie != -1)
		cookie_value = cookie_value.substr(0, end_of_cookie);
	return(cookie_value);
}

// functions for consolidating cookies: START
var _cookie = null;

function findMasterCookie() {
	if (!_cookie) {
		_cookie = new Array();        
	}

	var index = document.cookie.indexOf("master=");
	var cval = document.cookie.substr(index + 7, document.cookie.length);
	var eoc = cval.indexOf(";");

	if (eoc != -1) cval = cval.substr(0, eoc);
	var ccomp = cval.split("&");
	for (var i = 0; i < ccomp.length; i++) {
		var kv = unescape(ccomp[i]).split("=");
		_cookie[kv[0]] = kv[1];
	}

	return _cookie;
}


function setCookie(name, value) {
	var c = findMasterCookie();
	c[name] = value;
	var cval = "";
	var ccomp = new Array();
	for (var k in c) {
		ccomp[ccomp.length] = escape(k + "=" + c[k]);
	}
	document.cookie = 'master='+ ccomp.join("&") +'; path=/'; // set session cookie
}

function getCookie(name) {
	var c = findMasterCookie();
	if (c[name])
		return c[name];
	else
		return getCookieValue(name);
}
// functions for consolidating cookies: END

// Funktion zum Extrahieren von URL-Parametern
function getURLParam(strParamName)
{
	var strReturn = "";
	var strHref = document.URL;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?"));
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
				}
			}
		}
	return strReturn;
}

// Wenn URL einen Refpid-Paramaeter enthält, dann setze ein rpid-Cookie.
function setKomdatCookie()
{
	var refvalue = getURLParam("refpid");

	if (refvalue != "")
	{
		document.cookie = 'rpid='+ refvalue;
		var expiredate = new Date();
		expiredate.setTime(expiredate.getTime()+(30*24*60*60*1000));
		document.cookie = 'rpidp='+ refvalue +'; expires='+ expiredate.toGMTString() + '; path=/'; // set permanent cookie
	}
}
//  Internet Terminal Javascript START
var InternetTerminal = false;
if (getCookieValue("InternetTerminal")) {
	InternetTerminal = true;
	var qit_login = getCookieValue('qit_login');
}
//  Internet Terminal Javascript END

// set cookie for goodbye popup if not yet set
// value depends on request: if from google (url param p=1) value=1 (no popup!), else value=2 (popup is shown)

if(getCookie("pok")=="") {
	if (document.URL.indexOf('p=1')>0) {
		setCookie("pok", 1);
	} else {
		setCookie("pok", 2);
	}
	setKomdatCookie(); // only in the first request of the session
}

// set cookie for goodbye popup if not yet set
// default value=2; if once shown value becomes 1, popup will not show again

if(getCookie("popened")=="") {
	setCookie("popened", 2);
}

// set cookie for jingle if not yet set
// default value=2; if once played value becomes 3 (function in templates q_category_100.isml + q_category_10.isml), jingle will not play again

if(getCookie("j")=="") {
	setCookie("j", 2);
}

// tracking for popup blockers

function blockedPopupTracking(blocksid, popupurl)
{
	var trackImg = new Image();
	if(blocksid == undefined) {
		trackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackResultPage-Start?page=popupblock:"+popupurl;
	}else{
		trackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackResultPage-Start"+blocksid+"?page=popupblock:"+popupurl;
	}
}


// general function for opening popups

function newWin(name, url, width, height, args) {

	var popupurl = url;
	var isurl = popupurl.search(/INTERSHOP/);
	if(isurl != -1) {
		var blocksid = popupurl.match(/\;s[i]d=[-_0-9A-Za-z]+=/);
		var popupurl = popupurl.replace(/\;s[i]d=[-_0-9A-Za-z]+=/, '');
		var popupurl = popupurl.match(/e[CT]S\/.*$/);
	}else{
		var isurl = popupurl.search(/;s[i]d=/);
		if(isurl != -1) {
			var popupurl = popupurl.replace(/\;s[i]d=[-_0-9A-Za-z]+=/, '');
		}
	}

	var newWin = new Object();

		newWin.args = args;
		newWin.url = url;
		newWin.name = name;
		newWin.width = width;
		newWin.height = height;

		if (document.layers) {// browser is NN
				newWin.left = window.screenX + ((window.outerWidth - newWin.width) / 2);
				newWin.top = window.screenY + ((window.outerHeight - newWin.height) / 2);
				var attr = 'screenX=' + newWin.left + ',screenY=' + newWin.top + ',resizable=yes,width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		} else {// browser is MSIE
			newWin.left = (screen.width - newWin.width) / 2;
			newWin.top = (screen.height - newWin.height) / 2;
			var attr = 'left=' + newWin.left + ',top=' + newWin.top + ',resizable=yes,width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		}
		newWin.win=window.open(newWin.url, newWin.name, attr);
		if( (!newWin.win) || (newWin.win.closed) ) {// probably popup-blocker active
				if(document.cookie && getCookie("pub")!=1) {
					alert("Lieber quelle.de Besucher, wir möchten Ihnen  quelle.de-Inhalte in einem Popup präsentieren, das vermutlich durch Ihren PopUp-Blocker unterdrückt wird. Bitte schalten Sie quelle.de in Ihrem PopUp-Blocker frei, oder deaktivieren diesen.");
					var pub_now = new Date();
					var pub_reactive = pub_now.getTime() + (90 * 24 * 60 * 60 * 1000);
					pub_now.setTime(pub_reactive);
					// change expires to pub_now
					setCookie("pub", 1);
				}
				blockedPopupTracking(blocksid,popupurl);
			return;
		}
		newWin.win.opener=self;
		newWin.win.focus();

	var protName =( (newWin.name=='') ? ('_blank'+(new Date()).getTime()) : newWin.name);
	if(!window.newWinObjects)
		window.newWinObjects = new Array();
	window.newWinObjects[ protName ] = newWin;
}

if (navigator.userAgent.toLowerCase().indexOf("gecko") > 1)
{
	document.write("<style type='text/css'>.q-mehrwert-250px-div-border {width:248px;}</style>");
	document.write("<style type='text/css'>.q-mehrwert-250px-div-border-neutral {width:248px;}</style>");
}

if (navigator.userAgent.toLowerCase().indexOf("msie 5.5") > 1)
{
	document.write("<style type='text/css'>.q-mehrwert-1px-dotted-line {margin-top:-2px;}</style>");
	document.write("<style type='text/css'>.bottom-line {margin-top:-2px;}</style>");
}

function is_mac_msie() {
	var uas = navigator.userAgent.toLowerCase();
	return(	(uas.indexOf("msie 5") > 1) && (
			(uas.indexOf("mac_powerpc") > 1) ||
			(uas.indexOf("mac_ppc") > 1) ||
			(uas.indexOf("mac os") > 1) ||
			(uas.indexOf("macintosh") > 1)
		)
	);
}
if (is_mac_msie())
{
	document.write("<link rel=\"stylesheet\" href=\"/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/css/position_mac.css\" type=\"text/css\">");
	document.write("<link rel=\"stylesheet\" href=\"/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/css/font_mac.css\" type=\"text/css\">");
}

//	Funktion fuer Job 8321
function bsdownload() {
var main_url;
search_sid = ( ( window.location.href.indexOf('sid') > 0) ? (window.location.href.substr(window.location.href.indexOf('sid')-1,window.location.href.indexOf('=',window.location.href.indexOf('sid')+4)-(window.location.href.indexOf('sid')-2))) : "" );
win_url = "http://www.quelle.de/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_ViewTemplate-View"+search_sid+"?Template=q_redirect&RedirectURL=%2fis-bin%2fINTERSHOP.static%2fWFS%2fQuelle-quelle_de-Site%2fde_DE%2fmedia%2fquelle_fussballfieber%2ezip&LinkType=J";
mac_url = "http://www.quelle.de/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_ViewTemplate-View"+search_sid+"?Template=q_redirect&RedirectURL=%2fis-bin%2fINTERSHOP.static%2fWFS%2fQuelle-quelle_de-Site%2fde_DE%2fmedia%2fquelle_fussballfieber%2esit&LinkType=J";
mac_safari_url = "/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/media/quelle_fussballfieber.sit";

if (navigator.appVersion.indexOf("Window") < 0) {
if ( (navigator.appVersion.indexOf("Safari") > 0) || (navigator.appVersion.indexOf("MSIE") > 0) )
main_url = mac_safari_url;
else
main_url = mac_url;
} else {
main_url = win_url;
}
location.href=main_url;
}



// 				DSL M E S S U N G   U N D   I N I T I A L I S I E R U N G

// Einbinden des DSL-Switches
document.writeln('<scr'+'ipt type="text/javascr'+'ipt" src="/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/js/dslswitch.js?sar='+Math.random()+'"></script>');
var __DSL_MeasureImage_path = "/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/imagesOnline/";

// Cookies
function DSLPuGetCookie(name) {
    var cookie_string = document.cookie;
    var index = cookie_string.indexOf(name + "=");
    if (index == -1) return null;
    index = cookie_string.indexOf("=", index) + 1;
    var endstr = cookie_string.indexOf(";", index);
    if (endstr == -1) endstr = cookie_string.length;
    return unescape(cookie_string.substring(index, endstr));
}

function DSLPuSetCookie(name, value, persistent) {
   var today = new Date();
   var expiry = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000);
   document.cookie=name + "=" + escape(value) + (((DSLPuSetCookie.arguments.length == 3) && (persistent==true)) ? '; expires='+expiry.toGMTString() : '') + ";path=/";
}

function DSLUserWants (speed) {
   var cookieVal = eval(DSLPuGetCookie('DSL'));
   if ((speed == 'DSL') && (cookieVal >= 11)) {return(true);}
   if ((speed == 'Modem') && (cookieVal == 0)) {return(true);}
   else {return(false);}
}
function DSLUserHas (speed) {
   var cookieVal = eval(DSLPuGetCookie('DSL'));
   if ((speed == 'DSL') && (cookieVal >= 2)) {return(true);}
   if ((speed == 'Modem') && (cookieVal == 1)) {return(true);}
   else {return(false);}
}
function DSLGetModemCounter () {
   if (document.cookie.indexOf('DSL') < 0) {return(-1);}
   else {return (eval(DSLPuGetCookie('DSL')));}
}

// Technische Vorraussetzungen
function DSLPu_CheckRequirements () {
   if ((document.getElementById) && (document.cookie)) {
      return (true);
   }
   else if ((document.getElementById) && (!document.cookie)) {
      setCookie('CookieActive', 'yes');
      if (document.cookie) {return(true);}
   }
   return (false);
}

var __DSL__SpeedMeasureStart = 0;
var __DSL__SpeedMeasureSize = 10;
var __DSL__SpeedMeasureTimeout = null;
var __DSL__Measuring = false;

//Am Ende einer Messung
function DSLOnMeasureComplete () {
   if (__DSL__SpeedMeasureTimeout != null) {window.clearTimeout(__DSL__SpeedMeasureTimeout); __DSL__SpeedMeasureTimeout = null;}
   var jetzt = new Date();
   var timestamp = jetzt.getTime();
   var delta = timestamp - __DSL__SpeedMeasureStart;
   var rate = __DSL__SpeedMeasureSize  / (delta / 1000);
   if (rate < 20) {
        DSLPuSetCookie('DSL', '1');
        var cnt = 0;
   }
   else {
      DSLPuSetCookie('DSL', '2', true);
   }
}

// Startet eine Messung
function DSLStartSpeedMeasurement () {
   if (__DSL__Measuring) {return;}
   if (DSLUserHas('DSL')) {
       return;
   }
   __DSL__Measuring = true;
    var MeasurePixel = new Image();
    var jetzt = new Date();
    __DSL__SpeedMeasureStart = jetzt.getTime();

    MeasurePixel.onload = DSLOnMeasureComplete;
    MeasurePixel.src = __DSL_MeasureImage_path + 'dslmeasure.jpg?sar='+Math.random();
    __DSL__SpeedMeasureTimeout = window.setTimeout("DSLOnMeasureComplete()", 10000);

}

// Beim Laden jeder Seite aufrufen
function DSLCheckUp () {
   // Fallback: DSL-features wurden serverweit abgeschaltet
   try {
   if (typeof(DSLFeaturesOn) == "undefined") {DSLPuSetCookie('DSL', '1'); return;}
   else if (DSLFeaturesOn == false) { DSLPuSetCookie('DSL', '0'); return;}
   } catch (e) {DSLPuSetCookie('DSL', '1'); return;}

   //Nötige Vorraussetzungen prüfen
   if (!DSLPu_CheckRequirements()) {DSLPuSetCookie('DSL', '1'); return;}

   //Messe falls notwendig
   if (document.cookie.indexOf('DSL=') < 0) {
     document.body.onload=function () {
        try{focusBehindNewWins();}
        catch(e) {;}
        DSLStartSpeedMeasurement();}
     //Alls Fllback starten wir die Messung in 2 Sekunden
     window.setTimeout("DSLStartSpeedMeasurement()", 2000);
   }
}

// 				DSL M E S S U N G   U N D   I N I T I A L I S I E R U N G	ENDE

function wochentag(zeit) // zeit: Date-Objekt
{
	switch(zeit.getDay()) {
		case 0: return 'Sonntag';
		case 1: return 'Montag';
		case 2: return 'Dienstag';
		case 3: return 'Mittwoch';
		case 4: return 'Donnerstag';
		case 5: return 'Freitag';
		case 6: return 'Samstag';
	}
}
function datumstext(zeit) // zeit: Date-Objekt
{
	var x = zeit.getDate();
	x = ((x<10) ? '0' : '') + x + '. ';
	switch(zeit.getMonth()) {
		case 0: x=x+'Januar '; break;
		case 1: x=x+'Februar '; break;
		case 2: x=x+'M&auml;rz '; break;
		case 3: x=x+'April '; break;
		case 4: x=x+'Mai '; break;
		case 5: x=x+'Juni '; break;
		case 6: x=x+'Juli '; break;
		case 7: x=x+'August '; break;
		case 8: x=x+'September '; break;
		case 9: x=x+'Oktober '; break;
		case 10: x=x+'November '; break;
		case 11: x=x+'Dezember '; break;
	}
	return x + zeit.getFullYear();
}
function div_r(stilattr,innen)
{
	return '<div style="position:relative;'+stilattr+'">'+innen+'</div>';
}
function div_rc(stilattr,innen,klasse)
{
	return div_r(stilattr+'" class="'+klasse,innen)
}
function divbh(b,h)
{
	return 'width:'+b+'px;height:'+h+'px;';
}

function fTrackingPx(session, type, categoryname, SelectedCategoryID, LinkType)
{
	var faceTrackImg = new Image();
	if(SelectedCategoryID == undefined) {
		if(LinkType == undefined) {
			faceTrackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackClick-Start;"+"sid"+"="+session+"?type="+type+"&CategoryName="+categoryname+"&LinkType=M";
		}else{
			faceTrackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackClick-Start;"+"sid"+"="+session+"?type="+type+"&CategoryName="+categoryname+"&LinkType="+LinkType;
		}
	}else{
		if(LinkType == undefined) {
			faceTrackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackClick-Start;"+"sid"+"="+session+"?type="+type+"&CategoryName="+categoryname+"&SelectedCategoryID="+SelectedCategoryID+"&LinkType=H";
		}else{
			faceTrackImg.src = "http://" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_TrackClick-Start;"+"sid"+"="+session+"?type="+type+"&CategoryName="+categoryname+"&SelectedCategoryID="+SelectedCategoryID+"&LinkType="+LinkType;
		}
	}
}

function moveit(compID, pagerpos, productsArray, how, klick){
    if (how == 1) { //cycle foward
      if (pagerpos < productsArray.length - 1)
	  {
        pagerpos++;
	  }
      else
	  {
        pagerpos = 0;
	  }
	} else if(how == 2) {
		//null
    } else { //cycle backward
      if (pagerpos == 0)
	  {
        pagerpos = productsArray.length - 1;
	  }
      else
      {
	    pagerpos--;
	  }
    }
    showProduct(pagerpos,0,compID,productsArray);

    if(klick == 1)
      klicked = true;

	 return pagerpos;
  }

  function showProduct(pos, klick, compID, productsArray) {
    if(klick == 1)
	{
      klicked = true;
	}

	var pagerProductLink = window.location.protocol + "//" + window.location.hostname + "/is-bin/INTERSHOP.enfinity/WFS/Quelle-quelle_de-Site/de_DE/-/EUR/Q_DisplayProductInformation-Start;"+"sid"+"="+parse_enfsession+"?ProductSKU="+productsArray[pos]["ProductSKU"]+"&AAID="+productsArray[pos]["AAID"]+"&ProductRefID="+productsArray[pos]["ProductSKU"]+"Quelle-quelle_de&CategoryName="+productsArray[pos]["CategoryName"]+"&PromoShopID="+productsArray[pos]["PromoShopID"]+"&Linktype=M";

    document.getElementById(compID+"desc").innerHTML = '<a href="'+pagerProductLink+'" style="color:#A0A585;font-face:arial;font-size:12px;font-weight:bold;text-decoration:underline;">'+productsArray[pos]["desc"]+'</a>';
    document.getElementById(compID+"longdesc").innerHTML = productsArray[pos]["longdesc"];
	document.getElementById(compID+"overlay").innerHTML = '<a href="'+pagerProductLink+'"><img src="/space.gif" width="230" height="120" border="0" alt=""></a>';
	if(productsArray[pos]["secondaryprice"].length > 1) {
	    document.getElementById(compID+"secondaryprice").innerHTML = "&euro; " + productsArray[pos]["secondaryprice"];
	}else{
		document.getElementById(compID+"secondaryprice").innerHTML = "";
	}
    document.getElementById(compID+"price").innerHTML = "&euro; " + productsArray[pos]["price"];
	document.getElementById(compID+"pic").style.backgroundImage = "url(" + productsArray[pos]["pic"] + ")";
    for (var i = 0; i < productsArray.length; i++)
	{
       document.getElementById(compID+"pager"+i).style.color = "white";
    }
      document.getElementById(compID+"pager"+pos).style.color = "red";
  }


var flash_version = 0;
function getFlashVersion()
{
        // get the flash plugin version
        mimetypes=navigator.mimeTypes;
        flash_mimetype=mimetypes["application/x-shockwave-flash"];

        if(navigator.plugins && mimetypes && flash_mimetype?flash_mimetype.enabledPlugin:0)
        {
                flash_plugin_list=navigator.plugins["Shockwave Flash"];

                if (!flash_plugin_list) return 0;
                flash_plugin_list=flash_plugin_list.description.split(' ');

                for(i=0;i<flash_plugin_list.length;++i)
                        if (!isNaN(parseInt(flash_plugin_list[i])))
                        {
                                flash_version=flash_plugin_list[i];
                                break;
                        }
        } else
        {
                if (window.ActiveXObject)
                {
                        for(i=8;i>2;i--)
                        {
                                try
                                {
                                        if (eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+i+"');"))
                                        {
                                                flash_version=i;
                                                break;
                                        }
                                } catch(ex) {}
                        }
                } else {flash_version=0}
        }

        return parseInt(flash_version)+0;
}

function showFlash(swfUrl, imgUrl, w, h, imgLink)
{
	if(getFlashVersion() >= 5)
	{
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '+
			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" '+
			'width="'+w+'" height="'+h+'" align="middle">'+
			'<param name="menu" value="false" />'+
			'<param name="movie" value="'+swfUrl+'" />'+
			'<param name="quality" value="high" />'+
			'<param name="base" value="." />'+
			'<param name="wmode" value="transparent" />'+
			'<param name="FlashVars" value="SID='+parse_enfsession+'" />'+
			'<embed src="'+swfUrl+'" quality="high" '+
			'width="'+w+'" height="'+h+'" align="middle" '+
			'wmode="transparent" '+
			'FlashVars="SID='+parse_enfsession+'" '+
			'type="application/x-shockwave-flash" '+
			'pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>');
	}
	else
	{
		document.write('<a href="'+imgLink+'"><IMG class=noStyle width="'+w+'" height="'+h+'" alt="" src="'+imgUrl+'" border=0></a>');
	}
}

// neuer Select
function filter(inCollection,inClassFilter){
	var newCollection = new Array();
	for (i = 0; i < inCollection.length; i++){
		if (inCollection[i].className == inClassFilter){
			newCollection.push(inCollection[i]);
		}
	}
	return newCollection;
}

function swapFilter(refId,on){
	var theDiv = document.getElementById(refId).getElementsByTagName('DIV')[0];
	if (theDiv == null) return;
	theDiv.style.visibility = on ? "visible" : "hidden";
}

function toggleFilter(refId){
	var theDiv = document.getElementById(refId).getElementsByTagName('DIV')[0];
	theDiv.style.visibility = theDiv.style.visibility == "visible" ? "hidden" : "visible";
}

//  Phaydon Javascript BEGIN
document.writeln('<scr'+'ipt type="text/javascr'+'ipt" src="/is-bin/intershop.static/WFS/Quelle-quelle_de-Site/-/de_DE/phaydonrandom.js?sar='+Math.random()+'"></script>');
var phaydonreq;

function sendpath(useProxy)
// URL muss einen Parameter names sid enthalten. Bsp: "www.quelle.de?sid=hgjavhavcdgha"
{
   if (window.location.host.indexOf("meinepost") > -1)
   	return;

   phaydonreq=null;
   if (window.XMLHttpRequest) {
       phaydonreq = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
       phaydonreq = new ActiveXObject("Microsoft.XMLHTTP");
   }

   if (phaydonreq != null){
      phaydonreq.onreadystatechange = callback;
      if(useProxy)
      	phaydonreq.open("POST", "/phaydon/pathobserver.asmx/CheckSurvey", true);
      else
      	phaydonreq.open("POST", "http://quelle.e-mediad.de/pathobserver.asmx/CheckSurvey", true);
      phaydonreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      phaydonreq.send('url='+encodeURIComponent(window.location.href));
   }
}

function callback() 
{
    if (phaydonreq.readyState == 4) 
    {
       if (phaydonreq.status == 200) 
       {
           try {
               var message = phaydonreq.responseXML.getElementsByTagName("string")[0].firstChild.nodeValue;
               if (message.substr(0,7) == "http://")
               {
                   	var winprops = 'height=500,width=760,top='+(screen.height-500)/2+',left='+(screen.width-760)/2+',scrollbars=yes,resizable=yes';
                   	var win = window.open(message, 'questionnaire', winprops);
	    	win.window.focus();
                }
            }
            catch(e) {}
        }
    }
}

//  Phaydon Javascript END


// 'background-color' -> 'backgroundColor' usw.
function crunch_word_parts(s, delim) {
	var i = s.indexOf(delim);
	while(i>-1) {
		s = s.substr(0,i)+s.charAt(i+delim.length).toUpperCase()+s.substr(i+delim.length+1);
		i = s.indexOf(delim);
	}
	return s;
}
// "42px" -> 42 usw.
function cutPxOff(s) {
	return Number(s.substr(0,s.length-2));
}
// erzeugt HTML-Elemente aus Struktur-Objekten wie {'_typ':'div','style':'left:7px;','_sub':[{...},{...}]}
// mode: 0 erzeugt HTML-Text, 1 erzeugt DOM-Objekt im MSIE, 2 erzeugt DOM-Objekt
function build_doc_element_r(struct, mode) {
	var erg;
	if(mode==0) {
		var erg = '<'+struct._typ;
		for(var a in struct)
			if(a.charAt(0)!='_')
				erg += ' '+a+'="'+struct[a]+'"';
		erg += '>';
		if(struct._sub && struct._sub.length)
			for(var i=0; i<struct._sub.length; i++)
				erg += build_doc_element_r(struct._sub[i], mode);
		if(struct._txt)
			erg += struct._txt;
		erg += '</'+struct._typ+'>';
		return erg;
	} else {
		if((mode==1)&&((struct._typ=='input')||(struct._typ=='select')||(struct._typ=='textarea')))
			erg = document.createElement('<'+struct._typ+' name="'+struct.name+'">');	// MSIE-Bug, http://forum.de.selfhtml.org/archiv/2006/1/t120754/#m775697
		else
			erg = document.createElement(struct._typ);
		for(var a in struct)
			if(a.charAt(0)!='_') {
				if(mode==1) {	// Sonderbehandlung für Fälle, die im MSIE mit setAttribute nicht funktionieren
					switch(a.toLowerCase()) {
						case 'class':
							erg.className = struct[a];
							continue;
						case 'id':
							erg.id = struct[a];
							continue;
						case 'frameborder':	// iframe
							erg.frameBorder = struct[a];
							continue;
						case 'style':
							var sty = struct[a].split(';');
							for(var s in sty)
								if(sty[s]) {
									var s2 = sty[s].split(':');
									try
									{
										erg.style[crunch_word_parts(s2[0].toLowerCase(),'-')] = s2[1];
									}
									catch(e)
									{}	// MSIE 5.5 wirft z.B. bei cursor:pointer; eine exception aus
								}
							continue;
						// handler-Angabe geht nur mit einzelnem Funktionsaufruf ohne Parameter (leeres Klammernpaar)
						case 'onclick':
							erg.onclick = eval(struct[a].substr(0,struct[a].indexOf('(')));
							continue;
						case 'onmouseover':
							erg.onmouseover = eval(struct[a].substr(0,struct[a].indexOf('(')));
							continue;
						case 'onmouseout':
							erg.onmouseout = eval(struct[a].substr(0,struct[a].indexOf('(')));
							continue;
						case 'name':
							if((struct._typ=='input')||(struct._typ=='select'))
								continue;	// oben schon erledigt
						case 'checked':	// auch in mode 1 gibt es ein Problem; für ausgeschaltete Box das Attribut weglassen!
							if((struct._typ=='input')&&(struct.type=='checkbox')) {	// ggf. radio ergänzen
								if(struct[a])
									erg.defaultChecked = true;
								continue;
							}
						//ggf. ergänzen (weitere handler; 'title' ?)
					}
				}
				erg.setAttribute( a, struct[a] );
			}
		if(struct._sub && struct._sub.length)
			for(var i=0; i<struct._sub.length; i++)
				erg.appendChild( build_doc_element_r(struct._sub[i], mode) );
		if(struct._txt)
			erg.appendChild(document.createTextNode( struct._txt ));
		//if(erg.outerHTML) alert('modus '+mode+':'+erg.outerHTML); else alert('modus '+mode+':<...>'+erg.innerHTML+'<...>');
		return erg;
	}
}
// Konstruktor eines Objekts mit .b .h .x .y: Fenstergröße und Scrollposition
function ScrollCoord() {
	this.timestamp = (new Date()).getTime();
	// Ermittlung nach http://www.quirksmode.org/viewport/compatibility.html
	// Inner width. The inner dimensions of the window or frame.
	if (self.innerHeight) // all except Explorer
	{
		this.b = self.innerWidth;
		this.h = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		this.b = document.documentElement.clientWidth;
		this.h = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		this.b = document.body.clientWidth;
		this.h = document.body.clientHeight;
	}
	// Scrolling offset.  How much the page has scrolled.
	if (self.pageYOffset) // all except Explorer
	{
		this.x = self.pageXOffset;
		this.y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		this.x = document.documentElement.scrollLeft;
		this.y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		this.x = document.body.scrollLeft;
		this.y = document.body.scrollTop;
	}
}
// Konstruktor eines Objekts mit .x .y: Position eines Elements plus ang. offset-Werte
function OffsetTopPos(elem,x0,y0) {
	this.x = x0;
	this.y = y0;
	for(var e = elem; e; e = e.offsetParent) {
		this.x += e.offsetLeft;
		this.y += e.offsetTop;
	}
}
// trivialer Konstruktor eines Objekts mit .x .y
function xyObject(x,y) {
	this.x = x;
	this.y = y;
}
// Schaltet elem auf sichtbar (display:block); verwendet x_hint und y_hint zum Positionieren, kann aber davon abweichen (Sichtbarkeit).
// b und h gehen nur in diese Berechnung ein, die Größe des elem wird von dieser Funktion nicht verändert.
// offsetBaseElem, bgHackElem und oldScrollpos dürfen null sein.
function appearElementAt(elem, b, h, x_hint, y_hint, offsetBaseElem, bgHackElem, oldScrollpos) {
	var pop_height = ( (typeof(h)=='function') ? h() : h );
	var pop_width = ( (typeof(b)=='function') ? b() : b );
	var pos;	// Soll-Position
	if(offsetBaseElem)
		pos = new OffsetTopPos(offsetBaseElem,x_hint,y_hint);
	else
		pos = new xyObject(x_hint,y_hint);
	elem.style.display = 'block';
	pos = new OffsetTopPos(elem,-(pos.x+cutPxOff(elem.style.left)),-(pos.y+cutPxOff(elem.style.top)));
	var scro = new ScrollCoord();
	if(oldScrollpos && (oldScrollpos.timestamp > scro.timestamp - 5000)) {	// Sprung durch href="#" rückgängig machen
		window.scrollTo( oldScrollpos.x, oldScrollpos.y );
		scro.x=oldScrollpos.x;
		scro.y=oldScrollpos.y;
	}
	var e_x = -pos.x;
	var e_y = -pos.y;
	if(e_x+pop_width > scro.x+scro.b)
		if((e_x -= pop_width) < scro.x)
			e_x = scro.x;
	if(e_y+pop_height > scro.y+scro.h)
		if((e_y -= pop_height) < scro.y)
			e_y = scro.y;
	elem.style.left = ''+e_x+'px';
	elem.style.top = ''+e_y+'px';
	if(bgHackElem) {
		bgHackElem.style.left	= elem.style.left;
		bgHackElem.style.top	= elem.style.top;
		bgHackElem.style.width	= pop_width;
		bgHackElem.style.height	= pop_height;
		bgHackElem.style.visibility	= 'visible';
		bgHackElem.style.display	= 'block';
	}
}

function showObjectByName(objName) {
	document.getElementById(objName).style.visibility = "visible";
}


function hideObjectByName(objName) {
	document.getElementById(objName).style.visibility = "hidden";
}


function showNextImageDiv (componentID)
{
	hideObjectByName('imgDiv' + componentID + '_' + eval('cntRotations' + componentID));

	if (eval('cntRotations' + componentID) < eval('maxRotations' + componentID))
		eval('cntRotations' + componentID + '++;');
	else
		eval('cntRotations' + componentID + '=1;');
	showObjectByName('imgDiv' + componentID + '_' + eval('cntRotations' + componentID));
}

//  Internet Terminal Javascript START 

function setOnLoad() {
  var bdy = document.getElementsByTagName("body")[0];
  var d = document.getElementById("footer-container");
  if (bdy && d)
    hidePers();
  else
    window.setTimeout(setOnLoad, 300);
}

function checkAllowed(e) {
  return ( e.match(/Basket/) || e.match(/DirectOrder/) || e.match (/q_internet_terminal/) || e.match (/Q_BrowseCatalog/) || e.match (/Q_DisplayProductInformation/) || e.match (/Q_ViewStatic/) || e.match (/Q_View_FW/) || e.match (/Q_Storefront/) || e.match (/javascript/) || e.match(/Q_ECatalog/));
}

function hidePers() {
  var d;
  d = document.forms["loginform"];
  if (d) d.parentNode.parentNode.style.display="none";

  d = document.getElementById("bluebar-logout-container");
  if (d) d.style.display = "none";

  d = document.getElementById("welcome-cookie-container");
  if (d) d.style.display = "none";

  d = document.getElementsByTagName("a");

  for (i = 0; i < d.length; i++) {
    if ( ! checkAllowed(d[i].href) ) {
      d[i].style.display = "none";
    }
  }

  var my_url = location.href;
	if ( ! checkAllowed(my_url) ) {
		gotoTerminalStart();
	}
}

function gotoTerminalStart() {
	var my_url = location.href;
	my_url = my_url.replace(/^https:/,'http:');
	my_url = my_url.replace(/\/EUR\/[^;]*/,'/EUR/Q_ViewTemplate_ets-View');
	my_url = my_url.replace(/\?.*/,'');
	location.href = my_url + '?Template=pers%2fq_internet_terminal_1';
}

function internetTerminalRefresh() {
	location.reload(true);
}

function resetInternetTerminalCookies() {
  var expire = new Date();
	expire.setTime(expire.getTime() + (7 * 24 * 60 * 60 * 1000));
	document.cookie = 'InternetTerminal=1; path=/; expires=' + expire.toGMTString();
	if ( qit_login && (qit_login != '') ) {
		document.cookie = 'qit_login='+qit_login+'; path=/; expires=' + expire.toGMTString();
	}
	window.setTimeout(resetInternetTerminalCookies, (10 * 1000));
}

if (getCookieValue("InternetTerminal")) {
	setOnLoad();
  	resetInternetTerminalCookies();
	window.setTimeout(internetTerminalRefresh, (30 * 60 * 1000));
}

//  Internet Terminal Javascript END


function randomLayerNavi()
{
	var expire = new Date();
	expire.setTime(expire.getTime() + (365 * 24 * 60 * 60 * 1000));
	document.cookie = 'newLayerNav=0; path=/; expires=' + expire.toGMTString();
}

function generateRandomNum (anz)
{
	rand = 0.5 + anz * ( Math.random() );
	rand = Math.round(rand);
	
	return rand;
}
