function SU_isEmpty(id)
{
	if(!TrimString(document.getElementById(id).value))	{		return false;}
	return true;
}

function SU_isName(id)
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);
	if(!(/^[a-zA-Z ]+$/.test(document.getElementById(id).value)))
	{
		return false;
	}
	return true;
}

function SU_isRadioSelected(fieldName,count)
{
	
	var radio_choice = false;
	
	for (counter = 0;  counter < count; counter++)
	{
		
		var optGroup = fieldName + "-" + counter;
		if(document.getElementById(optGroup).checked)	radio_choice = true; 
	}
	if (!radio_choice)	return false;
	return true;
}
function SU_isSelectSelected(fieldName,count)
{
	if(!TrimString(document.getElementById(fieldName).value))
	{
		return true;
	}
	else
	{
		return false;
	}
	
}
function SU_isRadioSelected_temp(btn) {
	alert("HI");
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) 
	{
		alert("TRUE");
		return btn[cnt].value;
	}

    else
	{
		alert("FALSE");
		return false;
	}
}
function SU_isRadioSelected2(group, form) 
{
	alert("start");
    if (typeof group == 'string') group = form.elements[group];
    for (var i = 0, n = group.length; i < n; ++i)
        if (group[i].checked) return group[i];
	alert("end");
    return null;
}
                  

function SU_isCheckMinimum(inputName,totalCount,minimumCount)
{
	var count = 0;
	for (counter = 0;  counter < totalCount; counter++)
	{
		var element = inputName+ "-" + counter;
		if (document.getElementById(element).checked)		count++; 
	}
	if(minimumCount > count)		
	{
		return false;
	}
	return true;
}
/*
function SU_isAddress(id)
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);
	if(!(/^[a-zA-Z0-9.&,!@#$%^*\(\)\-\+:; \/]+$/.test(document.getElementById(id).value)))
	{
		document.getElementById(id).focus();
		alert("Please use letters (a-z), numbers or special characters (.,#/&) only in this field.");
		return false;
	}
	return true;
}

function SU_isAlpha(id)			// only alphabetics
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);

	if(!(/^[a-zA-Z]+$/.test(document.getElementById(id).value)))
	{
		document.getElementById(id).focus();
		alert("Please use letters (a-z) in this field. Space is not allowed");
		return false;
	}
	return true;
}
function SU_isValidSrtLen(id,start,end)			// only alphabetics
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);
	var len = document.getElementById(id).value.length;
	if(len<start || len>end)
	{
		document.getElementById(id).focus();
		if(start==end)
		{
			alert("Length of this field  should be "+start);
		}
		else
		{
			alert("Length of this field  between ( "+start+" - "+end+" )");
		}
		return false;
	}
	return true;
}*/
function SU_isEmail(id)
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);
	if(!(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(document.getElementById(id).value)))
	{
		return false;
	}
	return true;
}
function SU_isUrl(id)
{
	document.getElementById(id).value = TrimString(document.getElementById(id).value);
	if(!(/^(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(document.getElementById(id).value)))
	{
		return false;
	}
	return true;
}
function SU_isDigit(id)				/***	Only Numbers	****/
{
	if(!(/^[0-9 ()-]+$/.test(document.getElementById(id).value)))
	{
		return false;
	}	
	return true;
}
function SU_isBetween(id,from,to)
{
	var t = document.getElementById(id).value*1;
	if(t<from || t>to)
	{
		return false;
	}	
	return true;
}
/*
function SU_isDate(dd,mm,yy)
{
	var Day1 = document.getElementById(dd).value*1;
	var Mon1 = document.getElementById(mm).value*1;
	var Year1 = document.getElementById(yy).value*1;
	var flag=true;
	if(Day1 <= 0 || Mon1 <= 0 || Year1 <= 0)
	{
		flag=false;
	}
	if((Year1%4 ==0 && Year1 %100 != 0) || Year1%400 ==0)
	{
		if(Mon1 == 2 && Day1>29)	{		flag=false;		}
	}
	else
	{
		if(Mon1 == 2 && Day1>28)	{		flag=false;		}
	}
	if(Mon1 == 4 || Mon1 == 6 || Mon1 == 9 || Mon1 == 11)
	{
		if(Day1 >30)
		{
			flag=false;
		}
	}
	if(flag==false)
	{
		document.getElementById(dd).focus();
		alert("Invalid Date.");
	}
	return flag;
} 
*/
/***************	Trim Start here			***********/
function TrimString(sInString) 
{
	sInString = sInString.replace( /^\s+/g, "" );	// strip leading
	return sInString.replace( /\s+$/g, "" );		// strip trailing
}
/***************	Trim end here			***********/