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]+$/;

var RegexUrl = /^(http(s?):\/\/{1})((\w+\.){1,})\w{2,}(\/?)$/i;
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';


var whitespace = " \t\n\r";
// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
// 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;
}

//check for tel number
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

//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
}

// 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;
}

//Upload Image form Validation
//Uses function msg() defined at top



	
//Delete Image form Validation
//Pastry display form validate
function delimgValidate(){
	var x=0;
	var err_msg="";
	var tmp = 0;
	//delete image check
		var conf = confirm("The image will be permanently deleted from the server.\nAre you sure?")
		if(!conf) 
			return false;
		else
			return true;
		
	}		
	
	
	//Delete Image form Validation
//Pastry display form validate
function delcamValidate(){
	var x=0;
	var err_msg="";
	var tmp = 0;
	//delete image check
		var conf = confirm("The campaign will be permanently deleted from the server.\nAre you sure?")
		if(!conf) 
			return false;
		else
			return true;
		
	}		
		

// UPLOAD IMAGES -----------------------------------------------------------------



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+"\n\n"
if(x==1){alert(msg); return false;}
return true;
}
function EnquiryValidate(){
	
		var x=0;
	var err_msg="";
		
		if(document.revForm.title.value==""){
		err_msg=err_msg+"Enquiry Title\n"; x=1;
		}
		if(document.revForm.uname.value==''){
		err_msg=err_msg+"Your Name\n"; x=1;
		}
		if(document.revForm.enquiry.value==""){
		err_msg=err_msg+"Enquiry details\n"; x=1;
		}
	
		if(document.revForm.email.value=="")
		{
			 err_msg=err_msg+"Your E-mail Address.\n";x=1;
		}
		if(document.revForm.email.value!="")
		{
			
		
			if (document.revForm.email.value.indexOf("@", 0) < 0)
    		{
       			 err_msg=err_msg+"Invalid E-mail Address.\n";x=1;
       
    		}
    		else if (document.revForm.email.value.indexOf(".", 0) < 0)
    		{
       			err_msg=err_msg+"Invalid E-mail Address.\n";x=1;
    		}
		
		}
		if(document.revForm.code.value==""){
		err_msg=err_msg+"Verification\n"; x=1;
		}
			
		return msg(err_msg,x)
    }
	
