﻿// JScript File
                    
                    function fnValidate() {
	                    if (fnrequired("")) {
	                        fnSubmitEmail();
	                    }
	                }

                    function fnSubmitEmail() {
	                    document.join.target="ifrSaveItems";
	                    document.getElementById("Mysubmit").click();
	                    //document.join.submit();
                    }

                    function validateEmail(src) {
		                emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[a-zA-Z]$"
		                var regex = new RegExp(emailReg);
		                if(regex.test(src) == false){
			                alert('Please enter a valid email address and try again');
			                return false;
		                }
		                if (src.lastIndexOf(".")==-1) {
			                alert('Please enter a valid email address and try again');
			                return false;		
		                }
		                return regex.test(src);
                    }

                     function fnrequired(text) {
                      var txt_OBJ = document.join.elements;
                      var cantTXT = txt_OBJ.length 
                      var txtEmail="";
                        for (var i=0; i<cantTXT; i++) {
                       //if (txt_OBJ[i].name.substring(0, 4)=="txt_" ) { 
                                 try {
                                    //alert(txt_OBJ[i].name + "--" + txt_OBJ[i].name.indexOf("mail"));
                                     if (txt_OBJ[i].name.indexOf("Mail") > 0 && txt_OBJ[i].value!="" && txt_OBJ[i].name!="email_response") {
                                            txtEmail=txt_OBJ[i].value;
                                            //alert(txt_OBJ[i].name+":"+txtEmail)
                                            if (!validateEmail(txtEmail)) {
                                                 txt_OBJ[i].style.backgroundColor="orange";
                                                 try {
                                                 txt_OBJ[i].focus();
                                                 } catch(e) {
                                                 
                                                 }                            
                                                return false;
                                                }
                                        }                 
                                     if (txt_OBJ[i].title=="required" && txt_OBJ[i].value=="") {

                                         alert("Required field: "+txt_OBJ[i].name.replace(text,"").replace("_r","_").replace("i_"," ").replace("_"," ").replace("-"," ").replace(/\d/," "));
                                         txt_OBJ[i].style.backgroundColor="orange";
                                         try {
                                         txt_OBJ[i].focus();
                                         } catch(e) {
                                         
                                         }
                                         return false;
                                        } else {
                                         txt_OBJ[i].style.backgroundColor="white";
                                        }
                                 } catch(e) {
                                        
                                 }
                                }
                      //}  
                      return true;
                     }  
                        
                    function fnReloadEmail(bolSuccess) {
	                    if (bolSuccess=="1") {
		                    //alert("Informatreceived!");
                            self.location.href=(document.getElementById("redirect").value);
		                    return;
		                } else {
		                    alert("Error sending the information!");
	                    }
                    }                         


