// JavaScript Document
function checkEmailForm(){
	var frm	=	document.subjectEMailFRM;
	frm.processReqEst.value= 'Processing...';
	frm.processReqEst.disabled= true;
	frm.submit();
	return true;
}


function isValidEmail(str) {
	if(!(/^[^a-zA-Z]/.test(str)) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))) {
		return true
	} else {
		return false
	}
   }



function isValidString(str){
		var result	=	true;
		var iChars = "`~!@#$%^&*()+=-[]0123456789\\\;,./{}|\":<>?";
		//if string is NULL return false;
		if(str.length == 0) return false;
		for (var i = 0; i < str.length; i++) {
			if (iChars.indexOf(str.charAt(i)) != -1) {
				result	=	false;
			}
		}
	 return result;
	}



function processLEASignUpFRM(frm){
	
	<!--Add By yogesh-->
	
	//Common Java Script Files   

	var cntError = 0;
	var errorMsg = Array();
	var errorField = Array();
	 
	 var pass_length = frm.password.value.length;

	//alert(frm);
	if (!isValidString(frm.first_name.value)) 
	  {
		errorMsg[cntError] = 'Invalid First Name String';
		errorField[cntError] = 'first_name';
		document.getElementById('fname_label').style.color = "#990000"
		cntError++;
	  } else {
		document.getElementById('fname_label').style.color = "#0a5b9c";
	}
	
	 
	if (isValidString(frm.last_name.value) == false) 
	  {
		errorMsg[cntError] = 'Invalid Last Name String.';
		errorField[cntError] = 'last_name';
		document.getElementById('lname_label').style.color = "#990000"
		cntError++;
	  }else {
		document.getElementById('lname_label').style.color = "#0a5b9c";
	 }
	
	if(!isValidEmail(frm.email.value)){
		errorMsg[cntError] = 'Email is not in Proper format';
		errorField[cntError] = 'email';
		document.getElementById('email_label').style.color = "#990000"
		cntError++;
	}
	else
	{
		document.getElementById('email_label').style.color = "#0a5b9c";
		
	}
	
 if(frm.password.value=="" || pass_length < '3'){
		errorMsg[cntError] = 'Password Can Not Be Blank';
		errorField[cntError] = 'password';
		document.getElementById('password_label').style.color = "#990000"
		cntError++;
	}else
	{
		document.getElementById('password_label').style.color = "#0a5b9c";
		
	 }		  
			  
				  
	 if(frm.confirm.value==""){
		errorMsg[cntError] = 'confirm Password Can Not Be Blank';
		errorField[cntError] = 'confirm_password';
		document.getElementById('confirm_password_label').style.color = "#990000"
		cntError++;
	}
	else
	{
		document.getElementById('confirm_password_label').style.color = "#0a5b9c";
		
	 }	
	 
	 if(frm.password.value!=frm.confirm.value){
		errorMsg[cntError] = 'Password is not Matched with Confirm Password.';
		errorField[cntError] = 'confirm_password';
		document.getElementById('confirm_password_label').style.color = "#990000"
		cntError++;
	}		 
		  
		
		
	 
	 
	 <!--Add By yogesh-->
	
	
	
	
	if(errorMsg.length > 0){
		//alert(errorMsg.length);
		//alert('Please Fill All The Fields With Red Color');
		document.getElementById("errorDiv").style.display='block';
		showErrorMsg = document.getElementById("errorInnerDiv");
		showErrorMsg.style.display='block';
		showErrorMsg.innerHTML = "";
		showErrorMsg.innerHTML = '<div style="margin-left:20px;padding:0;">';
		//for(i=0;i<errorMsg.length;i++){
			//showErrorMsg.innerHTML += '<div class="errorList">'+errorMsg[i]+'</div>';
			showErrorMsg.innerHTML += '<div class="errorList">Please properly complete all required fields highlighted in red</div>';
			//document.getElementById(errorField[i]).style.color = "Red";
			//document.getElementById(errorField[i]).style.color = "White";
		//}
		 //alert(errorMsg);
		showErrorMsg.innerHTML += '</div>';		
		return false;
	}else{
	
	frm.processData.value= 'Processing...';
	frm.processData.disabled= true;
	frm.submit();
	}
	
	//return true;
}

function updateGroup(elem){
		
		var group_id	=	document.getElementById('web_group_id');
		if(elem.value=="180"){
			group_id.value	=	"00010180";	
		}else if(elem.value=="360"){
			group_id.value	=	"00010360";		
		}else{
			group_id.value	=	"00010360";
		}
		
		
}
function processForgotPassFRM(){
	document.getElementById('errorSpan').innerHTML='';
	var frm	=	document.forgotPassFRM;
	var errorSpan	=	document.getElementById('errorSpan');
	errorSpan.style.display='block';
	errorSpan.innerHTML='';
	if(!isValidEmail(frm.vEmail.value)){
		errorSpan.innerHTML +='Please Provide Valid Email';
	    return false;
	}else{
		//errorSpan.innerHTML='';
		//errorSpan.style.display='block';
		
		var file	=	'forgot_password_request.php';
		//frm.submit();
	 var myAjax = new Ajax.Request(file, 
                                   {method: 'post', parameters:{vEmail: frm.vEmail.value,mode:'IfOrGOtmYPasWoRd'},  onLoading: showLoad,
                                     onSuccess: function(transport){
												document.getElementById('errorSpan').innerHTML=transport.responseText;						
												
												}
						});
	}
	//frm.processReqEst.value= 'Processing...';
	//frm.processReqEst.disabled= true;
	///frm.submit();
	//return true;
}
function previewEmailData(frm){
	
	$('previwEmailContents').style.visibility	=	'visible';
	var file	=	'admin_preview_subject_mass_email.php';
	 var myAjax = new Ajax.Request(file, 
                                   {method: 'post', parameters: $(frm).serialize(),  onLoading: showLoad,
                                     onSuccess: function(transport){
												$('previwEmailContents').innerHTML=transport.responseText;
												$('load').style.display = 'none';
												//alert(transport.responseText)
												}
						});
	}
	
function previewSubjectMassEmailAllData(frm){
	
	$('previwEmailContents').style.visibility	=	'visible';
	var file	=	'admin_preview_subject_mass_email_all.php';
	 var myAjax = new Ajax.Request(file, 
                                   {method: 'post', parameters: $(frm).serialize(),  onLoading: showLoad,
                                     onSuccess: function(transport){
												$('previwEmailContents').innerHTML=transport.responseText;
												$('load').style.display = 'none';
												//alert(transport.responseText)
												}
						});
	}
function showLoad () {
	$('load').style.display = 'block';
}
function hideLoad () {
	$('load').style.display = 'none';
}
function clearDivContents(divId){
	if(eval($(divId))){
		$(divId).innerHTML='';
	}		
}
function hideAjaxDiv(){
	var boxDivId	= document.getElementById('previwEmailContents');
		boxDivId.style.visibility	='hidden';
	}

 function isValidEmail(str) {
	if(!(/^[^a-zA-Z]/.test(str)) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))) {
		return true
	} else {
		return false
	}
   }
  function processSignUpForm(frm){
		frm.submitFRM.disabled=true;
		frm.submit();
	}
//call function below on key events i.e. onkeypress, onkeyup etc.
function numericValue(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        //alert("Enter only numeric values\nThat is between 0-9\n in this field.");
        return false;
    }
    return true;
}/*END function numericValue(evt)*/

/** function below is to check if field value is a valid zip code for US // START*/
function isValidZip(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   if(strString.length!=5) return false;
	var totalValue	=	0;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
	  totalValue	+=	parseInt(strString.charAt(i));
		
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
	
      }
	if(totalValue==0) return false;
   return blnResult;
   }
/** function below is to check if field value is a valid zip code for US//END */

/*FUNCTION FOR MEASURES DATA#START*/

function getMeasuresText(frm){
	var cntError = 0;
	var errorMsg = Array();
	var measure_id =	document.getElementById("measures_id");
	var mesures_text =	document.getElementById("measures_text");
	if(measure_id.options[measure_id.selectedIndex].value==0){
		errorMsg[cntError] = 'Please Select Measure';
		cntError++;
	}
	if(mesures_text.value==0){
		errorMsg[cntError] = 'Please Select Measures Text';
		cntError++;
	}

	if(errorMsg.length > 0){
		//document.getElementById("errorDiv").style.display='block';
		showErrorMsg = document.getElementById("errorDiv");
		showErrorMsg.style.display='block';
		showErrorMsg.className='error';
		showErrorMsg.innerHTML = "";
		for(i=0;i<errorMsg.length;i++){
			showErrorMsg.innerHTML += '<div class="errorList">'+errorMsg[i]+'</div>';
		}
		return false;
	}else{
		document.getElementById("showMeasuresTextDiv").style.display="block"
		document.getElementById("errorDiv").style.display="none"
		var url = 'admin_get_measures_text.php';
		var myAjax = new Ajax.Request(url, {method: 'post', parameters: $(frm).serialize(),
											onLoad:showLoad(),
		                                    onComplete:function(transport){
											 $('showMeasuresTextDiv').innerHTML = transport.responseText;
											 hideLoad();
											 }
											 }); 
	}
}

function updateMeasuresText(frm){
	//alert(controller);
	var count	=	0;
	var errorMsg = Array();
	var errorMsgShow = "";
	var massage_final="";
	var check=0;
	var append='';
	var elemAll	=	frm.elements.length;
	for (k=0; k<elemAll; k++){
		var elem	=	eval(frm.elements[k]);
			
			if(elem.type.toUpperCase()=='HIDDEN'){
				
				if(eval("frm.elements[k].name.match(/hiddenText/)")){
				var editorText = null; 
				var contentName	=	elem.name.split('-');
				var hiddenNames	=	elem.name;
				//alert(hiddenNames)
				var oEditor = FCKeditorAPI.GetInstance(contentName[1]) ; 
				if(oEditor) { 
					editorText = oEditor.GetXHTML(true);
				}
				
				$(hiddenNames).value	=	editorText;
				if(editorText==null || editorText=='<p></p>'  || editorText=='<p>&nbsp;</p>' || editorText=='' || editorText==' '){
				
				//var checkName	=	frm.contentName[1];
				
					var spanMeasureName	=	'measureText_'+contentName[1];
					if(eval($(spanMeasureName)))
						errorMsg[count]=$(spanMeasureName).innerHTML;
					
					if(check!=0)
						 append=', ';
					else
						append='';
						
					errorMsgShow += append+$(spanMeasureName).innerHTML;							
					
					count++;
					check++;
					
					
				}
				massage_final='Please Provide Valid Text For '+errorMsgShow;	
			}		
		}
	}
	
	if(errorMsg.length > 0){
		showErrorMsg = document.getElementById("errorDiv");
		showErrorMsg.style.display='block';
		showErrorMsg.innerHTML = "";
		showErrorMsg.innerHTML += '<div class="errorList">'+massage_final+'</div>';
		
		return false;
	}else{
		//submit the form
		$('update_Measures').disabled=true;
		$('update_Measures').value='Processing...';
		frm.submit();
	}
}
function changeEnter(){
	//alert('hi')
// If we already have an editor, let's destroy it first.
	// Create the editor again, with the appropriate settings.
	//alert(editor.destroy);
	editor = CKEDITOR.replace( 'mailBody', { toolbar : 'Basic' });	
}
//add by kinnari on 26/2/2010
function login_validate(frm){
	var errorMsg = Array();
	var cntError = 0;
	
	
	if(document.getElementById('mail').value==''){
		
		errorMsg[cntError]='Please Provide Email';
		cntError++;
		
	}
	if(document.getElementById('password1').value==''){
		errorMsg[cntError]='Please Provide Password';
		cntError++;
		
	}
	/*if(document.getElementById('email').value!=''){
		if(!isValidEmail(document.getElementById('email').value)){
			errorMsg[cntError]='Please Provide Valid Email';
			cntError++;
		}
	}*/
	
	if(errorMsg.length > 0){
		
		showErrorMsg = document.getElementById("login_errors");
		showErrorMsg.style.display='block';
		showErrorMsg.className='error';
		showErrorMsg.innerHTML = "";
		for(i=0;i<errorMsg.length;i++){
			showErrorMsg.innerHTML += '<div class="errorList">'+errorMsg[i]+'</div>';
		}
		return false;
	}else{
	return true;
	}
	
}
//end
/*FUNCTION FOR MEASURES DATA#END*/

