//Confirm Delete
function confirmDelete(message)
{
    if(!(message)) { message = "This action will delete the record and also all its relations, it is not reversable. Do you want to continue?"; }
	var agree = confirm(message);
    if (agree)
        return true;
    else
        return false;
} 

//Function for image popup
function showImage(imgname) {
	window.open('enlarge.html?imgname='+imgname,'','scrollbars=yes,resizable=yes,width=500,height=500,centre=0,middle=00');
}

//This function email format to be entered in Text box
function isemail(m) {
	len=m.length;
	i=0;
	// Checking for "@" in the address
	while((i<len) && (m.charAt(i)!="@"))
		i++;
	if((i>=len) || (m.charAt(i)!="@")) return(false);
		i+=2;
	// Checking for "." in the address
	while((i<len) && (m.charAt(i)!="."))
		i++;
	if((i>len-1) || (m.charAt(i)!=".")) return(false);
		return(true)
}

//This function stops non numeric values to be entered in Text box
function AllowNumeric(e, sText)	{ 
	var key, keychar, Char, i, ValidChars;
	ValidChars = "-";
	l = sText;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) ||(key==9) || (key==13) || (key==27) || (key==48) || (key==49) || (key==50) ||(key==51) || (key==52) || (key==53) || (key==54) || (key==55) ||(key==56) || (key==57) || (key==45)  ) {
		if(keychar == "-") {
			return false;
		}
		return true;
	}
	else
		return false;
}   

//This function stops non decimal values to be entered in Text box
function AllowDecimal(e, sText) { 
	var key;
	var keychar;
	var Char;
	var i;
	var ValidChars;
	var ValidChars1;
	ValidChars  = ".";
	ValidChars1  = "-";
	l=sText;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
		if ((key==null) || (key==0) || (key==8) ||(key==9) || (key==13)  || (key==48) || (key==49) || (key==50) ||(key==51) || (key==52) || (key==53) || (key==54) || (key==55) ||(key==56) || (key==57)  || (key==2) || (key==46) || (key==45)) {
		if(keychar == ".") {
			for (i = 0; i < l.length; i++) { 
				Char = l.charAt(i);
				if (ValidChars.indexOf(Char) != -1) 
					return false;
			}
		}
		if(keychar == "-") {
			return false;
		}
		return true;
	}
	else if (key==22)
		return false;
	else
		return false;
}           

//This function stops wildcards to be entered in Text box
function disallowWildCard(e, sText)	{ 
	var key, keychar, Char, i;
	l = sText;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if(keychar == "%")
		return false;
	else
		return true;
}

//Trim Function
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
