/*
* For checking data format
* @param sText string data
* @param isDecimal boolean
*/
function IsNumeric(sText, isDecimal)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	
	if (isDecimal)
		ValidChars = ValidChars + '.'
	
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
   return IsNumber;
}

/*
* For checking data format(Numeric and Alphet)
* @param sText string data
*/
function IsNumericAndAlphet(sText)
{
	var ValidCharsNum = "0123456789";
	var ValidCharsAlphet = "ABCDEFGHIJKLMNOPQRSTUVWRSTXYZabcdefghijklmnopqrstuvwxyz";
	var NumCounter = 0;
	var AlphetCounter = 0;
	var Char;
	
	for (i = 0; i < sText.length; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidCharsNum.indexOf(Char) != -1) 
		{
			NumCounter++;
		}
		else if (ValidCharsAlphet.indexOf(Char) != -1) 
		{
			AlphetCounter++;
		}
	}
	if (NumCounter + AlphetCounter != sText.length)
		return false;
   return true;
}


/*
* To calculate how many of month
*/
function getLastDayOfMonth(month,year)
{
	var day = 0;	
	switch(month)	
	{		
		case '1' :
		case '3' :
		case '5' :
		case '7' :
		case '8' :
		case '10':
		case '12':
			day = 31;
			break;
		case '4' :
		case '6' :
		case '9':
		case '11':
			day = 30;
			break;
		case '2' :
			if( ( (year % 4 == 0) && ( year % 100 != 0) ) || (year % 400 == 0) )
				day = 29;
			else
				day = 28;
			break;	
	}
	return day;
}

/*
* AJAX function is import from prototype.js
*/
function requestContent(url,labelID)
{
	Ajax.Responders.register(
					{
						onCreate: function()
						{
						},
						onComplete: function()
						{
						}
					}
	);
	new Ajax.Request(url,
					{
						method:"post",
						onSuccess:function(transport){
							var response=transport.responseText;
							document.getElementById(labelID).innerHTML=response;
						},
						onFailure:function(){
						},
						onUninitialized:function(){
						},
						onLoading:function(){
						},
						onLoaded:function(){
						},
						onInteractive:function(){
						},
						onComplete:function(){
						},
						onException:function(){
						}
					});
}
