
function delspace(feild){
var thisval=feild.value;
var re = / /g;
thisval=thisval.replace(re,"");
feild.value=thisval;
}

function isDigit(c)	{
	if ((c >= '0') && (c <= '9')) 
	return true;
	return false;
}

function isChar(c)	{
	if ((c >= 'a') && (c <= 'z'))
	return true;
	if ((c >= 'A') && (c <= 'Z'))
	return true;
	return false;
}

function isNumber(inputVal)	{
	inputStr=inputVal.toString();
	for (var i = 0; i < inputStr.length; i++)	{
		var onechar = inputStr.charAt(i);
		if (onechar < "0" || onechar > "9")return false;		
	}
	return true;
}

function isEmpty(str) {
	return ((str == null) || (str == ""));
}
var msgwin = null;
var winwide = screen.availWidth;

function open_window(URL,wt,ht)	{

msgwin=window.open(URL,"NewWindow","toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+ wt +",height="+ ht +",top=230,left=500")
}

function shutIt() {
  if (msgwin != null && msgwin.open) msgwin.close();
}
window.onfocus=shutIt;
function checkradio(radio){
	for (var i = 0; i < radio.length; i++)    {
		if (radio[i].checked) return true;
	}
}

function isChecked(object) {
	for (var i = 0; i < object.length; i++)    {
		if (object[i].checked) return true;
	}
}

function validate(f){
    var err = "";
    var focus = "";

    if (isEmpty(regfrm.Name.value)){
        if (isEmpty(err))
			focus="#name";
        	err += "You must provide your Name.\n";
		};
    if (isEmpty(regfrm.Company.value)){
        if (isEmpty(err))
			focus="#company";
        	err += "You must provide your Campany.\n";
		};
	if (isEmpty(document.regfrm.Email.value)){
        if (isEmpty(err))
            focus="#email";
        err += "You must provide your email address.\n";
        }
        else {
	        tempstring = document.regfrm.Email.value;
        	if ((tempstring.indexOf('@') == -1 ) || (tempstring.indexOf('.') == -1 )){
    	      err += "Ensure that your email address is valid.\n";
        	  focus="#email";
        	}
    	};
		if (isEmpty(regfrm.Subject.value)){
        if (isEmpty(err))
			focus="#country";
        	err += "You must provide Subject.\n";
		};
		
		if (isEmpty(regfrm.Message.value)){
        if (isEmpty(err))
			focus="#comments";
        	err += "You must provide some Message.\n";
		};
		
	
    // check if any errors have been generated, if so display alert

    if (err != "") {
        var msg = "The form was not submitted.\n";
        msg += "Please fill in all required fields and resubmit. Thank you.\n\n" + err;
        alert(msg);
        location.href = focus;
        return false;
    }
    // all checks validated, allow form to be submitted
    return true;
}
