function checkEmail (email)
	{
		//alert ('asda');
		  ////// checking the imput values 
			   var filter2 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (!filter2.test(email) && email !='') {
					//alert ('asda');
					$("#mesaj").html("Va rugam introduceti o adresa de email valida");
					$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 3000).slideUp('slow')
					$("#email").val("");
				}
				else
				{

							/*
							$.ajax({
							   type: "POST",
							   url: "scripturi/useri.php",
							   data: 'verifica_email='+1+'&email='+email,
							   success: function(msg){
								  // $("#"+str).html(msg);
								  if (msg == 1)
									{
										$("#mesaj").html("Adresa de email mai exista in baza de date");
										$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 3000).slideUp('slow')
										$("#email").val("");
									}
								   
							
						   }
						 }); */
					
				}
	} 


function check_form ()
{
		var email = $("#email2").val();
		var parola =$("#parola2").val();
		var vparola = $("#vparola").val();
		var nume = $("#realName").val();
		
		var filter2 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter2.test(email) || email =='') {
			//alert ('asda');
			$("#mesaj").html("Va rugam introduceti o adresa de email valida");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			$("#email").val("");
			return false;
		}
		
		if (nume =='')
		{
			$("#mesaj").html("Va rugam introduceti un nume valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		if (parola =='')
		{
			$("#mesaj").html("Va rugam introduceti o parola valida");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		if (vparola =='' || parola != vparola)
		{
			$("#mesaj").html("Va rugam introduceti o parola de verificare valida");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}

}

function checkPersonalData ()
{
		var nume = $("#realName").val();
		var email = $("#userEmail").val();
		var cnp =$("#userCNP").val();
		var serie = $("#userCiSerie").val();
		var nr = $("#userCiNr").val();
		var phone = $("#userPhone").val();
		var fax =$("#userFax").val();
		
		if (nume =='')
		{
			$("#mesaj").html("Va rugam introduceti un nume valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		var filter2 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter2.test(email) || email =='') {
			//alert ('asda');
			$("#mesaj").html("Va rugam introduceti o adresa de email valida");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			$("#email").val("");
			return false;
		}
		
		if (cnp =='')
		{
			$("#mesaj").html("Va rugam introduceti un cnp valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		if (serie =='')
		{
			$("#mesaj").html("Va rugam introduceti o serie buletin valida");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		if (nr =='')
		{
			$("#mesaj").html("Va rugam introduceti un numar serie buletin valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		if (phone =='')
		{
			$("#mesaj").html("Va rugam introduceti un numar de telefon valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		if (fax =='')
		{
			$("#mesaj").html("Va rugam introduceti un numar de fax valid");
			$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
			
			return false;	
		}
		
		
}

function checkPassword ()
{
	var oldPassword = $("#oldPassword").val();
	var newPassword = $("#newPassword").val();
	var retypedPassword = $("#retypedPassword").val();
	
	if (oldPassword =='')
	{
		$("#mesaj").html("Va rugam introduceti vechea parola");
		$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
		return false;	
	}
	if (newPassword =='')
	{
		$("#mesaj").html("Va rugam introduceti noua parola");
		$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
		return false;	
	}
	
	if (newPassword != retypedPassword)
	{
		$("#mesaj").html("Parolele noi nu se potrivesc");
		$("#mesaj").slideDown("slow").animate({opacity: 1.0}, 2000).slideUp('slow')
		return false;	
	}

}


function checkAddress ()
{
	
	
}

/* ------------------------ SHOW BUYERS -----------*/

function show_buyers (userId)
{	
	$("#buyer_clicked").val("0");
	$.ajax({
		type: "POST",
		url: "ajax.php",
		data: 'action=show_buyers&userId='+userId,
		success: function(msg){
		 
		  $("#buyers").html(msg);
		}
	});
}

function show_buyer_address(itemId,type)
{
		$("#buyer_clicked").val(itemId);
		
		$.ajax({
		type: "POST",
		url: "ajax.php",
		data: 'action=show_buyers_address&type='+type+'&itemId='+itemId,
		success: function(msg){
		 
		  $("#buyers").html(msg);
		}
	});
	
}

/* ------------- SHOW USER ADDRESS -----------------*/

function shpping_address (userId)
{
	$("#address_clicked").val("0");
	$.ajax({
		type: "POST",
		url: "ajax.php",
		data: 'action=show_address&userId='+userId,
		success: function(msg){
		  $("#shpping_address").html(msg);
		}
	});
}


function show_full_address (addressId)
{
		$("#address_clicked").val(addressId);
	$.ajax({
		type: "POST",
		url: "ajax.php",
		data: 'action=show_full_address&addressId='+addressId,
		success: function(msg){
		  $("#shpping_address").html(msg);
		}
	});
}


function go_cauta ()
{
	var domainname = new String(location.host); 
	var keys = $("#cuvant").val();
window.location.href='http://'+domainname+'/cauta/'+keys;	
}