/* 
 * Project name :
 * Page name:
 * Power by CagunA Software
 * www.publidesign.org
 */


// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){
return (false);
}
}

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);
}

}

}



function check_form(f) { // f is the form (passed using the this keyword)
var Mesage ="";
// check name
if(!f.nume.value){
	Mesage += "# Trebuie sa specificati numele! \n";
}

//check prenume
if(!f.prenume.value){
	Mesage += "# Trebuie sa specificati prenumele! \n";
}

if(!f.telefon.value){
	Mesage += "# Trebuie sa specificati nr. de telefon! \n";
}



// check the first email address ( the exclamation means "not" )
if(!check_email(f.email.value)){
	Mesage += "# Trebuie sa specificati o adresa de email corecta \n";
f.email.focus();
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.email.style.background = "yellow";
}

// make sure the form is not submitted

}



if(!f.ocup.value){
	Mesage += "# Trebuie sa specificati ocupatia \n";
}

if((true == f.vineri1.checked) || (true == f.vineri2.checked) || (true == f.sambata1.checked) || (true == f.sambata2.checked)){
}else{
	Mesage += "# Trebuie sa specificati ziua in care doriti sa plantati \n";
}

if(Mesage == ""){
	return true;
}else{

alert("Trebuie sa comletati urmatoarele \n "+Mesage+"");
return false;
}
}


function check_juridic_form(f){
	
	var Mesage ="";	
	if(!f.firma.value){
		Mesage += "# Trebuie sa specificati numele firmei! \n";
	}

	
	if(!f.per_contact.value){
		Mesage += "# Trebuie sa specificati o persoana de contact! \n";
	}
	
	if(!f.func.value){
		Mesage += "# Trebuie sa specificati functia! \n";
	}

	if(!f.telefon.value){
		Mesage += "# Trebuie sa specificati nr. de telefon! \n";
	}
	
	if(!f.adresa.value){
		Mesage += "# Trebuie sa specificati adresa! \n";
	}


	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.email.value)){
		Mesage += "# Trebuie sa specificati o adresa de email corecta \n";
	f.email.focus();
	// if the browser is Netscape 6 or IE
	if(document.all || document.getElementByID){
	// change the color of text field
	f.email.style.background = "yellow";
	}

	// make sure the form is not submitted

	}

	
	if(Mesage == ""){
		return true;
	}else{

	alert("Trebuie sa comletati urmatoarele \n "+Mesage+"");
	return false;
	}
}



function check_fizic_form(f){
	
	var Mesage ="";	
	if(!f.nume.value){
		Mesage += "# Trebuie sa specificati numele! \n";
	}

	//check prenume
	if(!f.prenume.value){
		Mesage += "# Trebuie sa specificati prenumele! \n";
	}
	


	if(!f.telefon.value){
		Mesage += "# Trebuie sa specificati nr. de telefon! \n";
	}
	
	if(!f.adresa.value){
		Mesage += "# Trebuie sa specificati adresa! \n";
	}


	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.email.value)){
		Mesage += "# Trebuie sa specificati o adresa de email corecta \n";
	f.email.focus();
	// if the browser is Netscape 6 or IE
	if(document.all || document.getElementByID){
	// change the color of text field
	f.email.style.background = "yellow";
	}

	// make sure the form is not submitted

	}

	
	if(Mesage == ""){
		return true;
	}else{

	alert("Trebuie sa comletati urmatoarele \n "+Mesage+"");
	return false;
	}
}



function select_person(e){
	 if(e.selectedIndex == 0){
		 document.getElementById("juridic").style.display='none';
		 document.getElementById("fizic").style.display='none';
	 }
	 
	 if(e.selectedIndex == 1){
		 document.getElementById("fizic").style.display='block';
		 document.getElementById("juridic").style.display='none';
	 }
	 
	 if(e.selectedIndex == 2){
		 document.getElementById("juridic").style.display='block';
		 document.getElementById("fizic").style.display='none';
	 }
	}
