document.ifElementContains= function ifElementContains(eid, value, ihtm){
var vapp= (eid.charCodeAt ? document.getElementById(eid) : eid ) || eid;
var val = vapp.value || ihtm || window[vapp] || vapp;
return !! val.match(value);
}
if (typeof document.getElementsByClassName!='function') {
    document.getElementsByClassName = function() {
        var elms = document.getElementsByTagName('*');
        var ei = new Array();
        for (i=0;i<elms.length;i++) {
            if (elms[i].getAttribute('class')) {
                ecl = elms[i].getAttribute('class').split(' ');
                for (j=0;j<ecl.length;j++) {
                    if (ecl[j].toLowerCase() == arguments[0].toLowerCase()) {
                        ei.push(elms[i]);
                    }
                }
            } else if (elms[i].className) {
                ecl = elms[i].className.split(' ');
                for (j=0;j<ecl.length;j++) {
                    if (ecl[j].toLowerCase() == arguments[0].toLowerCase()) {
                        ei.push(elms[i]);
                    }
                }
            }
        }
        return ei;
    }
}
function GetElementInsideContainer(containerID, childID) {
    var elm = document.getElementById(childID);
    var parent = elm ? elm.parentNode : {};
    return (parent.id && parent.id === containerID) ? elm : {};
}
function isPropertySupported(itsproperty, itsparent) {
	return itsproperty in itsparent.style;
}
function getStyle(el, styleProp) {
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return y;
}
function setStyle( itsElement, propertyObject ) {
	if (itsElement!=null) {
		for (var property in propertyObject)
    	if (isPropertySupported(property, itsElement)) itsElement.style[property] = propertyObject[property];
	}
}
var x_enabled=0;
var lastID="";
var lastIcn="";
var lastSource="";
var sourceKeeper="";
var noFade=0;
var targetOpen=false;

function HighlightAllThisOpacity(itsElements, itsHighlicht) {
	for(var i=0,j=itsElements.length; i<j; i++) {	
		if (itsElements.hasOwnProperty(i) && itsElements[i].id!=itsHighlicht) { setStyle(itsElements[i], { 'opacity':'0.3' } ); 
		} else { if (itsElements.hasOwnProperty(i) && itsElements[i].id==itsHighlicht) setStyle(itsElements[i], { 'opacity':'1' }); }
	}
}

function ClassSwitchAll(itsOldClass, itsNewClass, itsUseClass) {
	// itsUseClass = 1 changes itsOldClass to itsNewClass
	// itsUseClass <> 1 changes itsNewClass to itsOldClass
	theElements=document.getElementsByClassName((itsUseClass==1 ? itsOldClass :itsNewClass));
	for(var i=0,j=theElements.length; i<j; i++) { if (theElements.hasOwnProperty(0)) { theElements[0].className=(itsUseClass!=1 ? itsOldClass :itsNewClass); } }
}

function HighlightAll(itsElements, itsPct) {
	for(var i=0,j=itsElements.length; i<j; i++) { if (itsElements.hasOwnProperty(i)) { setStyle(itsElements[i], { 'opacity':itsPct }); } }
}

function SwitchAll(itsClass, itsOn, itsOff) {
	itsElements=document.getElementsByClassName(itsClass);
	for(var i=0,j=itsElements.length; i<j; i++) { if (itsElements.hasOwnProperty(i)) { 
		if (itsElements[i].style['display']==itsOff) setStyle(itsElements[i], { 'display':itsOn }); 
		else setStyle(itsElements[i], { 'display':itsOff }); 
	} }
}

function OpenIcon(itsTarget, itsIcon, itsIconStart, itsNoSource) {
	var theID='pdViewport_'+itsTarget;
	var theTarget = document.getElementById(theID);
	var theSourceID='content_'+itsIcon;
	var theSource = document.getElementById(theSourceID);
	var theTitleID = 'grtitle_'+itsIcon;
	var theTopContainer = theTarget.offsetParent;
	var theMultiWeeks = document.getElementById("cMultiWeeks");
	var theTopWeek = document.getElementById("week_0");
	var theLogistics = document.getElementById("plannerbody");
	
	itsNoSource = typeof itsNoSource !== 'undefined' ? itsNoSource : false;
	itsIconStart = typeof itsIconStart !== 'undefined' ? itsIconStart : "icn_";
	if ((noFade==0) && (lastSource!=theSourceID)) setStyle(theTarget, { 'opacity':'0' });
	
	if ((lastID!="") && (lastID!=theID) && (lastSource!="")) {
		document.getElementById(lastSource).innerHTML=sourceKeeper;
		document.getElementById(lastID).innerHTML="";
	}
	
	if (lastSource==theSourceID) { 
		HighlightAll(document.getElementsByClassName('cPlanWeek'),1);
		HighlightAll(document.getElementsByClassName('cPlanWeekActive'),1);
				
		if (theLogistics!=null)  {
			if (lastSource!="") document.getElementById(lastSource).innerHTML=sourceKeeper;
			theTarget.innerHTML=""; 
			lastID=""; 
			lastSource="";
			sourceKeeper="";
			targetOpen=false;
			if (theMultiWeeks!=null) setStyle(theMultiWeeks, { 'overflow-y':'hidden' });
			if (theTopWeek!=null) theTopWeek.scrollIntoView(true);
		}
	} else { 
		HighlightAll(document.getElementsByClassName('cPlanWeek'),1);
		HighlightAll(document.getElementsByClassName('cPlanWeekActive'),1);

		if ((lastSource!="") && (lastID==theID)) document.getElementById(lastSource).innerHTML=sourceKeeper;
		if (theSource!=null) {
			if (((theSource.innerHTML!="") || (theLogistics!=null)) && (itsNoSource==false)) theTarget.innerHTML=theSource.innerHTML; 
			sourceKeeper=theSource.innerHTML;
			theSource.innerHTML="";
			lastSource=theSourceID;
			targetOpen=true;
		} else lastSource="";
		scrollIntoViewIfOutOfView(theTarget);
		theTitle = document.getElementById(theTitleID);
		if (theMultiWeeks!=null) setStyle(theMultiWeeks, { 'overflow-y':'auto' });
		if ((itsIconStart=="icn_") && (theTopContainer.id!="contentviewer")  && (theTopContainer.id!="ajaxinfodiv") && (theTopContainer.id!="myBody") && (theTopContainer.id!="cMultiWeeks"))  setStyle(theTopContainer, { 'overflow-y':'hidden' });
		if (theTitle!=null) scrollIntoViewIfOutOfView(theTitle);
		lastID=theID; 
		if (!(theTarget==null)) fade(theTarget,0.14);
	}
}

function scrollIntoViewIfOutOfView(el) {
	if (el!=null) {
  var topOfPage = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  var heightOfPage = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  var elY = 0;
  var elH = 0;
  if (document.layers) { // NS4
	elY = el.y;
	elH = el.height;
  } else {
	for(var p=el; p&&p.tagName!='BODY'; p=p.offsetParent){ elY += p.offsetTop; }
	elH = el.offsetHeight;
  }
  if ((topOfPage + heightOfPage) < (elY + elH)) { el.scrollIntoView(false);
  } else if (elY < topOfPage) { el.scrollIntoView(true); }
 	}
}

function ParentIsID(itsMe, itsID) {
	if (itsMe.parentNode!=null) {
		if (itsMe.parentNode.id==itsID) { return true; } else return ParentIsID(itsMe.parentNode, itsID);
	} else return false;	
}
function loadXMLProd(itsLocation, itstarget, itstargetSource, itsMe) { 
	if (targetOpen==true) {
	  	var theTarget = document.getElementById(itstarget);
	  	var theTargetSource=document.getElementById(itstargetSource);
	  	if (!(theTarget==null)) fade(theTarget,1);
		
		if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }  // code for IE7+, Firefox, Chrome, Opera, Safari
		else { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }		// code for IE6, IE5

		xmlhttp.async = false;
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				if (!(theTarget==null)) {
						var theSourceID='content_'+itstargetSource;
						var theSourceTarget = document.getElementById(theSourceID);
			
		if (!ParentIsID(itsMe,"pdViewport_history") && !ParentIsID(itsMe,"pdViewport_related")) {
			theHistoryContentTarget=document.getElementById("pdViewport_history");
			theHistoryContent=document.getElementById("pdViewport_history_1");
			
			if (ParentIsID(itsMe,"pdViewport_history_1") && !(theHistoryContentTarget==null)) theHistoryContentTarget.innerHTML=theHistoryContent.innerHTML;
			else if (theHistoryContentTarget.innerHTML!="") {
				theHistoryContentTarget.innerHTML=theTarget.innerHTML+'<div id="pdViewport_history_1" class="pdViewport" style="margin: 0px;">'+theHistoryContent.innerHTML+'</div>';
			}
		}
						if ((sourceKeeper!="") && (lastSource!="")) {
							document.getElementById(lastSource).innerHTML=sourceKeeper;
							document.getElementById(lastID).innerHTML="";
							lastSource="";
						} else if (!(theSourceTarget==null)) sourceKeeper=theSourceTarget.innerHTML;
			
						theTarget.innerHTML=xmlhttp.responseText;
						if (itstarget=="pdViewport_0") window.history.pushState({"html":xmlhttp.html,"pageTitle":xmlhttp.pageTitle},"", itsLocation.replace('&ajax=-1','&ajax=2'));
						scrollIntoViewIfOutOfView(theTarget);
						if (!(theSourceTarget==null)) theSourceTarget.innerHTML="";
						if (!(theTarget==null)) fade(theTarget,0.14);
				}
			}
		}
		xmlhttp.open("POST",itsLocation,true);
		xmlhttp.send();
	}
}

function loadXMLDoc(itsLocation, itstarget, itsOldContentTarget, itsMe, itsPrint) { 
 var theTarget = document.getElementById(itstarget);
  if ((itsMe==null) && !(theTarget==null)) fade(theTarget,1);
  
  if (loadXMLDoc.arguments.length > 2) { 
  	var theHistoryContentTarget = document.getElementById(itsOldContentTarget); 
  }
  if (loadXMLDoc.arguments.length > 3) { 
  	var theCallID = true; 
  } else var theCallID=false;
  if (loadXMLDoc.arguments.length < 5) itsPrint=0;
  
  if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }  // code for IE7+, Firefox, Chrome, Opera, Safari
  else { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }		// code for IE6, IE5

  xmlhttp.async = false;
  xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4 && xmlhttp.status==200) {
		if (!(theTarget==null)) { 
				theLoadSpotlight=false;
				if (theCallID) {	
					if (ParentIsID(itsMe,"pdViewport_history_2")) {
						theHistoryContent=document.getElementById("pdViewport_history");
						theHistoryContent.innerHTML="";
						theLoadSpotlight=true;
						
					} else if (ParentIsID(itsMe,"pdViewport_history_1")) {
						theHistoryContent=document.getElementById("pdViewport_history_1");
						theHistoryContentTarget=document.getElementById("pdViewport_history");
						theHistoryContentTarget.innerHTML= '<div id="pdViewport_history_1" class="pdViewport" style="margin: 0px;">'+theHistoryContent.innerHTML+'</div>'; 
						theLoadSpotlight=true;
						
					} else if (ParentIsID(itsMe,"pdViewport_history")) {
						theLoadSpotlight=true;
						
					} else if ((itstarget!='userpage') && (itstarget!='cct'))
						{
						theHistoryContent=document.getElementById("pdViewport_history_1");
						theHistoryContentTarget=document.getElementById("pdViewport_history");
						if (!(theHistoryContent==null)) {
							theHistoryContentTarget.innerHTML=theTarget.innerHTML+ '<div id="pdViewport_history_1" class="pdViewport" style="margin: 0px;">'+theHistoryContent.innerHTML+'</div>'; 
						} else if (!(theHistoryContentTarget==null)) theHistoryContentTarget.innerHTML= '<div id="pdViewport_history_1" class="pdViewport" style="margin: 0px;">'+theTarget.innerHTML+'</div>'; 
					}	
				}
				
				if (itsPrint==-1) {
				    var popupWin = window.open('', '_blank', 'width=300,height=300');
				    popupWin.document.open();
				    popupWin.document.write(xmlhttp.responseText);
				    popupWin.document.close();		
				    popupWin.focus();				
				    popupWin.print();
				} else {
					theTarget.innerHTML=xmlhttp.responseText; 
					if (itstarget=="pdViewport_0") window.history.pushState({"html":xmlhttp.html,"pageTitle":xmlhttp.pageTitle},"", itsLocation.replace('&ajax=-1','&ajax=2'));
					if (!(itsMe==null)) if (!ParentIsID(itsMe,"spotlights")) scrollIntoViewIfOutOfView(theTarget);
					if ((itsMe==null) && !(theTarget==null)) fade(theTarget,0.14);
					if (itsLocation.indexOf("cart.add")>-1) loadXMLDoc('call.php?action=user.info&ajax=-1&cartid=-1','userpage');
					//if (theLoadSpotlight) loadXMLDoc("call.php?action=Spotlights&ajax=-1", "spotlights", 0);
				}
		}
	}
  }
  
  xmlhttp.open("POST",itsLocation,true);
  xmlhttp.send();

}

function fade(element, itsIO) {
//	if (1==2) {
	var op = itsIO;  // initial opacity
	if (noFade==0) {
		clearInterval(timer);
		var timer = setInterval(function () {
			if ((op <= 0.1) || (op >1)) { clearInterval(timer); } 
				theValue = 'alpha(opacity=' + op * 100 + ")";
				setStyle(element, { 'opacity':op, 'filter':theValue } );
				if (itsIO<1) { op = op * 1.2; } else { op -= op * 0.2; }
			
		}, 50);
	}
}
function trunc (n) {
	return ~~n;
}
function msieversion() {
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )

	if ( msie > 0 )	// If Internet Explorer, return version number
		return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
	else				// If another browser, return 0
		return 0

   }
function slowScripting() {
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { return true; } else { return false; }
}
function GetAbsPosition(object) {
	var position = new Object;
	position.x = 0;
	position.y = 0;

	if( object ) {
		position.x = object.offsetLeft;
		position.y = object.offsetTop;
	
	if( object.offsetParent ) {
			var parentpos = GetAbsPosition(object.offsetParent);
			position.x += parentpos.x;
			position.y += parentpos.y;
		}
	}

	position.cx = object.offsetWidth;
	position.cy = object.offsetHeight;

	return position;
}
function getEventOffsetXY( evt ) {
	if ( evt.offsetX != null )
		return [ evt.offsetX , evt.offsetY ];

	var obj = evt.target || evt.srcElement;
   	setPageTopLeft( obj );
	return [ ( evt.clientX - obj.pageLeft ) , ( evt.clientY - obj.pageTop ) ];
}
function setPageTopLeft( o ) {
	var top = 0,
	left = 0,
	obj = o;

	while ( o.offsetParent )
	{
		left += o.offsetLeft ;
		top += o.offsetTop ;
		o = o.offsetParent ;
	};

	obj.pageTop = top;
	obj.pageLeft = left;

}
function GetSwitchReturnable(itsElements) {
	wrong=0;
	right=0;
	for (var i=0,j=itsElements.length; i<j; i++) { 
		if ((itsElements[i].style.visibility == "visible") && (itsElements[i].value=='')) wrong++; 
		else if ((itsElements[i].style.visibility == "visible") && (itsElements[i].value!='')) right++;
	}
	if ((wrong>0) || (right==0)) return true; else return false;
}
function swichtReturnable(itsID, itsQuantity) {
	if (itsQuantity==0) {
		document.getElementById(itsID).value='';
		itsV="hidden";
	} else {
		itsV="visible";
	}
	setStyle(document.getElementById(itsID), { 'visibility':itsV } );
	document.getElementById('maakRetourBon').disabled=GetSwitchReturnable(document.getElementsByClassName('reason'));	
}
var last_shown="";
function swichtVisible(itsID, itsV, itsCID) {
	if (swichtVisible.arguments.length<3) itsCID=false;
	if (swichtVisible.arguments.length<2) { if (document.getElementById(itsID).style.visibility == "visible") { itsV="hidden";	} else { itsV="visible"; } } 
	if (itsV == "hidden")  { 
		document.getElementById(itsID).style.height = "0px"; 
		if (itsCID) { if (document.getElementById(itsID).value!='') {  x_enabled=x_enabled-0.9999; document.getElementById(itsID).value=''; } }
	} else { 
		if (last_shown != "") {
			setStyle(document.getElementById(last_shown), { 'visibility':'hidden' } );
			last_shown="";
		}
		document.getElementById(itsID).style.height = "auto"; 
		last_shown=itsID;
	}
	setStyle(document.getElementById(itsID), { 'visibility':itsV } );
}
var ax_source="";
var ax_X=-1;
var ax_Y=-1;
var bhm_content="";
var bhm_contentHolder="";

function bhm_hit(me, itsTarget, itsSx, itsSy, itsSource, itsTmx, itsTmy) { 
	if (itsSource!="") {
		if (bhm_content!="") {
			var theTarget = document.getElementById(bhm_contentHolder);
			theTarget.innerHTML=bhm_content;
			bhm_content="";
		}
		ax_source = document.getElementById(itsSource).src;
		if (document.getElementById(itsTarget).src != ax_source) { 
			document.getElementById(itsTarget).src = ax_source;
			ax_X=itsSx;
			ax_Y=itsSy;
			if (itsSx>itsTmx) {
				itsSy=itsTmx/itsSx*itsSy;
				itsSx=itsTmx; 
			}
			if (itsSy>itsTmy) {
				itsSx=itsTmy/itsSy*itsSx;
				itsSy=itsTmy;
			}
			//if (itsSx<itsTmx) { 
			document.getElementById(itsTarget).style.left='0px'; 
			//Math.round((itsTmx-itsSx)/2)+'px'; } else { document.getElementById(itsTarget).style.left='0px'; }
			document.getElementById(itsTarget).width=Math.round(itsSx); 
				
			if (itsSy<itsTmy) { document.getElementById(itsTarget).style.top=Math.round((itsTmy-itsSy)/2)+'px'; } else { document.getElementById(itsTarget).style.top='0px'; }
			document.getElementById(itsTarget).height=Math.round(itsSy);
		}
	}
}
function bhm_Substitute(itsTarget, itsSource) {
	var theTarget = document.getElementById(itsTarget);
	var theSource=document.getElementById(itsSource);
	if (bhm_content=="") {
		bhm_content=theTarget.innerHTML;
		bhm_contentHolder=itsTarget;
	}
	var theYTC='<iframe width="415" height="240" src="//'+theSource.innerHTML+'" frameborder="0" allowfullscreen></iframe>';
	theTarget.innerHTML=theYTC;
	
}
function bhm_him(me, e, itsTarget, itsSx, itsSy, itsSource, itsTmx, itsTmy) { 
	if (ax_source=="") bhm_hit(me, itsTarget, itsSx, itsSy, itsSource, itsTmx, itsTmy);	
	
	if (slowScripting()==true) {
		//bhm_hit(me, itsTarget, itsSx, itsSy, itsSource, itsTmx, itsTmy);
	} else {
		if (document.getElementById(itsTarget).src == ax_source) { 
		    thePos = getEventOffsetXY(e);
			theSize = GetAbsPosition(me);

			thTxC = Math.round(itsTmx/2);
			theX = -Math.round((Math.abs(thePos[0])/theSize.cx * ax_X))+thTxC; 
			if (document.getElementById(itsTarget).width<ax_X) { document.getElementById(itsTarget).width=ax_X; }
			document.getElementById(itsTarget).style.left=theX+'px'; 

			thTyC = Math.round(itsTmy/2);
			theY = -Math.round((Math.abs(thePos[1])/theSize.cy * ax_Y))+thTyC; 
			if (document.getElementById(itsTarget).height<ax_Y) { document.getElementById(itsTarget).height=ax_Y; }
			document.getElementById(itsTarget).style.top=theY+'px'; 
		}
	}
}	
function bhm_out(me, itsTarget, itsSx, itsSy, itsSource, itsTmx, itsTmy) { 
	if (document.getElementById(itsTarget).src == ax_source) { 
		itsSx=ax_X;
		itsSy=ax_Y;
		if (itsSx>itsTmx) {
			itsSy=itsTmx/itsSx*itsSy;
			itsSx=itsTmx; 
		}
		if (itsSy>itsTmy) {
			itsSx=itsTmy/itsSy*itsSx;
			itsSy=itsTmy;
		}
		// if (itsSx<itsTmx) { 
		document.getElementById(itsTarget).style.left='0px'; 
		// Math.round((itsTmx-itsSx)/2)+'px'; } else { document.getElementById(itsTarget).style.left='0px'; }
		document.getElementById(itsTarget).width=Math.round(itsSx); 
			
		if (itsSy<itsTmy) { document.getElementById(itsTarget).style.top=Math.round((itsTmy-itsSy)/2)+'px'; } else { document.getElementById(itsTarget).style.top='0px'; }
		document.getElementById(itsTarget).height=Math.round(itsSy); 				
	}
}
function clear_focus(e,o,compare){
	if (o.value != compare) {return}
	if(o.firstTime){return}
		o.firstTime=true
		o.value=""
}
function bgstyle(me, itsID, itsImage) {
		if ( msieversion() == 0 )  {
			document.getElementById(itsID).style.background=itsImage;
			alert(document.getElementById(itsID).style.background);
		} else {
			if (bgstyle.arguments.length > 2) { me.style.background=itsImage;
			} else {  me.style.background="";  }
		}
	}
	
function ClickMe(itsLocation, itstarget) { window.open(itsLocation, itstarget); }
function isElement(obj) {
  try {
    //Using W3 DOM2 (works for FF, Opera and Chrom)
    return obj instanceof HTMLElement;
  }
  catch(e){
    //Browsers not supporting W3 DOM2 don't have HTMLElement and
    //an exception is thrown and we end up here. Testing some
    //properties that all elements have. (works on IE7)
    return (typeof obj==="object") &&
      (obj.nodeType===1) && (typeof obj.style === "object") &&
      (typeof obj.ownerDocument ==="object");
  }
}
function UpdateInputFields() {
	for(var i=0; i<14; i++) {
		theElement=document.getElementById('iv_'+i);
		if (!(theElement==null)) updateFieldValid(theElement, "av_"+i);
	}
}
function updateFieldValid(itsElement, itsID) {
	if (!(itsElement==null)) fade(itsElement,1);
	theVerifyBtn=document.getElementById(itsID);
	if (itsElement.value!="") {
		itsElement.className="done_Field inline";
		if (theVerifyBtn) theVerifyBtn.className="im_warned inline";
	} else{
		itsElement.className="inputFields inline";
		if (theVerifyBtn) theVerifyBtn.className="im_warn inline";
	}
	if (itsElement.form.getElementsByClassName('im_warn').length==0) setStyle( itsElement.form.getElementsByClassName("g-recaptcha").GRC, { 'visibility':'visible' } );
	if (!(itsElement==null)) fade(itsElement,0.14);
	if (theVerifyBtn) fade(theVerifyBtn,0.14);
}
function ClickFavourite(itsElement, itsID) {
	fade(itsElement,1);
	if (itsElement.className=="bm_fav_btns bm_fav_del") {
		loadXMLDoc("call.php?action=user.info&ajax=-1&quantity=0&favoriteid="+itsID, "userpage", 0); 
		itsElement.className="bm_fav_btns bm_fav_add";
	} else{
		loadXMLDoc("call.php?action=user.info&ajax=-1&quantity=1&favoriteid="+itsID, "userpage", 0); 		
		itsElement.className="bm_fav_btns bm_fav_del";
	}
	fade(itsElement,0.14);
}
function MailMe() { 
	theCall='call.php?action=infoid&infoid=-904&ajax=-1&email='+document.getElementById('Email').value; 
	loadXMLDoc(theCall, "forgotme"); 
}
var set=false;
var v=0;
var a;
var xSpeed=1;
var xStep=4;
var xLast=0;
var xPause=false;
var xShiftService;
function GotoElement(itsElement, itsNumber, itsWidth) {
	theObject=document.getElementById(itsElement);
	theObject.style.left=(-itsNumber*itsWidth)+'px';
	SelectCurentButton(itsElement, itsNumber);
}
function SelectCurentButton(itsElement, itsNew) {
	theNewButtonObject=document.getElementById(itsElement+"_"+xLast);
	theNewButtonObject.className = "fPI_button";
	
	theNewButtonObject=document.getElementById(itsElement+"_"+itsNew);
	theNewButtonObject.className = "fPI_button_";
	setStyle(document.getElementById("fPI_buttons"), { 'visibility':'visible' } );
	xLast=itsNew;
}
function ShiftService(itsCount, itsWidth) { scrollElement('frontPageImages', xSpeed, itsCount, itsWidth, 0, xStep, 0, 0, 'ShiftService('+itsCount+','+itsWidth+')', 4000); }
var priority="";
function scrollElement(itsElement, itsSpeed, itsNrScrollObjects, itsScrollWidth, itsRigth, itsStep, itsCount, itsPriority, itsLoop, itsLoopSpeed) {
	itsNumber=xLast;
	
	if ((slowScripting()==true) &&  (Math.abs(itsStep)!=Math.abs(itsScrollWidth))) { if (itsStep<0) { itsStep=-itsScrollWidth; } else { itsStep=itsScrollWidth; } }
	
	if (scrollElement.arguments.length < 10) itsLoopSpeed=itsSpeed;
	if (scrollElement.arguments.length < 9) itsLoop="";
	if (scrollElement.arguments.length < 8) itsPriority=0;
	if (itsPriority==1) priority=itsElement;
	if ((priority==itsElement) || (priority=="")) {
		theObject=document.getElementById(itsElement);
		if ((theObject==null)) { return; }
		
		if (itsLoop != "") {
			if (parseInt(theObject.style.left)==-((itsNrScrollObjects-1)*itsScrollWidth)) { itsStep=Math.abs(itsStep); }
			if (parseInt(theObject.style.left)==itsRigth) { itsStep=-Math.abs(itsStep); }
		}
		theObject.style.left=parseInt(theObject.style.left)+itsStep+'px';
		itsCount++;
	}
	theNoTsO=(itsCount*Math.abs(itsStep))/itsScrollWidth;
	if (itsCount<(((itsNrScrollObjects-1)*itsScrollWidth))/Math.abs(itsStep)) {
		if (theNoTsO!=parseInt(theNoTsO)) {	

			setStyle(document.getElementById("fPI_buttons"), { 'visibility':'hidden' } );

			setTimeout(function() { scrollElement(itsElement, itsSpeed, itsNrScrollObjects, itsScrollWidth, itsRigth, itsStep, itsCount, itsPriority, itsLoop, itsLoopSpeed) }, itsSpeed);
		} else if ((itsLoop != "") && (itsCount<(Math.abs(((itsNrScrollObjects-1)*itsScrollWidth))/Math.abs(itsStep)))) { 
			
			if (itsStep<0) itsNumber++; else { if (itsNumber>0) itsNumber--; }
			SelectCurentButton(itsElement, itsNumber);
			setTimeout(function() { scrollElement(itsElement, itsSpeed, itsNrScrollObjects, itsScrollWidth, itsRigth, itsStep, itsCount, itsPriority, itsLoop, itsLoopSpeed) }, itsLoopSpeed);	}
			
	} else if ((itsLoop != "") && (theNoTsO==parseInt(theNoTsO)) && (itsCount>=(Math.abs(((itsNrScrollObjects-1)*itsScrollWidth))/Math.abs(itsStep)))) {
		if (itsStep<0) itsNumber++; else { if (itsNumber>0) itsNumber--; }
		SelectCurentButton(itsElement, itsNumber);
		xShiftService = setTimeout(itsLoop, itsLoopSpeed) 
	} else if ((theNoTsO==parseInt(theNoTsO)) && (priority==itsElement) && (priority!="")) {
		priority="";
	}
}
var cOpacity, d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function so_init(itsImageContainer) {
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement("link");
	css.setAttribute("href","call.php?action=css.xfade");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);
	if (d.getElementById(itsImageContainer)!=null) {
		imgs = d.getElementById(itsImageContainer).getElementsByTagName("img");
		for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
		imgs[0].style.display = "block";
		imgs[0].xOpacity = .99;
		setTimeout(so_xfade,1000);
	}
}
function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

function PrintDiv(itsDiv) {    
    var divToPrint = document.getElementById(itsDiv);
    var popupWin = window.open('', '_blank', 'width=300,height=300');
    popupWin.document.open();
    popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
    popupWin.document.close();
}
  function RECvalidate(event) {
  	theElement=document.getElementById('af_send');
	if (!(theElement==null)) theElement.disabled=false;
  	theElement=document.getElementById('submitBtn');
	if (!(theElement==null)) theElement.disabled=false;
   }
  function RECunvalidate(event) {
  	theElement=document.getElementById('af_send');
	if (!(theElement==null)) theElement.disabled=true;
  	theElement=document.getElementById('submitBtn');
	if (!(theElement==null)) theElement.disabled=true;
   }
  function update_cart(product, char, itsFormPreID, itsTarget, extendcart, inLine) { 
	if ( char == "13" ) { 
		theUrl='call.php?action=cart.replace&productid='+product+'&ajax=-1&inLine='+inLine+'&extendcart='+extendcart+'&gotit=0&called='+itsTarget+'&quantity='+document.getElementById('qtty_'+itsFormPreID+product).value; 
		theElement=document.getElementById('xpid_'+itsFormPreID+product);
		if (!(theElement==null)) theUrl=theUrl+'&xpid='+theElement.value;
		loadXMLDoc(theUrl, 'cct');
	} 
}
function formExecute() {
if (document.forms['RequestForm'].delxBase.value!="") {
 document.forms['RequestForm'].submit();
} else  if ((document.forms['RequestForm'].Ecom_BillTo_Postal_Company.value=="") || (document.forms['RequestForm'].Ecom_ShipTo_Postal_Street_Line1.value=="") || (document.forms['RequestForm'].Ecom_ShipTo_Postal_PostalCode.value=="") || (document.forms['RequestForm'].Ecom_ShipTo_Postal_City.value=="") || (document.forms['RequestForm'].Ecom_ShipTo_Postal_CountryCode.value=="")) { alert('Lieferadresse nicht Komplet!');
} else { document.forms['RequestForm'].submit(); }
} 