function isEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var b=true;

	if (str=="") b=false;
	if (str.indexOf(at)==-1) b=false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) b=false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) b=false;
	if (str.indexOf(at,(lat+1))!=-1) b=false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) b=false;
	if (str.indexOf(dot,(lat+2))==-1) b=false;
	if (str.indexOf(" ")!=-1) b=false;

	if (b) {
		var x=false;
		if (str.indexOf(".com")>0) x=true;
		if (str.indexOf(".co.uk")>0) x=true;
		if (str.indexOf(".net")>0) x=true;
		if (str.indexOf(".org")>0) x=true;
		if (str.indexOf(".gov")>0) x=true;
		if (str.indexOf(".eu")>0) x=true;
		if (str.indexOf(".tv")>0) x=true;
		if (str.indexOf(".me")>0) x=true;
		if (str.indexOf(".es")>0) x=true;
		if (str.indexOf(".info")>0) x=true;
		if (str.indexOf(".biz")>0) x=true;
		if (str.indexOf(".ac.uk")>0) x=true;
		if (str.indexOf(".gb")>0) x=true;
		if (str.indexOf(".ie")>0) x=true;
		if (str.indexOf(".name")>0) x=true;
		if (str.indexOf(".uk")>0) x=true;
		if (str.indexOf(".us")>0) x=true;
		if (str.indexOf(".edu")>0) x=true;
		b=x;
	}

	if (b) {
		return true;
	} else {
		return false;
	}					
}

function isBlank(str) {
	var space=" ";
	var b=true;

	if (str.length==0) return true;

	for (i=0; i<str.length && b==true; i++) { 
		c=str.charAt(i);
		if (c!=space) b=false;
	}
	return b;
}

function fillSearch(x,y) {
	if (isBlank(x.value)) {
		x.value	= y;
	}
}

function clearSearch(x,y) {
	if (x.value==y) {
		x.value='';
	}
}

function checkSearch(x,y) {
	if (isBlank(x.value) || x.value==y) {
		return false;
	} else {
		return true;
	}
}

function checkSubmit(f,t,y) {
	var x = eval("document."+f+"."+t);
	var s = eval("document."+f);
	if (isBlank(x.value) || x.value==y) {
		//return false;
	} else {
		s.submit();
	}
}

function isNumeric(str,acceptpoint,allowblank) {
	//  check for valid numeric strings	
	var strValidChars = "0123456789";
	var c;
	var b=true;
	var j=0;
	
	if (acceptpoint) strValidChars = "0123456789.";
	if (str.length==0 && !allowblank) return false;
	//  test strString consists of valid characters listed above
	for (var i=0; i<str.length; i++) {
		if (b) {
			c=str.charAt(i);
			if (strValidChars.indexOf(c)==-1) b=false;
			if (c==".") j++;
		}
	}
	if (j>1) b=false;
	return b;
}

function roundCurrency(num) {
	var i
	//and all beacuse javascript doesn't have a rounding to decimal place function
	num=new String(num);
	i=num.indexOf(".");
	if (i==-1) {
		num=num + ".00";
	}
	else {
		if (i==num.length-2) { 
			num=num + "0";
		}
		else {
			num=String(parseFloat(num) + 0.005)
			num=num.substring(0,i+3);
		}
	}
	return num;
}
