$(document).ready(function(){	
$("#slider").easySlider({
	controlsBefore:	'<p id="controls2">',
	controlsAfter:	'</p>',
	auto: true, 
	continuous: true,
	prevId: 'prevBtn2',
	nextId: 'nextBtn2',
	vertical: true	
	
});
$("#slider2").easySlider({
	controlsBefore:	'<p id="controls">',
	controlsAfter:	'</p>',
	auto: true, 
	prevId: 'prevBtn2',
	nextId: 'nextBtn2',
	continuous: true
	
});

 $(function() {
        $('a.light').lightBox();
    });
    


//$("ul.subnav").parent().append("<span> v</span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span ").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});





// end from top 			
});

function cauta ()
{
	var type = $("#type").val();
	
	var key = $("#key").val();
	var slugcontent = key;
		var slugcontent_hyphens = slugcontent.replace(/\s/g,'-');
		var finishedslug = slugcontent_hyphens.replace(/[^a-zA-Z0-9\-]/g,'');
	
		if (type== 'oferta')
		{	
			location.href='http://valdirtour.ro/cauta/oferta/'+finishedslug;
		}
		else 
		{
			location.href='http://valdirtour.ro/cauta/hotel/'+finishedslug;
		}
	//alert(finishedslug);
	
	return false;
}

function abonare ()
{
	var email= $("#email").val();
	
	//alert (email);
	var nume = $("#name").val();
	//alert (nume);
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (nume == '')
	{
		alert("Nume invalid");
	
	}
	
	else if (!filter.test(email))
	{ 
		alert ("Email invalid");
	   //$("#email").addClass("input_error");
	}
	else {
	
	  
	
	 $.ajax({
	   type: "POST",
	   url: "ajax.php",
	   data: "nume="+nume+"&email="+email+"&action=newsletter",
	   success: function(msg){
	     if (msg == 0)
	     {
	     	alert ("Ati fost abonat cu succes");
	     }
	     else 
	     {
	     	alert ("Adresa de email mai exista");
	     } 
	   }
		 });	
	
	  }



	
	return false;
}	