function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

	function CheckPhone(tel)
	{
		allowed="+()1234567890.-/";
		for (i = 0; i < tel.length; i++)
		{
			var c=tel.charAt(i);
			// test for spaces
			if(c != " ")
			{
				if(allowed.indexOf(c)==-1)
					return false;
			}
		}
		return true;
	}


	function validare(param)
	{
	    var M_login,M_password,M_password_cf,M_firstname,M_lastname,M_email,M_city,M_country,M_zip_code,M_phone,M_address;

 	    if(param!=1)
		{
		    M_login=document.contfrm.M_login;
			M_password=document.contfrm.M_password;
 		   // M_password_cf=document.contfrm.M_password_cf;
			//M_email_cf = document.contfrm.M_email_cf;
		}
	    M_firstname=document.contfrm.M_firstname;
	    M_lastname=document.contfrm.M_lastname;
	    M_email=document.contfrm.M_email;
	    M_city=document.contfrm.M_city;
	    M_address=document.contfrm.M_address;
	    M_country=document.contfrm.M_country;
	    M_zip_code=document.contfrm.M_zip_code;
	    M_phone=document.contfrm.M_phone;
	    M_how_find=document.contfrm.M_how_find;



		if(param == 0)
			{
			if(document.contfrm.terms.checked == false)
				{
				alert(dtl_validare_001);
				return false;
				}
			}
		if(param!=1)
		{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(M_email.value)))
		    {
		    	alert(dtl_validare_002);
				M_email.focus();
				M_email.select();
				return false;
		    }
	  	    if (M_login.value.length==0)
	  	    {
	   	    	alert (dtl_validare_003);
				M_login.focus();
	    		M_login.select();
	    		return false;
	   	    }
			else
			{
				//detect spaces
				splitlogin = M_login.value.split(" ");
				if(splitlogin.length > 1)
				{
		   	    	alert (dtl_validare_004);
					M_login.focus();
		    		M_login.select();
	    			return false;
				}
				else
				{
				if(CheckPhone(M_login.value))
					{
		   	    	alert (dtl_validare_005);
					M_login.focus();
		    		M_login.select();
	    			return false;
					}
				if (!M_login.value.match(/^[a-zA-Z0-9]+$/))
					{
					alert (dtl_validare_006);
					M_login.focus();
		    		M_login.select();
	    			return false;
					}
				}
			}
		    if (M_password.value.length<6)
	  	    {
		   		alert (dtl_validare_007);
		   		M_password.focus();
	    		M_password.select();
				return false;
		    }

		}
		/* alta varianta
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (!filter.test(M_email.value))*/

			 /*if(param != 1)
			{
			   if (M_email.value!=M_email_cf.value)
		  	    {
			   		alert ('Your email confirmation is incorrect!');
			   		M_email_cf.focus();
		    		M_email_cf.select();
					return false;
			    }
			}*/
		if (document.contfrm.M_all.checked)
		{
	  	    if (M_firstname.value.length<2)
	  	    {
	   	    	alert (dtl_validare_008);
				M_firstname.focus();
	    		M_firstname.select();
	    		return false;
	   	    }
	  	    if (M_lastname.value.length<2)
	  	    {
	   	    	alert (dtl_validare_009);
				M_lastname.focus();
	    		M_lastname.select();
	    		return false;
	   	    }
			if (param == 1) {
				if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(M_email.value)))
		    	{
			    	alert(dtl_validare_002);
					M_email.focus();
					M_email.select();
					return false;
		    	}
		    }

	  	    if (M_city.value.length==0)
	  	    {
	   	    	alert (dtl_validare_010);
				M_city.focus();
	    		M_city.select();
	    		return false;
	   	    }
	  	    if (M_address.value.length==0)
	  	    {
	   	    	alert (dtl_validare_011);
				M_address.focus();
	    		M_address.select();
	    		return false;
	   	    }
		    if(document.forms['contfrm'].elements['M_country'].value==0)
		    {
				alert(dtl_validare_012);
				return false;
		    }
			if(M_zip_code.value.length==0)
			{
				alert (dtl_validare_013);
				M_zip_code.focus();
				M_zip_code.select();
				return false;
			}
			if(M_phone.value.length==0 || !CheckPhone(M_phone.value))
			{
				alert (dtl_validare_014);
				M_phone.focus();
				M_phone.select();
				return false;
		    }
			if(param!=1)
			{
		  	    if (M_how_find.value.length < 4)
		  	    {
		   	    	alert (dtl_validare_015);
					M_how_find.focus();
		    		M_how_find.select();
		    		return false;
		   	    }
			}
		}
   	}

	function validare_contact()
	{
	    var M_firstname,M_lastname,M_email,M_city,M_country,M_phone,M_comments;
		document.contactfrm.M_browser.value = trimString(document.contactfrm.M_browser.value);
		document.contactfrm.M_system.value = trimString(document.contactfrm.M_system.value);
	    M_firstname=document.contactfrm.M_firstname;
	    M_lastname=document.contactfrm.M_lastname;
	    M_email=document.contactfrm.M_email;
	    M_city=document.contactfrm.M_city;
	    M_browser=document.contactfrm.M_browser;
	    M_system=document.contactfrm.M_system;
	    M_country=document.contactfrm.M_country;
	    M_goesto=document.contactfrm.M_goesto;
	    M_phone=document.contactfrm.M_phone;
	    M_comments=document.contactfrm.M_comments;

  	    if (M_firstname.value.length==0)
  	    {
   	    	alert (dtl_validare_contact_001);
			M_firstname.focus();
    		M_firstname.select();
    		return false;
   	    }
  	    if (M_lastname.value.length==0)
  	    {
   	    	alert (dtl_validare_contact_002);
			M_lastname.focus();
    		M_lastname.select();
    		return false;
   	    }
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(M_email.value)))
	    {
	    	alert(dtl_validare_contact_003);
			M_email.focus();
			M_email.select();
			return false;
	    }
	    if (M_city.value.length==0)
	  	    {
	   	    	alert (dtl_validare_010);
				M_city.focus();
	    		M_city.select();
	    		return false;
	   	    }
  	    if(document.forms['contactfrm'].elements['M_country'].value==0)
	    {
			alert(dtl_validare_contact_004);
			return false;
	    }
		if(M_phone.value.length!=0)
		{
			if(!CheckPhone(M_phone.value))
			{
				alert (dtl_validare_contact_005);
				M_phone.focus();
				M_phone.select();
				return false;
			}
	    }
  	    if (M_browser.value.length==0)
  	    {
   	    	alert (dtl_validare_contact_006);
			M_browser.focus();
    		M_browser.select();
    		return false;
   	    }
  	    if (M_system.value.length==0)
  	    {
   	    	alert (dtl_validare_contact_007);
			M_system.focus();
    		M_system.select();
    		return false;
   	    }
  	    if (M_comments.value.length==0)
  	    {
   	    	alert (dtl_validare_contact_008);
			M_comments.focus();
    		M_comments.select();
    		return false;
   	    }
  	    if(document.forms['contactfrm'].elements['M_goesto'].value==0)
	    {
			alert(dtl_validare_contact_009);
			return false;
	    }
   	}

	function CK_log(frm)
	{
	    var uname,pass;
	    uname=document.forms[frm].uname;
 	    pass=document.forms[frm].pass;
  	    if (uname.value.length==0)
  	    {
   	    	alert (dtl_CK_log_001);
			uname.focus();
    		uname.select();
    		return false;
   	    }
  	    if (pass.value.length==0)
  	    {
   	    	alert (dtl_CK_log_002);
			pass.focus();
    		pass.select();
    		return false;
   	    }
	}

	function CK_image(frm_u)
	{
	    var up_image;
	    up_image = document.forms[frm_u].up_image;
  	    if (up_image.value.length==0)
  	    {
   	    	alert (dtl_CK_image_001);
			up_image.focus();
    		up_image.select();
    		return false;
   	    }
		/*else
		{
			var file;
			file = up_image.value;
			extArray = new Array(".jpg", ".jpeg");
			allowSubmit = false;

			while (file.indexOf("\\") != -1)
				file = file.slice(file.indexOf("\\") + 1);
			ext = file.slice(file.indexOf(".")).toLowerCase();
			for (var i = 0; i < extArray.length; i++)
			{
				if (extArray[i] == ext) { allowSubmit = true; break; }
			}

			if(!allowSubmit)
			{
	   	    	alert ("Please choose a JPG image file!");
				up_image.focus();
    			up_image.select();
    			return false;
			}
		}*/
		else
		{
			//document.all['td1'].style.display='none';
			document.all['td2'].style.display='inline';
			return true;
		}
	}

	function CK_image_ag(frm_u)
	{
	    var up_image;
	    var M_terms;
	    M_terms = document.forms[frm_u].M_terms;
	    up_image = document.forms[frm_u].up_image;

	    if (M_terms.checked == false)
  	    {
   	    	alert (dtl_CK_image_ag_001);
			return false
	    }
  	    if (up_image.value.length==0)
  	    {
   	    	alert (dtl_CK_image_ag_002);
			up_image.focus();
    		up_image.select();
    		return false;
   	    }

	}

function validSum(sText)
	{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   if (!IsNumber)
	   	{

		return false;
		}
   return IsNumber;
   }


	function countnrwords(stringu)

		{
		/*
		var myString = new String(stringu.replace(/[^\w\s,]/gi,' '));
		var myArray = myString.split(/([, ])/);
		return myArray.length;
		*/
		return CountWords(stringu, true, true);
		}
function CountWords (this_field, show_word_count, show_char_count) {
if (show_word_count == null) {
show_word_count = true;
}
if (show_char_count == null) {
show_char_count = false;
}
var char_count = this_field.length;
var fullStr = this_field + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}
if (word_count == 1) {
wordOrWords = " word";
}
else {
wordOrWords = " words";
}
return word_count;
}

	function CK_upload(T)
	{
	    var name,description,keywords,terms,sr_price;
	    name=document.uploadfrm1.M_title;
	    description=document.uploadfrm1.M_description;
	    keywords=document.uploadfrm1.M_keywords;
	    terms=document.uploadfrm1.M_terms;
  	    sr_price=document.uploadfrm1.sr_price;

		if (sr_price.value!=0 && sr_price.value!='' && (sr_price.value<350 || sr_price.value>25000))
  	    {
   	    	alert (dtl_CK_upload_001);
			sr_price.focus();
    		sr_price.select();
    		return false;
   	    }

		if (name.value.length==0)
  	    {
   	    	alert (dtl_CK_upload_002);
			name.focus();
    		name.select();
    		return false;
   	    }
		if (name.value.length>50)
  	    {
   	    	alert (dtl_CK_upload_003);
			name.focus();
    		name.select();
    		return false;
   	    }
  	    if (description.value.length==0)
  	    {
   	    	alert (dtl_CK_upload_004);
			description.focus();
    		description.select();
    		return false;
   	    }
		if (description.value.length>1500)
  	    {
   	    	alert (dtl_CK_upload_005);
			description.focus();
    		description.select();
    		return false;
   	    }
		if (countnrwords(description.value)<5)
			{
			alert (dtl_CK_upload_006);
			description.focus();
    		description.select();
    		return false;
			}
		if(name.value == description.value)
		{
			alert(dtl_CK_upload_007);
			description.focus();
    		description.select();
    		return false;
		}
	    if(document.forms['uploadfrm1'].elements['M_category_1'].value==0 && document.forms['uploadfrm1'].elements['M_category_2'].value==0 && document.forms['uploadfrm1'].elements['M_category_3'].value==0)
	    {
			alert(dtl_CK_upload_008);
			return false;
	    }
  	    if (keywords.value.length==0)
  	    {
   	    	alert (dtl_CK_upload_009);
			keywords.focus();
    		keywords.select();
    		return false;
   	    }
		if (countnrwords(keywords.value)>80)
  	    {
   	    	alert (dtl_CK_upload_010+" "+countnrwords(keywords.value)+" "+dtl_CK_upload_011+". "+dtl_CK_upload_012);
			keywords.focus();
    		keywords.select();
    		return false;
   	    }
		if(T == 0)
		{
			if (terms.checked == false)
  		    {
   				alert (dtl_CK_upload_013);
    			return false;
	   	    }
		}

		if (validSum(sr_price.value))
			{
			if (sr_price.value!=0 && sr_price.value!='' && (sr_price.value<350 || sr_price.value>25000) )
		 	    {
		  	    alert (dtl_CK_upload_014);
				sr_price.focus();
		   		sr_price.select();
		   		return false;
		  	    }
			}
		else
			{
			alert (dtl_CK_upload_015);
			sr_price.focus();
	   		sr_price.select();
	   		return false;
			}

	   if (document.uploadfrm1.checkbox_sr.checked && !(document.uploadfrm1.checkbox_usereco.checked || document.uploadfrm1.sr_price.value))
		   	{
			alert (dtl_CK_upload_016);
			sr_price.focus();
	   		sr_price.select();
		   	return false;
			}
		return;
	}

	function CK_upload_keymaster(T)
	{
	    var terms,sr_price;

	    terms=document.uploadfrm1.M_terms;
  	    sr_price=document.uploadfrm1.sr_price;

		if (sr_price.value!=0 && sr_price.value!='' && (sr_price.value<350 || sr_price.value>25000))
  	    {
   	    	alert (dtl_CK_upload_keymaster_017);
			sr_price.focus();
    		sr_price.select();
    		return false;
   	    }


		if(T == 0)
		{
			if (terms.checked == false)
  		    {
   				alert (dtl_CK_upload_keymaster_018);
    			return false;
	   	    }
		}

		if (validSum(sr_price.value))
			{
			if (sr_price.value!=0 && sr_price.value!='' && (sr_price.value<350 || sr_price.value>25000) )
		 	    {
		  	    alert (dtl_CK_upload_keymaster_017);
				sr_price.focus();
		   		sr_price.select();
		   		return false;
		  	    }
			}
		else
			{
			alert (dtl_CK_upload_keymaster_019);
			sr_price.focus();
	   		sr_price.select();
	   		return false;
			}

	   if (document.uploadfrm1.checkbox_sr.checked && !(document.uploadfrm1.checkbox_usereco.checked || document.uploadfrm1.sr_price.value))
		   	{
			alert (dtl_CK_upload_keymaster_020);
			sr_price.focus();
	   		sr_price.select();
		   	return false;
			}
		return;
	}
	function CK_freeupload(T)
	{
	    var name,description,keywords;
	    name=document.uploadfrm1.M_title;
	    description=document.uploadfrm1.M_description;
	    keywords=document.uploadfrm1.M_keywords;

		if (name.value.length==0)
  	    {
   	    	alert (dtl_CK_freeupload_001);
			name.focus();
    		name.select();
    		return false;
   	    }
  	    if (description.value.length==0)
  	    {
   	    	alert (dtl_CK_freeupload_002);
			description.focus();
    		description.select();
    		return false;
   	    }
		if (countnrwords(description.value)<5)
			{
			alert (dtl_CK_freeupload_003);
			description.focus();
    		description.select();
    		return false;
			}
		if(name.value == description.value)
		{
			alert(dtl_CK_freeupload_004);
			description.focus();
    		description.select();
    		return false;
		}

  	    if (keywords.value.length==0)
  	    {
   	    	alert (dtl_CK_freeupload_005);
			keywords.focus();
    		keywords.select();
    		return false;
   	    }
		if (countnrwords(keywords.value)>80)
  	    {
   	    	alert (dtl_CK_freeupload_006+" "+countnrwords(keywords.value)+" "+dtl_CK_freeupload_007+". "+dtl_CK_freeupload_008);
			keywords.focus();
    		keywords.select();
    		return false;
   	    }


		return;
	}

	function validare_board()
	{
	    var M_subject,M_message;
	    M_subject=document.boardfrm.M_subject;
	    M_message=document.boardfrm.M_message;

  	    if (M_subject.value.length==0)
  	    {
   	    	alert ("Please type the subject!");
			M_subject.focus();
    		M_subject.select();
    		return false;
   	    }
  	    if (M_message.value.length==0)
  	    {
   	    	alert ("Please type the message!");
			M_message.focus();
    		M_message.select();
    		return false;
   	    }
	}

	function ConvertCF()
	{
	    var convertvalue;
	    convertvalue=document.convertfrm.convertvalue;

  	    if (convertvalue.value.length==0 || convertvalue.value==0 || isNaN(convertvalue.value))
  	    {
   	    	alert (dtl_ConvertCF_001);
			convertvalue.focus();
    		convertvalue.select();
    		return false;
   	    }


		if (convertvalue.value!=Math.floor(convertvalue.value))
  	    {
   	    	alert (dtl_ConvertCF_002);
			convertvalue.focus();
    		convertvalue.select();
    		return false;
   	    }
	return true;
	}

	function PayCK(maxval)
	{
	    var payvalue;
	    payvalue=document.payfrm.payvalue;
  	    if (payvalue.value.length==0 || payvalue.value==0 || isNaN(payvalue.value))
  	    {
   	    	alert (dtl_PayCK_001);
			payvalue.focus();
    		payvalue.select();
    		return false;
   	    }
		if (payvalue.value>10000)
  	    {
   	    	alert (dtl_PayCK_002);
			payvalue.focus();
    		payvalue.select();
    		return false;
   	    }
		if (payvalue.value>maxval)
  	    {
   	    	alert (dtl_PayCK_003+" $"+maxval+".");
			payvalue.focus();
    		payvalue.select();
    		return false;
   	    }
	}

	function ImageDownCK(frmname)
	{
	    var M_agree,comments;
		M_agree=document.forms[frmname].M_agree;
		comments=document.forms[frmname].comments;
  	    if (M_agree.checked == false)
  	    {
   	    	alert (dtl_ImageDownCK_001);
			return false
   	    }
		/*
		if (comments.value == 0)
  	    {
   	    	if (confirm ('Before downloading please leave a short comment and include a few words for the photographer (i.e. future image usage). We kindly ask you to avoid very  short messages such as "Nice" or "Thanks". Your feedback is extremely important to our contributors and highly valued.'))
			return false;
		else
			return true;

   	    }
		*/
		return true;
	}

	function TermsCK(frmname)
	{
	    var M_agree;
		M_agree=document.forms[frmname].M_agree;
  	    if (M_agree.checked == false)
  	    {
   	    	alert (dtl_TermsCK_001);
			return false
   	    }
		else
			return true;
	}


	function PassCK()
	{
	    var M_email_request;
	    M_email_request=document.passfrm.M_email_request;

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(M_email_request.value)))
	    {
	    	alert(dtl_PassCK_001);
			M_email_request.focus();
			M_email_request.select();
			return false;
	    }
	}

	function ConfirmDelete(frm)
	{
		if (window.confirm("Are you sure you want to delete this file?"))
			document.forms[frm].submit();
	}

	function DisableImage(frm)
	{
		var rd_confirm = document.forms[frm].rd_confirm;
		var M_reason = document.forms[frm].M_reason.value;
		if(!rd_confirm[0].checked)
		{
			alert(dtl_DisableImage_001);
			return false;
		}
		if(M_reason.length < 3)
		{
			alert(dtl_DisableImage_002);
			return false;
		}
		return true;
	}

	function BNewsAdd(field)
	{
		var news = document.forms['frm_forum'].message;
		if(news.value.length == 0)
		{
			alert(dtl_BNewsAdd_001);
			news.focus();
			news.select();
			return false;
		}
		else
		{
			var MaxCharacters = 1500;
			if (news.value.length > MaxCharacters)
			{
				alert(dtl_BNewsAdd_002+' '+MaxCharacters+' '+dtl_BNewsAdd_003);
				news.value = news.value.substring(0, MaxCharacters);
				return false;
			}
		}
	}

	function CollectionsCheck(forma,imageid)
	{
		var collectionid = forma.collectionid.value;
		if(collectionid == 0)
		{
			alert(dtl_CollectionsCheck_001);
			return false;
		}
		if(collectionid == -1)
		{
			forma.do_action.value="";
			forma.collectionid.value="";
			forma.action = "collections.php?image_identifier="+imageid+"#point";
		}
	}

	function CollectionsAdd(forma,mode)
	{
		if(mode == 1)
			var image_identifier = forma.image_identifier;
		var ctitle = forma.ctitle;
		var cdescription = forma.cdescription;
		var ckeywords = forma.ckeywords;

		if(mode == 1)
		{
			if(image_identifier.value.length == 0)
			{
				alert(dtl_CollectionsAdd_001);
				image_identifier.focus();
				image_identifier.select();
				return false;
			}
		}
		if(ctitle.value.length == 0)
		{
			alert(dtl_CollectionsAdd_002);
			ctitle.focus();
			ctitle.select();
			return false;
		}
		if(cdescription.value.length == 0)
		{
			alert(dtl_CollectionsAdd_003);
			cdescription.focus();
			cdescription.select();
			return false;
		}
		if(ckeywords.value.length == 0)
		{
			alert(dtl_CollectionsAdd_004);
			ckeywords.focus();
			ckeywords.select();
			return false;
		}
	}

	function CollectionsSearch(forma)
	{
		var srh_coll = forma.srh_coll;
		if(srh_coll.value.length == 0 || srh_coll.value==dtl_CollectionsSearch_000)
		{
			alert(dtl_CollectionsSearch_001);
			srh_coll.focus();
			srh_coll.select();
			return false;
		}
	}

	function PaymentRequest(forma)
	{
		var paytype = forma.paytype;
		var paypalid = forma.paypalid;
		var bookersid = forma.bookersid;

		if(paytype[0].checked)
		{
			if(paypalid.value == "")
			{
				alert(dtl_PaymentRequest_001);
				paypalid.focus();
				paypalid.select();
				return false;
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(paypalid.value)))
			{
				alert(dtl_PaymentRequest_002);
				paypalid.focus();
				paypalid.select();
				return false;
			}
		}
		if(paytype[1].checked)
			{
			if(bookersid.value == "")
			{
				alert(dtl_PaymentRequest_003);
				bookersid.focus();
				bookersid.select();
				return false;
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(bookersid.value)))
			{
				alert(dtl_PaymentRequest_004);
				bookersid.focus();
				bookersid.select();
				return false;
			}
			}
		return true;
	}

	function OMS_review(forma)
	{
		var message = forma.message;
		var do_action = forma.do_action;
		var reason = forma.reason;
		var coll = forma.elements;
		if(do_action.value == "escalate")
		{
			if(message.value.length == 0)
			{
				alert("Please type message to site admins!");
				message.focus();
				message.select();
				return false;
			}
		}
		if(do_action.value == "refuse")
		{
			check = false;
			nr = coll.length;
			for (i=0;i<=nr;i++)
			{
				if(null != coll[i] &&  null != coll[i].name)
				{
					if(coll[i].name.substr(0,3)=="rs_")
					{
						if(coll[i].checked == true)
						{
							check = true;
						}
					}
				}
			}
			if(reason.value.length == 0 && !check)
			{
				alert("Please type or choose reason to refuse image!");
				reason.focus();
				reason.select();
				return false;
			}
		}
	}

	function LightboxAdd(forma)
	{
		var lname = forma.name;
		if(lname.value.length == 0)
		{
			alert(dtl_LightboxAdd_002);
			lname.focus();
			lname.select();
			return false;
		}
		if (!lname.value.match(/^[a-zA-Z0-9\s]+$/))
			{
				alert (dtl_LightboxAdd_001);
				lname.focus();
		   		lname.select();
	    		return false;
			}

	}

function check_secure_form()
	{
	var x_card_num = document.frm_secure.x_card_num;
	var x_exp_date1 = document.frm_secure.x_exp_date1;
	var x_exp_date2 = document.frm_secure.x_exp_date2;
	var x_card_code = document.frm_secure.x_card_code;
	var x_first_name = document.frm_secure.x_first_name;
	var x_last_name = document.frm_secure.x_last_name;
	var x_address = document.frm_secure.x_address;
	var x_city = document.frm_secure.x_city;
	var x_zip = document.frm_secure.x_zip;
	var x_country = document.frm_secure.x_country;
	var x_phone = document.frm_secure.x_phone;
	var x_email = document.frm_secure.x_email;


	if(x_card_num.value == '')
		{
			alert(dtl_check_secure_form_001);
			x_card_num.focus();
			x_card_num.select();
			return false;
		}

	if(x_exp_date1.value == '--' || x_exp_date2.value == '----')
		{
			alert(dtl_check_secure_form_002);
			return false;
		}

	if(x_card_code.value == '')
		{
			alert(dtl_check_secure_form_003);
			x_card_code.focus();
			x_card_code.select();
			return false;
		}

    if(x_first_name.value == '')
		{
			alert(dtl_check_secure_form_004);
			x_first_name.focus();
			x_first_name.select();
			return false;
		}
	if(x_last_name.value == '')
		{
			alert(dtl_check_secure_form_005);
			x_last_name.focus();
			x_last_name.select();
			return false;
		}

	if(x_address.value == '')
		{
			alert(dtl_check_secure_form_006);
			x_address.focus();
			x_address.select();
			return false;
		}

	if(x_city.value == '')
		{
			alert(dtl_check_secure_form_007);
			x_city.focus();
			x_city.select();
			return false;
		}

	if(x_zip.value == '')
		{
			alert(dtl_check_secure_form_008);
			x_zip.focus();
			x_zip.select();
			return false;
		}

	if(x_country.options.selectedIndex < 0 || (x_country.options.selectedIndex >= 0 && (x_country.options[x_country.selectedIndex].value == '' || x_country.options[x_country.selectedIndex].value == 0)))
		{
			alert(dtl_check_secure_form_009);
			x_country.focus();
			//x_country.select();
			return false;
		}

	if(x_phone.value == '')
		{
			alert(dtl_check_secure_form_010);
			x_phone.focus();
			x_phone.select();
			return false;
		}

    if(x_email.value == '')
		{
			alert(dtl_check_secure_form_011);
			x_email.focus();
			x_email.select();
			return false;
		}
	document.getElementById('gobutton').disabled=true;
	return true;
	}

function validare_anonymous(param)
	{
	    var M_login,M_password,M_password_cf,M_firstname,M_lastname,M_email,M_city,M_country,M_zip_code,M_phone,M_address;

 	    if(param!=1)
		{
		    M_login=document.frm_secure.M_login;
			M_password=document.frm_secure.M_password;

		}
		var M_card_num = document.frm_secure.M_card_num;
		var M_exp_date1 = document.frm_secure.M_exp_date1;
		var M_exp_date2 = document.frm_secure.M_exp_date2;
		var M_card_code = document.frm_secure.M_card_code;
	    M_firstname=document.frm_secure.M_firstname;
	    M_lastname=document.frm_secure.M_lastname;
	    M_email=document.frm_secure.M_email;
	    M_city=document.frm_secure.M_city;
	    M_state=document.frm_secure.M_state;
	    M_address=document.frm_secure.M_address;
	    M_country=document.frm_secure.M_country;
	    M_zip_code=document.frm_secure.M_zip_code;
	    M_phone=document.frm_secure.M_phone;



		if(param!=1)
		{
		if(M_card_num.value == '')
		{
			alert(dtl_check_secure_form_001);
			M_card_num.focus();
			M_card_num.select();
			return false;
		}

		if(M_exp_date1.value == '--' || M_exp_date2.value == '----')
			{
				alert(dtl_check_secure_form_002);
				return false;
			}

		if(M_card_code.value == '')
			{
				alert(dtl_check_secure_form_003);
				M_card_code.focus();
				M_card_code.select();
				return false;
			}
		if (M_login.value.length==0)
	  	    {
	   	    	alert (dtl_validare_003);
				M_login.focus();
	    		M_login.select();
	    		return false;
	   	    }
			else
			{
				//detect spaces
				splitlogin = M_login.value.split(" ");
				if(splitlogin.length > 1)
				{
		   	    	alert (dtl_validare_004);
					M_login.focus();
		    		M_login.select();
	    			return false;
				}
				else
				{
				if(CheckPhone(M_login.value))
					{
		   	    	alert (dtl_validare_005);
					M_login.focus();
		    		M_login.select();
	    			return false;
					}
				if (!M_login.value.match(/^[a-zA-Z0-9]+$/))
					{
					alert (dtl_validare_006);
					M_login.focus();
		    		M_login.select();
	    			return false;
					}
				}
			}
			if (M_password.value.length<6)
	  	    {
		   		alert (dtl_validare_007);
		   		M_password.focus();
	    		M_password.select();
				return false;
		    }
		    if (M_password.value == M_login.value) {
		    	alert ("'Desired login' and password must be different.");
		   		M_password.focus();
	    		M_password.select();
				return false;
		    }
			if (M_firstname.value.length<2)
	  	    {
	   	    	alert (dtl_validare_008);
				M_firstname.focus();
	    		M_firstname.select();
	    		return false;
	   	    }
	  	    if (M_lastname.value.length<2)
	  	    {
	   	    	alert (dtl_validare_009);
				M_lastname.focus();
	    		M_lastname.select();
	    		return false;
	   	    }
			 if (M_address.value.length==0)
	  	    {
	   	    	alert (dtl_validare_011);
				M_address.focus();
	    		M_address.select();
	    		return false;
	   	    }
	   	     if (M_city.value.length==0)
	  	    {
	   	    	alert (dtl_validare_010);
				M_city.focus();
	    		M_city.select();
	    		return false;
	   	    }

	   	    if(M_zip_code.value.length==0)
			{
				alert (dtl_validare_013);
				M_zip_code.focus();
				M_zip_code.select();
				return false;
			}
			 if(document.forms['frm_secure'].elements['M_country'].value==0)
		    {
				alert(dtl_validare_012);
				return false;
		    }

			if(M_phone.value.length==0 || !CheckPhone(M_phone.value))
			{
				alert (dtl_validare_014);
				M_phone.focus();
				M_phone.select();
				return false;
		    }
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(M_email.value)))
		    {
		    	alert(dtl_validare_002);
				M_email.focus();
				M_email.select();
				return false;
		    }



		}

   	}
