function ValidateFileUploader(FilecontId,Extension,IsRequired){var IsValidFile=true;var FileName=GetFileName(FilecontId);if(IsRequired && FileName=="")
{IsValidFile=false;document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").className="form_input_error";document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").title="Please Select file for Uploading";}
else if(!IsValidFileExtension(FilecontId,Extension)) 
{IsValidFile=false;document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").className="form_input_error";if(Extension=='xls')
document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").title="Please upload Excel files only";else
document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").title="Allowed File Extensions are: " + Extension;}
return IsValidFile;}
function IsValidFileExtension(FilecontId,Extension)
{var IsValidExt=false;if(Extension!="")
{var FileName = GetFileName(FilecontId).toLowerCase();var FnameIndex=FileName.lastIndexOf('.');if(FnameIndex>0)
{var NoofChars=FileName.length-FnameIndex-1;if(Extension.toLowerCase().indexOf(FileName.substr(FnameIndex+1,NoofChars))>=0)
IsValidExt=true;else
IsValidExt=false;}
else
IsValidExt=false;}
else
IsValidExt=true;return IsValidExt;}
function UploadFile(FilecontId,flename,CallBackfunction,MaxFileSize,Extension,Maxwidth,MaxHeight)
{var IsValidExt=IsValidFileExtension(FilecontId,Extension);if(IsValidExt)
{var iFrm=document.getElementById(FilecontId + "_FileUploader");iFrm.contentWindow.document.getElementById("htxtFilePath").value=flename;iFrm.contentWindow.document.getElementById("htxtCallBack").value=CallBackfunction;iFrm.contentWindow.document.getElementById("htxtFileSize").value=MaxFileSize;if(Maxwidth!=null)
{iFrm.contentWindow.document.getElementById("htxtMaxWidth").value=Maxwidth;iFrm.contentWindow.document.getElementById("htxtMaxHeight").value=MaxHeight;}
iFrm.contentWindow.document.form1.submit();}
}
function FileControl(FilecontId)
{var iFrm=document.getElementById(FilecontId + "_FileUploader");return iFrm.contentWindow.document.getElementById("fileUp");}
function GetFileName(FilecontId)
{var ifile=document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").value;var fileName="";if(ifile!="")
{var FnameIndex=ifile.lastIndexOf('\\');if(FnameIndex==-1)
FnameIndex=ifile.lastIndexOf('/');if(FnameIndex>0)
{var NoofChars=ifile.length-FnameIndex-1;fileName=ifile.substr(FnameIndex+1,NoofChars);}
else
{fileName = ifile;}
}
return fileName;}
function ClearFileName(FilecontId)
{document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").value="";}
function ResetFileName(FilecontId)
{var _isIE    = false;if(navigator.appName.indexOf("Microsoft")!=-1)
_isIE=true;if(_isIE)
document.getElementById(FilecontId + "_FileUploader").contentWindow.document.forms[0].reset();else    
document.getElementById(FilecontId + "_FileUploader").contentWindow.document.getElementById("fileUp").value="";}



