// JavaScript Document




/**************************************************************/
/* You may freely distribute and modify the following code,   */
/* but please don't delete the refference to my email id, so  */
/* that people could ask the updates on it ... THANK YOU      */
/* AUTHOR: Rajesh (Kochu)                                     */
/* EMAIL: rajeshkochu@hotmail.com                             */
/**************************************************************/

function checkUploadQFile()
{
	//alert('checkUploadQFile called');
//Checks wheather any file is present for uploading
if(document.frm.questionImage.value=="")
{
// alert("Please select the image")
return true;
}
var t=document.frm.questionImage.value
var f=t.split('.')
if (f.length>2)
{
	alert("The file type is not Correct or please check the file type...")
	document.frm.btnSubmit.value='Save Question';
	return false
}
else
{
// You can modify the file extentions to which ever file extensions you want to unblock
// Example you can modify ".jpg" extension to ".bmp" extension if you want to allow ".bmp" //file to upload.

if(
	(document.frm.questionImage.value.lastIndexOf(".jpg")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".jpeg")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".jpe")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".pjpeg")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".gif")==-1) &&
	(document.frm.questionImage.value.lastIndexOf(".JPG")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".JPEG")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".JPE")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".PJPEG")==-1) && 
	(document.frm.questionImage.value.lastIndexOf(".GIF")==-1)
	)
{

alert("You can upload only GIF, JPG, JPEG, JPE and PJPEG extension files")
document.frm.btnSubmit.value='Save Question';
return false;
}
}
// alert('changing button text');
document.frm.btnSubmit.value='Please wait...';
document.frm.btnSubmitWithTEKS.value='Please wait...';
return true;

}

// same as checkUploadQFile above, except that
// this script is engineered to work with answer image
// uploads.
function checkUploadAFile()
{
	// alert('checkUploadAFile called');
	//Checks wheather any file is present for uploading
	if(document.frm.answerImage.value=="")
	{
		// alert("Please select the image")
		return true;
	}
	var t=document.frm.answerImage.value
	var f=t.split('.')
	if (f.length>2)
	{
		alert("The file type is not Correct or please check the file type...")
		document.frm.btnSubmit.value='Save Answer';
		return false
	} else {
		// You can modify the file extentions to which ever file extensions you want to unblock
		// Example you can modify ".jpg" extension to ".bmp" extension if you want to allow ".bmp" //file to upload.
		
		if(
			(document.frm.answerImage.value.lastIndexOf(".jpg")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".jpeg")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".jpe")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".pjpeg")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".gif")==-1) &&
			(document.frm.answerImage.value.lastIndexOf(".JPG")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".JPEG")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".JPE")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".PJPEG")==-1) && 
			(document.frm.answerImage.value.lastIndexOf(".GIF")==-1)
			)
		{
		
			alert("You can upload only GIF, JPG, JPEG, JPE and PJPEG extension files");
			document.frm.btnSubmit.value='Save Answer';
			return false;
		}
	}
	return true;

}
/**********************************************/
/*   Done with Image Upload Checking Script   */
/**********************************************/
