//alert('Alerta!');

//GLOBALS ########################
	
	var nrClickContactRapid = 0;
	var nrClickProgrService = 0;
	
//################################


// FUNCTII FORMULARE SERVICE (Buline)

	function afiseazaContactRapid()
		{
			$('.contact-rapid-btn').css("background", "url(/images/contact-rapid-invers.png)")
			$('.contact-rapid-container').stop().animate({
														width: "557px"}, 500 );
			$('#contact-rapid-form-container').stop().animate({
														width: "450px"}, 500 );
			$('#form-contact-rapid-container').css("display", "block");
			//alert(nrClickContactRapid);
			nrClickContactRapid ++;
		}
	function afiseazaProgramareService()
		{
			$('.programare-service-btn').css("background", "url(/images/programare-service-invers.png)");
			$('.programare-service-container').stop().animate({
														width: "557px"}, 500, 
							function(){
										$('#programare-service-form-container').stop().animate({marginTop: "-154px"}, 500 
									);									
																});
			
			$('#programare-service-form-container').stop().animate({
														width: "450px"}, 500 );
			$('#form-programare-service-container').css("display", "block");
			$('#confirmare-programare-service').css("display", "block");
			
			//alert(nrClickProgrService);
			nrClickProgrService ++;
		}
	function ascundeContactRapid()
		{
			$('.contact-rapid-btn').css("background", "url(/images/contact-rapid.png)")
			$('#contact-rapid-form-container').stop().animate({
														width: "0px"}, 500 , function(){													
														$('#form-contact-rapid-container').css("display", "none");
																});
			$('.contact-rapid-container').stop().animate({
														width: "107px"}, 500 );
			
			//alert(nrClickContactRapid);
			nrClickContactRapid ++;
			
		}
	function ascundeProgramareService()
		{
			$('.programare-service-btn').css("background", "url(/images/programare-service.png)");
			$('#programare-service-form-container').stop().animate({marginTop: "0px"}, 500,
																   function(){
																	   //alert('incep micsorarea');
																	   $('#programare-service-form-container').animate({																					width: "0px"}, 500);
																	   $('.programare-service-container').stop().animate({
														width: "107px"}, 500, function(){
																				$('#form-programare-service-container').css("display", "none");
																				$('#confirmare-programare-service').css("display", "none");
																			} );
																	   });
			
			
			//alert(nrClickProgrService);
			nrClickProgrService ++;		
		}
////////////////////////////////////////////////////////////////


// FUNCTII slide-uri OFERTE  (Buline)
function afiseazaSlideOferte(id){

		$('.oferte-paginate-slide').stop().fadeOut("fast", function(){
													$('#slide-oferta-' + id).fadeIn("fast");
																	});
	}

////////////////////////////////////////////////////////////////



	////////////////////
	// DOCUMENT READY //
	////////////////////

$(document).ready(function() {
						   
			//VALIDARE FORMULAR SEARCH GENERAL
			$('#searchForm').submit(function(){
												string = $('#searchString').val();
												if(string.length < 3)
												{
													alert("Pentru o cautare eficienta, introduceti minim 3 caractere!");
													return false;
												}
											});   
						   
			//VALIDARE FORMULAR TELEFON			   
			$('#formularTrimitereTelefon').submit(function(){
												nrTel = $('#numarTelefon').val();
												if(nrTel == "07xx xxx xxx" || nrTel == " ")
												{
													alert("Va rugam, introduceti un numar de telefon valid!");
													return false;
												}
											});
			
			// ANIMATII SERVICE LEFT FORMS			
			$('#contact-rapid-link').click(
				function(){
					if(nrClickContactRapid == 0 || nrClickContactRapid % 2 == 0)
					{
						afiseazaContactRapid();
					}
					else
					{
						ascundeContactRapid();
					}					
				});
			
			$('#programare-service-link').click(
				function(){
					if(nrClickProgrService == 0 || nrClickProgrService % 2 == 0)
					{
						afiseazaProgramareService();
					}
					else
					{
						ascundeProgramareService();
					}					
				});
			/////////////////////////////////////////////////////////		
			
			// SELECT BOX
			//--------------------
			$("#marci-select").selectbox();
			$("#tip-serviciu-select").selectbox();
			$('.jquery-custom-selectboxes-replaced').css("width", "145px");
			$('.jquery-custom-selectboxes-replaced-list').css("width", "145px");
			$('.jquery-custom-selectboxes-replaced-list').css("height", "");
			//////////////////////////////////////////////////////////////////////
			
			// ALINIERI
			
				//aliniere produse - servicii
				$('div.big-prod:nth-child(1)').attr("style", "margin-left:0px;");
				$('div.big-prod:nth-child(3n + 1)').attr("style", "margin-left:0px;");
				$('div.small-prod:nth-child(1)').attr("style", "margin-left:0px;");
				$('div.small-prod:nth-child(3n + 1)').attr("style", "margin-left:0px;");
				
				//aliniere tab-uri
				$('div.tab:nth-child(1)').attr("style", "margin-left:-4px;");
				$('div.tab:nth-child(3n + 1)').attr("style", "margin-left:-4px;");
		
			
			
			// OFERTE PAGINATE CONTROLS
			$('#slide-oferta-1').css("display", "table");
			$('#oferte-paginate-control-1').addClass('oferte-paginate-control-link-active');
			
			$('.oferte-paginate-control-link').click(function(){
				$('.oferte-paginate-control-link-active').removeClass('oferte-paginate-control-link-active').addClass('oferte-paginate-control-link');
				$(this).addClass('oferte-paginate-control-link-active');
				thisId = $(this).attr('id');
				thisId = thisId.replace("oferte-paginate-control-", "");
				id = parseInt(thisId);
				afiseazaSlideOferte(id);
			});
			
});

	

	
