/* Function to select the first element of the combo or list box*/
function SetIndexZ(lst){
	if(lst.selectedIndex == -1) lst.selectedIndex = 0;
}

function IsNull(txt){
	if(txt == "" || txt == null){
		return true;
	}
	return false;
}

function IsEmpty(txt){
	if(txt.length == 0)
		return true;
	for(var i = 0;i < txt.length; i++){
		if(txt.charAt(i) != " ")
			return false;
	}
	return true;
}

function LTrim(value){
	var l,i,n,newvalue;
	l = value.length; //txt.charAt(i)
	for(i=0;i<l;i++){
		if(value.charAt(i) != " ")
			break;
	}
	newvalue="";
	for(n=i;n<l;n++)
		newvalue=newvalue+value.charAt(n);
	return newvalue;
}

function RTrim(value){
	var l,i,n,newvalue;
	l = value.length; //txt.charAt(i)
	for(i=l-1;i>=0;i--){
		if(value.charAt(i) != " ")
			break;
	}
	newvalue="";
	for(n=0;n<=i;n++)
		newvalue=newvalue+value.charAt(n);
	return newvalue;
}

function LTrim_Hyp(value){
	var l,i,n,newvalue;
	l = value.length; //txt.charAt(i)
	for(i=0;i<l;i++){
		if(value.charAt(i) != "-"  && value.charAt(i) != " ")
			break;
	}
	newvalue="";
	for(n=i;n<l;n++)
		newvalue=newvalue+value.charAt(n);
	return newvalue;
}

function RTrim_Hyp(value){
	var l,i,n,newvalue;
	l = value.length; //txt.charAt(i)
	for(i=l-1;i>=0;i--){
		if(value.charAt(i) != "-"  && value.charAt(i) != " ")
			break;
	}
	newvalue="";
	for(n=0;n<=i;n++)
		newvalue=newvalue+value.charAt(n);
	return newvalue;
}

function HasSpace(txt){		
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == " ")
			return true;
	}
	return false;
}

function TextLength(txt){
	var intLength = 0;
	if(txt.length == 0)
		return 0;
	for(var i = 0;i < txt.length;i++)
		 intLength++;
	return intLength;	 
}
function FirstLetter(txt){
	if(SplChar(txt.charAt(0)) == true)
		return false
    if(IsNumberPresent(txt.charAt(0)) == true)
		return false
	return true
	}
function SplChar(txt){
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == '@' || txt.charAt(i) == '#' 
			|| txt.charAt(i) == '!' || txt.charAt(i) == '$'
			|| txt.charAt(i) == '%' || txt.charAt(i) == '&' 
			|| txt.charAt(i) == '^' || txt.charAt(i) == '*'
			|| txt.charAt(i) == '~' || txt.charAt(i) == '_'
			|| txt.charAt(i) == '-' || txt.charAt(i) == '='
			|| txt.charAt(i) == '+' || txt.charAt(i) == '|'
			|| txt.charAt(i) == '?' || txt.charAt(i) == '<'
			|| txt.charAt(i) == '>' || txt.charAt(i) == '/'
			|| txt.charAt(i) == '[' || txt.charAt(i) == ']'
			|| txt.charAt(i) == '(' || txt.charAt(i) == ')'
			|| txt.charAt(i) == '`' || txt.charAt(i) == ","
			|| txt.charAt(i) == "." || txt.charAt(i) == ":"
			|| txt.charAt(i) == ";" || txt.charAt(i) == "'"
			|| txt.charAt(i) == "{" || txt.charAt(i) == "}"
			|| txt.charAt(i) == '"' || txt.charAt(i) == '\\' )
			return true;
	}
	return false;
}
function SplNameChar(txt){
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == '@' || txt.charAt(i) == '#' 
			|| txt.charAt(i) == '!' || txt.charAt(i) == '$' 
			|| txt.charAt(i) == '%' || txt.charAt(i) == '&' 
			|| txt.charAt(i) == '^' || txt.charAt(i) == '*' 
			|| txt.charAt(i) == '~' || txt.charAt(i) == '_' 
			|| txt.charAt(i) == '-' || txt.charAt(i) == '=' 
			|| txt.charAt(i) == '+' || txt.charAt(i) == '|' 
			|| txt.charAt(i) == '?' || txt.charAt(i) == '<' 
			|| txt.charAt(i) == '>' || txt.charAt(i) == '/' 
			|| txt.charAt(i) == '[' || txt.charAt(i) == ']' 
			|| txt.charAt(i) == '(' || txt.charAt(i) == ')' 
			|| txt.charAt(i) == '`' || txt.charAt(i) == "," 
			|| txt.charAt(i) == ":" || txt.charAt(i) == ";" 
			|| txt.charAt(i) == "{" 
			|| txt.charAt(i) == "}" || txt.charAt(i) == '"'
			|| txt.charAt(i) == '\\' )
			return true;
	}
	return false;
}

function SplNameCharOthers(txt){
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == '@' || txt.charAt(i) == '#'
			|| txt.charAt(i) == '!' || txt.charAt(i) == '$' 
			|| txt.charAt(i) == '%' 
			|| txt.charAt(i) == '^' || txt.charAt(i) == '*' 
			|| txt.charAt(i) == '~' 
			|| txt.charAt(i) == '=' 
			|| txt.charAt(i) == '+' || txt.charAt(i) == '|' 
			|| txt.charAt(i) == '?' || txt.charAt(i) == '<' 
			|| txt.charAt(i) == '>' 
			|| txt.charAt(i) == '[' || txt.charAt(i) == ']' 
			|| txt.charAt(i) == '`' 
			|| txt.charAt(i) == ":" 
			|| txt.charAt(i) == "{" 
			|| txt.charAt(i) == "}" || txt.charAt(i) == '"'
			|| txt.charAt(i) == '\\' )
			return true;
	}
	return false;
}

function SpLogin(txt){
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == '@' || txt.charAt(i) == '#' 
			|| txt.charAt(i) == '!' || txt.charAt(i) == '$' 
			|| txt.charAt(i) == '%' || txt.charAt(i) == '&' 
			|| txt.charAt(i) == '^' || txt.charAt(i) == '*' 
			|| txt.charAt(i) == '~' || txt.charAt(i) == '-'
			|| txt.charAt(i) == '=' || txt.charAt(i) == ']' 
			|| txt.charAt(i) == '+' || txt.charAt(i) == '|' 
			|| txt.charAt(i) == '?' || txt.charAt(i) == '<' 
			|| txt.charAt(i) == '>' || txt.charAt(i) == '/' 
			|| txt.charAt(i) == '[' || txt.charAt(i) == ']' 
			|| txt.charAt(i) == '(' || txt.charAt(i) == ')' 
			|| txt.charAt(i) == '`' || txt.charAt(i) == "," 
			|| txt.charAt(i) == "." || txt.charAt(i) == ":" 
			|| txt.charAt(i) == ";" || txt.charAt(i) == "'" 
			|| txt.charAt(i) == "{" || txt.charAt(i) == "}" 
			|| txt.charAt(i) == '"' || txt.charAt(i) == '\\' )
			return true;
	}
	return false;
}

function IsWholeNumber(obj){
	if(obj.length == 0)
		return true;
	for(var i = 0;i < obj.length;i++){
		if(obj.charAt(i) >= '0' && obj.charAt(i) <= '9') 
			continue;
		else
			return false;
	}
	//if(parseFloat(obj) < 1){
		//return false;
//	}
	return true;
}

function IsInteger(obj){
	if(obj.length == 0)
		return true;
	for(var i = 0;i < obj.length;i++){
		if(obj.charAt(i) >= '0' && obj.charAt(i) <= '9') 
			continue;
		else
			return false;
	}
	if(parseFloat(obj) < 1){
		return false;
	}
	return true;
}

function IsNumber(obj){
	var blnDecimal = false;
	
	if(obj.length == 0)
		return true;
	for(var i = 0;i < obj.length;i++){
		if(obj.charAt(i) == '.' && blnDecimal == true)
			return false;
		if( obj.charAt(i) == '.')
			blnDecimal =  true;
		if((obj.charAt(i) >= '0' && obj.charAt(i) <= '9') || obj.charAt(i) == 
'.')
			continue;
		else
			return false;
	}
	return true;
}		

function IsNumberPresent(obj){
	if(obj.length == 0)
		return false;
	for(var i = 0;i < obj.length;i++){
		if(obj.charAt(i) >= '0' && obj.charAt(i) <= '9') 
			return true;
		else
			continue;
	}
	return false;
}

function IsEmailCorrect(obj){
	var blnDecimal = false;
	var blnAt = false
	
	if(obj.length == 0)
		return true;
	for(var i = 0;i < obj.length;i++){
		if(obj.charAt(i) == '.')
			blnDecimal = true;
		else if(obj.charAt(i) == '@')
			blnAt = true;
		if(blnDecimal == true && blnAt == true)
			return true;
	}
	return false;
}
		
function EndCheck(strSource,strTest){
	var strTemp,i,j
	j = strSource.length - strTest.length;
	strTemp = ""
	for(var i = j;i < strSource.length;i++)
		strTemp = strTemp + strSource.charAt(i)
	if (strTemp.length == strTest.length && strTemp == strTest)
		return true
	else
		return false
}
