// JavaScript Document

/* Varsha */

/* distributor_empanelment_frm.asp starts here*/

var VALIDATE_ANUM="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234568790"
var VALIDATE_COMPNAME= "abcdefghijklmnopqrstuvwxyz1234567890/,.()-&\n\r "
var VALIDATE_CITY="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
var VALIDATE_ADDR= "abcdefghijklmnopqrstuvwxyz1234567890&[],./-'()#\n\r "
var VALIDATE_NUM="1234567890"
var VALIDATE_EMAIL= "^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"

function formValidate()
	{
		var f =document.frmempanelment;

		if(f.arncode.value=="")
			{
				alert("Please provide your ARN Code.");
				f.arncode.focus();
				f.arncode.select();
				return false;
			}
		if(f.arncode.value.charAt(0)==" ")
			{
				alert("ARN Code cannot start with spaces.");
				f.arncode.focus();
				f.arncode.select();
				return false;
			}
		if(chkinput((f.arncode.value).toLowerCase(), VALIDATE_ANUM)==false)
			{
				alert("Please provide valid details in ARN Code.");
				f.arncode.focus();
				f.arncode.select();
				return false;
			}			

		if(f.compname.value=="")
			{
				alert("Please provide your Company Name.");
				f.compname.focus();
				f.compname.select();
				return false;
			}
		if(f.compname.value.charAt(0)==" ")
			{
				alert("Company Name cannot start with spaces.");
				f.compname.focus();
				f.compname.select();
				return false;
			}
		if(chkinput((f.compname.value).toLowerCase(), VALIDATE_COMPNAME)==false)
			{
				alert("Please provide valid details in Company Name.");
				f.compname.focus();
				f.compname.select();
				return false;
			}			

		if(f.city.value=="")
			{
				alert("Please provide your City.");
				f.city.focus();
				f.city.select();
				return false;
			}
		if(f.city.value.charAt(0)==" ")
			{
				alert("City cannot start with spaces.");
				f.city.focus();
				f.city.select();
				return false;
			}
		if(chkinput((f.city.value).toLowerCase(), VALIDATE_CITY)==false)
			{
				alert("Please provide valid details in City.");
				f.city.focus();
				f.city.select();
				return false;
			}			

		if(f.address.value=="")
			{
				alert("Please provide your Address.");
				f.address.focus();
				f.address.select();
				return false;
			}
		if(f.address.value.charAt(0)==" ")
			{
				alert("Address cannot start with spaces.");
				f.address.focus();
				f.address.select();
				return false;
			}
		if(chkinput((f.address.value).toLowerCase(), VALIDATE_ADDR)==false)
			{
				alert("Please provide valid details in Address.");
				f.address.focus();
				f.address.select();
				return false;
			}			
			
		if((f.phone_isd.value=="")&&(f.phone_std.value=="")&&(f.phone_no.value=="")&&(f.mobile.value==""))
		{
			alert("Please enter any one contact number.")
			f.phone_isd.focus()
			f.phone_isd.select()
			return false
		}

		if((f.phone_isd.value=="")&&((f.phone_std.value!="")||(f.phone_no.value!="")))
		{
			alert("Please enter ISD code for phone number.")
			f.phone_isd.focus()
			f.phone_isd.select()
			return false
		}

		if((f.phone_isd.value!="")&&(f.phone_std.value=="")&&((f.phone_no.value!="")||(f.phone_no.value=="")))
		{
			alert("Please enter STD code for phone number.")
			f.phone_std.focus()
			f.phone_std.select()
			return false
		}

		if((f.phone_isd.value!="")&&(f.phone_std.value!="")&&(f.phone_no.value==""))
		{
			alert("Please enter phone number.")
			f.phone_no.focus()
			f.phone_no.select()
			return false
		}

		if((f.phone_isd.value)!="")
		{
			if(isNaN(f.phone_isd.value) || parseInt(f.phone_isd.value,10) == 0 || f.phone_isd.value.length<2 || f.phone_isd.value.length>5)
			{
				alert("Please provide a valid ISD code of phone number.");
				f.phone_isd.focus();
				f.phone_isd.select();
				return false;
			}
		}
	
		if((f.phone_std.value)!='')
		{
			if(isNaN(f.phone_std.value) || parseInt(f.phone_std.value,10) == 0 || f.phone_std.value.length<2 || f.phone_std.value.length>5)
			{
				alert("Please provide a valid STD code of phone number.");
				f.phone_std.focus();
				f.phone_std.select();
				return false;
			}
		}
	
		if((f.phone_no.value)!='')
		{
			if(isNaN(f.phone_no.value) || parseInt(f.phone_no.value,10) == 0 || f.phone_no.value.length<7 || f.phone_no.value.length>8)
			{
				alert("Please provide a valid landline number.");
				f.phone_no.focus();
				f.phone_no.select();
				return false;
			}	
		}

		if((f.mobile.value)!='')
		{
			if(isNaN(f.mobile.value) || parseInt(f.mobile.value,10) == 0 || f.mobile.value.length!=10 || f.mobile.value.charAt(0)!=9)
			{
				alert("Please provide a valid mobile number.");
				f.mobile.focus();
				f.mobile.select();
				return false;
			}	
		}

		if(f.email.value=="")
		{
			alert("Please provide your E-Mail Id.");
			f.email.focus();
			f.email.select();
			return false;			
		}
		if(f.email.value.charAt(0)==" ")
		{
			alert("E-Mail Id cannot start with spaces.");
			f.email.focus();
			f.email.select();
			return false;
		}
		if(emailValidate_dis(f.email.value)==false)
		{
			alert("Please provide valid E-Mail Id.");
			f.email.focus();
			f.email.select();
			return false;
		}

		return true;
	}

function emailValidate_dis(incomingString)
{
	if(((incomingString).length==0) || (incomingString.search(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g)==-1))
	{
		return false;
	}
	else
	{
		return true;	
	}	
}

function chkinput(val,chklst)
{
	var checkOK =chklst ;
	var checkStr = val;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			  break;
		  if (j == checkOK.length)
			{
			  allValid = false;
			  break;
			}
	  }

	if (!allValid)
	  {	
		return false;
	  }
}




function ARNcode(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890
{
	var unicode=e.charCode? e.charCode : e.keyCode;
	//alert(unicode)
	if (unicode!=8 && unicode!=13 && unicode!=15 && unicode!=14)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode>47 && unicode<58) || (unicode==9))
			return true;
		else
			return false;
	}
}

function CompName(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890/,.()-&
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode>47 && unicode<58) || (unicode==9) || (unicode==32) || (unicode>43 && unicode<48)|| (unicode>39 && unicode<42) || (unicode==38) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function City(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode==9) || (unicode==32) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function Address(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890/,.()-&'#
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode>47 && unicode<58) || (unicode==9) || (unicode==32) || (unicode>43 && unicode<48)|| (unicode>38 && unicode<42) || (unicode==35) || (unicode==38) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function Numbers(e) //allow only these characters -> 1234567890
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8)
	{
		if ((unicode<48||unicode>57) && unicode!=9 && unicode!=13 && unicode!=15 && unicode!=14 )
			return false
	}
}

/* distributor_empanelment_frm.asp ends here*/

/* email_delivery_register.asp starts here */

var VALIDATE_NAME="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' "
var VALIDATE_FOLIO="0123456789/"

function ValidateName(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'space
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode==9) || (unicode==32) || (unicode==39) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function ValidateFolio(e) //allow only these characters -> 0123456789/
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>47 && unicode<58) || (unicode==9) || (unicode==47) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function chkinput(val,chklst)
{
	var checkOK =chklst ;
	var checkStr = val;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			  break;
		  if (j == checkOK.length)
			{
			  allValid = false;
			  break;
			}
	  }

	if (!allValid)
	  {	
		return false;
	  }
}

function emailValidate_reqstmt(incomingString)
{
	if(((incomingString).length==0) || (incomingString.search(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g)==-1))
	{
		return false;
	}
	else
	{
		return true;	
	}	
}

function frmValidate()
{
	var f=document.frmEmailDeliveryRegister
	var name=f.txtname
	var folio=f.txtfolio
	var email=f.txtemail

	if(name.value=="")
	{
		alert("Please provide Name of the unitholder.");
		name.focus();
		name.select();
		return false;
	}
	if(name.value!="")
	{
		if(name.value.charAt(0)==" ")
		{
			alert("Name of the unitholder cannot start with spaces.");
			name.focus();
			name.select();
			return false;
		}
		if(chkinput((name.value).toLowerCase(), VALIDATE_NAME)==false)
		{
			alert("Please provide valid details in Name of the unitholder.");
			name.focus();
			name.select();
			return false;
		}
	}			

	if(folio.value=="")
	{
		alert("Please provide Folio No.");
		folio.focus();
		folio.select();
		return false;
	}
	if(folio.value!="")
	{
		if(folio.value.charAt(0)==" ")
		{
			alert("Folio No cannot start with spaces.");
			folio.focus();
			folio.select();
			return false;
		}
		if(chkinput((folio.value).toLowerCase(), VALIDATE_FOLIO)==false)
		{
			alert("Please provide valid details in Folio No.");
			folio.focus();
			folio.select();
			return false;
		}
	}			

	if(email.value=="")
	{
		alert("Please provide Registered email id.");
		email.focus();
		email.select();
		return false;
	}
	if(email.value!="")
	{
		if(email.value.charAt(0)==" ")
		{
			alert("Registered email id cannot start with spaces.");
			email.focus();
			email.select();
			return false;
		}
		if(emailValidate_reqstmt(email.value)==false)
		{
			alert("Please provide valid details in Registered email id.");
			email.focus();
			email.select();
			return false;
		}
	}			

	f.submit();
	return true;
}
/* email_delivery_register.asp ends here */

/* subscribe.asp starts here */

function charonly(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8)
			{
				if ((unicode!=32 && (unicode<65 || (unicode>90 && (unicode<97 || unicode>122)))) && unicode!=39 && unicode!=45&& unicode!=9)
				return false
			}
	} 
	
//Catch Characters & Special Character Keys.....
function numbersonly(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8)
			{
				if ((unicode<48||unicode>57)&& unicode!=9)
				return false
			}
	}

function echeck(sobjValue) 
	{
		var ePass = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;	
			if (!ePass.test(sobjValue.replace(/\s/g,"")))
			{
				alert("Please enter valid Email ID");
				return false;
			}
		return true;				
	}

function trimAll( strValue ) 
	{
		var objRegExp = /^(\s*)$/;
		if(objRegExp.test(strValue)) {
		strValue = strValue.replace(objRegExp, '');
		if( strValue.length == 0)
		return strValue;
	}
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(strValue)) 
		{			
			strValue = strValue.replace(objRegExp, '$2');
		}
	return strValue;
}

function checkFld()
{
	if(document.frmsub.subcribe[0].checked)
		{
			if (document.frmsub.elements.length==4)
			{
			alert("You've subscribed for all of the services")
			return false
			}
			var chkCtr=0
			for(i=0; i<document.frmsub.elements.length; i++)
				{
					if(document.frmsub.elements[i].type=="checkbox")
					{chkCtr=chkCtr+1
						if(document.frmsub.elements[i].checked==true)
							return true;
						else if(document.frmsub.subcribe[1].checked==true && chkCtr==1)
							return true;
					}
				}
			alert("Please select atleast one option to subscribe.");	
			return false
		}
	return true
}

function checkFldForUnSub()
{
if(document.frmsub.subcribe[1].checked)
	{
		if (document.frmsub.elements.length==4)
			{
			alert("You've not subscribed for any of the services")
			return false
			}
		var chkCtr=0
		for(i=0; i<document.frmsub.elements.length; i++)
			{
			if(document.frmsub.elements[i].type=="checkbox")
				chkCtr=chkCtr+1
			}
			if(chkCtr>1 && document.frmsub.subcribe[1].checked==false)
				{
				for(i=0; i<document.frmsub.elements.length; i++)
					{
					if(document.frmsub.elements[i].type=="checkbox" && !document.frmsub.elements[i].checked)
						return true
					}
					alert("Please select atleast one option to unsubscribe.");
					return false
				}
	}
	return true
}
////////////
function chkvalidate() 
{
	if (trimAll(document.frmsub.txtName.value)=="") 
		{
			alert("Please enter your Name.");
			document.frmsub.txtName.focus();
			document.frmsub.txtName.select();
			return false;
		}
	if (trimAll(document.frmsub.subEmail.value)=="") 
		{
			alert("Please enter your Email Id.");
			document.frmsub.subEmail.focus();
			document.frmsub.subEmail.select();
			return false;
		}
		
	if (trimAll(document.frmsub.subEmail.value)!="" && !echeck(document.frmsub.subEmail.value))
		{
			document.frmsub.subEmail.focus();
			document.frmsub.subEmail.select();
			return false;
		}
	if(!checkFld())
	{			
		return false;
	}
	
	if(!checkFldForUnSub())
	{			
		return false;
	}
	
	
		if (document.frmsub.subcribe[0].checked==false && document.frmsub.subcribe[1].checked==false)
		{
			alert("Please select you want to subscribe or unsubscribe.");			
			return false;
		}
		
	
}

function chkNameEmail()
{
if (trimAll(document.frmsub.txtName.value)=="") 
		{
			alert("Please enter your Name.");
			document.frmsub.txtName.focus();
			document.frmsub.txtName.select();
			document.frmsub.subcribe[0].checked = false;
			document.frmsub.subcribe[1].checked = false;
			document.getElementById("subscribeDiv").innerHTML='';
			return false;
		}
	if (trimAll(document.frmsub.subEmail.value)=="") 
		{
			alert("Please enter your Email Id.");
			document.frmsub.subEmail.focus();
			document.frmsub.subEmail.select();
			document.frmsub.subcribe[0].checked = false;
			document.frmsub.subcribe[1].checked = false;
			document.getElementById("subscribeDiv").innerHTML='';
			return false;
		}
		
	if (trimAll(document.frmsub.subEmail.value)!="" && !echeck(document.frmsub.subEmail.value))
		{
			alert("Please enter a Valid Email Address.");
			document.frmsub.subEmail.focus();
			document.frmsub.subEmail.select();
			document.frmsub.subcribe[0].checked = false;
			document.frmsub.subcribe[1].checked = false;
			document.getElementById("subscribeDiv").innerHTML='';
			return false;
		}
		return true
}

function setHidOptionVal(srcid,destid)
{
	if(!document.getElementById(srcid).checked)
	{
		document.getElementById(destid).value=document.getElementById(srcid).value		
	}
	else if(document.getElementById(srcid).checked)
	{
		document.getElementById(destid).value=""		
	}	
}

////retrieve subscription options through AJAX//
var xmlHttp
function checkInDB(option)
{ 
var flag=chkNameEmail()
if(flag)
{
var email=document.frmsub.subEmail.value
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getusers.asp";
url=url+"?email="+email+"&choice="+option;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("subscribeDiv").innerHTML=xmlHttp.responseText;
}
else
{document.getElementById("subscribeDiv").innerHTML="<b>Please wait.....</b>";}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

/* subscribe.asp ends here */

/* request_statement.asp starts here */

var VALIDATE_NAME="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' "
var VALIDATE_FOLIO="0123456789/"

function ValidateName(e) //allow only these characters -> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'space
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode==9) || (unicode==32) || (unicode==39) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function ValidateFolio(e) //allow only these characters -> 0123456789/
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13)
	{		
		if ((unicode>47 && unicode<58) || (unicode==9) || (unicode==47) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
		else
			return false;
	}
}

function chkinput(val,chklst)
{
	var checkOK =chklst ;
	var checkStr = val;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			  break;
		  if (j == checkOK.length)
			{
			  allValid = false;
			  break;
			}
	  }

	if (!allValid)
	  {	
		return false;
	  }
}

function emailValidate_reqstmt(incomingString)
{
	if(((incomingString).length==0) || (incomingString.search(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g)==-1))
	{
		return false;
	}
	else
	{
		return true;	
	}	
}

function frmValidate()
{
	var f=document.frmRequestStatement
	var name=f.txtname
	var folio=f.txtfolio
	var email=f.txtemail
	var stmtopt=f.stmtopt
	var deliverby=f.deliverby
	
	if(name.value=="")
	{
		alert("Please provide Name of the unitholder.");
		name.focus();
		name.select();
		return false;
	}
	if(name.value!="")
	{
		if(name.value.charAt(0)==" ")
		{
			alert("Name of the unitholder cannot start with spaces.");
			name.focus();
			name.select();
			return false;
		}
		if(chkinput((name.value).toLowerCase(), VALIDATE_NAME)==false)
		{
			alert("Please provide valid details in Name of the unitholder.");
			name.focus();
			name.select();
			return false;
		}
	}			

	if(folio.value=="")
	{
		alert("Please provide Folio No.");
		folio.focus();
		folio.select();
		return false;
	}
	if(folio.value!="")
	{
		if(folio.value.charAt(0)==" ")
		{
			alert("Folio No cannot start with spaces.");
			folio.focus();
			folio.select();
			return false;
		}
		if(chkinput((folio.value).toLowerCase(), VALIDATE_FOLIO)==false)
		{
			alert("Please provide valid details in Folio No.");
			folio.focus();
			folio.select();
			return false;
		}
	}			

	if(email.value=="")
	{
		alert("Please provide Registered email id.");
		email.focus();
		email.select();
		return false;
	}
	if(email.value!="")
	{
		if(email.value.charAt(0)==" ")
		{
			alert("Registered email id cannot start with spaces.");
			email.focus();
			email.select();
			return false;
		}
		if(emailValidate_reqstmt(email.value)==false)
		{
			alert("Please provide valid details in Registered email id.");
			email.focus();
			email.select();
			return false;
		}
	}			

	if(stmtopt[0].checked==false && stmtopt[1].checked==false && stmtopt[2].checked==false)
	{
			alert("Please select Statement Option.");
			stmtopt[0].focus();
			return false;
	}

	if(deliverby[0].checked==false && deliverby[1].checked==false)
	{
			alert("Please select Delivery by.");
			deliverby[0].focus();
			return false;
	}

	f.submit();
	return true;
}

/* request_statement.asp ends here */