function CheckEmail( string )
{
	if ( !string ) return false;
	
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if( !filter.test( string ) )
		return false;
	return true;
}

function checkForm( form )
{
	if( !form.name.value )
	{
		alert( "Introdueix el teu Nom" );
		form.name.focus();
		return false;
	}
	if( !IsNumeric( form.telephone.value ) )
	{
		alert( "Has d'introduir un teléfon correcte" );
		form.telephone.focus();
		return false;
	}
	if( !CheckEmail( form.email.value ) )
	{
		alert( "El format de l'e-mail no es correcte" );
		form.email.focus();
		return false;
	}
	if( !form.user_check_age.checked )
	{
		alert( "Ha d'acceptar el terminis i condicions." )
		
		return false;
	}
	if( form.comments.value < 20 )
	{
		alert( "Escriu un comentari!" );
		form.comments.focus();
		return false;
	}
	return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
   strChar = strString.charAt(i);
   if (strValidChars.indexOf(strChar) == -1)
      {
      blnResult = false;
      }
   }
   return blnResult;
 }

var Popup = {
		  open: function(options)
		  {
		    this.options = {
		      url: '#',
		      width: 600,
		      height: 500,
		      name:"_blank",
		      location:"no",
		      menubar:"no",
		      toolbar:"no",
		      status:"no",
		      scrollbars:"yes",
		      resizable:"no",
		      left:"300",
		      top:"160",
		      normal:false
		    }
		    Object.extend(this.options, options || {});

		    if (this.options.normal){
		        this.options.menubar = "yes";
		        this.options.status = "yes";
		        this.options.toolbar = "yes";
		        this.options.location = "yes";
		    }

		    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
		    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
		    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
		    if (this.options.top!="")openoptions+=",top="+this.options.top;
		    if (this.options.left!="")openoptions+=",left="+this.options.left;
		    window.open(this.options.url, this.options.name,openoptions );
		    return false;
		  }
		}