
/*For others function*/
function onEnter(e)
{	
	if(e.keyCode == 13) return true;
	return false;
}

function onEscape(e)
{	
	if(e.keyCode == 27) return true;
	return false;
}

function isValidEmail(text_box_class_name, err_msg_id)
{	
	err_msg = 'Invalid email address.';
	email = $('.'+text_box_class_name);			
	if(!/^([a-zA-Z0-9_\.])+\@([a-zA-Z0-9\-])+\.([a-zA-Z0-9]{2,4})(\.[a-zA-Z0-9]{2,4})?$/.test(email.val()))
	{			
		email.focus();
		if(err_msg_id!=null) $('#'+err_msg_id).html(err_msg);
		else alert(err_msg);
		return false;
	}
	return true;
}

function IsNumeric(strString, option) 
{ 
	if(option==null || option==false)
	    var strValidChars = "0123456789"; 
	else var strValidChars = "0123456789."; 	
    var strChar; 
    var blnResult = true; 
    //var strSequence = document.frmQuestionDetail.txtSequence.value; 

    //test strString consists of valid characters listed above 

    if (strString.length == 0) 
        return false; 
    for (i = 0; i < strString.length && blnResult == true; i++) 
    { 
        strChar = strString.charAt(i); 
        if (strValidChars.indexOf(strChar) == -1) 
        { 
            blnResult = false; 
        } 
     } 
	return blnResult; 
}

function is_positive_float_number(item_id, err_msg_id) {
		
	$("#"+item_id).css('backgroundColor','white');
	if(err_msg_id!=null) $("#"+err_msg_id).html('');
	value = $("#"+item_id).val();	    
	invalid_number = false; 
	is_error = false;
	err_msg = "";
	
	if(value.length==0)
	{
		if(err_msg_id!=null) $("#"+err_msg_id).html('This field cannot be empty.'); else alert('This field cannot be empty.');
		$("#"+item_id).focus(); 
		return false;
	}
	
	for(i=0; i<value.length; i++)
	{
		if(value.charAt(i)=="-" )
		{
			invalid_number = true;
			break;
		}
	}
	
	if(isNaN(value))
	{
		is_error = true;
		err_msg = "Invalid number.";		
	}	    
	else if(parseFloat(value)==0)
	{
		is_error = true;
		err_msg = "This field must be greater than zero.";			
	}
	else if(invalid_number)
	{
		is_error = true;
		err_msg = "This field cannot be negative number.";			
	}
	
	if(is_error)
	{        	
		if(err_msg_id!=null) $("#"+err_msg_id).html(err_msg);  else alert(err_msg);
		$("#"+item_id).focus();  	
		$("#"+item_id).css('backgroundColor','red');
		return false;
	}
	return true;
} 

function trimAllChar(str, char) 
{ 
    if(char==null) char=' ';
	var str1 = ''; 
    var i = 0; 
    while(i != str.length) 
    { 
        if(str.charAt(i) != char) 
            str1 = str1 + str.charAt(i); i ++; 
    } 
    return str1; 
}

function roundNumber(num, dec)
{
	if(dec==null) dec = 2;
	result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}