function validateExt(fieldName) {
	extArray = new Array(".gif", ".jpg", ".png",".GIF", ".JPG", ".PNG");
	
	allowSubmit = false;
	var lenth = fieldName.length ;
	while(fieldName.indexOf("\\") != -1)
	fieldName = fieldName.slice(fieldName.indexOf("\\") + 1);
	ext = fieldName.slice(fieldName.indexOf(".")).toLowerCase();
	
	for(var i = 0; i < extArray.length; i++) 
	{	
		if (extArray[i] == ext) 
		{ 
			allowSubmit = true; break; 
		}
	}
	
	var temp = new Array();
	temp = fieldName.split('.');
	
	if(temp[temp.length-1] == 'gif' || temp[temp.length-1] == 'jpg' || temp[temp.length-1] == 'png' || temp[temp.length-1] == 'GIF' || temp[temp.length-1] == 'JPG' || temp[temp.length-1] == 'PNG')
		allowSubmit = true; 
	else
		allowSubmit = false; 
	
	if (allowSubmit) 
		return true;
	else
	{
		return false;
    }
	return true;}


function validateAudio(fieldName) {
	
	extArray = new Array(".mp3", ".MP3");
	
	allowSubmit = false;
	var lenth = fieldName.length ;
	while(fieldName.indexOf("\\") != -1)
	fieldName = fieldName.slice(fieldName.indexOf("\\") + 1);
	ext = fieldName.slice(fieldName.indexOf(".")).toLowerCase();

	for(var i = 0; i < extArray.length; i++) 
	{	
		if (extArray[i] == ext) 
		{ 
			allowSubmit = true; 
			break; 
		}
	}
	
	var temp = new Array();
	temp = fieldName.split('.');
	
	if(temp[temp.length-1] == 'mp3' || temp[temp.length-1] == 'MP3')
		allowSubmit = true; 
	else
		allowSubmit = false; 
	
	if (allowSubmit) 
		return true;
	else
	{
		return false;
    }
	return true;
}

function validateVideo(fieldName) {
	extArray = new Array(".mpg", ".mpeg", ".avi",".MPG", ".MPEG", ".AVI", ".asf", ".ASF", ".mov", ".MOV", ".mp4", ".MP4", ".divx", ".DIVX", ".wmv", ".WMV", ".dat", ".DAT", ".flv", ".FLV" );
	
	allowSubmit = false;
	var lenth = fieldName.length ;
	while(fieldName.indexOf("\\") != -1)
	fieldName = fieldName.slice(fieldName.indexOf("\\") + 1);
	ext = fieldName.slice(fieldName.indexOf(".")).toLowerCase();
	
	for(var i = 0; i < extArray.length; i++) 
	{	
		if (extArray[i] == ext) 
		{ 
			allowSubmit = true; break; 
		}
	}
	
	var temp = new Array();
	temp = fieldName.split('.');
	
	if(temp[temp.length-1] == 'mpg' || temp[temp.length-1] == 'mpeg' || temp[temp.length-1] == 'avi' || temp[temp.length-1] == 'MPG' || temp[temp.length-1] == 'MPEG' || temp[temp.length-1] == 'AVI' || temp[temp.length-1] == 'asf' || temp[temp.length-1] == 'ASF' || temp[temp.length-1] == 'mov' || temp[temp.length-1] == 'MOV' || temp[temp.length-1] == 'mp4' || temp[temp.length-1] == 'MP4' || temp[temp.length-1] == 'divx' || temp[temp.length-1] == 'DIVX' || temp[temp.length-1] == 'wmv' || temp[temp.length-1] == 'WMV' || temp[temp.length-1] == 'dat' || temp[temp.length-1] == 'DAT' || temp[temp.length-1] == 'flv' || temp[temp.length-1] == 'FLV')
		allowSubmit = true; 
	else
		allowSubmit = false;
	
	if (allowSubmit) 
		return true;
	else
	{
		return false;
    }
	return true;}

//validate the non empty text field in the form.
function LTrim(value) {
	
	//alert(value);
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	}

// Removes ending whitespaces
function RTrim( value ) {
	//alert(value);
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
	}

function isNotValidEmail(value) {
	var str = trim(value); 
	var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
	if (!str.match(re)) 
	{ 
		return true; 
	} 
	return false; }

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					}
	 
function isBlank(value){
	if(trim(value) == "" || trim(value) == null){
		return true;	
	}
	return false;}