// JavaScript Document
//meniu 
$(document).ready(function(){
	$('#nav_1').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});
	$('#nav_1a').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});
 
 	$('#nav_2').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});
	$('#nav_2a').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});
	
	$('#nav_3').click(function() {
		document.location.href='http://www.lazarservice.ro/vehicule_de_ocazie';
	});
	$('#nav_3a').click(function() {
		document.location.href='http://www.lazarservice.ro/vehicule_de_ocazie';
	});
	$('#nav_4').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/despre_noi';
	});
	$('#nav_5').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/oferte_speciale';
	});
	$('#nav_4a').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/despre_noi';
	});
	$('#nav_5a').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/oferte_speciale';
	});
	//////////////////////////////////////////
	$('#top_1').click(function() {
		document.location.href='http://www.lazarservice.ro/PaginaPrincipala';
	});
	$('#top_2').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/despre_noi';
	});
	$('#top_3').click(function() {
		document.location.href='http://www.lazarservice.ro/index/page/rent_a_car';
	});
	$('#top_4').click(function() {
		document.location.href='http://www.lazarservice.ro/service';
	});
	$('#top_5').click(function() {
		document.location.href='http://www.lazarservice.ro/contact';
	});
	
	
	////////////////////////////////////
 	$('#dacia').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});
		$('#thisDacia').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});
	$('#renault').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});
	$('#thisRenault').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});
	$('#ocazie').click(function() {
		document.location.href='http://www.lazarservice.ro/vehicule_de_ocazie';
	});	
	$('#ImgRenault').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});	
	$('#RenaultImg').click(function() {
		document.location.href='http://www.lazarservice.ro/renault';
	});	
	
	$('#ImgDacia').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});	
	$('#DaciaImg').click(function() {
		document.location.href='http://www.lazarservice.ro/dacia';
	});	
	////////////////////////////////////////
	$("#RenaultImg").hover(
		function () {
			 $(this).stop().animate({opacity: 1}, 500 );
		}, 
		function () {
			 $(this).stop().animate({opacity: 0.5}, 500 );
		}
	); 
	
	$("#DaciaImg").hover(
		function () {
			 $(this).stop().animate({opacity: 1}, 500 );
		}, 
		function () {
			 $(this).stop().animate({opacity: 0.5}, 500 );
		}
	); 
 
 
	
	 Cufon.replace('.h1', { fontFamily: 'Zurich Cn BT', color: '-linear-gradient(#FFFFFF, #FFFFFF, #c0c0c0, rgb(200, 200, 200))', textShadow: '#FFFFFF 0px 1px'});
	Cufon.replace('h1',{fontFamily: 'Yanone Kaffeesatz Light'});
	Cufon.replace('h2'); 
 	Cufon.replace('.nav a.link',{fontFamily: 'Yanone Kaffeesatz Light'});
	Cufon.replace('.dactiv',{fontFamily: 'Yanone Kaffeesatz Light'});
	Cufon.replace('.ractiv',{fontFamily: 'Yanone Kaffeesatz Light'});
	Cufon.replace('.activ', { fontFamily: 'Yanone Kaffeesatz Light' });
	Cufon.replace('.comment', { fontFamily: 'Yanone Kaffeesatz Light', textShadow: '#e9e9e9 1px 1px' });
	Cufon.replace('.tabs li', { fontFamily: 'Yanone Kaffeesatz Light'  });
	$(":date").dateinput({
		format: 'dd-mm-yyyy',	// the format displayed for the user 
		selectors: true,             	// whether month/year dropdowns are shown
		min: 2,                    // min selectable day (100 days backwards)
	//	max: 10,                    	// max selectable day (100 days onwards)
	//	offset: [10, 20],            	// tweak the position of the calendar
		speed: 'fast',               	// calendar reveal speed
		firstDay: 1                  	// which day starts a week. 0 = sunday, 1 = monday etc..
	});

});


//contact
$(document).ready(function(){
	//global vars
	var form = $("#FormContact");
	var nume = $("#nume");
  	var email = $("#email");
 	var tel = $("#tel");
  	var mesaj = $("#mesaj");
	
	//On blur
	nume.blur(validateNume);
 	email.blur(validateEmail);
	tel.blur(validateTel);
	mesaj.blur(validateMesaj);
	//On key press
 	nume.keyup(validateNume);
 	email.keyup(validateEmail);
	tel.keyup(validateTel);
	mesaj.keyup(validateMesaj);
	
	//On Submitting
	form.submit(function(){
		if(validateNume() & validateEmail() & validateTel() & validateMesaj() )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 5){
			nume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nume.css("border-color","#CCCCCC");
			return true;
		}
	}
		
	function validateTel(){
		//if it's NOT valid
		var b = $("#tel").val();
		var filters = /[^0-9]/ ;
		if(filters.test(b) || b.length < 10 ){
			tel.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			tel.css("border-color","#CCCCCC");
			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.css("border-color","#CCCCCC");
			return true;
		}
		//if it's NOT valid
		else{
			email.css("border-color","red");	
			return false;
		}
	}
	
	 
 
	function validateMesaj(){
		//it's NOT valid
		if(mesaj.val().length < 10){
			mesaj.css("border-color","red");
			return false;
		}
		//it's valid
		else{			
			mesaj.css("border-color","#CCCCCC");
			return true;
		}
	} 
});


//itp si service
$(document).ready(function(){
	//global vars
	var form = $("#FormITP");
	var nume = $("#nume");
	var prenume = $("#prenume");
	var marca = $("#marca");
	var tip = $("#tip");
  	var email = $("#email");
 	var tel = $("#tel");
  	var data = $("#data");
	
	//On blur
	nume.blur(validateNume);
	prenume.blur(validatePrenume);
	marca.blur(validateMarca);
	tip.blur(validateTip);
	data.blur(ValidData);
 	email.blur(validateEmail);
	tel.blur(validateTel);
 	
	//On key press
 	nume.keyup(validateNume);
	prenume.keyup(validatePrenume);
	marca.keyup(validateMarca);
	tip.keyup(validateTip);
 	email.keyup(validateEmail);
	tel.keyup(validateTel);
	data.keyup(ValidData);
	
	//On Submitting
	form.submit(function(){
		if(validateNume() & validatePrenume() & validateMarca() & validateTip() & ValidData() & validateEmail() & validateTel()  )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 3){
			nume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nume.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validatePrenume(){
		//if it's NOT valid
		if(prenume.val().length < 3){
			prenume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			prenume.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateMarca(){
		//if it's NOT valid
		if(marca.val().length < 3){
			marca.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			marca.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateTip(){
		//if it's NOT valid
		if(tip.val().length < 3){
			tip.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			tip.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function ValidData(){
		//if it's NOT valid
		if(data.val().length < 1){
			data.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			data.css("border-color","#CCCCCC");
			return true;
		}
	}
		
	function validateTel(){
		//if it's NOT valid
		var b = $("#tel").val();
		var filters = /[^0-9]/ ;
		if(filters.test(b) || b.length < 10 ){
			tel.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			tel.css("border-color","#CCCCCC");
			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.css("border-color","#CCCCCC");
			return true;
		}
		//if it's NOT valid
		else{
			email.css("border-color","red");	
			return false;
		}
	}
 
}); 


//validare test drive 
$(document).ready(function(){
	//global vars
	var form = $("#FormTest");
	var nume = $("#nume");
	var prenume = $("#prenume");
	var adresa = $("#adresa");
	var nastere = $("#nastere");
	var companie = $("#companie");
	var functie = $("#functie");
 	var actualul = $("#actualul");
	var dorim = $("#dorim");
  	var email = $("#email");
 	var tel = $("#tel");
  	var data = $("#data");
	
	//On blur
	nume.blur(validateNume);
	prenume.blur(validatePrenume);
	adresa.blur(validateAdresa);
	nastere.blur(validateNastere);
	companie.blur(validateCompanie);
	functie.blur(validateFunctie);
	actualul.blur(validateActualul);
	dorim.blur(validateDorim);
	data.blur(ValidData);
 	email.blur(validateEmail);
	tel.blur(validateTel);
 	
	//On key press
 	nume.keyup(validateNume);
	prenume.keyup(validatePrenume);
	adresa.keyup(validateAdresa);
	nastere.keyup(validateNastere);
	companie.keyup(validateCompanie);
	functie.keyup(validateFunctie);
	actualul.keyup(validateActualul);
	dorim.keyup(validateDorim);
 	email.keyup(validateEmail);
	tel.keyup(validateTel);
	data.keyup(ValidData);
	
	//On Submitting
	form.submit(function(){
		if(validateNume() & validatePrenume() & validateAdresa() & validateNastere() & validateCompanie() & validateFunctie() & validateDorim() & validateActualul() & ValidData() & validateEmail() & validateTel()  )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 3){
			nume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nume.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validatePrenume(){
		//if it's NOT valid
		if(prenume.val().length < 3){
			prenume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			prenume.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateAdresa(){
		//if it's NOT valid
		if(adresa.val().length < 2){
			adresa.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			adresa.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateNastere(){
		//if it's NOT valid
		if(nastere.val().length < 4){
			nastere.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nastere.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateCompanie(){
		//if it's NOT valid
		if(companie.val().length < 3){
			companie.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			companie.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateFunctie(){
		//if it's NOT valid
		if(functie.val().length < 3){
			functie.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			functie.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateActualul(){
		//if it's NOT valid
		if(actualul.val().length < 3){
			actualul.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			actualul.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateDorim(){
		//if it's NOT valid
  	    if ($('#dorim').val() == "0") 
	    { 
	     dorim.css("border-color","red");
 			return false;
	   }
		//if it's valid
		else{
			dorim.css("border-color","#CCCCCC");
			return true;
		}
 	}
	
	function ValidData(){
		//if it's NOT valid
		if(data.val().length < 1){
			data.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			data.css("border-color","#CCCCCC");
			return true;
		}
	}
		
	function validateTel(){
		//if it's NOT valid
		var b = $("#tel").val();
		var filters = /[^0-9]/ ;
		if(filters.test(b) || b.length < 10 ){
			tel.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			tel.css("border-color","#CCCCCC");
			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.css("border-color","#CCCCCC");
			return true;
		}
		//if it's NOT valid
		else{
			email.css("border-color","red");	
			return false;
		}
	}
 
});


//validare remat
$(document).ready(function(){
	//global vars
	var form = $("#FormRemat");
	var nume = $("#nume");
 	var str = $("#str");
	var bloc = $("#bloc");
	var app = $("#app");
	var loc = $("#loc");
 	var judet = $("#judet");
	var dorim = $("#dorim");
  	var email = $("#email");
 	var tel = $("#tel");
 	
	//On blur
	nume.blur(validateNume);
 	str.blur(validateStr);
	bloc.blur(validateBloc);
	app.blur(validateApp);
	loc.blur(validateLocalitate);
	judet.blur(validateJudet);
	dorim.blur(validateDorim);
  	email.blur(validateEmail);
	tel.blur(validateTel);
 	
	//On key press
 	nume.keyup(validateNume);
 	str.keyup(validateStr);
	bloc.keyup(validateBloc);
	app.keyup(validateApp);
	loc.keyup(validateLocalitate);
	judet.keyup(validateJudet);
	dorim.keyup(validateDorim);
 	email.keyup(validateEmail);
	tel.keyup(validateTel);
 	
	//On Submitting
	form.submit(function(){
		if(validateNume()   & validateStr() & validateBloc() & validateApp() & validateLocalitate() &  validateJudet() & validateDorim() & validateEmail() & validateTel()  )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 3){
			nume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nume.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateStr(){
		//if it's NOT valid
		if(str.val().length < 2){
			str.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			str.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateBloc(){
		//if it's NOT valid
		if(bloc.val().length < 1){
			bloc.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			bloc.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateApp(){
		//if it's NOT valid
		if(app.val().length < 1){
			app.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			app.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateLocalitate(){
		//if it's NOT valid
		if(loc.val().length < 2){
			loc.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			loc.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateJudet(){
		//if it's NOT valid
		if(judet.val().length < 2){
			judet.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			judet.css("border-color","#CCCCCC");
			return true;
		}
	}
	
	function validateDorim(){
		//if it's NOT valid
  	    if ($('#dorim').val() == "0") 
	    { 
	     dorim.css("border-color","red");
 			return false;
	   }
		//if it's valid
		else{
			dorim.css("border-color","#CCCCCC");
			return true;
		}
 	}
		
	function validateTel(){
		//if it's NOT valid
		var b = $("#tel").val();
		var filters = /[^0-9]/ ;
		if(filters.test(b) || b.length < 10 ){
			tel.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			tel.css("border-color","#CCCCCC");
			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.css("border-color","#CCCCCC");
			return true;
		}
		//if it's NOT valid
		else{
			email.css("border-color","red");	
			return false;
		}
	}
 
});


//form mic
$(document).ready(function(){
	//global vars
	var form = $("#FormularMic");
	var nume = $("#nume");
  	var email = $("#email");
	//On blur
	nume.blur(validateNume);
 	email.blur(validateEmail);
	//On key press
 	nume.keyup(validateNume);
 	email.keyup(validateEmail);
	//On Submitting
	form.submit(function(){
		if(validateNume() & validateEmail() )
			return true
		else
			return false;
	});
	//validation functions 	
	function validateNume(){
		//if it's NOT valid
		if(nume.val().length < 3){
			nume.css("border-color","red");
 			return false;
		}
		//if it's valid
		else{
			nume.css("border-color","#CCCCCC");
			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.css("border-color","#CCCCCC");
			return true;
		}
		//if it's NOT valid
		else{
			email.css("border-color","red");	
			return false;
		}
	}
 
});


$(document).ready(function(){
	$("#main").fadeIn(500);
});


function OverImage(imgaer)
{
	document.getElementById("img_mare").src = "http://www.lazarservice.ro/poze/"+imgaer;
}

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!

		//centering with css
		centerPopup();
		//load popup
		loadPopup();

				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
