// JavaScript Document
function IsValidEmail(str) 
{
	/*if ( str.indexOf(".") <=2 || str.indexOf("@") <=0  )
		return false;*/
		
	if( str.indexOf(",") >=0 )
		return false;
	if( str.indexOf(";") >=0 )
		return false;
	if( str.indexOf("(") >=0 )
		return false;
	if( str.indexOf(")") >=0 )
		return false;
	if( str.indexOf("+") >=0 )
		return false;
	if( str.indexOf(" ") >=0 )
		return false;
	if( str.indexOf("?") >=0 )
		return false;
	if( str.indexOf("`") >=0 )
		return false;
	if( str.indexOf("#") >=0 )
		return false;
	if( str.indexOf("!") >=0 )
		return false;
	if( str.indexOf("$") >=0 )
		return false;
	if( str.indexOf("%") >=0 )
		return false;
	if( str.indexOf("*") >=0 )
		return false;
	if( str.indexOf("=") >=0 )
		return false;																										
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}
function display(el)
{
	//alert(el);
	var product_description=document.getElementById('product_description');
	var recomanda=document.getElementById('recomanda');
	var opinii=document.getElementById('opinii');
	var compara=document.getElementById('compara');

	var det_prod=document.getElementById('det_prod');
	var rec=document.getElementById('rec');
	var op=document.getElementById('op');
	var comp=document.getElementById('comp');

	if(el=='product_description')
	{
		det_prod.className='description_on';
		rec.className='description';
		op.className='description';
		comp.className='description';
		
		product_description.style.display='block';
		recomanda.style.display='none';
		opinii.style.display='none';
		compara.style.display='none';
	}else if(el=='recomanda')
	{
		det_prod.className='description';
		rec.className='description_on';
		op.className='description';
		comp.className='description';
		
		product_description.style.display='none';
		recomanda.style.display='block';
		opinii.style.display='none';
		compara.style.display='none';
	}else if(el=='opinii')
	{
		det_prod.className='description';
		rec.className='description';
		op.className='description_on';
		comp.className='description';
		
		product_description.style.display='none';
		recomanda.style.display='none';
		opinii.style.display='block';
		compara.style.display='none';
	}else if(el=='compara')
	{
		det_prod.className='description';
		rec.className='description';
		op.className='description';
		comp.className='description_on';
		
		product_description.style.display='none';
		recomanda.style.display='none';
		opinii.style.display='none';
		compara.style.display='block';
	}
	
	
}
function validateRecomanda(form)
{
	if (form.numeprieten.value.length == 0 ) 
	{
		alert("Introduceti \"Nume prieten\".");
		form.numeprieten.focus();
		return (false);
	}
	stremail=document.getElementById("emailprieten");
	if (stremail.value.length==0)
	{
		alert("Introduceti \"Email prieten\".");
		stremail.focus();
		return (false);
	}
	if(!IsValidEmail(stremail.value))
	 {
		alert("Formatul \"Email prieten\" este incorect.");
		stremail.focus();
		return(false);
	}
	
	stremail1=document.getElementById("email");
	if (stremail1.value.length==0)
	{
		alert("Introduceti \"Adresa ta de email\".");
		stremail1.focus();
		return (false);
	}
	if(!IsValidEmail(stremail1.value))
	 {
		alert("Formatul \"Adresa ta de email\" este incorect.");
		stremail1.focus();
		return(false);
	}
	
	if (form.mesaj.value.length == 0 ) 
	{
		alert("Introduceti \"Mesaj\".");
		form.mesaj.focus();
		return (false);
	}
}