function login()
	{
		if(document.frm.mobile.value=="")
			{
			alert("Please enter Mobile No.");
			document.frm.mobile.focus();
			return false;
			}
					
			else
			{
				var len,p,digit,i,j,str,ch;
				str=document.frm.mobile.value;
				digit="0123456789";
				len=str.length;
				for(i=0;i<len;i++)
					{
						ch=str.charAt(i);
						p=digit.indexOf(ch);
						if(p<0)
						{
							alert("Please enter numeric value ");
							document.frm.mobile.focus();
							return false;
							
						}
					}
			  }
		if(document.frm.mobile.value.length<10 || document.frm.mobile.value.length>10)
				{
					 alert("Please enter only 10 digit mobile number!");
					 document.frm.mobile.focus();
					return false;
				}
		
				
				if(document.frm.password.value.length="")
				{
					 alert("Please enter Password");
					 document.frm.password.focus();
					return false;
				}
				
				
			return true;	
	}
///////////////CORP LOGIN VALIDATION/////////

function corp()
	{
		if(document.frm.senderid.value=="")
			{
			alert("Please enter Sender ID.");
			document.frm.senderid.focus();
			return false;
			}
					
			
		if(document.frm.senderid.value.length>8)
				{
					 alert("Please enter 8 Characters Sender ID!");
					 document.frm.senderid.focus();
					return false;
				}
		
				
				if(document.frm.password.value.length="")
				{
					 alert("Please enter Password");
					 document.frm.password.focus();
					return false;
				}
				
				
			return true;	
	}
	
///////////////Send SMS Validation///////////

function fun()
	{
		if(document.frm.mobile.value=="")
			{
			alert("Please enter Mobile No.");
			document.frm.mobile.focus();
			return false;
			}
					
			else
			{
				var len,p,digit,i,j,str,ch;
				str=document.frm.mobile.value;
				digit="0123456789";
				len=str.length;
				for(i=0;i<len;i++)
					{
						ch=str.charAt(i);
						p=digit.indexOf(ch);
						if(p<0)
						{
							alert("Please enter numeric value ");
							document.frm.mobile.focus();
							return false;
							
						}
					}
			  }
		if(document.frm.mobile.value.length<10 || document.frm.mobile.value.length>10)
				{
					 alert("Please enter only 10 digit mobile number!");
					 document.frm.mobile.focus();
					return false;
				}
		
				
				if(document.frm.message.value.length<10)
				{
					 alert("Please enter minimum 10 character!");
					 document.frm.message.focus();
					return false;
				}
				if(document.frm.message.value.length>148)
				{
					alert("Message length exceecls");
					document.frm.message.focus();
					return false;
				}
				
			return true;	
	}
	
///////////////////////Text Counter ///////////////////////

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

/////////////////////Group Validation ///////////////////
function group()
	{
		if(document.fgroup.g_name.value=="")
			{
			alert("Please Enter Group Name");
			document.fgroup.g_name.focus();
			return false;
			}
			
				
			return true;	
	}
///////////////////Contacts//////////////////////////
function addcontact()
	{
		if(document.fcontact.Name.value=="")
			{
			alert("Please enter Name.");
			document.fcontact.Name.focus();
			return false;
			}
		
		if(document.fcontact.mobile.value=="")
			{
			alert("Please enter Mobile No.");
			document.fcontact.mobile.focus();
			return false;
			}
					
			else
			{
				var len,p,digit,i,j,str,ch;
				str=document.fcontact.mobile.value;
				digit="0123456789";
				len=str.length;
				for(i=0;i<len;i++)
					{
						ch=str.charAt(i);
						p=digit.indexOf(ch);
						if(p<0)
						{
							alert("Please enter numeric value ");
							document.fcontact.mobile.focus();
							return false;
							
						}
					}
			  }
		if(document.fcontact.mobile.value.length<10 || document.fcontact.mobile.value.length>10)
				{
					 alert("Please enter only 10 digit mobile number!");
					 document.fcontact.mobile.focus();
					return false;
				}
		
				
				
				
			return true;
	}
	
	function sri(){
alert("HI Sri");
}

///////////////   Get contacts////////////////


function showHint(str){

var xmlhttp;
if(str.length==0){
document.getElementById("getcontacts").innetHTML="";
}
xmlhttp = GetXmlHttpObject();
if(xmlhttp==null){
alert("Your Browser will Not Support Ajax");
return;
}
var url = "getcontacts.php";
url = url+"?q="+str;
url = url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

}
////////////// End Get Contacts //////////////////////
function checkval(chkname1)
{
	var allchkbox=document.forms['formx'].elements[chkname1];
	var countallchkbox = allchkbox.length;
	for(var i = 0; i < countallchkbox; i++)
		{
			if(allchkbox[i].checked == 0)
			document.formx.selall.checked=0;
		}
}	

function checkstate(chkname)
{
	if(document.formx.selall.checked==1)
	{
		checkall("formx",chkname,1);
		
	}
	if(document.formx.selall.checked==0)
	{
		checkall("formx",chkname,0);
	}
}	
function checkstate1(chkname)
{
	
		checkall("formx",chkname,1);
	
}
function checkall(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}	
function email_user()

{

var cnt=document.formx.chk.length;

var uid='';

var valu='';

msg=document.formx.msg.value;
alert("msg");
if(cnt>1)

{

	for(i1=0;i1<cnt;i1++)

	{

			if(document.formx.chk[i1].checked == 1)

			{

			valu="selected";

			}

	}

	if(valu=='')

	{

	alert("please select a user to send sms");

	return false;

	}

	else

	{

		for(i2=0;i2<cnt;i2++)

		{

		if(document.formx.chk[i2].checked == 1)

		{

		uid+=document.formx.chk[i2].value+",";

		}
		}
		   x = (640 - 600)/2, y = (480 - 320)/2;

    if (screen) {
        y = (screen.availHeight - 320)/2;
        x = (screen.availWidth - 600)/2;
    }

    window.open('group-sms-process.php?uid='+uid,'newWin','width='+600+',height='+320+',screenX='+x+',screenY='+y+',top='+y+',left='+x);

		/*mywindow=window.open('group-sms.php?uid='+uid,'mywindow','width=322,height=30,location=1,status=1');
		mywindow.moveTo(500,300);*/
	}

}



else

{

if(document.formx.chk.checked)

{

uid=document.formx.chk.value;

 x = (640 - 600)/2, y = (480 - 320)/2;

    if (screen) {
        y = (screen.availHeight - 320)/2;
        x = (screen.availWidth - 600)/2;
    }

    window.open('group-sms-process.php?uid='+uid,'newWin','width='+600+',height='+320+',screenX='+x+',screenY='+y+',top='+y+',left='+x);

//window.open('group-sms.php?uid='+uid,'mywindow','width=322,height=30');

}

else 

{

alert("please select a user");

return false;

}

}

}

function delete_user(uid){
	if(confirm("Are you sure want to delete?")){
		document.location.href = 'manage-contacts.php?del=1&uid='+uid;
	}
}
function delete_groups(uid){
	if(confirm("Are you sure want to delete?")){
		document.location.href = 'addressbook.php?del=1&uid='+uid;
	}
}
function delete_sms(uid){
	if(confirm("Are you sure want to delete?")){
		document.location.href = 'sent-sms.php?del=1&uid='+uid;
	}
}

function getpass_mobile(){

	if(document.frm.mobile.value=="")
			{
			alert("Please enter Mobile No.");
			document.frm.mobile.focus();
			return false;
			}
					
			else
			{
				var len,p,digit,i,j,str,ch;
				str=document.frm.mobile.value;
				digit="0123456789";
				len=str.length;
				for(i=0;i<len;i++)
					{
						ch=str.charAt(i);
						p=digit.indexOf(ch);
						if(p<0)
						{
							alert("Please enter numeric value ");
							document.frm.mobile.focus();
							return false;
							
						}
					}
			  }
		if(document.frm.mobile.value.length<10 || document.frm.mobile.value.length>10)
				{
					 alert("Please enter only 10 digit mobile number!");
					 document.frm.mobile.focus();
					return false;
				}
				return true;
}
function getpass_email(){

	if(document.frm.to.value=="")
			{
			alert("Please enter Email");
			document.frm.to.focus();
			return false;
			}
					
		
				return true;
}

