var SifrAanHetLaden = '2';
var HuidigSubMenuID = '';
var HuidigMenuItem = '';

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

$(document).ready(function () {
	
});

function LaadSifr(){
	if(SifrAanHetLaden == '2'){
		SifrAanHetLaden = '1';
		
		$('.kop1').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		
		$('.kopFlowershipping').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		
		$('.kopArcazen').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		
		$('.kopBusiness').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		$('.kopBulb').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		$('.kopRecycling').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		$('.kopMicro').sifr( {
			font: URLPref + 'fonts/helvetiva_neue',
			textAlign : 'left'
		});
		$('.kop3Flowershipping').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.kop3Business').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.kop3Bulb').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.kop3Recycling').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.kop3Micro').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.kop4').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'right'
		});
		$('.SifrLinkje').sifr( {
			font: URLPref + 'fonts/helvetica_neue_light',
			textAlign : 'left'
		});
		
		
		SifrAanHetLaden = '2';
	}
}

function BerekenHoogtes(){
	var browserName=navigator.appName;
	if(browserName == 'Microsoft Internet Explorer'){
		var Hoogte = document.getElementById('ContentContainer').offsetHeight;
	} else {
		var Hoogte = document.getElementById('ContentContainer').clientHeight;
	}
	document.getElementById('ImgSchaduwLinks').style.height = Hoogte + 'px';
	document.getElementById('ImgSchaduwRechts').style.height = Hoogte + 'px';
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};
/**
 / THIRD FUNCTION
 * getPageScroll() by quirksmode.com
 *
 * @return Array Return an array with x,y page scroll values.
 */
function getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
};

function ToonMelding(Pagina){
	var arrayPageSizes = getPageSize();
	var PaginaHoogte = (arrayPageSizes[1]+"px");
	var PaginaBreedte = '100%';
	
	//document.getElementById('GaSnelNaar').style.visibility = 'hidden';
	document.getElementById('DivAlertBoxAchtergrond').style.height = PaginaHoogte;
	document.getElementById('DivAlertBoxAchtergrond').style.width = PaginaBreedte;
	
	
	LaadMeldingInDiv(Pagina, 'DivAlertBoxContent');
	
	var NieuweBreedteDiv = 600;
	var NieuweHoogteDiv = 200;
	
	var arrPageScroll = getPageScroll();
	var arrPageSizes = getPageSize();
	var TopPositie = arrPageScroll[1] + (arrPageSizes[3] / 10),
	TopPositie = TopPositie+'px';
	document.getElementById('DivAlertBoxContent').style.top = TopPositie;

	var LinkerPositie = ((arrPageSizes[0] - NieuweBreedteDiv)/2);
	LinkerPositie = LinkerPositie+'px';
	document.getElementById('DivAlertBoxContent').style.left = LinkerPositie;
}

function LaadMeldingInDiv(option, DivID) {
	var urls = option;
	if(window.XMLHttpRequest) {
		reqss = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		reqss = new ActiveXObject("Microsoft.XMLHTTP");
	}
	reqss.open("GET", urls, true);
	reqss.onreadystatechange = callbackMelding;
	
	reqss.send(null);
}

function callbackMelding(DivID) {
	if(reqss.readyState != 4) { 
		document.getElementById('DivAlertBoxContent').innerHTML = '';
	}
	
	if(reqss.readyState == 4) {
		if(reqss.status == 200) {
			response = reqss.responseText;
			document.getElementById('DivAlertBoxContent').innerHTML = response;
			$('#DivAlertBoxAchtergrond').css({ backgroundColor: '#000', opacity: '0.7' }).fadeIn('300', function(){
				$('#DivAlertBoxContent').fadeIn('300',function(){
					LaadSifr();
					$('img[@src$=.png]').ifixpng();
				});
			});
			
		} else {

		}
	}
}

function MeldingSluiten(Pagina){
	$('#DivAlertBoxContent').fadeOut('300', function() {
		$('#DivAlertBoxAchtergrond').fadeOut('300');
	});
}

function ToonUiklapmenu(MenuItem){
	$('#' + MenuItem).animate({width: '220px'},'300');
}
function VerbergUiklapmenu(MenuItem){
	$('#' + MenuItem).animate({width: '0px'},'300');
}
function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, prec = decimals;
    var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
    };
 
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
 
    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = toFixedFix(Math.abs(n), prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
    if (s.indexOf(dec) === -1 && prec > 1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    var Temp = s.split(",");
    if(Temp[1].length == '1'){
    	s = s+'0';
    }
    return s;
}

function VeranderNeus(){
	/*
	var EnkelEenheden = Math.ceil(document.getElementById('InputEnkelneus').value / 1000);
	var EnkelPrijs = (document.getElementById('KostenEnkelneus').value * EnkelEenheden);
	document.getElementById('SchubPrijsEnkel').innerHTML = '&euro; '+number_format(EnkelPrijs, 2, ',', ' ');
	*/
	
	var EnkelEenheden = document.getElementById('InputEnkelneus').value;
	var EnkelPrijs = ((document.getElementById('KostenEnkelneus').value / 1000) * EnkelEenheden);
	document.getElementById('SchubPrijsEnkel').innerHTML = '&euro; '+number_format(EnkelPrijs, 2, ',', ' ');
	/*
	var DubbelEenheden = Math.ceil(document.getElementById('InputDubbelneus').value / 1000);
	var DubbelPrijs = (document.getElementById('KostenDubbelneus').value * DubbelEenheden);
	document.getElementById('SchubPrijsDubbel').innerHTML = '&euro; '+number_format(DubbelPrijs, 2, ',', ' ');
	*/
	var DubbelEenheden = document.getElementById('InputDubbelneus').value;
	var DubbelPrijs = ((document.getElementById('KostenDubbelneus').value / 1000) * DubbelEenheden);
	document.getElementById('SchubPrijsDubbel').innerHTML = '&euro; '+number_format(DubbelPrijs, 2, ',', ' ');
	
	var SubTotaalPrijs = ((EnkelPrijs * 1) + (DubbelPrijs * 1));
	document.getElementById('SchubPrijsSubtotaal').innerHTML = '&euro; '+number_format(SubTotaalPrijs, 2, ',', ' ');
	var BTW = (SubTotaalPrijs * 0.06);
	document.getElementById('SchubPrijsBTW').innerHTML = '&euro; '+number_format(BTW, 2, ',', ' ');
	var TotaalPrijs = (SubTotaalPrijs * 1.06);
	document.getElementById('SchubPrijsTotaal').innerHTML = '&euro; '+number_format(TotaalPrijs, 2, ',', ' ');
}

function PlaatsOrder(){
	var VerderGaan = '1';
	
	if(document.FormBestellen.InputEnkelneus.value < 1 && document.FormBestellen.InputDubbelneus.value < 1){
		document.FormBestellen.InputEnkelneus.style.backgroundColor = '#FFE8E8';
		document.FormBestellen.InputDubbelneus.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.InputEnkelneus.style.backgroundColor = '#FFFFFF';
		document.FormBestellen.InputDubbelneus.style.backgroundColor = '#FFFFFF';
	}
	
	if(document.FormBestellen.Bedrijfsnaam.value == ''){
		document.FormBestellen.Bedrijfsnaam.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Bedrijfsnaam.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Contactpersoon.value == ''){
		document.FormBestellen.Contactpersoon.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Contactpersoon.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Adres.value == ''){
		document.FormBestellen.Adres.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Adres.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Postcode.value == ''){
		document.FormBestellen.Postcode.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Postcode.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Plaats.value == ''){
		document.FormBestellen.Plaats.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Plaats.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Telefoon.value == ''){
		document.FormBestellen.Telefoon.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Telefoon.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.Email.value == ''){
		document.FormBestellen.Email.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.Email.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.FactuurAdres.value == ''){
		document.FormBestellen.FactuurAdres.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.FactuurAdres.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.FactuurPostcode.value == ''){
		document.FormBestellen.FactuurPostcode.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.FactuurPostcode.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.FactuurPlaats.value == ''){
		document.FormBestellen.FactuurPlaats.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.FactuurPlaats.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.OpafhaalAdres.value == ''){
		document.FormBestellen.OpafhaalAdres.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.OpafhaalAdres.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.OpafhaalPostcode.value == ''){
		document.FormBestellen.OpafhaalPostcode.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.OpafhaalPostcode.style.backgroundColor = '#FFFFFF';
	}
	if(document.FormBestellen.OpafhaalPlaats.value == ''){
		document.FormBestellen.OpafhaalPlaats.style.backgroundColor = '#FFE8E8';
		VerderGaan = '2';
	} else {
		document.FormBestellen.OpafhaalPlaats.style.backgroundColor = '#FFFFFF';
	}
	if(VerderGaan == '1'){
		if(document.FormBestellen.AkkoordAlgemeneVoorwaarden.checked == false){
			ToonMelding(URLPref+'alert.php?Tekstje='+AkkoordVerplicht);
		} else {
			document.FormBestellen.submit();
		}
	} else {
		ToonMelding(URLPref+'alert.php?Tekstje='+MeldingVeldenVerplicht);
	}
}

function OrderVolgendeStap(){
	$('#VerderKnop').fadeOut(400, function(){
		$('#BestelUwGegevens').slideDown(500, function(){
/*			 $.scrollTo('#BestelUwGegevens');*/
		});
	});
}