function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submitting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg
if(x==1){alert(msg); return false;}
}

//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
}

//Delete news release check
function delCheck() {
	var conf = confirm("This record will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}
	
//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 = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';
 	
// 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 illegal characters for url
function checkIllegweb(va)
{
	var stripped = stripCharsInBag (va, illegalCharStrWeb);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}



//Subscribe Form Validation
function ggAmbRegValidate(){
	var x=0;
	var err_msg=""
	if (!document.GGForm.name.value) {
		err_msg=err_msg+"Name\n"; x=1;
		}
	if (!document.GGForm.indid.value) {
		err_msg=err_msg+"Industry\n"; x=1;
		}	
	if (!document.GGForm.cntry.value) {
		err_msg=err_msg+"Country\n"; x=1;
		}	
	if (!document.GGForm.email.value) {
		err_msg=err_msg+"Email\n"; x=1;
		}
		else {
		email = document.GGForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Incorrect Email Address\n"; x=1;
			}
		}	
	if (!document.GGForm.tel.value) {
		err_msg=err_msg+"Tel\n"; x=1;
		}
	if (!document.GGForm.captcha.value)
        {
         err_msg=err_msg+"Authorization Code\n"; x=1;
        }
	else if (document.GGForm.captcha.value !=  document.GGForm.captcha1.value)
        {
         err_msg=err_msg+"Incorrect Authorization Code\n"; x=1;
        }	
	return msg(err_msg,x)
	}	


//Subscribe Form Validation
function ggAmbReqValidate(){
	var x=0;
	var err_msg=""
	
	
	if (!document.GGForm.company.value) {
		err_msg=err_msg+"Organisation/Corporate\n"; x=1;
		}
	if (!document.GGForm.name.value) {
		err_msg=err_msg+"Name of Contact\n"; x=1;
		}
	if (!document.GGForm.cntry.value) {
		err_msg=err_msg+"Country\n"; x=1;
		}	
	if (!document.GGForm.email.value) {
		err_msg=err_msg+"Email\n"; x=1;
		}
		else {
		email = document.GGForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Incorrect Email Address\n"; x=1;
			}
		}	
	if (!document.GGForm.tel.value) {
		err_msg=err_msg+"Tel\n"; x=1;
		}
	if (!document.GGForm.captcha.value)
        {
         err_msg=err_msg+"Authorization Code\n"; x=1;
        }
	else if (document.GGForm.captcha.value !=  document.GGForm.captcha1.value)
        {
         err_msg=err_msg+"Incorrect Authorization Code\n"; x=1;
        }	
	return msg(err_msg,x)
	}	


//Subscribe Form Validation
function ggAmbLgnValidate(){
	var x=0;
	var err_msg=""
	if (!document.GGForm.email.value) {
		err_msg=err_msg+"Email\n"; x=1;
		}
		else {
		email = document.GGForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Incorrect Email Address\n"; x=1;
			}
		}	
	if (!document.GGForm.pswd.value) {
		err_msg=err_msg+"Password\n"; x=1;
		}
	if (!document.GGForm.captcha.value)
        {
         err_msg=err_msg+"Authorization Code\n"; x=1;
        }
	else if (document.GGForm.captcha.value !=  document.GGForm.captcha1.value)
        {
         err_msg=err_msg+"Incorrect Authorization Code\n"; x=1;
        }	
	return msg(err_msg,x)
	}	
	
