function checkfield(alertmessage, lcRequiredInsert, lcRequiredField, lcInvalidEmail) {
	var ret = true;
	var div_name = '';
	var val_field;
	
	for (i=0; i<required_field.length; i++) {
		div_field = 'mandatorysymbol_' + required_field[i][0] ;
		if(required_field[i][2]=="S"){
			val_field = document.all.item(required_field[i][0]).value;
		}else{
			var index=document.all.item(required_field[i][0]).selectedIndex;
			val_field = document.all.item(required_field[i][0]).options[index].value;
		}
		
		if(val_field == ''){
    		if(ret){
				alert(lcRequiredInsert + ' ' + required_field[i][1] + ' ' + lcRequiredField);
				document.all.item(required_field[i][0]).focus()				
				ret = false;			
			}
			showdiv(div_field);
		}else{
			if (required_field[i][0]=='email'){
				if(!verifyEmail(document.all.item('email').value,1)) {
					alert(lcInvalidEmail);
					document.all.item('email').focus()
					ret = false;
				}else if(!(document.all.item('email').value == document.all.item('email_confirm').value)){	
					alert(lcInvalidEmail_Confirm);
					document.getElementById('mandatorysymbol_emailConf').style.display='block';
					document.all.item('email_confirm').focus()
					ret = false;		
				} else {
					document.getElementById('mandatorysymbol_emailConf').style.display='none';
				}
			}
			hidediv(div_field);
		}
		
	}


	//if (ret && document.all.item('reg_typecod').value==""){
	//	alert("empty code");
	//	ret=false;
	//}
	

	if (ret && !document.all.item('chkTerms').checked){
		alert(alertmessage);
		ret=false;
	}
//	alert('return='+ret);
	return ret;	
}


function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function verifyEmailold(myEmail) {
	checkEmail = myEmail.value
	myReturn = true
	
	//alert(checkEmail.indexOf('@'));
	
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
		myReteurn = false;
		
	alert(myReturn);
	return myReturn	
}

function verifyEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var myret = true
	
	 if (str.indexOf(at)==-1){
	    myret = false
	 }
	 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	    myret = false
	 }
	 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    myret = false
  	 }
	 if (str.indexOf(at,(lat+1))!=-1){
	    myret = false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    myret = false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
	    myret = false
	 }
     if (str.indexOf(" ")!=-1){
	    myret = false
	 }
 
 	 return myret					
}
