var popupCurrent = 0;
var popupMailAFriend = false;

function popup_show(elem){
	popupCurrent = elem.getAttribute('pureId');
	document.getElementById('popup_aanbod_aantal').value = document.getElementById('product_' + popupCurrent).value;
	document.getElementById('popup_img').src = elem.getAttribute("afb");
	if(elem.getAttribute('specialPopup')!=''){
		document.getElementById('popup_aanbod_bar_top').style.backgroundColor = '#' + elem.getAttribute('specialPopup');
		document.getElementById('popup_aanbod_bar_bottom').style.backgroundColor = '#' + elem.getAttribute('specialPopup');
		document.getElementById('popup_aanbod_aantal_min').style.backgroundColor = '#' + elem.getAttribute('specialPopup');
		document.getElementById('popup_aanbod_aantal_plus').style.backgroundColor = '#' + elem.getAttribute('specialPopup');
	}
	document.getElementById('popup_placeHolder_name').innerHTML = elem.getAttribute('windowName');
	document.getElementById('popup_aanbod_achtergrond').className="popup_aanbod_visible";
	document.getElementById('popup_aanbod_content').className="popup_aanbod_visible";
};

function popup_hide(){
	document.getElementById('popup_img').src = "online/images/eenmoment.gif";
	document.getElementById('popup_aanbod_achtergrond').className="popup_aanbod_invisible"; 
	document.getElementById('popup_aanbod_content').className="popup_aanbod_invisible";
	if(popupMailAFriend) popup_mailAFriend();
};

function popup_mailAFriend() {
	popupMailAFriend = !popupMailAFriend;
	document.getElementById('popup_placeHolder_img').className = (popupMailAFriend ? 'rowHidden' : 'rowVisible');
	document.getElementById('popup_placeHolder_mailAFriend').className = (popupMailAFriend ? 'rowVisible' : 'rowHidden');
}

function validateForm_mailafriend(){
	var elem; 
	var element;
	var errs=0;
	var falseColor = "#ed1c24";
	var trueColor = "white";
	
	element = document.getElementById('mailafriend_from_email'); 	if (!validateEmail   (element, true)) { errs += 1; element.style.backgroundColor = falseColor;	} else { element.style.backgroundColor = trueColor }
	element = document.getElementById('mailafriend_to_email'); 		if (!validateEmail   (element, true)) { errs += 1; element.style.backgroundColor = falseColor;	} else { element.style.backgroundColor = trueColor }
	element = document.getElementById('mailafriend_from_name'); 	if (!validatePresent (element, true)) { errs += 1; element.style.backgroundColor = falseColor;	} else { element.style.backgroundColor = trueColor }
	element = document.getElementById('mailafriend_to_name'); 		if (!validatePresent (element, true)) { errs += 1; element.style.backgroundColor = falseColor;	} else { element.style.backgroundColor = trueColor }

	if (errs>=1){
		document.getElementById('alertMessage').innerHTML = '<strong><font color="red">U heeft een of meerdere velden niet correct ingevuld.</font></strong>';
	}	
	return (errs==0);
};

