function validateUser()
{
	if( document.getElementById('userName') && Trim(document.getElementById('userName').value) == "" )
	{
		document.getElementById('userName').value = "" ;
		alert("الرجاء إدخال اسم المستخدم");
		document.getElementById('userName').focus();
		return false ;
	}
	else if(document.getElementById('password') && Trim(document.getElementById('password').value) == "" )
	{
		alert("الرجاء إدخال كلمة المرور");
		document.getElementById('password').value = "" ;
		document.getElementById('password').focus();
		return false ;
	}	
	else if(document.getElementById('confirmPassword') && Trim(document.getElementById('confirmPassword').value) == "" )
	{
		alert("الرجاء تأكيد كلمة المرور");
		document.getElementById('confirmPassword').value = "" ;
		document.getElementById('confirmPassword').focus();
		return false ;
	}	
	else if( Trim(document.getElementById('confirmPassword').value) != Trim(document.getElementById('password').value) )
	{
		alert("الرجاء تأكيد كلمة المرور بشكل صحيح");
		document.getElementById('confirmPassword').focus();
		return false ;
	}		
	else if(document.getElementById('name') && Trim(document.getElementById('name').value) == "" )
	{
		alert("الرجاء إدخال الإســـم");
		document.getElementById('name').value = "" ;
		document.getElementById('name').focus();
		return false ;
	}
	if( document.getElementById('telephoneNo')  )
	{
		if( Trim(document.getElementById('telephoneNo').value) != "" && !validateHomeTelephoneNo(document.getElementById('telephoneNo')) )
		{
			//alert("الرجاء إدخال رقم الهاتف ب");
			//document.getElementById('telephoneNo').focus();
			return false ;
		}	
	}	
	
	if(document.getElementById('email') && !isEmailValid(document.getElementById('email').value) )
	{
		return false ;
	}
	else if(document.getElementById('email') && !isEmail(Trim(document.getElementById('email').value)) )
	{
		alert("الرجاء إدخال البريد الالكتروني بشكل صحيح");		
		document.getElementById('email').focus();
		return false ;
	}	
	if( document.getElementById("submitBtn") )
	{
		document.getElementById("submitBtn").disabled = true ;	
	}	
	if( document.getElementById("resetBtn") )
	{
		document.getElementById("resetBtn").disabled = true ;	
	}		
	// resetBtn
	//alert(" جاري عملية التسجيل ..... الرجاء الانتظار ");
	return true;	

}
function isEmailValid(strEmail)
{
	if( Trim(strEmail) == ""  )
	{
		alert("الرجاء إدخال البريد الالكتروني ");		
		document.getElementById('email').focus();			
		return false ;
	}	
	if( !isEmail(strEmail) )
	{
		alert("الرجاء إدخال البريد الالكتروني بشكل صحيح");		
		if(document.getElementById('email'))
			document.getElementById('email').focus();			
		return false ;
	}
	
	return true ;	
}
function validateHomeTelephoneNo(objTelNo)
{
	if(!objTelNo)
		return true ;
	
	if (objTelNo.value != "" )
	{
		if (objTelNo.value.length!=8){
			alert(' يتكون رقم الهاتف  من 8 أرقام');			
			objTelNo.focus();
			return false;
		}
	 	/*if (objTelNo.value.substring(0,1)!="4" || ){
			alert('يجب أن يبدأ هاتف المنزل برقم 4');
			displayErrorMessage('يجب أن يبدأ هاتف المنزل برقم 4');	
			objTelNo.focus();
			return false;
		}
		*/
	}

	return true ;	
}
function validateMobileNo(objMobileNo)
{
	if(!objMobileNo)
		return false ;
	if (objMobileNo.value != "")
	{
		/*if (objMobileNo.value.length != 7  ){
			alert(' يتكون رقم الجوال من 7 أرقام');
			objMobileNo.focus();
			return false;
		}
		*/
	 	/*if ( objMobileNo.value.substring(0,1) != "5"  )
	 	{
	 		if( objMobileNo.value.substring(0,1)!="6" )
			{
			alert('يجب أن يبدأ رقم الجوال برقم 5 أو 6');
			objMobileNo.focus();
			return false;
			}
		}	*/
	}
	
	return true ;
}

function login(action)
{
	
	if(action == "forgetPassword" )
	{
		if( document.getElementById("tdLogin") )
		{
			document.getElementById("tdLogin").style.display = "none" ;
		}
		if( document.getElementById("tdParticipate") )
		{
			document.getElementById("tdParticipate").style.display = "none" ;
		}		
		//
		if( document.getElementById("tdHint") )
		{
			document.getElementById("tdHint").style.display = 'none' ;
		}		
		if( document.getElementById("tdPassword") )
		{
			document.getElementById("tdPassword").style.display = 'inline' ;
		}	
		
	}
	else if(action == "hint" )
	{
		if( document.getElementById("tdLogin") )
		{
			document.getElementById("tdLogin").style.display = "none" ;
		}
		if( document.getElementById("tdParticipate") )
		{
			document.getElementById("tdParticipate").style.display = "none" ;
		}		
		// 
		if( document.getElementById("tdPassword") )
		{
			document.getElementById("tdPassword").style.display = 'none' ;
		}
		if( document.getElementById("tdHint") )
		{
			document.getElementById("tdHint").style.display = 'inline' ;
		}		
	}
	else 
	{
		if( document.getElementById("tdLogin") )
		{
			document.getElementById("tdLogin").style.display = 'inline' ;
		}
		if( document.getElementById("tdPassword") )
		{
			document.getElementById("tdPassword").style.display = "none" ;
		}
		if( document.getElementById("tdPassword") )
		{
			document.getElementById("tdPassword").style.display = "none" ;
		}		
	}
}
function displayParticipate()
{
	if( document.getElementById("tdParticipate") )
	{
		document.getElementById("tdParticipate").style.display = 'inline' ;
	}	
	if( document.getElementById("tdHint") )
	{
		document.getElementById("tdHint").style.display = 'none' ;
	}		
}
function displayNonePass()
{
	if( document.getElementById("tdPassword") )
	{
		document.getElementById("tdPassword").style.display = 'none' ;
	}	
	displayParticipate() ;
}
function displayNone()
{
	if( document.getElementById("tdLogin") )
	{
		document.getElementById("tdLogin").style.display = "none" ;
	}
	// 
	
	if( document.getElementById("tdParticipate") )
	{
		document.getElementById("tdParticipate").style.display = 'none' ;
	}		
	if( document.getElementById("tdHint") )
	{
		document.getElementById("tdHint").style.display = 'none' ;
	}	
}
function validateForgetPasswordEmail()
{
	if( document.getElementById('email')  )
	{
		return isEmailValid(document.getElementById('email').value);
	}
	
	return false ;
}


function validateLogin()
{
	if(document.getElementById('j_userName') && Trim(document.getElementById('j_userName').value) == ""  )
	{
		alert("الرجاء إدخال اسم المستخدم");
		document.getElementById('j_userName').focus();
		return false ;
	}
	else if(document.getElementById('j_password') && Trim(document.getElementById('j_password').value) == "" )
	{
		alert("الرجاء إدخال كلمة المرور");
		document.getElementById('j_password').focus();
		return false ;
	}	
	
	return true ;
}
function logout()
{
	if( document.getElementById("logoutFrm"))
	{
		document.getElementById("logoutFrm").submit();
	}
}
function updateInfo()
{
	if( document.getElementById("updateFrm"))
	{
		document.getElementById("updateFrm").submit();
	}	
}
function showParticipation()
{
	if( document.getElementById("tdParticipation") )
	{
		document.getElementById("tdParticipation").style.display = "" ;
	}	
}
function validateParticipation()
{
	
	if( document.getElementById("participationText") )
	{
		if(Trim(document.getElementById("participationText").value) == "" )
		{
			alert("الرجاء إدخال نص المشاركة");
			document.getElementById("participationText").focus();
			return false ;
		}
	}	
	return true ;
}
function validateGuestParticipation()
{
	
	if( validateParticipation() )
	{	
		if( document.getElementById('emailPart') && Trim(document.getElementById('emailPart').value) != ""  )
		{
			if( !isEmail(Trim(document.getElementById('emailPart').value)) )
			{
				alert("الرجاء إدخال البريد الالكتروني بشكل صحيح");		
				if(document.getElementById('emailPart'))
					document.getElementById('emailPart').focus();			
				return false ;
			}			
			
		}
		return true;
	}
	
	return false ;
}
function validateSuggestion()
{
	if( document.getElementById("participationTitle") )
	{
		if(Trim(document.getElementById("participationTitle").value) == "" )
		{
			alert("الرجاء إدخال موضوع الاقتراح");
			document.getElementById("participationTitle").focus();
			return false ;
		}
	}		
	if( document.getElementById("participationText") )
	{
		if(Trim(document.getElementById("participationText").value) == "" )
		{
			alert("الرجاء إدخال نص الاقتراح");
			document.getElementById("participationText").focus();
			return false ;
		}
	}	
	return true ;	
}
function onFocusParticipationText(show,objName)
{
	if(document.getElementById(objName) )
	{	
		if( show )
			document.getElementById(objName).style.display='inline' ;
		else
			document.getElementById(objName).style.display='none' ;
	}	
			
}
function displayGuestPart(status)
{

	if( status == "0")
	{
		
		if( document.getElementById("refDisplayGutest") )
		{
			document.getElementById("refDisplayGutest").className = "discLink1" ;
		}		
		if( document.getElementById("refDisplayLogin") )
		{
			document.getElementById("refDisplayLogin").className = "discLink" ;
		}
		if( document.getElementById("tdGuestParticipate") )
		{
			document.getElementById("tdGuestParticipate").style.display = "" ;
		}	
		if( document.getElementById("tdLoginGuest") )
		{
			document.getElementById("tdLoginGuest").style.display = "none" ;
		}			
		
	}
	else if( status == "1")
	{
	
		if( document.getElementById("refDisplayLogin") )
		{
			document.getElementById("refDisplayLogin").className = "discLink1" ;
		}		
		if( document.getElementById("refDisplayGutest") )
		{
			document.getElementById("refDisplayGutest").className = "discLink" ;
		}
		if( document.getElementById("tdGuestParticipate") )
		{
			document.getElementById("tdGuestParticipate").style.display = "none" ;
		}	
		if( document.getElementById("tdLoginGuest") )
		{
			document.getElementById("tdLoginGuest").style.display = "" ;
		}			
				
	}
	
	
}
