arrPictures = new Array();

function FNC_checkFrmContact() {
	document.getElementById('noSpam').value = (2*25)/5;
	
	return true;
}

function FNC_checkFrmChange() {
	objForm = document.forms['change_profile'];
	
	if (objForm.cmp_name.value == '') {
		alert('Vul a.u.b. uw bedrijfsnaam in.');
		objForm.cmp_name.focus();
		return false;
	}
	if (objForm.cmp_abc_nrs.value == '') {
		alert('Vul a.u.b. minimaal één huisnummer van uw vestiging in.');
		objForm.cmp_abc_nrs.focus();
		return false;
	}	
	if (objForm.cmp_abc_zip.value == '') {
		alert('Vul a.u.b. de postcode van uw vestiging  in.');
		objForm.cmp_abc_zip.focus();
		return false;
	}	
	if (objForm.cmp_abc_city.value == '') {
		alert('Vul a.u.b. de plaatsnaam van uw vestiging in.');
		objForm.cmp_abc_city.focus();
		return false;
	}	
	if (objForm.cmp_tel.value == '') {
		alert('Vul a.u.b. het telefoonnummer van uw vestiging in.');
		objForm.cmp_tel.focus();
		return false;
	}	
	if (objForm.cmp_email.value == '') {
		alert('Vul a.u.b. het email adres van uw bedrijf in.');
		objForm.cmp_email.focus();
		return false;
	}	
	if (objForm.cmp_cp_name.value == '') {
		alert('Vul a.u.b. uw eigen naam in.');
		objForm.cmp_cp_name.focus();
		return false;
	}	
	if (objForm.cmp_cp_tel.value == '') {
		alert('Vul a.u.b. uw eigen telefoonnummer in.');
		objForm.cmp_cp_tel.focus();
		return false;
	}	
	if (objForm.cmp_cp_email.value == '') {
		alert('Vul a.u.b. uw eigen email adres in.');
		objForm.cmp_cp_email.focus();
		return false;
	}
	
	objForm.noSpam.value = (3*25)/5;

	return true;
}

function FNC_getWindowHeight() {
	if (screen.height > 900) {
		intCmpWindowHeight = 800;
	}
	else {
		intCmpWindowHeight = screen.height-100;
	}

	return intCmpWindowHeight;
}

objCompanyWindow = false;
function FNC_popUpWin(p_strHref, p_intWidth, p_intHeight) {
	if (objCompanyWindow) {
		objCompanyWindow.close();
	}
	objCompanyWindow = window.open(p_strHref, "", "width=" + p_intWidth + ",height=" + p_intHeight + ",scrollbars=yes,toolbar=no,location=no,left=20,top=20,screenX=0,screenY=100'");
}

function FNC_fadeImage(p_strImageName, p_strImageSrc) {
	document.getElementById(p_strImageName).filters.blendTrans.Apply();
	document.getElementById(p_strImageName).src = p_strImageSrc;
	document.getElementById(p_strImageName).filters.blendTrans.Play();
}

intLastPicture = 0;
function FNC_startSlideShow() {
	intTotalPictures = arrPictures.length;
	if (intTotalPictures > 1) {
		document.getElementById('imgSlideShow').filters.blendTrans.Apply();
		document.getElementById('imgSlideShow').src = arrPictures[intLastPicture].src;
		document.getElementById('imgSlideShow').filters.blendTrans.Play();

		if (intLastPicture < (intTotalPictures-1)) {
			intLastPicture++;
		}
		else {
			intLastPicture = 0;
		}
		x = setTimeout('FNC_startSlideShow()', 5000);
	}
	else {
		return true;
	}
}

//ABC marktplaats functies
function FNC_checkFrmNewAd() {
	objForm = document.forms['frmNewAdvertisement'];
	var strEmailAddressFilter = /^.+@.+\..{2,3}$/
	
	if (objForm.adv_avc_id.options[objForm.adv_avc_id.selectedIndex].value == 0) {
		alert('Selecteer a.u.b. een categorie.');
		objForm.adv_avc_id.focus();
		return false;
	}
	if (objForm.adv_cmp_id.options[objForm.adv_cmp_id.selectedIndex].value == 0) {
		alert('Selecteer a.u.b. een bedrijf.');
		objForm.adv_cmp_id.focus();
		return false;
	}
	if (objForm.adv_contact_name.value == '' || objForm.adv_contact_name.value.length < 2) {
		alert('Vul a.u.b. uw naam in.');
		objForm.adv_contact_name.focus();
		return false;
	}
	if (!strEmailAddressFilter.test(objForm.adv_contact_email.value) || objForm.adv_contact_email.value.length < 4) {
		alert('Vul a.u.b. uw email adres correct in. Uw ontvangt automatisch een email met daarin een link om de advertentie te bevestigen.');
		objForm.adv_contact_email.focus();
		return false;
	}
	if (objForm.adv_location.value == '' || objForm.adv_location.value.length < 3) {
		alert('Vul a.u.b. uw woonplaats of de plaats waar het product te koop staat in.');
		objForm.adv_location.focus();
		return false;
	}
	if (objForm.adv_name.value == '' || objForm.adv_name.value.length < 3) {
		alert('Vul a.u.b. de advertentietitel in.');
		objForm.adv_name.focus();
		return false;
	}
	if (objForm.adv_price.value == '' && objForm.adv_apt_id.options[objForm.adv_apt_id.selectedIndex].value == 0) {
		alert('Vul a.u.b. de prijs van het product of de dienst in of kies een prijsstelling.');
		objForm.adv_price.focus();
		return false;
	}
	objForm.adv_no_spam.value = (4+(8*6))/2;
	
	return true;
}

function FNC_updatePriceField() {
	objForm = document.forms['frmNewAdvertisement'];
	if (objForm.adv_apt_id.options[objForm.adv_apt_id.selectedIndex].value > 0) {
		objForm.adv_price.value = '';
	}
}

function FNC_updatePriceType() {
	objForm = document.forms['frmNewAdvertisement'];
	objForm.adv_apt_id.selectedIndex = 0;
}


function removeAllCommas(A){while(A.indexOf(",")!=-1){A=A.replace(",","","g")}return A}
function removeAllDots(A){while(A.indexOf(".")!=-1){A=A.replace(".","","g")}return A}
function checkMoneyInput(C,B){var A;if(window.event){A=window.event.keyCode}else{if(B){A=B.which}else{return true}}if((A>=58&&A<=126)||(A>=32&&A<=43)||A==45||A==47){return false}else{if(A==44){if(C.value.indexOf(",")!=-1){return false}}}return true}
function formatNoCommaHasDot(C,B){var D=C.lastIndexOf(".");if(D<C.length-3){C=removeAllDots(C);C=C+",00"}else{if(D==B){C=C.replace(".",",","g");if(D==C.length-1){C=C+"00"}else{if(D==C.length-2){C=C+"0"}}}else{if(D==C.length-1){C=removeAllDots(C);C=C+",00"}else{if(D==C.length-2){var A=C.substring(0,D)+",";A=removeAllDots(A);if(C.substring(D+1).length==1){C=A+C.substring(D+1)+"0"}else{C=A+C.substring(D+1)}C=removeAllDots(C)}}}}return C}
function FNC_changePriceFormat(F){var D=""+F.value;var G=D.indexOf(",");var C=D.indexOf(".");if(D=="0,00"||D.length==0){return }if(G==-1&&C==-1){D=D+",00"}else{if(G==-1&&C!=-1){D=formatNoCommaHasDot(D,C)}}D=removeAllDots(D);G=D.indexOf(",");if(G==0){D="0"+D;G=D.indexOf(",")}var E=D.lastIndexOf(",");var B=D.substring(0,G);while(B.indexOf("0")==0&&B.length>1){B=B.substring(1)}B=B+",";var A="";if(E!=G){A=D.substring(G+1);A=removeAllCommas(D)}else{A=D.substring(G+1)}if(A.length>1){D=B+A.substring(0,2)}else{if(A.length==1){D=B+A+"0"}else{if(A.length==0){D=B+"00"}}}D=insertThousandsDots(D);F.value=D}
function insertThousandsDots(A){if(parseInt(A)>=9999999){A="9.999.999,00"}else{commaLoc=A.indexOf(",");euros=A.substring(0,commaLoc);cents=A.substring(commaLoc);if(euros.length>3){if(euros.length>5){cents=""}if(euros.length>6){euros=euros.substring(0,euros.length-6)+"."+euros.substring(euros.length-6)}euros=euros.substring(0,euros.length-3)+"."+euros.substring(euros.length-3)}A=euros+cents}return A}

function FNC_getPopupPicWin(strUrl) {
	window.open(strUrl, "",  "resizable=1,height=50,width=50,toolbars=no,location=no,status=no"); 
}

function FNC_submitAdvContact() {
	objForm = document.forms['frmAdvContact'];
	var strEmailAddressFilter = /^.+@.+\..{2,3}$/

	if (objForm.contact_name.value == '' || objForm.contact_name.value.length < 2) {
		alert('Vul a.u.b. uw naam in.');
		objForm.contact_name.focus();
		return false;
	}
	if (!strEmailAddressFilter.test(objForm.contact_email.value) || objForm.contact_email.value.length < 4) {
		alert('Vul a.u.b. uw email adres correct in.');
		objForm.contact_email.focus();
		return false;
	}
	
	objForm.adv_no_spam.value = (4+(9*4))/4;
	return true;
}