// *****************************************************************************
// Purpose			: To Check whether string is valid number
// Input aurguments	: string
// Return value  	: 
// Author           : G.Karunakar July 09 2003
// Modified/Date 	: July 09 2003
// *****************************************************************************

function isan(string) {
    if (string.length == 0)
        return false;
    for (var i=0;i < string.length;i++)
        if ((string.substring(i,i+1) < '0') || (string.substring(i,i+1) > '9'))
            return false;
    
    return true;
}



// *****************************************************************************
// Purpose			: To Check whether email id is valid or not
// Input aurguments	: Emailid
// Return value  	: 
// Author           : G.Karunakar July 09 2003
// Modified/Date 	: July 09 2003
// *****************************************************************************

function validateemailid(emailid)
{
	var pos1;
	var pos2;
	var bef;
	var aft;
	pos1=emailid.indexOf('@');
	pos2=emailid.indexOf('.');
	if(pos1 == -1 || pos2 == -1)
	{
		return false;
	}
	if(pos1 > pos2)
	{
		return false;
	}else
	{
		if((pos2-pos1)<2)
		{
			return false;
		}else
		{
			if(pos1!=0)
			{				
				bef=emailid.substring((pos1-1),pos1);
			}else
			{
				return false;
			}
			
			if((pos1+1)!=emailid.length)
			{	
				aft=emailid.substring(pos1+1,pos1+2);
			}else
			{
				return false;
			}

			if((pos2+1)!=emailid.length)
			{
				aft=emailid.substring(pos2+1,pos2+2);
			}else
			{
				return false;
			}

		}
	}
return true;
}








// *****************************************************************************
// Purpose					: To  validate date entered is greater than or equal to todays date or not
// Input aurguments		:  date in MM/DD/YYYY format only
// Return value  			: returns valid if true
// Author					: G.Karunakar July 09 2003
// Modified/Date 			: 
// *****************************************************************************

function vdatewithtoday(d)
{
	
    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());
	var tyear=now.getYear();
	var tmonth=now.getMonth()+1;
	var tday=now.getDate();
	date1=d.split("/"); //MM/DD/YYYY
	dm=date1[0];
	dd=date1[1];
	dy=date1[2];
	
	
	if(dy<tyear)
	{
		return "invalid";
	}else
	{
		if(dy==tyear)
		{
			if(dm<tmonth)
			{
				return "invalid";
			}else
			{
				if(dm==tmonth)
				{
					if(dd<tday)
					{
						return "invalid";
					}
				}
			}
		}
	}

	return "valid";

}






/*function checkabove(opt)

/*******************************************************************************************
Purpose					: To validate Create Question page
Input aurguments		:  questiontype,page
Return value  			: 
Author					: G.Karunakar July 09 2003
Modified/Date 			: 
*******************************************************************************************
*/
function validatecreatequestion(Type,page)
{             
	var result;
	var ch;
	ch=false;
	if(document.frm1.Question.value=="")
	{
			alert("Enter the Question");					
			document.frm1.Question.select();
			return false;
	}
   
	switch(Type)
	{
		case 1:
				if(document.frm1.option1.value!="" || document.frm1.option2.value!="" || document.frm1.option3.value!="" || document.frm1.option4.value!="" )
				{
					ch=true;
				}
				if(!ch)
				{
					alert("Enter Atleast one Anwer option");
					document.frm1.option1.focus();
					return false;						
				}
				switch(document.frm1.canswer.value)
				{
				
					case "1":
							if(document.frm1.option1.value=="")
							{
								alert("Enter a Answer Option for Answer Option 1");
								document.frm1.option1.focus();
								return false;														
							}
							break;
					case "2":
							if(document.frm1.option2.value=="")
							{
								alert("Enter a Answer Option for Answer Option 2");
								document.frm1.option2.focus();
								return false;														
							}
							break;
					case "3":
							if(document.frm1.option3.value=="")
							{
								alert("Enter a Answer Option for Answer Option 3");
								document.frm1.option3.focus();
								return false;														
							}
							break;
					case "4":
							if(document.frm1.option4.value=="")
							{
								alert("Enter a Answer Option for Answer Option 4");
								document.frm1.option4.focus();
								return false;														
							}
							break;
				}

				if(document.frm1.score.value=="")
				{		
					alert("Enter Score for Correct Answer");
					document.frm1.score.focus();
					return false;						
				}

				break;
		case 3:
				if(document.frm1.score.value=="")
				{		
					alert("Enter Maximum Score for this question ");
					document.frm1.score.focus();
					return false;						
				}
			break;
		}

	return true;
}










