function trackforgotform()
{
	document.getElementById('lblhidden').value='forgotpwdform';

	return true;
}
function clearform() 
{
	document.getElementById('lblhidden').value='clear'
}
function form_forgot_pwd_validator()
{

	var email = document.getElementById('email_forgot_pwd');
	if(isemptylogin(email, 'Please Enter Email Address'))
	{
		document.getElementById('lblhidden').value='forgotpwd';
		return true;
	}
	return false;
}
function login_validate()
{
	var email = document.getElementById('email_login');
	var password = document.getElementById('password_login');
	if(isemptylogin(email, 'Please Enter Email Address'))
	{
		if(isemptylogin(password,'Please Enter Password'))
		{
			document.getElementById('lblhidden').value='login';
			return true;
		}
	}
	return false;
	
}
function login_validate_Home()
{
	var email = document.getElementById('email_login');
	var password = document.getElementById('password_login');
	if(isemptylogin(email, 'Please Enter Email Address'))
	{
		if(isemptylogin(password,'Please Enter Password'))
		{
			return true;
		}
	}
	return false;
	
}
function registration_validate()
{

	var name = document.getElementById('name');
	var category=document.getElementById('Category');
	//var company = document.getElementById('company');
	var address1 = document.getElementById('address1');	
	var address2 = document.getElementById('address2');
	var city = document.getElementById('city');
	var postcode = document.getElementById('postcode');
	var telephone = document.getElementById('telephone');
	var email = document.getElementById('email_registration');
	var password = document.getElementById('password_registration');
	var confirm_password = document.getElementById('confirm_password');

	if(isempty(name,'Please Enter Your Name'))
	{
		if(checkradio(category,'please Select atleast one Category'))
		{
			if(isempty(address1,'Please Enter Your Address Line1'))
			{
				if(isempty(city,'Please Enter Your City'))
				{
					if(isempty(postcode,'Please Enter Your Postcode'))
					{
						if(isempty(telephone,'Please Enter Your Telephone'))
						{
							if(isemail(email,'Please Enter Valid Email Address'))
							{
								if(isempty(password,'Please Enter Your Password'))
								{
									if(ispassword(confirm_password,password))
									{
										document.getElementById('lblhidden').value='registration'
										return true;
							
									}
						
								}
					
							}
					
						}
				
					}
				}
		
			}
		}
	}
	return false;
}
/*	PEL validation	*/
function pel_registration_validate()
{

	var name = document.getElementById('name');
	var category=document.getElementById('Category');
	//var company = document.getElementById('company');
	var address1 = document.getElementById('address1');	
	var address2 = document.getElementById('address2');
	var city = document.getElementById('city');
	var postcode = document.getElementById('postcode');
	var telephone = document.getElementById('telephone');
	var email = document.getElementById('email_registration');
	var password = document.getElementById('password_registration');
	var confirm_password = document.getElementById('confirm_password');

	if(isempty(name,'Please Enter Your Name'))
	{
			if(isempty(address1,'Please Enter Your Address Line1'))
			{
				if(isempty(city,'Please Enter Your City'))
				{
					if(isempty(postcode,'Please Enter Your Postcode'))
					{
						if(isempty(telephone,'Please Enter Your Telephone'))
						{
							if(isemail(email,'Please Enter Valid Email Address'))
							{
								if(isempty(password,'Please Enter Your Password'))
								{
									if(ispassword(confirm_password,password))
									{
										document.getElementById('lblhidden').value='registration'
										return true;
							
									}
						
								}
					
							}
					
						}
				
					}
				}
		
			}
		}
	return false;
}

function isempty(elem, message)
{

	if(elem.value.length == 0)
	{
		document.getElementById('user_register').innerText=message;
		document.getElementById('user_register').textContent=message;
		
		
		elem.focus();
		return false;
	}else
	{
		return true;
	}
}
function checkradio(elem,message)
{

	var flag=false;
	for (i = 0; i < document.user_login.Category.length; i++)
	{
		if (document.user_login.Category[i].checked)
		{
			
			if(document.user_login.Category[i].value=="Others")
			{
				if(document.getElementById('CategoryOthers').value.length==0)
				{
					document.getElementById('user_register').innerText='Please Enter Other Category';
					document.getElementById('user_register').textContent='Please Enter Other Category';
					return false;
				}
			}
			flag = true; 
		}
	}
	if (flag==false)
	{

		document.getElementById('user_register').innerText=message;
		document.getElementById('user_register').textContent=message;

		return false;
	}
	else
	{
		return true;
	}

}
function isemptylogin(elem, message)
{

	if(elem.value.length == 0)
	{
		document.getElementById('user_exist').innerText=message;
		document.getElementById('user_exist').textContent=message;
		elem.focus();
		return false;
	}else
	{
		return true;
	}
}
function ispassword(elem, elempwd)
{

	if(elem.value.length == 0)
	{
		document.getElementById('user_register').innerText='Please Enter Verify Password';
		document.getElementById('user_register').textContent='Please Enter Verify Password';
		elem.focus();
		return false;
	}else
	{
		if (elem.value==elempwd.value)
		{
			return true;
		}
		else
		{
			document.getElementById('user_register').innerText='Password and Verify Password are not same';
			document.getElementById('user_register').textContent='Password and Verify Password are not same';
			elem.focus();
			return false;
		}
		
	}
}

function isemail(elem, message){
	var emailCnt = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailCnt)){
		return true;
	}else{
		document.getElementById('user_register').innerText=message;
		document.getElementById('user_register').textContent=message;
		elem.focus();
		return false;
	}
}

//function goAdminLogin()
//{
//window.location.href='adminlogin.asp';
//}


function approve_click()
{
    
    
//     var strSqlUpdate = 'update PEL_tblInvestors set Comments = ';
//     var strSqlWhere = ' where  userid = ';
//     var arrayUpdates = new Array();     
     var strBunchUpdate ='';
     
	        count=document.getElementById('lblcount').value;
	        strAcceptsql="";	        
	        strdeniedsql="";
	        flag=0
	        j=0;
	var commenttmp='';
	var comment='';
	
	var admintmp2='';
	var admintmp1='';
	var admin='';
	var strChangedIds='';
	var adminName='';
	
//ReplaceText(document.getElementById('comment1'+'').value,"~");
//alert(document.getElementById('comment1'+'').value.replace(/~/g));
	
	for(i=1;i<=count;i++)
	{	
	
	    commenttmp = document.getElementById('comment'+i+'').value.replace(/#/g,"");
	    commenttmp = commenttmp.replace(/~/g,"")
	    comment = commenttmp.replace(/&/g,"")
	    
	    adminName = '';
	    
	    	    	
	    strBunchUpdate= strBunchUpdate +    comment + '~' + document.getElementById('Identifier'+i+'').value + '#';
	    
	    //strBunchUpdate= strBunchUpdate + strSqlUpdate + '\'' + document.getElementById('comment'+i+'').value +'\'  '  + strSqlWhere + document.getElementById('Identifier'+i+'').value+';';
		
		if(document.getElementById('role'+i+'').selectedIndex>0)
		{ 
			j++;
			if(document.getElementById('role'+i+'')[document.getElementById('role'+i+'').selectedIndex].text=='Approve')
			strAcceptsql = strAcceptsql + "" +document.getElementById('role'+i+'').value+",";
		    if(document.getElementById('role'+i+'')[document.getElementById('role'+i+'').selectedIndex].text=='Deny')
			strdeniedsql = strdeniedsql + "" +document.getElementById('role'+i+'').value+",";
						
			flag=1
			
			strChangedIds = strChangedIds + "" + document.getElementById('role'+i+'').value + ",";
				
		}		
		
		
		
		
	}
	strAcceptsql=strAcceptsql.substring(0,(strAcceptsql.length-1))	
	strdeniedsql=strdeniedsql.substring(0,(strdeniedsql.length-1))
	strChangedIds=strChangedIds.substring(0,(strChangedIds.length-1))
	
 
	
	 
	if (flag==0) 
	{
		document.getElementById('lblAccept').value="";
		
		document.getElementById('lbldenied').value="";
		
	}
	else
	{
		document.getElementById('lblAccept').value=strAcceptsql;
		
		document.getElementById('lbldenied').value=strdeniedsql;
		
	}
 
	document.getElementById('hdnBunchUpdates').value=strBunchUpdate;
	document.getElementById('hdnChangedIds').value=strChangedIds; 
	

	
	document.getElementById('lblhidden').value="approve";
	document.getElementById('lblselcount').value=j;
   
}
