/* Default Javascript File - For Non jQuery code */

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

String.prototype.trim = function() {
	return this.ltrim().rtrim();
}

function isEmail(s){ 
    if (s.trim() == "") return false;
    
    var i = 1;
    var sLength = s.length;

	while ((i < sLength) && (s.charAt(i) != "@")){ 
		i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != ".")){ 
		i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isRadioSelected(val) {
	var isSelected = false;

	if(!val){
	   return false;
    }
	
	if(!val.length){
		if(val.checked){
			isSelected = true;	
		}
	}

	for (i=0; i<val.length; i++) {
		var currVal = val[i];
		if (currVal.checked) {
			isSelected = true;
			break;
		}
	}

    if (!isSelected) {
        return false;
    } else return true;
}	  