// JavaScript Document


//----------------------------------Admin Login Module---------------------------------//
function chkValidationLogin()
{
	if(document.frmLogin.txtLogin.value == "")
	{
		alert("Please enter Login ID");
		document.frmLogin.txtLogin.focus();
		return false;
	}
	if(document.frmLogin.txtPasswd.value == "")
	{
		alert("Please enter Password");
		document.frmLogin.txtPasswd.focus();
		return false;
	}
	document.frmLogin.action = "index.php";
	document.frmLogin.submit();	
}

function chkValidationLogincl()
{
	if(document.frmLogin.txtLogin.value == "")
	{
		alert("Please enter Login ID");
		document.frmLogin.txtLogin.focus();
		return false;
	}
	if(document.frmLogin.txtPasswd.value == "")
	{
		alert("Please enter Password");
		document.frmLogin.txtPasswd.focus();
		return false;
	}
	document.frmLogin.action = "participant_login.php";
	document.frmLogin.submit();	
}
/*---------------------------------Change Password-----------------------------*/
function changePassword(password, user_id, session)
{
	if(document.frmEditPass.txtOld.value == "")
	{
		alert('Enter Value in Old Password');
		document.frmEditPass.txtOld.focus();
		return false;
	}
	if(document.frmEditPass.txtNew.value == "")
	{
		alert('Enter Value in New Password');
		document.frmEditPass.txtNew.focus();
		return false;
	}
	if(document.frmEditPass.txtConfirm.value == "")
	{
		alert('Enter Value in New Password Again');
		document.frmEditPass.txtConfirm.focus();
		return false;
	}
	if(document.frmEditPass.txtOld.value != password)
	{
		alert('Your Old Password not match with your Entered Password');
		document.frmEditPass.txtOld.focus();
		return false;
	}
	if(document.frmEditPass.txtNew.value != document.frmEditPass.txtConfirm.value)
	{
		alert('Please Enter Same password In both Field');
		document.frmEditPass.txtConfirm.focus();
		return false;		
	}
	return true;
	
}
/*------------------------------------------------------------------------------------*/
function chkType()
{
	if(document.frmUploadFile.selType.selectedIndex == 0)
	{
		alert("Please Select Type of CSV !!!");
		document.frmUploadFile.selType.focus();
		return false;
	}
	return true;
}
/*------------------------------------------------------------------*/
function InsertWindow(pagename)
{
	window.open(pagename, "Add", "width=520,height=580,left=200,top=0,resizable=no,scrollbars=yes")
}
function UpdateWindow(pagename)
{
	window.open(pagename, "Add", "width=520,height=540,left=200,top=0,resizable=no,scrollbars=yes")
}
function WindowRefresh()
{
	window.close();
	window.opener.location.reload();
}
/*---------------------------------------------------------------------------------------------*/


function DeleteRecord(no)
{	 
	del = 0;
	if (document.getElementById('chk_0').checked==true)
	{	
		var str = "";
		for(i=1;i<=no;i++)
		{	
			
			if(str == "")
			{
				str = document.frmUserMgmt.check_2[i].value;
				//alert('delRecord : '+document.getElementById('chki').checked);
			}
			else
			{
				str = str+","+document.frmUserMgmt.check_2[i].value;
			}								
  		}
		//alert(str);
		document.frmUserMgmt.iChk.value=str; 
		if(confirm("Would u like to Delete Record(s)?"))
		{
			document.frmUserMgmt.action = "mail_sending.php";
			document.frmUserMgmt.submit();	 	
		}
		return true;
	}
	if(no >= 1)
    {				
		for(i=0;i<=no;i++)
		{
			if((document.frmUserMgmt.check_2[i].status == true) || (document.getElementById('chk_0').checked==true)){
				del = 1;
			}
		}
		if(del == 0)
		{
			alert("Please select a record first");
			return false;
		}
	}	
	 var str="";
	 var val;
	 if(document.frmUserMgmt.check_2.status == true && document.frmUserMgmt.check_2.value!=0 )
	 {	
			if(confirm("Would u like to Delete Record(s)?"))
			{
				str = document.frmUserMgmt.check_2.value;
				document.frmUserMgmt.iChk.value=str;			
				document.frmUserMgmt.action = "mail_sending.php";
				document.frmUserMgmt.submit();	 	
			}		
     } 
	 for(i=0; i<=no; i++)
	 {	
			if((document.frmUserMgmt.check_2[i].status == true) || (document.getElementById('chk_0').checked==true))
			{	
				if(i==0)
				{	alert('i==0');
					str = document.frmUserMgmt.check_2[i+1].value;					
				}
				else if(str == "")
				{	
					str =document.frmUserMgmt.check_2[i].value;				
				}
				else
				{	
					str =str+","+document.frmUserMgmt.check_2[i].value;
				}								
				val = 1;
			}
	}
	document.frmUserMgmt.iChk.value=str;
	if(val == 1)
	{
		if(confirm("Would u like to Delete Record(s)?"))
		{
			document.frmUserMgmt.action = "user_mgmt.php";
			document.frmUserMgmt.submit();	 	
		}
	}
	return true;
}	


function toggleChecked(oElement) 
{ 
	oForm = oElement.form; 
	oElement = oForm.elements[oElement.name]; 
	if(oElement.length) 
	{ 
	  bChecked = oElement[0].checked; 
	  for(i = 1; i < oElement.length; i++) 
		oElement[i].checked = bChecked; 
	} 
} 
	  
function toggleController(oElement)
{
	oForm = oElement.form; 
	oElement = oForm.elements[oElement.name]; 
	if(oElement.length) 
	{ 
	  bChecked = true; 
	  nChecked = 0; 
	  for(i = 1; i < oElement.length; i++) 
		if(oElement[i].checked) 
		  nChecked++; 
	  if(nChecked < oElement.length - 1) 
		bChecked = false; 
	  oElement[0].checked = bChecked; 
	} 
}	 
/*-----------------------------------------------------------------------------------------*/

function chkValidation(val){
	
	document.frmUser.action = "User.php";
	document.frmUser.submit();				
}
function chkEmail()
{
	//alert('hi');
	if(document.frmPassword.txtEmail.value == "")
	{
		alert('Enter Email Address');
		document.frmPassword.txtEmail.focus();
		return false;
	}
	document.frmPassword.action="forgot_password.php";
	document.frmPassword.submit();
}
function chkEditProfile()
{
	document.frmEditProfile.action = "edit_profile.php";
	document.frmEditProfile.submit();
}