
function produse_recomandate(str)
{
	AARead(document.getElementById('srvurl').innerHTML + "cart_preview/", afisare_cart_preview, "cpc");
	//alert(document.getElementById('srvurl').innerHTML + "cart_preview/");
}

function afisare_cart_preview(data, element)
{
	document.getElementById('cpc').innerHTML = data;
}

function curata_cart_preview()
{
	document.getElementById('cpc').innerHTML = '';
}

function ascunde_delay(timp)
{
	var t = setTimeout("document.getElementById('cpc').innerHTML = ''", timp);
}

function trim(str) 
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function validare_email(mail)
{
	var x = mail;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function verificare_voucher()
{
	var vou_destinatar	= document.getElementById('vou_destinatar').value;
	var vou_mesaj		= document.getElementById('vou_mesaj').value;

	vou_destinatar	= trim(vou_destinatar);
	vou_mesaj		= trim(vou_mesaj);

	var mesaj		= "";
	var numar_erori = 0;

	//citesc limba
	var limba = document.getElementById('limba').value;
	
	//verific formularul daca este scris corect
	if(vou_destinatar.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Nu ati completat campul Destinatar (e-mail)! \n";	
		}
		else
		{
			mesaj += "You must complete the Recipient field! \n";
		}
		numar_erori += 1;
	}
	if(validare_email(vou_destinatar) == false)
	{
		if(limba == 'ro')
		{
			mesaj += "Adresa de email este scisa incorect! \n";
		}
		else
		{
			mesaj += "The Email address is incorect! \n";
		}
		numar_erori += 1;
	}
	if(vou_mesaj.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Nu ati completat campul Mesaj! \n";
		}
		else
		{
			mesaj += "You must complete the Email field! \n";
		}
		numar_erori += 1;
	}


	if(numar_erori != 0)
	{
		alert(mesaj);
		
		return false;
		
	} 
	else
	{
		document.frm_voucher.submit();
		
		return true;
	}
}