// JavaScript Document
function validate_image(file, frm) {
	var types =  /(jpg|jpeg|gif|png)$/i;

	if(file.value != "") {
		var pieces = file.value.split("\\");
		var piece = pieces[pieces.length-1].split(".");
		var imgtype = piece[piece.length-1];
		if(imgtype.search(types) == -1) {
			alert("Invalid file type.\n You can upload only the image files of type *.jpg, *.jpeg, *.gif, *.png etc.\n");
			frm.btnSubmit.disabled=true;
			file.style.backgroundColor="#FFFF99";
			return false;
		}
		else {
			file.style.backgroundColor="#FFFFFF";
			frm.btnSubmit.disabled=false;
			return true;
		}
	}
	else {
		file.style.backgroundColor="#FFFF99";
		return false;
	}
}

function validateForm(frm) {
	if(frm.dimg_file.value == ""){
		alert("Please browse the file to upload.");
		return false
	}
	return true;	
}

function validate_video(file, frm) {
	var types =  /(mov|avi|flv|wmv)$/i;

	if(file.value != "") {
		var pieces = file.value.split("\\");
		var piece = pieces[pieces.length-1].split(".");
		var imgtype = piece[piece.length-1];
		if(imgtype.search(types) == -1) {
			alert("Invalid file type.\n You can upload only the image files of type *.mov, *.flv, *.wmv, *.avi etc.\n");
			frm.btnSubmit.disabled=true;
			file.style.backgroundColor="#FFFF99";
			return false;
		}
		else {
			file.style.backgroundColor="#FFFFFF";
			frm.btnSubmit.disabled=false;
			return true;
		}
	}
	else {
		file.style.backgroundColor="#FFFF99";
		return false;
	}
}
