//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function blank_check( entry, msg )																	//For text boxes
{
    if( entry.search( /\S/ ) == -1 )
	{
	alert( msg )
	return false
    }
return true
}

function chosen_check( entry, msg )																//For drop down select boxes Nairit keeps valoe="0" for the first option(default)
{
    if( entry == "0" )
	{
	alert( msg )
	return false
    }
return true
}

function length_check( entry_leng, min_leng, msg )
{
    if( entry_leng < min_leng )
    {
    alert( msg )
    return false
    }
return true
}

function same_check( pass1, pass2, msg )
{
    if( pass1 != pass2 )
    {
    alert( msg )
    return false
    }
return true
}
/*
//--------------------------------------------------------------------------- Character checks ----------------------------------------------------------------------------------------
function chr_check( entry, msg )
{
    if( entry.search(/[^a-zA-Z0-9_~!@#$%^&*-=+|:<>?.,]/) > -1 )								//Nothing is allowed outside this set of characters. The first ^ probably stands for not(like !)
    {
    alert( msg )
    return false
    }
return true
}
*/
function strict_chr_check( entry, msg )																//Nothing is allowed outside alphanumeric & underscore characters.This technique is even better for character checks.THIS ONE WON'T ALLOW SPACES
{
	if( (/^[a-zA-Z0-9_]+$/).exec(entry) == null )
	{
    alert( msg )
	return false
	}
return true
}

/*function strict_chr_check2( entry, msg )															//THIS ONE WILL ALLOW SPACES
{
	if( (/^[a-zA-Z0-9_ ]+$/).exec(entry) == null )
	{
    alert( msg )
	return false
	}
return true
}*/

function quote_check( entry, msg )
{ 
    if(  entry.search('"') > -1  ||  entry.search("'") > -1  )								// Quote creates problems while entry into DB. Spammers may also try to put in executable code after ending the string using quotes
    {
    alert( msg )
    return false
    }
return true
}

//--------------------------------------------------------------------------- Number checks ----------------------------------------------------------------------------------------
function number_check( entry, msg )																//Checks that entry is a number.WON'T ALLOW ANY SPACE. HOWEVER IT ALLOWS BLANK BOX
{
	if( !isFinite(entry) )
	{
	alert(msg)
	return false
	}
return true
}
/*
function not_number_check( entry, msg )														//Checks that entry is not a number.WON'T ALLOW ANY SPACE. HOWEVER IT ALLOWS BLANK BOX
{
	if( isFinite(entry) )
	{
	alert(msg)
	return false
	}
return true
}

function zip_check( entry, msg )																	// Zip check. Only number & space are allowed in US zips. British zips allow capital letters however
{
	if( (/^[0-9 ]+$/).exec(ZipEntry) == null )
	{
	alert(msg)
	return false
	}
return true
}*/
//------------------------------------------------------------------------- E-mail address, URL, phone checks ----------------------------------------------------------------------------
function email_check( entry, msg )																	//THIS ONE WON'T ALLOW BLANK EMAIL ADDRESS
{
	if( (/^[a-zA-Z0-9-._]+(@[a-zA-Z0-9]{1,}[a-zA-Z0-9_.-]+\.)+[a-zA-Z]{2,4}$/).exec(entry) == null )
	{
	alert(msg)
	return false
    }
return true
}

/*function email_check2( entry, msg )																//THIS ONE ALLOWS BLANK EMAIL ADDRESS
{
	if( entry != "" )
	{
		if( (/^[a-zA-Z0-9-._]+(@[a-zA-Z0-9]{1,}[a-zA-Z0-9_.-]+\.)+[a-zA-Z]{2,4}$/).exec(entry) == null )
		{
		alert(msg)
		return false
    	}
	}
return true
}

function site_check( entry, msg )																	//ALLOWS BLANK WEB-SITE
{
	if( entry != "" )
	{
		if( (/^([a-zA-Z0-9_.-:\/]{1,}[a-zA-Z0-9_.-]+\.)+[a-zA-Z]{2,4}$/).exec(entry) == null )
		{
		alert(msg)
		return false
    	}
	}
return true
}

function phone_check( entry, msg )																	// Allows blank phone no. Otherwise allows only numerical & those 4 characters
{
	if( entry != "" )
	{
		if( (/^[0-9-)(+ ]+$/).exec(entry) == null )
		{
		alert(msg)
		return false
		}
	}
}
//----------------------------------------------------------------------------------- Date checks --------------------------------------------------------------------------------------
function isDate(da, mth, yr, msg1, msg2, msg3, msg4, msg5)
{
	if( (da==0) || (mth==0) || (yr==0) )
	{alert(msg1);return false}												//Please choose date of birth

	if( (mth==4) || (mth==6) || (mth==9) || (mth==11) )				// 30 days has SEPTEMBER, APRIL, JUNE and NOVEMBER
	{
		if( da > 30 )
		{alert(msg2);return false}											//The date is absurd
	}
//...................................................................................... If year is divisible by 4, then FEBRUARY has 1 day more ........................................................................................................
	if( mth == 2 )
	{
		if( da > 29 )
		{alert(msg3);return false}											//The date does not exist ! Observe that the month is February !

		else if( (yr%100) == 0 )											//Millenium years, though divisible by 4 are not leap years. But 1600, 2000, 2400 are normal leap years
		{
			if( (yr%400) != 0 )
			{
				if( da > 28 )
				{alert(msg4);return false}									//The date does not exist ! 1700, 1800, 1900, 2100 millenium years are not leap-years in spite of being divisible by 4.  But 1600, 2000, 2400 millenium years are normal leap years. Honestly, didn't you know ?
			}
		}

		else if( (yr%4) != 0 )
		{
			if( da > 28 )														//Non-leap years have only 28 days
			{alert(msg5);return false}										//The date does not exist ! The year chosen is not a leap-year. How can it have more than 28 days ?
		}
	}
//...................................................................................................................................................................................................................................................................................................................
return true
}*/

function cmp_dates( start_date, end_date, msg )					//Recieving the dates with same name
{
	if( (end_date - start_date) < 0 )
    {
	alert( msg )
	return false
    }
return true
}