﻿function checkRequired(btnName,fieldstoValidate,Messages){
if(btnName!="" && fieldstoValidate!="" && Messages!=""){
    
        if(fieldstoValidate.length==Messages.length){
        var HTMLmessage=""
        for (i = 0; i < fieldstoValidate.length; i++) {                  
                if(document.getElementById("ctl00_"+fieldstoValidate[i]).value=="") {                           
                    HTMLmessage+="فیلد "+Messages[i]+" باید مقداردهی شود"+".<br/>";    
                    document.getElementById("ctl00_"+fieldstoValidate[i]).style.backgroundColor="#FF9F9F";                    
                }else{
                    document.getElementById("ctl00_"+fieldstoValidate[i]).style.backgroundColor="";  
                }
            }
                   
            if(HTMLmessage!=""){               
             showAlertDiv(HTMLmessage);                       
                return false;                
            }
        }
        else{
            alert("number of fields and messages for validation function is not equal.");
            return false;
        }
    }      
}
//****************************************************************************************
function checkRequiredContactus(btnName, fieldstoValidate, Messages) {
      
    if(btnName!="" && fieldstoValidate!="" && Messages!=""){   
        if(fieldstoValidate.length==Messages.length){       
        var HTMLmessage=""
        for (i = 0; i < fieldstoValidate.length; i++) {            
            if (document.getElementById("ctl00_Content_" + fieldstoValidate[i]).value == "") {                           
                    HTMLmessage+="فیلد "+Messages[i]+" باید مقداردهی شود"+".<br/>";
                    document.getElementById("ctl00_Content_" + fieldstoValidate[i]).style.backgroundColor = "#FF9F9F";                                   
                }else{
                document.getElementById("ctl00_Content_" + fieldstoValidate[i]).style.backgroundColor = "";                     
                }
            }
                   
            if(HTMLmessage!=""){               
             showAlertDiv(HTMLmessage);                       
                return false;                
            }
//            else{
//                showWait();
//            }
        }
        else{
            alert("number of fields and messages for validation function is not equal.");
            return false;
        }
    }    
}
//****************************************************************************************
//****************************************************************************************
function checkRequiredNoMasterPage(btnName, fieldstoValidate, Messages) {

    if (btnName != "" && fieldstoValidate != "" && Messages != "") {
        if (fieldstoValidate.length == Messages.length) {
            var HTMLmessage = ""
            for (i = 0; i < fieldstoValidate.length; i++) {
                if (document.getElementById(fieldstoValidate[i]).value == "") {
                    HTMLmessage += "فیلد " + Messages[i] + " باید مقداردهی شود" + ".<br/>";
                    document.getElementById(fieldstoValidate[i]).style.backgroundColor = "#FF9F9F";
                } else {
                    document.getElementById(fieldstoValidate[i]).style.backgroundColor = "";
                }
            }

            if (HTMLmessage != "") {
                showAlertDiv(HTMLmessage);
                return false;
            }
//            else {
//                showWait();
//            }
        }
        else {
            alert("number of fields and messages for validation function is not equal.");
            return false;
        }
    }
}
//****************************************************************************************
function showWait(){  
    document.getElementById('FullDIV').style.left=0+'px';   
	document.getElementById('FullDIV').style.top=0+'px';	
	document.getElementById('FullDIV').style.width='800px';
	document.getElementById('FullDIV').style.height='500px';    
    document.getElementById("FullDIV").style.display = "inline-block";  
    document.getElementById('FullDIV').getAttribute('style').zIndex="0";   
    
    // document.getElementById('Wait').style.display = "inline-block";    
}
//****************************************************************************************
function TextAreaMaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
//****************************************************************************************
function TextAreaMaxlengthLen(obj,len){
if (obj.value.length>len)
obj.value=obj.value.substring(0,len)
}


