﻿function sprawdzAnkiete(){	var error=false;	var firma=document.ankieta.firma.value;	var osoba=document.ankieta.osoba.value;	var adres=document.ankieta.adres.value;	var telefon=document.ankieta.telefon.value;	var email=document.ankieta.email.value;	var jakosc=$("input[name='jakosc']:checked").val();	var terminy=$("input[name='terminy']:checked").val();	var dotrzymywane=$("input[name='dotrzymywane']:checked").val();	var wyroby=$("input[name='wyroby']:checked").val();	var przedstawiciele=$("input[name='przedstawiciele']:checked").val();	var postrzegana=$("input[name='postrzegana']:checked").val();	var wspolpraca=$("input[name='wspolpraca']:checked").val();	var kopia=$("input[name='kopia']:checked").val();	var opinia=$("input[name='opinia']:checked").toArray();	var uwagi=document.ankieta.uwagi.value;		if(!firma){		alert("Company name field is required.");		document.ankieta.firma.focus();		error=true;		return false;	}	if(!osoba){		alert("Contact person field is required.");		document.ankieta.osoba.focus();		error=true;		return false;	}	if(!adres){		alert("Company adress field is required.");		document.ankieta.adres.focus();		error=true;		return false;	}	if(!telefon){		alert("Phone/fax field is required.");		document.ankieta.telefon.focus();		error=true;		return false;	}	if(!email){		alert("E-mail/WWW field is required.");		document.ankieta.email.focus();		return false;	}	if(!jakosc){		alert("Please fix one of field: 6.WZM S.A. products and services quality opinion is");		document.ankieta.jakosc[0].focus();		error=true;		return false;	}	if(!terminy){		alert("Please fix one of field: 7.WZM S.A. orders realization terms are");		document.ankieta.terminy[0].focus();		error=true;		return false;	}	if(!dotrzymywane){		alert("Please fix one of field: 8.Are the order realization terms being held");		document.ankieta.dotrzymywane[0].focus();		error=true;		return false;	}	if(!wyroby){		alert("Please fix one of field: 9.Opinion about WZM S.A. products, which is presented by your clients is");		document.ankieta.wyroby[0].focus();		error=true;		return false;	}	if(!przedstawiciele){		alert("Please fix one of field: 10.Your opinion about WZM S.A. representatives expertness is");		document.ankieta.przedstawiciele[0].focus();		error=true;		return false;	}	if(!postrzegana){		alert("Please fix one of field: 11.Your perception of WZM S.A. company is");		document.ankieta.postrzegana[0].focus();		error=true;		return false;	}	if(opinia==0){		alert("Please fix one or more of field: 12.Your opinion about WZM S.A.");		error=true;		return false;	}	if(!wspolpraca){		alert("Please fix one of field: 13.What is your opinion about co-operation with WZM S.A. in comparison with other, based on similar activity company");		document.ankieta.wspolpraca[0].focus();		error=true;		return false;	}	if(!error){		$.post("/admin/includes/ankieta_send.php",{firma:firma,osoba:osoba,adres:adres,telefon:telefon,email:email,jakosc:jakosc,terminy:terminy,dotrzymywane:dotrzymywane,wyroby:wyroby,przedstawiciele:przedstawiciele,postrzegana:postrzegana,wspolpraca:wspolpraca,opinia:[opinia],uwagi:uwagi,kopia:kopia},function(data){			alert(data);			document.ankieta.reset();		});	}	return false;}function validateEmail(email){// a very simple email validation checking. // you can add more complex email checking if it helps     var splitted = email.match("^(.+)@(.+)$");    if(splitted == null) return false;    if(splitted[1] != null )    {      var regexp_user=/^\"?[\w-_\.]*\"?$/;      if(splitted[1].match(regexp_user) == null) return false;    }    if(splitted[2] != null)    {      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;      if(splitted[2].match(regexp_domain) == null)       {	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;	    if(splitted[2].match(regexp_ip) == null) return false;      }// if      return true;    }return false;}function sprawdzFormularz(){	var osoba=document.kontakt.osoba.value;	var email=document.kontakt.email.value;	var error=false;		if(!osoba){		alert("\"Contact person\" field is required.");		document.kontakt.osoba.focus();		error=true;	}	if(!email && !error){		alert("E-mail address field is required.");		document.kontakt.email.focus();		error=true;	}else{		var valid=validateEmail(email);		if(!valid && !error){			alert("Please enter a valid email address.");			document.kontakt.email.focus();			error=true;		}	}	if(!error){		$.post("/admin/includes/mailform_send.php",{firma:document.kontakt.firma.value,osoba:osoba,tresc:document.kontakt.tresc.value,telefon:document.kontakt.telefon.value,email:email},function(data){			alert(data);			document.kontakt.reset();		});	}	return false;}