function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submiting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg+"\n\n"
if(x==1){alert(msg); return false;}
}

//for email addresses
var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

//illegal characters in fields
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';
 	
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//check for illegal characters
function checkIlleg(va)
{
	var stripped = stripCharsInBag (va, illegalCharStr);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check for tel number
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

var whitespace = " \t\n\r";

// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace (s)
{   var i;
    // Is s empty?
    if (isEmpty(s)) return true;
    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


//Verify TEXTAREA field - general
function VerifyMsg(f_ld,c_nt,cnt_fld) {

	var len = f_ld.value.length
	var cl

	if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
		f_ld.value = ""
		len = 0
	}
	if (len > (c_nt-10)) {
		f_ld.value = f_ld.value.substring(0, c_nt)
		cl = 0
	}
	else {
		cl = c_nt - len
	}
	eval(cnt_fld).value = cl
}

//validate resaturant feedback
function ValRestFb()
{
var x=0;
var err_msg=""	
if(!document.DCG_FB.fb_service[0].checked && !document.DCG_FB.fb_service[1].checked && !document.DCG_FB.fb_service[2].checked)
        {
        err_msg=err_msg+"Quality of Service\n"; x=1;
        }	
if(!document.DCG_FB.fb_quality[0].checked && !document.DCG_FB.fb_quality[1].checked && !document.DCG_FB.fb_quality[2].checked)
        {
        err_msg=err_msg+"Quality of Food\n"; x=1;
        }
if(!document.DCG_FB.fb_cost[0].checked && !document.DCG_FB.fb_cost[1].checked && !document.DCG_FB.fb_cost[2].checked)
        {
        err_msg=err_msg+"Value for money\n"; x=1;
        }	
if(!document.DCG_FB.fb_ambience[0].checked && !document.DCG_FB.fb_ambience[1].checked && !document.DCG_FB.fb_ambience[2].checked)
        {
        err_msg=err_msg+"Ambience\n"; x=1;
        }
if(!document.DCG_FB.fb_rating[0].checked && !document.DCG_FB.fb_rating[1].checked && !document.DCG_FB.fb_rating[2].checked && !document.DCG_FB.fb_rating[3].checked && !document.DCG_FB.fb_rating[4].checked)
        {
        err_msg=err_msg+"Overall Rating\n"; x=1;
        }		
if(!document.DCG_FB.fbd_rcmnd[0].checked && !document.DCG_FB.fbd_rcmnd[1].checked)
        {
        err_msg=err_msg+"Recommend to a friend?\n"; x=1;
        }				
if(document.DCG_FB.cust_comments.value=="")
        {
        err_msg=err_msg+"Comments\n"; x=1;
        }	
if(document.DCG_FB.cust_name.value=="")
        {
        err_msg=err_msg+"Your Name\n"; x=1;
        }			
if(document.DCG_FB.cust_email.value=="")
        {
                err_msg=err_msg+"Email\n"; x=1;		 
        }							
else {
		email = document.DCG_FB.cust_email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}	
if (!document.DCG_FB.cust_age[document.DCG_FB.cust_age.selectedIndex].value)
		{
		err_msg=err_msg+"Age\n"; x=1;		
		}				
if(!document.DCG_FB.agree.checked)
        {
        err_msg=err_msg+"Disclaimer\n"; x=1;
        }										
return msg(err_msg,x);	
}		


//validate feedback select
function ValSelFb()
{
var x=0;
var err_msg=""	
if (!document.DCG_FB.fbcat[document.DCG_FB.fbcat.selectedIndex].value)
		{
		err_msg=err_msg+"Please select any one option\n"; x=1;		
		}								
return msg(err_msg,x);	
}	
