// JavaScript Document

	function clearthis(obj, type)
	{
		if(type=='title')
		{
			if(obj.value == 'Title / Actor / Director') {
					obj.value = '';
			}
		}
		if(type=='email')
		{
			if(obj.value == 'E-mail Address...') {
					obj.value = '';
			}
		}
	}
	function setthis(obj, type)
	{
		if(type=='title')
		{
			if(obj.value == '') {
					obj.value = 'Title / Actor / Director';
			}
		}
		if(type=='email')
		{
			if(obj.value == '') {
					obj.value = 'E-mail Address...';
			}
		}
	}

	function validate_required(field, msg)
	{
		with (field)	
		{
  			if (value==null||value=="Title / Actor / Director"||value=="E-mail Address..."||value=="")
  			{
 	 			alert(msg);
				return false;
  			}
  			else
  			{
  				return true;
  			}
		}
	}
	function validate_email(field,alerttxt)
	{
		with (field)
		{
			apos=value.indexOf("@");
			dotpos=value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) 
			{
				alert(alerttxt);return false;
			}
			else
			{
			return true;
			}
		}
	}
	function validate_form(thisform)
	{
		with (thisform)
		{
			if ( (title.value != 'Title / Actor / Director' && title.value != 'Titel / Schauspieler / Regisseur') &&alphanumeric(title,"Title / Author field must be alphanumeric!")==false)
  			{
				title.focus();
				return false;
			}
			/*if ( alpha(genre,"Genre field must be contain alphabets only!")==false)
  			{
				genre.focus();
				return false;
			}
			if ( alpha(country,"Country field must be contain alphabets only!")==false)
  			{
				genre.focus();
				return false;
			}*/
			if ( formatNum(price_st,"Min price must be an integer!")==false)
  			{
				price_st.focus();
				return false;
			}
			if ( formatNum(price_ed,"Max price must be an integer!")==false)
  			{
				price_ed.focus();
				return false;
			}
			/*if ( validate_required(country,"Country must be filled out!")==false)
  			{
				country.focus();
				return false;
			}
			if ( validate_email(sub_email,"Email is invalid. Please specify again!")==false)
  			{
				sub_email.focus();
				return false;
			}*/			
		}
				
	}
	function alphanumeric(field,alerttxt)
	{
		with (field)
		{
			var numaric = value;
			for(var j=0; j<numaric.length; j++)
				{
				  var alphaa = numaric.charAt(j);
				  var hh = alphaa.charCodeAt(0);
				 
				  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh == 32)
				  {
				  }
				else	{
					 alert(alerttxt); return false;
				  }
				}
		 return true;
		}
	}
	
	function alpha(field,alerttxt)
	{
		with (field)
		{
			var numaric = value;
			for(var j=0; j<numaric.length; j++)
				{
				  var alphaa = numaric.charAt(j);
				  var hh = alphaa.charCodeAt(0);
				 
				  if((hh > 64 && hh<91) || (hh > 96 && hh<123) || hh == 32)
				  {
				  }
				else	{
					 alert(alerttxt); return false;
				  }
				}
		 return true;
		}
	}
	
	function digitvalidation(entered, min, max, alertbox, datatype)
	{
		// Digit Validation by Henrik Petersen / NetKontoret
		// Explained at
		//www.echoecho.com/jsforms.htm
		// Please do not remove this line and the two lines above.
		with (entered)
		{
		checkvalue=parseFloat(value);
		if (datatype)
		{smalldatatype=datatype.toLowerCase();
		if (smalldatatype.charAt(0)=="i")
		{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
		}
		if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max
		&& value.length>max) || value!=checkvalue)
		{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
		}
	}
	
	function formatNum(field,alerttxt) {
		with (field)
		{
		
			if(value == '€')
			{
				return true;
			}
		
			var S = value;
			//var OK = /^\d{1,5}(\.\d\d?)?$/.test(S);
			var OK = /^\d{1,9}(\.\d\d?)?$/.test(S);
			if (OK) 
			{
			return true;
			}
			else {
				alert(alerttxt); return false;
			}
		}
	}