//meniu 
$(document).ready(function(){
	$('#nav1').click(function() {
		document.location.href='index.php';
	});
	$('#nav2').click(function() {
		document.location.href='dotari.php';
	});
	$('#nav3').click(function() {
		document.location.href='produse.php';
	});
	$('#nav4').click(function() {
		document.location.href='servicii.php';
	});
	$('#nav5').click(function() {
		document.location.href='certificari.php';
	});
	$('#nav6').click(function() {
		document.location.href='noutati.php';
	});
	$('#nav7').click(function() {
		document.location.href='companie.php';
	});
	$('#nav8').click(function() {
		document.location.href='proiecte.php';
	});
	$('#nav9').click(function() {
		document.location.href='contact.php?id=2';
	});
});

$(document).ready(function(){
	$('#nav_en1').click(function() {
		document.location.href='index.php';
	});
	$('#nav_en2').click(function() {
		document.location.href='dotari.php';
	});
	$('#nav_en3').click(function() {
		document.location.href='produse.php';
	});
	$('#nav_en4').click(function() {
		document.location.href='servicii.php';
	});
	$('#nav_en5').click(function() {
		document.location.href='certificari.php';
	});
	$('#nav_en6').click(function() {
		document.location.href='noutati.php';
	});
	$('#nav_en7').click(function() {
		document.location.href='companie.php';
	});
	$('#nav_en8').click(function() {
		document.location.href='proiecte.php';
	});
	$('#nav_en9').click(function() {
		document.location.href='contact.php?id=2';
	});
});



 
$(function() {
 	// Carusel certificari
	$("#carusel2").scrollable().navigator();

});

$(function() {
	//dialog box
	$("a[rel]").overlay({
		fixed: false,				
 		mask: '#CCCCCC',
		effect: 'apple',
		top: '5px',
		left: "center",
  		onBeforeLoad: function() {
 			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
  			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));	 
 		}
 	});
});
$(document).ready(function() {
	// light box
	//$("#triggers img[rel]").overlay({fixed: false, mask: '#CCCCCC',effect: 'apple' });
});
//validare
$(document).ready(function(){
	//global vars
	var form = $("#contactForm");
	var nume = $("#nume");
	var pren = $("#prenume");
 	var email = $("#email");
 	var tel = $("#telefon");
  	var mesaj = $("#mesaj");
	
	//On blur
	nume.blur(validateNume);
	pren.blur(validatePern);
	email.blur(validateEmail);
	tel.blur(validateTel);
	mesaj.blur(validateMesaj);
	//On key press
 	nume.keyup(validateNume);
	pren.keyup(validatePern);
	email.keyup(validateEmail);
	tel.keyup(validateTel);
	mesaj.keyup(validateMesaj);
	
	//On Submitting
	form.submit(function(){
		if(validateNume() & validatePern() & validateEmail() & validateTel() & validateMesaj() )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 3){
			nume.addClass("error");
 			return false;
		}
		//if it's valid
		else{
			nume.removeClass("error");
			return true;
		}
	}
	
	function validatePern(){
		//if it's NOT valid
		if(pren.val().length < 3){
			pren.addClass("error");
 			return false;
		}
		//if it's valid
		else{
			pren.removeClass("error");
			return true;
		}
	}
	
		
	function validateTel(){
		//if it's NOT valid
		var b = $("#telefon").val();
		var filters = /[^0-9]/ ;
		if(filters.test(b) || b.length < 10 ){
			tel.addClass("error");
 			return false;
		}
		//if it's valid
		else{
			tel.removeClass("error");
			return true;
		}
	}
	
	
	function validateEmail(){
		//testing regular expression
		var a = $("#email").val();
		var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
		//if it's valid email
		if(filter.test(a)){
			email.removeClass("error");
			return true;
		}
		//if it's NOT valid
		else{
			email.addClass("error");
			return false;
		}
	}
	
	 
 
	function validateMesaj(){
		//it's NOT valid
		if(mesaj.val().length < 10){
			mesaj.addClass("error");
			return false;
		}
		//it's valid
		else{			
			mesaj.removeClass("error");
			return true;
		}
	} 
});

//languege
function changeLocale (loc)
{
var str=new String(window.location);
var nstr='';
lg = str.length;
lk = str.substr(31);
	if (loc=='eng'){
		nstr=str.replace(/rom/,'eng');
	}else{
		nstr=str.replace(/eng/,'rom');
	}
 window.location=nstr;
} 
   $(document).ready(function(){

            // scale the example objects
            $(this).hide("scale", {}, 1000);
        });

