lupe_href  = 'xSystem/images/icons/lupe.png';


function initFancyBox() {
	var args = initFancyBox.arguments;
	$(document).ready(function() {
		$("a#"+args[0]).fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'hideOnContentClick'	: true,
			'showNavArrows'			: false,
			'showCloseButton'		: true,
			'transitionIn'			: 'elastic',
			'transitionOut'			: 'elastic'			
		});
	});
}
function initFancyBox4Images() {
	var args = initFancyBox4Images.arguments;
	var oNode = null;
	switch (args[1].substr(0,4)) {
		case ('file'):			
			if (args[1].lastIndexOf(".pdf") > 0){
				if ((oNode = document.getElementById(args[0])) != null) {
					for(i=0; i < oNode.childNodes.length; i++) {
						if (oNode.childNodes[i].tagName == 'IMG') {
							oNode.childNodes[i].src = 'xSystem/images/icons/pdf.gif';
						}
					}
				}
				openiFrameFancyBox(args[0]);
				break;
			}
			initFancyBox(args[0]);	
			break;
		case ('http'):
			openiFrameFancyBox(args[0]);
			break;
					//xSystem/images/icons/pdf.gif
	}	
}
function openiFrameFancyBox4Frm() {
	var args = openiFrameFancyBox4Frm.arguments;
	if (args[0] != ''){
		$("#"+args[0]).fancybox({
			'width'				: 500,
			'height'			: 600,		
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true
		});	
	}

}
function openiFrameFancyBox4Video() {
	var args = openiFrameFancyBox4Video.arguments;
	if (args[0] != ''){
		$("#"+args[0]).fancybox({
			'autoScale'			: true,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true			
		});	
	}
}
function openiFrameFancyBox() {
	var args = openiFrameFancyBox.arguments;
	var iFrameURL = args[0];
	var iFrameWidth = args[1];
	var iFrameHeight = args[2];
		//	
	if (iFrameURL != ''){
		if (iFrameWidth == null) {
			iFrameWidth = 850;
		}
		if (iFrameHeight == null) {
			iFrameHeight = 600;
		}
		$("#"+args[0]).fancybox({
			'width'				: iFrameWidth,
			'height'			: iFrameHeight,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true			
		});	
	}
}

function imgProdukt() {
	var args =imgProdukt.arguments;
	var oElem = args[0];
	var isOver = args[1];
	var path =(isOver==true)?"bunt/":"sw/";
	var key = args[2];

	if (isOver == true) {
		oElem.src = "xSystem/images/produkteLEFT/"+domainPath+"bunt/"+key+".jpg";
	} else {
//		path = (((typeof(produkte[mainAlias])=='undefined')||(key==mainAlias))?'bunt/':'sw/')
		if ((typeof(produkte[mainAlias])=='undefined')||(key==mainAlias)) {
			var path = (((mainAlias=='home')||(key==mainAlias))?'bunt/':'sw/')
		} else {
			var path = 'sw/';
		}		
		oElem.src = "xSystem/images/produkteLEFT/"+domainPath+path+key+".jpg";
	}	
}
function switchImgProdukte() {
	var oElem = null;
	if (typeof(produkte[mainAlias])=='undefined') {
//		var pathDefault = 'bunt/';
		var pathDefault = ((mainAlias=='home')?'bunt/':'sw/')
	} else {
		var pathDefault = 'sw/';
	}
//	var pathDefault = ((typeof(produkte[mainAlias])=='undefined')?'bunt/':'sw/')

	for (keyProdukt in produkte) {
		if ((oElem = document.getElementById('imgProdukt_'+keyProdukt)) != null) {		
			path = ((keyProdukt == mainAlias)?"bunt/":pathDefault);
			oElem.src = "xSystem/images/produkteLEFT/"+domainPath+path+keyProdukt+".jpg";
			if (keyProdukt==mainAlias) {
				oElem.parentNode.href= "xSystem/images/produkteLEFT/"+domainPath+"popup/"+keyProdukt+".jpg";
				oElem.parentNode.id= "aProdukt_PopUp_"+keyProdukt;
			}

		}
	}
}
function switchImgProdukte_sik() {
	var oElem = null;
	var pathDefault = ((typeof(produkte[mainAlias])=='undefined')?'bunt/':'sw/')

	for (keyProdukt in produkte) {
		if ((oElem = document.getElementById('imgProdukt_'+keyProdukt)) != null) {		
			path = ((keyProdukt == mainAlias)?"bunt/":pathDefault);
			oElem.src = "xSystem/images/produkteLEFT/"+domainPath+path+keyProdukt+".jpg";
			if (keyProdukt==mainAlias) {
				oElem.parentNode.href= "xSystem/images/produkteLEFT/"+domainPath+"popup/"+keyProdukt+".jpg";
				oElem.parentNode.id= "aProdukt_PopUp_"+keyProdukt;
			}

		}
	}
}
function news2FancyBox() {
	var args =news2FancyBox.arguments;
	openFancyBox(args[0]);
}
function chkLink4LightBox() {
	var args =chkLink4LightBox.arguments;
	var oLinks = document.getElementsByTagName("a");
	
	for (var i = 0; i < oLinks.length; i++) {
		if (oLinks[i].rel == 'lightbox') {
			if (oLinks[i].id == '') {
				oLinks[i].id = 'link_'+i;				
			}
			if(oLinks[i].onclick != null) {
				oLinks[i].onclick = null;
				openiFrameFancyBox(oLinks[i].id);
			} else {
				initFancyBox(oLinks[i].id);
			}
			if (lupe_href) {
				addLupe2ImageContainer(oLinks[i]);			
			}			
		}
	}
}
	
function chkDivs4KlappBox() {
	var args =chkDivs4KlappBox.arguments;
	var oNode = new Array();
	var oDivs = document.getElementsByTagName('div');
	var i, iChild, headerText = null;
	KlappBoxHeaderDefault = 'Lesen Sie mehr ...'
	var KlappBoxDefault = true;
	
	for (var i = 0; i < oDivs.length; i++) {
		KlappBoxHeader = KlappBoxHeaderDefault;
		if (oDivs[i].className.lastIndexOf('KlappBox') >=0) {
			oNode['divKB'] = oDivs[i];			
			if (oNode['divKB'].id == '') {
				oNode['divKB'].setAttribute('id','KlappBox_'+i);
			}
			for (iChild=0; iChild < oNode['divKB'].childNodes.length; iChild++) {
				if (oNode['divKB'].childNodes[iChild].tagName == 'H6') {
					KlappBoxHeader = oNode['divKB'].childNodes[iChild].innerHTML;
					oNode['divKB'].removeChild(oNode['divKB'].childNodes[iChild]);
					KlappBoxDefault = false;
					break;
				}
			}			
			oNode['parent'] = oNode['divKB'].parentNode;		
			oNode['spanSW'] = document.createElement('SPAN');		
			oNode['spanSW'].className = 'swKlappBoxContainer';
			oNode['aSW'] = document.createElement('a');			
			oNode['aSW'].className = 'switchKlappBox icon_none';
			oNode['aSW'].setAttribute('id','swkb_'+i);
			oNode['aSW'].setAttribute('href', "javascript:switchKlappbox('"+oNode['divKB'].id+"', '"+oNode['aSW'].id+"', '"+KlappBoxHeader+"',"+KlappBoxDefault+")");
			oNode['aSW'].appendChild((KlappBoxDefault)?document.createTextNode(KlappBoxHeader):createNodeKlappboxHeader(KlappBoxHeader));
//			oNode['aSW'].appendChild(createNodeKlappboxHeader(KlappBoxHeader));
//			oNode['aSW'].appendChild(document.createTextNode(KlappBoxHeader));
			oNode['spanSW'].appendChild(oNode['aSW']);
			//oNode['aSW'].setAttribute('id', 'div_event_'+key);
			//oNode['aSW'].className = 'KlappBox_Switch';
			
			oNode['parent'].insertBefore(oNode['spanSW'],oNode['divKB']);
//			oNode['parent'].appendChild(oNode['spanSW'],oNode['divKB']);

			oNode['divKB'].style.display='none';	
		}
		if (oDivs[i].className.lastIndexOf('ce_accordion') >=0) {		
//			oDivs[i].style.display='none';	
		}
	}
}
function switchKlappbox() {
	var args =switchKlappbox.arguments;
	var DivKlappBox = null;
	var swKlappBox = null;
	var KlappBoxHeader = args[2];
	var KlappBoxDefault = args[3];
	if ((DivKlappBox = document.getElementById(args[0])) != null) {		
		DivKlappBox.style.display=(DivKlappBox.style.display !='block')?'block':'none';
		if ((swKlappBox = document.getElementById(args[1])) != null) {		
			swKlappBox.className = 'switchKlappBox icon_'+DivKlappBox.style.display;
			while (swKlappBox.childNodes.length > 0) {
				var oNode = swKlappBox.firstChild;
				swKlappBox.removeChild(oNode)
			}
			if (DivKlappBox.style.display !='block') {
				swKlappBox.appendChild(
					(KlappBoxDefault)?document.createTextNode(KlappBoxHeader):createNodeKlappboxHeader(KlappBoxHeader)
					);
			} else {
				if (KlappBoxHeader != KlappBoxHeaderDefault) {
					swKlappBox.appendChild(
						(KlappBoxDefault)?document.createTextNode(KlappBoxHeader):createNodeKlappboxHeader(KlappBoxHeader)
					);
					//createNodeKlappboxHeader(KlappBoxHeader));
				} else {
					swKlappBox.appendChild(document.createTextNode(''));
				}
			}
		}		
	}
}
function createNodeKlappboxHeader() {
	var args =createNodeKlappboxHeader.arguments;
	var oNode = document.createElement('H6');	
	oNode.appendChild(document.createTextNode(args[0]));
	return oNode;
	
}
function chkTooglerAccordion() {
}
function addLupe2ImageContainer() {
	var args = addLupe2ImageContainer.arguments;
	var oNode = new Array;		
	var i = null;
	oNode['a_img'] = args[0];
	oNode['a_cloneImage'] = args[0].cloneNode(true);
	oNode['a_lupe'] = args[0].cloneNode(false);
	oNode['div_parent'] = args[0].parentNode;
	for (i=0; i < oNode['div_parent'].childNodes.length; i++) {
			// Alle ChildNodes des Parent werden durchlaufen
		if (oNode['div_parent'].childNodes[i] == oNode['a_img'] ) {
				// erzeuge eine DIV-Ebene
			oNode['div_container'] = document.createElement('DIV');
			oNode['div_container'].className = 'image_container4zoom';						
				// klebe geklontes Image an neue Ebene
			oNode['div_container'].appendChild(oNode['a_cloneImage']);	
				// erzeuge DIV-Ebene für Lupe
			oNode['div_lupe'] = document.createElement('DIV');
			oNode['div_lupe'].className = 'lupe4zoom';
				// erzeuge Link fuer Lupe
			oNode['a_lupe'].setAttribute('rel', '');			
			
				// erzeuge Image-Lupe
			oNode['img_lupe'] = document.createElement('IMG');
			oNode['img_lupe'].setAttribute('src', lupe_href);
			oNode['img_lupe'].setAttribute('alt',"Zoom");
			oNode['img_lupe'].setAttribute('title',oNode['img_lupe'].getAttribute('alt'));
			oNode['img_lupe'].setAttribute('border','0');							
				// klebe Lupen-Image an Link-Lupe
			oNode['a_lupe'].appendChild(oNode['img_lupe']);
				// klebe geklonten Link an Lupen-Ebene
			oNode['div_lupe'].appendChild(oNode['a_lupe']);					
				// klebe Lupen-Ebene an DIV-Container
			oNode['div_container'].appendChild(oNode['div_lupe']);	
			
			oNode['div_parent'].replaceChild(oNode['div_container'],oNode['div_parent'].childNodes[i]);		
			break;
		}
		
	}
}
