
function majl(aleco){
domena="swiezyoddech.pl";
document.write("<a href=\"mailto:");
document.write(aleco+"@");
document.write(domena+"\">");
document.write(aleco+"@");
document.write(domena+"</a>");
}

function toggle(cos){
	a=document.getElementById(cos);
	//alert(a.style.display);
	if(a.style.display=="block"){
		a.style.display="none"
	}
	else
	{
		a.style.display="block"
	}
}


var popup;
function pop(url,myWidth,myHeight ) { 
    myLeft = (screen.width-myWidth)/2;
    myTop = (screen.height-myHeight)/2;
    coords = 'scrollbars=0, resizable=0,left='+myLeft+',top='+myTop+',width='+myWidth+',height='+myHeight;
    if (popup) popup.close();
	popup=window.open(url,'popek',coords);
	}

function roll(){
	this.src = this.src.replace("_off","_on");
	}
function out(){
	this.src = this.src.replace("_on","_off");
	}
im=document.images;

function roller(){
ladowane = new Array();
for (i=0; i<(im.length); i++) {
	if (im[i].src.search('_off.jpg')!=-1){
		ladowane[i] = new Image;
		ladowane[i].src = im[i].src.replace("_off","_on");
		im[i].onmouseover = roll;
		im[i].onmouseout = out;
		}
	}
}

function recount(){
	f=document.forms[0];
	subtotal=parseInt(f.basic_plus.value)*239 + parseInt(f.basic.value)*169 + parseInt(f.rinse.value)*79 + parseInt(f.rinse_plus.value)*119 + parseInt(f.gel.value)*79 + parseInt(f.gel_plus.value)*119 + parseInt(f.spray.value)*59 + parseInt(f.cleaner.value)*14 + parseInt(f.squigi.value)*21 + parseInt(f.floss.value)*59 + parseInt(f.rinse_perio.value)*109 + parseInt(f.user.value)*209 + parseInt(f.user_plus.value)*309 /*+ parseInt(f.gum.value)*16 + parseInt(f.zox.value)*12 + parseInt(f.strips.value)*21 */+ parseInt(f.gel_aktiv.value)*109 /*+ parseInt(f.serum.value)*149*/ + parseInt(f.travel.value)*149 + parseInt(f.weekend.value)*59 /*+ parseInt(f.gel_nofluor.value)*69*/ + parseInt(f.rinse_brite.value)*139 + parseInt(f.gel_brite.value)*139 + parseInt(f.basic_brite.value)*279 + parseInt(f.basic_mix.value)*199 + parseInt(f.user_mix.value)*249;
	f.suma.value=subtotal;
	f.shipping.value=f.payment.value;
	
	if ((parseInt(f.shipping.value)<25)&&((subtotal >= 199.9) || parseInt(f.basic.value)|| parseInt(f.user.value)|| parseInt(f.travel.value) || parseInt(f.basic_mix.value))){
		wysylka = 0;
		f.shipping.style.textDecoration="line-through";
		}else{
		
		f.shipping.style.textDecoration="none";
		wysylka=parseInt(f.shipping.value);
		}
	if(subtotal){
		f.alles.value = subtotal+wysylka;
		}else{
		f.alles.value="0"
	}
	
}

function validuj(){
	f=document.forms[0];
	if(f.alles.value=="0") {
		alert("Nie wybrano produktów");
		return false;
	}else{	
		var check="Uzupełnij:\n\n";
		if (!f.imie.value) check+="imię\n";
		if (!f.nazwisko.value) check+="nazwisko\n";
		if (!f.adres.value) check+="adres\n";
		if (!f.miasto.value) check+="miasto\n";
		if(!/^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(f.email.value)){
   	    check+='prawidłowy adres email\n';
 	    }
 	    if(!/^\d\d-\d{3}$/.test(f.kod.value)){
 	     check+='kod pocztowy w formacie: XX-XXX\n';
    	}
		if(!/^[\d )\/(-]{9,}$/.test(f.telefon.value)){
			check+="numer telefonu wraz z kierunkowym\n\n"
		}
		if(!f.zgoda.checked)check+="Wymagana jest zgoda na przetwarzanie danych osobowych";
		if (check!="Uzupełnij:\n\n"){
			alert(check);
			return false;
			}else{
				return true;
			}
	}
}

