// WToD wt_ad
// Setzen der Variablen wt_ad
	var wt_ad = "";
// /WToD wt_ad  

function SetCursor(value){ document.getElementsByTagName("body")[0].style.cursor = value; }
function  WriteHTMLLayer(id, text) { document.getElementById(id).innerHTML = text; }
function AjaxRequestGroupBegin(groupName) { /*WriteHTMLLayer(groupName, 'Daten werden geladen...');*/ } 
function AjaxRequestGroupEnd(groupName) { }  

function myAyax() {
	//Defaultwerte:
	this.timeout = 10000;
//	this.username = '';
//	this.password = '';
	this.onSuccess = function(req){ WriteHTMLLayer(this.groupName, req.responseText); };
	this.onError = function(req){ /*alert('Error!\nStatusText='+req.statusText+'\nStatus='+req.status+'\nUrl='+req.url+'\nContents='+req.responseText);*/};
	this.onTimeout = function(){/*alert('Timeout!')*/;}
	this.onGroupBegin = AjaxRequestGroupBegin;
	this.onGroupEnd = AjaxRequestGroupEnd;
	
	//weitere Werte:
	this.groupName;
	this.url;
	
	this.Request = function (){
		//alert(this.url);
		var rp = new Object();
		rp.url = this.url;
		rp.timeout = this.timeout;
		rp.username = this.username;
		rp.password  = this.password;
		rp.onSuccess = this.onSuccess;
		rp.onError = this.onError;
		rp.onTimeout = this.onTimeout
		rp.groupName = this.groupName;
		rp.onGroupBegin = this.onGroupBegin; 
		rp.onGroupEnd = this.onGroupEnd;
		
		var ar = AjaxRequest.get(rp);
	}	
} 

function AddToWarenkorb(Kategorie, ProduktID, TarifID, VariationID, DienstID, GoTo, WToD) { document.location.href = '/ajax/warenkorb/add_warenkorb.asp?GoTo='+GoTo+'&kategorie='+Kategorie+'&Produkt='+ProduktID+'&tarif='+TarifID+'&variation='+VariationID+'&dienst='+DienstID+'&miete=1&wtod='+WToD; }

function AddWarenkorbByAjax(Kategorie, ProduktID, TarifID, VariationID, DienstID) {
	var ma;
	ma = new myAyax();
	ma.groupName = 'warenkorb_small';
	ma.url = '/ajax/warenkorb/add_warenkorb.asp?kategorie='+Kategorie+'&Produkt='+ProduktID+'&tarif='+TarifID+'&variation='+VariationID+'&dienst='+DienstID;
	ma.Request(); 
	//document.location.href = '#top';
}

function gAP(o) {
	var bN = "egal"
	if (bN.substr(0,2)=='N5') this.a=document.eval(o);
	else this.a=eval(o);
	
	this.x=this.a.offsetLeft;
	this.y=this.a.offsetTop;
	
	while((this.a = this.a.offsetParent) != null) {
		this.x += this.a.offsetLeft;
		this.y += this.a.offsetTop;
	}
}

function ShowInfoLayer(text, obj) {
	position=new gAP(obj)
	document.getElementById('InfoLayer').style.left = position.x + 100 + "px";
	document.getElementById('InfoLayer').style.top =  position.y - 20 + "px";
	document.getElementById('InfoLayer').style.display = '';
	document.getElementById('InfoLayer').innerHTML = text;
}

function HideInfoLayer() { document.getElementById('InfoLayer').style.display = 'none'; }
function SetStatus(text) { window.status = text; } 
function ClearStatus() { window.status = ''; }

// Einblendfunktion
function showme(id) { document.getElementById(id).style.display = ""; }
// Ausblendfunktion
function hideme(id) { document.getElementById(id).style.display = "none"; }
// Ein-/ Ausblendfunktion
function changevisibility(id) {
	if (document.getElementById(id).style.display == "none") {
		showme(id);
		if (id == "rechtstexte") {
			window.addEvent('domready', function() {
				new Fx.Scroll(window, {
				wait: false,
				duration: 800,
				offset: {'x': 0, 'y': 0},
				transition: Fx.Transitions.Quad.easeInOut
			}).toElement($('rtbereichlink'));
			});
		}
	} else {
		hideme(id);
	}
}

//Popup
function pU(url,name,breite,hoehe,parameter) {
	((parameter.indexOf("scrollbars=no")>=0)||(parameter.indexOf("scrollbars=0")>=0)) ? k=0 : k=17;
	p="width="+(parseInt(breite)+k)+",height="+hoehe+","+parameter;
	win=window.open(url,name,p);
	win.focus();
}  

function putreuevorteil() {
	pU('/include/content/treuevorteil_pu.asp', 'treuevorteil', 870, 650, 'resizable=0, scrollbars=1, status=1, toolbar=0');
}

//Ajaxcache
AjaxCaches = new Array()

function AjaxCache(Initiator,content) {
	this.Initiator = Initiator;
	this.content = content;
	return this;
}

function addAjaxCache(Initiator,content) {
	var add = true;
	for(i=0;i<AjaxCaches.length;i++){
		if(Initiator==AjaxCaches[i].Initiator){ add=false ; break;}
	}
	if(add){
		AC = new AjaxCache(Initiator,content);
		AjaxCaches.push(AC);
	}
}

function getAjaxCache(Initiator) {
	var r,i;
	r='';
	for(i=0;i<AjaxCaches.length;i++){
		if(Initiator==AjaxCaches[i].Initiator){ r = AjaxCaches[i].content; break;}
	}
	return r;
}

function clearAjaxCache(Initiator) {
	var i;
	for(i=0;i<AjaxCaches.length;i++){
		//alert(AjaxCaches[i].Initiator)
		if(Initiator==AjaxCaches[i].Initiator){ 
			AjaxCaches.splice(i,1);
			break;
		}
	}
}

function addOptionToDropdown(id, name, value, selected) {
	var aktObj = document.getElementById(id);
	if(aktObj){
		aktObj.options[aktObj.length] = new Option(name, value, false, false);
		if(selected) aktObj.options[aktObj.length-1].selected = true;
	}
}

function TopNaviInQuickNavi() {
	/* deprecated, wird jetzt in generate geschrieben!!
	addOptionToDropdown('quicknavUrl','Nokia','/redir/quick_handys.asp',false)
	addOptionToDropdown('quicknavUrl','Sony Ericsson','/redir/quick_handys.asp',false)
	addOptionToDropdown('quicknavUrl','Samsung','/redir/quick_handys.asp',false)
	addOptionToDropdown('quicknavUrl','Sonstige','/redir/quick_handys.asp',false)
	addOptionToDropdown('quicknavUrl','Prepaid','/redir/quick_prepaid-handys.asp',false)
	addOptionToDropdown('quicknavUrl','Tarife','/redir/quick_tarife.asp',false)
	addOptionToDropdown('quicknavUrl','Zubehör','/redir/quick_zubehoer.asp',false)
	addOptionToDropdown('quicknavUrl','Service','/redir/quick_service.asp',false)
	*/
}

function agb(){ pU('/agb/','agb',593,591,'menubar=no,location=no,resizable=no,toolbar=no,scrollbars=yes'); }

// funktionen für das bestellabbruch popunder (/aktionen/0612_bestellabbruch)
var openerDA = true;
var close_opener;

function open_popunder() {
	close_opener=false;
	var popUnder=window.open('/aktionen/0612_bestellabbruch/pu_neutral.asp','popUnder','width=410,height=430,scrollbars=1,toolbar=0,status=1,resizable=0');
	popUnder.blur();
	window.focus();
}

function close_popunder() {
	openerDA = false
	close_opener=true;
}


// infopopup checkout
function cInfo(code) { pU('/shop/checkout/popup/backend_'+ code +'.asp', 'Info'+ code, 500, 464, 'menubar=0, location=0, resizable=0, toolbar=0, scrollbars=1'); }
// infopopup checkout mit Parameter
function cInfoPara(code,Para) { pU('/shop/checkout/popup/backend_'+ code +'.asp?'+Para, 'Info'+ code, 500, 464, 'menubar=0, location=0, resizable=0, toolbar=0, scrollbars=1'); }
// 3d popup
function ddd(jar) { pU('/3D/3D.asp?jar='+ jar, '3d', 586, 560, 'menubar=0, location=0, resizable=0, status=1 toolbar=0, scrollbars=0'); }


/////////////////////////////////////////////////////////////////

function posLayerToReference(id, ref, difx, dify) {
	position=new gAP(ref);
	document.getElementById(id).style.left = position.x + difx + "px";
	document.getElementById(id).style.top =  position.y + dify + "px";
}

var toCloseInfoLayer;

function OpenInfoLayer(uid, code, ref, align) {
	var cache, ma;
	var id = 'ILayer';
	var uid = uid;
	var width = 265;
	var difx, dify;
	
	difx = (width+20)*-1;
	dify = 5;
	if(align == "right")
		difx = 50;
	if(align == "leftcenter")
		difx = (width-255)*-1;
	if(align == "leftcenterlabel")
		difx = (width+35);
	
	DivObj = document.getElementById(id);
	//DivObj.style.display = 'none';
	
	ma = new myAyax();
	ma.url = '/shop/checkout/popup/backend_'+ code +'_layer.asp?code='+code;
	
	ma.FillLayer = function(responseText) { 
		addAjaxCache(uid, responseText);
		posLayerToReference(id, document.getElementById(ref), difx, dify);
		DivObj.style.width = width+'px';
		DivObj.innerHTML = "";
		var div = document.createElement("div");
		div.innerHTML = responseText;
		DivObj.appendChild(div);
		DivObj.style.display = '';
	};
	ma.onSuccess = function(req){ ma.FillLayer(req.responseText) };
	
	cache = getAjaxCache(uid);
	(cache!='') ? ma.FillLayer(cache) : ma.Request();
	
	window.clearTimeout(toCloseInfoLayer);		
}

function OverLayer() { window.clearTimeout(toCloseInfoLayer); }
function OutButton() { toCloseInfoLayer = window.setTimeout("CloseInfoLayer();", 1000); }
function CloseInfoLayer() {
	var id = 'ILayer';
	document.getElementById(id).style.display = 'none';	
}


function goQuicknav() {
	var u;
	u = document.quicknav.quicknavUrl[document.quicknav.quicknavUrl.selectedIndex].value;
	if(u.length > 0){
		document.location.href = u;
	}else{
		document.quicknav.quicknavUrl.selectedIndex = 0;
	}
}

function change_hersteller() {
	if (!document.layers) {
		self.location = document.filter.filterBrand.value
	} else {
		self.location = document.filter.filterBrand.options[document.filter.filterBrand.selectedIndex].value;
	}
}

function change_model() {
	if (!document.layers) {
		self.location = document.filter.filterMod.value
	} else {
		self.location = document.filter.filterMod.options[document.filter.filterMod.selectedIndex].value;
	}
}


function zubehoerdetailWT(zubehoerID,vID, WTParam) { pU('/zubehoer/zubehoer_detail.asp?zID='+zubehoerID+'&vID='+vID + '&WT.ac=' + WTParam,'zdetail',500,464,'status=1,scrollbars=1') }


function zubehoerdetail(zubehoerID,vID) { pU('/zubehoer/zubehoer_detail.asp?zID='+zubehoerID+'&vID='+vID,'zdetail',500,464,'status=1,scrollbars=1') }
//{ pU('/zubehoer/zubehoer_detail.asp?zID='+zubehoerID+'&vID='+vID,'zdetail',445,430,'status=1,scrollbars=1') }


setheight = function() {
	var content			= document.getElementById("content");
	var innercontent	= document.getElementById("innercontent");
	var navibottom		= document.getElementById("navibottom");
	var navigation		= document.getElementById("navigation");
	var navimain		= document.getElementById("navimain");
	var maxheight		= 0;
	
	if (navigation.offsetHeight > content.offsetHeight) {
		maxheight					= navigation.offsetHeight;
		innercontent.style.height	= maxheight + "px";
		navigation.style.height		= maxheight + 7 + "px";
		navibottom.style.height		= maxheight - navimain.offsetHeight + 3 + "px";
	} else {
		maxheight					= content.offsetHeight;
		navigation.style.height		= maxheight - 3 + "px";
		navibottom.style.height		= maxheight - navimain.offsetHeight - 6 + "px";
		
		if (navigator.appName.substr(0,1)=='M') {
			navigation.style.backgroundImage	= "url(/img/navi/bg_blind.gif)";
			navigation.style.backgroundPosition	= "0 0";
		}
	}
}


setAjaxheight = function() { }


window.onload = function() {
	if (!document.getElementById('detailcontainer')) { setTimeout("setheight()", 500); }
}


/////////////////////////////////////////////////////////////////

function SubmitFlags() {
	formObj = document.forms.marketingflags;
	formObj.submit();
}

function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x + 20) + "px";
		wmtt.style.top 	= (y + 20) + "px";
	}
}

function startHover(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function stopHover() {
	wmtt.style.display = "none";
}

/////////////////////////////////////////////////////////////////

var loadpx = function(doc,inp) {
	// doc -> akt. document
	// inp -> inputfield
	cpx		= new Image();
	cpx.src	= "/log/bestelltrack" + doc + "/" + inp + ".asp";
}

function writeFlash(swf,width,height,name,align,AltenativImg,AlphaMode,imglink,n){

display=true;
if ((n==true)&&(bN.substr(0,1)=='N')) {display=false}

if (flash&&display){
if(name==null) swf.substr(0,(swf.length-4));
towrite='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"'+
' WIDTH=' + width +
' HEIGHT=' +height +
' ID='+name+'>'+
'<PARAM NAME=movie VALUE="'+swf+'">'+
'<PARAM NAME=quality VALUE=high>'+
'<PARAM NAME=menu VALUE=false>'
if(AlphaMode!=null) towrite = towrite + '<PARAM NAME=wmode VALUE=transparent>'
towrite = towrite + '<EMBED src="'+swf+'" quality=high '
if(AlphaMode!=null) towrite = towrite + 'wmode=transparent '
towrite = towrite + 'WIDTH='+ width  +' HEIGHT='+ height  +' TYPE="application/x-shockwave-flash" NAME="'+ name +'" ID="'+ name +'" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swliveconnect="true" menu="false"></EMBED></OBJECT>';
}else if (AltenativImg != ""){
towrite='<img src="/img/' + AltenativImg + '" width="'+width+'" height="'+height+'" border="0" alt="">'
if (imglink){
	if (imglink.indexOf("|target=")>=0) {
		imglink = imglink.split("|");
		towrite='<a href="' + imglink[0] + '" ' + imglink[1] +'>' + towrite + '</a>'
	} else {
		towrite='<a href="' + imglink + '" target="_blank">' + towrite + '</a>'
	}
}
//if (imglink){ towrite='<a href="' + imglink + '" target="_blank">' + towrite + '</a>' }
}else{
towrite='<table width="'+width+'" height="'+height+'" border="0" cellspacing="0" cellpadding="1" bgcolor="40886F">'+
'<tr>'+
'<td>'+
'<table width="'+width+'" height="'+height+'" border="0" cellspacing="0" cellpadding="5" bgcolor="#FFFFFF">'+
'<tr>'+
'<td align="center">'+
'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=German&P5_Language=German" target="_blank"><img src="/img/flash_icon.gif" width="30" height="36" border="0"></a><br>'+
'Zum Betrachten der Grafik benötigen Sie das <br />'+
'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=German&P5_Language=German" target="_blank"><img src="/img/anker_pfeil_rechts.gif" width="11" height="11" border="0" hspace="0" /><img src="/img/clear.gif" width="3" height="1" border="0" />Flash-5-Plugin</a> von Macromedia.<br><br></br></br>'+
'Nach erfolgreicher Installation klicken Sie bitte <nobr><a href="javascript:location.reload();"><img src="/img/anker_pfeil_rechts.gif" width="11" height="11" border="0" hspace="0" /><img src="/img/clear.gif" width="3" height="1" border="0" />hier</a></nobr> '+
'</td>'+
'</tr>'+
'</table>'+
'</td>'+
'</tr>'+
'</table>'
}

document.write(towrite);
}

function fR_init(fRid)
{
if (bN.substr(0,2)=='N4') fR_anker = new gAP('a_flexreiter_'+fRid);
else fR_anker = new gAP('px_flexreiter_'+fRid);
for (i=1;i<=eval('fR_menge_'+fRid);i++){
	fR_sty=fL('fRlay'+fRid+i);
	(bN.substr(0,2)=='N4') ? fR_sty.top=fR_anker.y : fR_sty.top=fR_anker.y+'px';
	if (bN.substr(0,3)=='M4M') fR_sty.left=(parseInt(fR_sty.left)+3)+'px';
}
fR_sty=fL('fRlay'+fRid+'1');
fR_sty.visibility='visible';

}

function fR(fRid,o)
{
for (i=1;i<=fR_menge_1;i++){
	fR_sty=fL('fRlay'+fRid+i);
	(i!=o) ? fR_sty.visibility='hidden' : fR_sty.visibility='visible';
	old_ext = eval('document.fR1'+i).src.split("_");
	(i==o) ? ext='on.gif' : ext='off.gif';
	cI(eval('document.fR1'+i),eval('document.fR1'+i).src.substr(0,(eval('document.fR1'+i).src.length- old_ext[old_ext.length-1].length ))+ext);
	
	}
}

if (navigator.appName.substr(0,1)=='M') //Internet Explorer
{
v=0
if (window.clipboardData) v=1;
bN='M'+(parseFloat(navigator.appVersion)+v); 
(!window.opera) ? null : bN='O';
} else if (navigator.appName.substr(0,1)=='N') //Netscape
{
v=parseFloat(navigator.appVersion)+""
v=v.substr(0,1);
bN='N'+v 
} else { bN='0'}
bN=bN+navigator.platform.substr(0,1);
//Netscape Flash-Abfrage
ver=0;
if (navigator.plugins && navigator.plugins['Shockwave Flash']) 
{
   var words = navigator.plugins["Shockwave Flash"].description.split(" ");
   for (var a = 0; a < words.length; ++a){
		if (isNaN(parseInt(words[a])))
		continue;
		ver = parseInt(words[a]);
    }
} 
(ver>=5) ? bN+=5 : bN+=0;

//Internet Explorer FlashAbfrage
if (bN=='M5W0' || bN=='M4W0')
{
document.write(''+
'<s'+'cript language="VBScript">\nOn error resume next\n'+
'ver=0\n'+
'For i=5 to 3 step -1\n'+
'Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n'+
'v = IsObject(x)\n'+
'if v then \n'+
'ver=i\n'+
'Exit For\n'+
'End If\n'+
'next\n'+
'</scrip'+'t>')
bN=bN.substr(0,3)+ver;
}
// allgemeine funktionen
function NEresize()
{
if (bN.substr(0,2)=='N4') 
{
wsssty=fL('wsslay')
wsssty.visibility='hidden'
self.location=self.location
}
}
(bN.substr(3,4)=='5')? flash=true : flash=false;


function RemWarenkorb(index){
	var ma;
	ma = new myAyax();
	ma.groupName = 'warenkorb_small';
	ma.url = '/ajax/warenkorb/rem_warenkorb.asp?index='+index;
	ma.Request();
}

function RemWarenkorbTO(index,code){
	var ma;
	ma = new myAyax();
	ma.groupName = 'warenkorb_small';
	ma.url = '/ajax/warenkorb/rem_warenkorbTO.asp?index='+index+'&code='+code;
	ma.Request();
}
