﻿function checkEmail(emailAddress) {

	var foundAtSymbol = 0;
	var foundDot = 0;
	var md;

	// Go through each character in the email address.
	for (var x=0; x<emailAddress.length - 1; x++) {
		md = emailAddress.substr(x, 1);
	
		// Is the character an @ symbol?
		if (md == '@') foundAtSymbol++;
	
		// Count how many dots there are after the @ symbol.
		if (md == '.' && foundAtSymbol == 1) foundDot++;
	}

	// Is there only one @ symbol, and are there more than one dots?
	if (foundDot > 0 && foundAtSymbol == 1) {
		return true;
	} else {
		return false;
	}
}
function checkFileExt(fname,ftype) {
	var returnFlag = false;
	var ext = fname.substring(fname.lastIndexOf('.'),fname.length).toLowerCase();
	if(ftype == 'Image') {
		var extList = ['.jpg','.jpeg','.gif','.png'];
	}
	if(ftype == 'Video') {
		var extList = ['.mpg','.mpeg','.mp4','.flv'];
	}
	if(ftype == 'Audio') {
		var extList = ['.mp3'];
	}
	if(ftype == 'Document') {
		var extList = ['.txt','.doc','.pdf'];
	}
	for(var i=0;i<extList.length;i++) {
		if(ext == extList[i]) {
			returnFlag = true;
		}
	}
	return returnFlag;
}