/*Common JavaScript functions*/


function fSetStatusBar(value)
{
	status = value;
}


function fParticipantRegistartion(formName)
{
        				
	var f = document.forms[0];
	
	if(checkFields(formName))
	{	    
		//f.method = 'post';		
		//f.name = formName;
		f.submit();
	}	
}


function fSetFormAction ( _formName, _stringURL )
{
	var _f = document.forms [ _formName ];
	_f.action = _stringURL;
}

function isEmail(inp, fname)
{
    var sEmail = inp.value;
    
    if(sEmail != ""){      
	  if (sEmail.length < 5 || sEmail.indexOf("@") == -1 ||
	     sEmail.indexOf(" ") != -1	|| sEmail.indexOf("@") < 1 ||
	     sEmail.lastIndexOf(".") < sEmail.indexOf("@") + 2) {
	        inp.focus();
	        excl(fname);
	        return false;
      }  
    } 
  return true;
}

function isPhone(inp,fname){
	var txt=inp.value;
	
	//may be empty
	if(txt == "")
	  return true;
	  
	txt=txt.toUpperCase();
	if (txt.length>0)	{
		var alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+ ()[]{<>}0123456789"
		for(var i=0; i< txt.length; i++) {
			if (alphabet.indexOf(txt.charAt(i))==-1) {
	      inp.focus(); excl(fname); return false;
	    }
		}
		return true;
	}
	inp.focus(); excl(fname); return false;
}

function isUrl(inp, fname)
{
 var Value = inp.value;
 var re=/^(http:\/\/)?(\w+(\.[\w%~&\?=-]+|\/[\w%~&\?=-]*)+)*\s*$/;
 //допускает пустое значение
 if (Value.search(re)!=-1)
  return true;

  inp.focus();
  excl(fname);
  return false;
}

function isEmpty(inp, fname)
{
  if(inp.value == ""){
    inp.focus();
    excl(fname);
    return false;
  }
  
  return true;    
}

function isText(inp, fname)
{
  var t = inp.value;
  var ok = 0;
  var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  for (i=0; i<t.length; i++){
    if (alphabet.indexOf(t.charAt(i)) != -1) ok++;
    if (t.charCodeAt(i) > 127) ok++;
    if (ok >= 0) return true;    
  }
  inp.focus();
  excl(fname);
  return false;
}
