

jQuery(document).ready(function() {

    jQuery('#mycarousel').jcarousel({
    	wrap: 'circular'
		, scroll:1
		, auto :4 /*seconds for autoscrool*/
		, animation: 1500
		, buttonNextHTML: null
		, buttonPrevHTML: null
		
    });
	load_shadowbox();
});


function load_shadowbox()
{
	
	Shadowbox.init({ skipSetup: true});
	Shadowbox.setup("a.poza_mare", {});
	//Shadowbox.setup();
	
}



 function initializeaza_harta() {
    var latlng = new google.maps.LatLng(46.755887, 23.538259);
    var myOptions = {
      zoom: 16,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
	var marker = new google.maps.Marker({
        position: latlng, 
        map: map,
        title:"AutoWorld Cluj Napoca!"
    });   	
  }
  
  function valideaza_contact()
 {
	 $("#contact").validate(
	{
		rules:
		{
			 nume: {required:true }
			, telefon: { number:true, rangelength: [10, 10]}			
			, email:{email: true}
			, mesaj:{required:true }
	
		}
		, messages:
		{
			  nume: {required:"<br>Introduceti numele"}
			, telefon: {number:"<br>Introduceti numarul de telefon din 10 cifre", rangelength:"<br>numarul telefonul trebuie sa aiba 10 cifre"}
			, email:{email:"<br>Introduceti o adresa valida"}
			, mesaj: {required:"<br>Mesajul este obligatoriu"}
		}
		, errorPlacement: function(error, element)
		{
			if(element.parent().children('label.error:visible').length == 0)
			{
				
				error.appendTo(element.parent());
			}
		}
		, success: function(element)
		{
			element.parent().children('label.error').remove();
		}
		, highlight: function(element)
		{
			//$(element).parents('div:first').addClass('bgerror');
			$(element).addClass('border_red');
		}
		, unhighlight: function(element)
		{
			//$(element).parents('div:first').removeClass('bgerror');
			$(element).removeClass('border_red');
		}
		, submitHandler: function() {salveaza_contact();}
	});
 
 } 
  
  function submit_formular_contact()
{
	// stergem toate erorile
	$('#contact label.error').remove();
	$('#contact').submit();
}
function salveaza_contact()
{
	$.ajax({
      url: "contact.ajax.php"
    , type: 'post'
	, cache: false
	, dataType:'json'
        , data:{
            op:'send'
            , nume: $('#nume').val()
			, email: $('#email').val()
			, telefon: $('#telefon').val()
			, mesaj: $('#mesaj').val()
        },
        success: function(response){
		
		if ( (response.status))
			{
			$('#nume').val('name');
			$('#email').val('e-mail');
			$('#mesaj').val('Introduceti mesajul');
			alert (response.message);
			}
			else alert (response.message);
        },
        onFailure: function(transport) {
            alert(transport);
        }
    });
	return false;

}




 function valideaza_utile()
 {
	 $("#form_utile").validate(
	{
		rules:
		{
			 nume: {required:true }
			, telefon: {required:true, number:true, rangelength: [10, 10]}			
			, email:{required:true, email: true}
			, data_itp:{required:true }
	
		}
		, messages:
		{
			  nume: {required:"Introduceti numele"}
			, telefon: {required:"Telefonul este obligatoriu", number:"Introduceti numarul de telefon din 10 cifre", rangelength:"numarul telefonul trebuie sa aiba 10 cifre"}
			, email:{required:"Introduceti adresa de email", email:"Introduceti o adresa valida"}
			, data_itp: {required:"Data ITP este obligatoriu"}
		}
		, errorPlacement: function(error, element)
		{
			if(element.parent().children('label.error:visible').length == 0)
			{
				
				error.appendTo(element.parent());
			}
		}
		, success: function(element)
		{
			element.parent().children('label.error').remove();
		}
		, highlight: function(element)
		{
			//$(element).parents('div:first').addClass('bgerror');
			$(element).addClass('border_red');
		}
		, unhighlight: function(element)
		{
			//$(element).parents('div:first').removeClass('bgerror');
			$(element).removeClass('border_red');
		}
		, submitHandler: function() {salveaza_utile();}
	});
 
 } 
 
   function submit_formular_utile()
{
	// stergem toate erorile
	$('#form_utile label.error').remove();
	$('#form_utile').submit();
}
function salveaza_utile()
{
	$.ajax({
      url: "utile.ajax.php"
    , type: 'post'
	, cache: false
	, dataType:'json'
        , data:{
            op:'send'
            , nume: $('#nume').val()
			, email: $('#email').val()
			, telefon: $('#telefon').val()
			, data_itp: $('#data_itp').val()
			, data_rca: $('#data_rca').val()
			, sasiu: $('#sasiu').val()
        },
        success: function(response){
		
		if ( (response.status))
			{
			$('#nume').val('name');
			$('#email').val('e-mail');
			$('#mesaj').val('Introduceti mesajul');
			alert (response.message);
			}
			else alert (response.message);
        },
        onFailure: function(transport) {
            alert(transport);
        }
    });
	return false;

}

