﻿// JScript File

function CheckSize(strPath)
{
	var objFS,objFile;
	var boolSuccess;
	var MAX_FILE_SIZE = 30000;
	
	 objFS=new ActiveXObject("Scripting.FileSystemObject");
	 objFile=objFS.GetFile(strPath);
	
	boolSuccess=true;
	
	if (objFile.size>MAX_FILE_SIZE)
	{
		alert( "File size should be less than " +  MAX_FILE_SIZE)
		document.form1.reset();
		document.getElementById("imgPhoto").src="images/Logo.jpg";
		boolSuccess=false;
	}
	
	
    var strFileName=objFile.Name
    strFileName=strFileName.toLowerCase();
    if((strFileName.indexOf("jpg")==-1) && (strFileName.indexOf("jpeg")==-1))
    {
      alert("only JPEG images are allowed");
        document.form1.reset();
        boolSuccess=false;
    }
    if (boolSuccess)
        document.getElementById("imgPhoto").src=strPath;
    
    
	 objFile=null;
	 objFS=null;
}

