// foJSUtilities.js

//global variables
var secs = 0
//global variables end

//JSDOC: To check if the document being uploaded is a PDF File
function isFileTypePDF(filePath)
{
	if(filePath == "")
	{
		return true;
	}
	var length = filePath.length;
	
	if(length < 4)
	{
		return false;
	}
	var last4 = filePath.substring(length-4, length);
	var upper = last4.toUpperCase();
	if(upper != '.PDF')
	{
		return false;
	}
}

// JSDOC To take out the file name from file Path
function getFileName(filePath)
{
	if(filePath=="")
	{
	   return null;
	}   
	var length=filePath.length;
	var stpos=filePath.lastIndexOf("\\");
	if(stpos>0)
	{	
		var strName=filePath.substring(stpos+1,length);
	}
	else
	{
	    stpos=filePath.lastIndexOf("/");
        strName=filePath.substring(stpos+1,length);
    }    	
	return strName;
}



function openEQMSTokenWindow(openEQMSWindow){

if (openEQMSWindow ==true)
{
	loadmode();
}
	
return false;
}

function loadmode(){

if (document.all){
	  var param = "fullscreen=yes;center:yes;resizable:yes;status:yes;scroll:no;titlebar:no";
	  showModalDialog("/"+contextRoot+"/dca/jsp/common/EQMSToken.html",'',param);

}
else alert("You need IE to see example")
}

// @148499 : to open a new window
function openNewWindow(url){
            var newWindow = window.open(url,"FormWindow",'toolbar=0,status=1,menubar=0,resizable=1,scrollbars=1');
			newWindow.focus();

}

//JSDOC: To calculate time for uplading a file to the server

function UploadTime()
    {
    secs=eval(parseInt(secs) + 1);
     
    if(secs<60)
      {
         document.forms[0].sec.value=secs;
         document.forms[0].min.value=0;
      }
      else
      {
         s=eval(parseInt(secs)%60);
         m=Math.round(eval(parseInt(secs)/60));
         document.forms[0].sec.value=s;
         document.forms[0].min.value=m;

      }
      
      window.setTimeout("UploadTime()", 1000);
    } 

//JSDOC: This method will be used to submit an html form while progress bar displays

function submitWithProgBar(method)
{
	centerLayer('progressLayer', 0, 0);
	showLayer('progressLayer');
	UploadTime();
	document.forms[0].method.value = method;
	document.forms[0].submit();   
	document.images["progressImg"].src = "/"+contextRoot+"/dca/images/common/uploading.gif";
}
//JSDOC: This method will be used to set the focus on a particular element

function focusOnMainElement(elementInst)
{

  if (document.forms.length > 0) {
   document.forms[0].elements[elementInst].focus();

 }



}

