//Author: Joby Mavelikara - Dec 2009 to Feb 2010

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
{
//if(document.getElementById('iframetop')!=null)
//    {
//		//Fix for overlapping dropdowns
//		// show layer
//		//alert('gg');
//        var layer = document.getElementById(anylinkmenu3.id);
//        layer.style.display = 'block';
//        // show IFRAME
//        var iframe = document.getElementById('iframetop');
//        iframe.style.display = 'block';
//        iframe.style.width = layer.offsetWidth-5;
//        iframe.style.height = layer.offsetHeight-5;
//        iframe.style.left = layer.offsetLeft;
//        iframe.style.top = layer.offsetTop;
//    }   
obj.visibility=visible
}
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
//dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")-22+"px"
//dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+11+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}



function load()
{
 window.opener.document.forms[0].modal=true;
}
function fileLink(upload)
{
       var path=document.getElementById("HiddenField1").value;
        var index=-1;
        var cnt=0,i,filename;
      
        if(upload==0)
        {
            for(i=1;i<=document.form1.length-1;i++)
		    {			
                if(document.form1.elements[i].checked)
			    {	
			    
                    filename=document.form1.elements[i].value;
                    index=filename.lastIndexOf(".");
                  
    	        }	
		    }
		    if(checkFolder(index)==true)
		    {
		       getLink(path,filename);
	        }
	    }
	    else
	    {
//	        alert(document.getElementById("HiddenField3").value);
//	        alert(upload);
            filename=document.getElementById("HiddenField3").value;
            getLink(path,filename);
	    }
}

function getLink(path,filename)
{
            path=path+"\\"+filename;
        		
	            var strReplaceAll = path;
                var intIndexOfMatch = strReplaceAll.indexOf( "\\" );

                while (intIndexOfMatch != -1)
                {

                     strReplaceAll = strReplaceAll.replace( "\\", "/" )
                     intIndexOfMatch = strReplaceAll.indexOf( "\\" );
                }
                path=strReplaceAll;
                     
                       //start replace more than one instance of \\

                var strReplaceAll = path;

                var intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                            // Loop over the string value replacing out each matching

                            // substring.

                while (intIndexOfMatch != -1)
                {
                            // Relace out the current instance.

                    strReplaceAll = strReplaceAll.replace( "\\\\", "\\" );

                            // Get the index of any next matching substring.

                   intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                }
                path=strReplaceAll;

                            //end replace more than one instance of \\

                          if(path.indexOf("Uploads")!=-1)
                 {
                    if(path.indexOf("Uploads")<1)
                    {
                            path="Uploads"+path;

                    }

		            path=path.substr(path.indexOf("Uploads"));
		        }
		        else if(path.indexOf("CustomerPortal")!=1)
                 {
                    if(path.indexOf("CustomerPortal")<1)
                    {
                            path="CustomerPortal"+path;

                    }

		            path=path.substr(path.indexOf("CustomerPortal"));
		        }
		        
                  
                 var tt=document.getElementById("HiddenField2").value;
	           // alert(tt);
	            window.opener.document.getElementById(tt).value=path;
                 self.close();
}
function checkform_Script_Index(varemail)
        {
            //alert('in');
	        if(varemail.value.length<=0)
	        {
	            alert("Please Enter Text for Search");
	            varemail.focus();
	            return false;
	        }
	        
         }
         
         function checkform_Script_Folder(varfolder)
        {
            //alert('in');
	        if(varfolder.value.length<=0)
	        {
	            alert("Enter Folder Name");
	            varfolder.focus();
	            return false;
	        }
	        
         }

function checkFolder(index)
{
    if(index==-1)
    {
        alert('Select File'); 
             return false;
    }
    else
        return true;
}

function aspxLink()
{
   
        var path=document.getElementById("HiddenField1").value;
       
        var cnt=0,i,filename;
        
        for(i=1;i<=document.form1.length-1;i++)
		{					
            if(document.form1.elements[i].checked)
			{	
                filename=document.form1.elements[i].value;
                
    	    }	
		}
		path=path+"\\"+filename;
		
	    var strReplaceAll = path;
        var intIndexOfMatch = strReplaceAll.indexOf( "\\" );

        while (intIndexOfMatch != -1)
        {

             strReplaceAll = strReplaceAll.replace( "\\", "/" )
             intIndexOfMatch = strReplaceAll.indexOf( "\\" );
        }
        path=strReplaceAll;
             
               //start replace more than one instance of \\

        var strReplaceAll = path;

        var intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                    // Loop over the string value replacing out each matching

                    // substring.

        while (intIndexOfMatch != -1)
        {
                    // Relace out the current instance.

            strReplaceAll = strReplaceAll.replace( "\\\\", "\\" );

                    // Get the index of any next matching substring.

           intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

        }
        path=strReplaceAll;

                    //end replace more than one instance of \\

        if(path.indexOf("WebForm")<1)
        {
                path="WebForm"+path;
        }

		path=path.substr(path.indexOf("WebForm"));
    
	    var tt=document.getElementById("HiddenField2").value;
	  
	    window.opener.document.getElementById(tt).value=path;
		
		 // window.opener.document.forms[0].HiddenField1.value=path;
	  //  window.opener.document.forms[0].submit();
		
         self.close();
	
}
function validateCheck()
{
    var cnt=0,i;
    for(i=1;i<=document.form1.length-1;i++)
	{	
	   
		a=document.form1.elements[i].name
									
		if (a.indexOf("chkDLFile")>=0)
		{	
			if(document.form1.elements[i].checked)
			{			
				cnt=cnt+1;				
			}
		}
	}	
	if(cnt>1)
	{
       alert('only one record should be selected'); 
             return false;
     }
     else
  		if(cnt<1)
		{
             alert('Please select a record'); 
                     return false;
        }
        else  
        {
              return true;
        }              
          
}
 
 function selectFile(id,chkit)
 {
 
    var index,i,check=false;
  document.getElementById(chkit).checked=false;
  
   index=document.form1.txtPath.value.lastIndexOf("/");
   var file=document.form1.txtPath.value.substring(index+1,document.form1.txtPath.value.length);
  
  
    for(i=1;i<=document.form1.length-1;i++)
	{	
	   
		a=document.form1.elements[i].name
									
		if (a.indexOf("chkDLFile")>=0)
		{	
		    if(document.form1.elements[i].checked==true)
		    {
		        check=true;
		    }
			document.form1.elements[i].checked=false;
		}
	}
	
	document.getElementById(chkit).checked=true;
    if(check==true)
    {
        index=document.form1.txtPath.value.lastIndexOf("/");
        if(index>=0)
        {
        document.form1.txtPath.value=document.form1.txtPath.value.substring(0,index);
           var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
 
        }
       
    document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
      var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
    if(file==document.getElementById(chkit).value)
    {
        document.form1.txtPath.value=document.form1.txtPath.value;
          var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
        document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
          var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    }

 }           
 
 function selectFile1(id,chkit)
 {
 
    var index,i,check=false;
  document.getElementById(chkit).checked=false;
  
  index=document.form1.txtPath.value.lastIndexOf("/");
   var file=document.form1.txtPath.value.substring(index+1,document.form1.txtPath.value.length);
    for(i=1;i<=document.form1.length-1;i++)
	{	
	   
		a=document.form1.elements[i].name
									
		if (a.indexOf("chkGRFile")>=0)
		{	
		    if(document.form1.elements[i].checked==true)
		    {
		        check=true;
		    }
			document.form1.elements[i].checked=false;
		}
	}
	
	document.getElementById(chkit).checked=true;
    if(check==true)
    {
        index=document.form1.txtPath.value.lastIndexOf("/");
        if(index>=0)
        {
        document.form1.txtPath.value=document.form1.txtPath.value.substring(0,index);
          var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
        
        }
       
    document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
      var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
    if(file==document.getElementById(chkit).value)
    {
        document.form1.txtPath.value=document.form1.txtPath.value;
          var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
        document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
          var path=document.form1.txtPath.value;
          if(path.indexOf("Uploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("Uploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    }

 }  



function aspxLinkNew()
{
   
        var path=document.getElementById("HiddenField1").value;
      // alert(path);
        var cnt=0,i,filename;
        
//        for(i=1;i<=document.form1.length-1;i++)
//		{					
//            if(document.form1.elements[i].checked)
//			{	
//                filename=document.form1.elements[i].value;
//                
//    	    }	
//		}
//		path=path+"\\"+filename;
		
	    var strReplaceAll = path;
        var intIndexOfMatch = strReplaceAll.indexOf( "\\" );

        while (intIndexOfMatch != -1)
        {

             strReplaceAll = strReplaceAll.replace( "\\", "/" )
             intIndexOfMatch = strReplaceAll.indexOf( "\\" );
        }
        path=strReplaceAll;
             
               //start replace more than one instance of \\

        var strReplaceAll = path;

        var intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                    // Loop over the string value replacing out each matching

                    // substring.

        while (intIndexOfMatch != -1)
        {
                    // Relace out the current instance.

            strReplaceAll = strReplaceAll.replace( "\\\\", "\\" );

                    // Get the index of any next matching substring.

           intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

        }
        path=strReplaceAll;

                    //end replace more than one instance of \\

//        if(path.indexOf("WebForm")<1)
//        {
//                path="WebForm"+path;
//        }

//		path=path.substr(path.indexOf("WebForm"));
   // alert(path)
	    var tt=document.getElementById("HiddenField2").value;
	  
	    window.opener.document.getElementById(tt).value=path;
		
		 // window.opener.document.forms[0].HiddenField1.value=path;
	  //  window.opener.document.forms[0].submit();
		
         self.close();
	
}











/////////////////Research UPLOADS///////////////////////
function fileResearchLink(upload)
{
       var path=document.getElementById("HiddenField1").value;
        var index=-1;
        var cnt=0,i,filename;
      
        if(upload==0)
        {
            for(i=1;i<=document.form1.length-1;i++)
		    {			
                if(document.form1.elements[i].checked)
			    {	
			    
                    filename=document.form1.elements[i].value;
                    index=filename.lastIndexOf(".");
                  
    	        }	
		    }
		    if(checkFolder(index)==true)
		    {
		       getResearchLink(path,filename);
	        }
	    }
	    else
	    {
//	        alert(document.getElementById("HiddenField3").value);
//	        alert(upload);
            filename=document.getElementById("HiddenField3").value;
            getResearchLink(path,filename);
	    }
}

 function selectFileResearch(id,chkit)
 {
    var index,i,check=false;
    document.getElementById(chkit).checked=false;
  
    index=document.form1.txtPath.value.lastIndexOf("/");
    var file=document.form1.txtPath.value.substring(index+1,document.form1.txtPath.value.length);
  
  
    for(i=1;i<=document.form1.length-1;i++)
	{	
	   
		a=document.form1.elements[i].name
									
		if (a.indexOf("chkDLFile")>=0)
		{	
		    if(document.form1.elements[i].checked==true)
		    {
		        check=true;
		    }
			document.form1.elements[i].checked=false;
		}
	}
	
	document.getElementById(chkit).checked=true;
    if(check==true)
    {
        index=document.form1.txtPath.value.lastIndexOf("/");
        if(index>=0)
        {
        document.form1.txtPath.value=document.form1.txtPath.value.substring(0,index);
           var path=document.form1.txtPath.value;
          if(path.indexOf("ResearchUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("ResearchUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
 
        }
       
    document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
      var path=document.form1.txtPath.value;
          if(path.indexOf("ResearchUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("ResearchUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
    if(file==document.getElementById(chkit).value)
    {
        document.form1.txtPath.value=document.form1.txtPath.value;
          var path=document.form1.txtPath.value;
          if(path.indexOf("ResearchUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("ResearchUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
        document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
          var path=document.form1.txtPath.value;
          if(path.indexOf("ResearchUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("ResearchUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    }

 }        
 
 
 
function getResearchLink(path,filename)
{
            path=path+"\\"+filename;
            // alert(path);
        		
	            var strReplaceAll = path;
                var intIndexOfMatch = strReplaceAll.indexOf( "\\" );

                while (intIndexOfMatch != -1)
                {

                     strReplaceAll = strReplaceAll.replace( "\\", "/" )
                     intIndexOfMatch = strReplaceAll.indexOf( "\\" );
                }
                path=strReplaceAll;
                     
                       //start replace more than one instance of \\

                var strReplaceAll = path;

                var intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                            // Loop over the string value replacing out each matching

                            // substring.

                while (intIndexOfMatch != -1)
                {
                            // Relace out the current instance.

                    strReplaceAll = strReplaceAll.replace( "\\\\", "\\" );

                            // Get the index of any next matching substring.

                   intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                }
                path=strReplaceAll;

                            //end replace more than one instance of \\

                          if(path.indexOf("ResearchUploads")!=-1)
                 {
                    if(path.indexOf("ResearchUploads")<1)
                    {
                            path="ResearchUploads"+path;

                    }

		            path=path.substr(path.indexOf("ResearchUploads"));
		        }
		        else if(path.indexOf("CustomerPortal")!=1)
                 {
                    if(path.indexOf("CustomerPortal")<1)
                    {
                            path="CustomerPortal"+path;

                    }

		            path=path.substr(path.indexOf("CustomerPortal"));
		        }
		        
                  
                 var tt=document.getElementById("HiddenField2").value;
	            // alert(tt);
	            
	            window.opener.document.getElementById(tt).value=path;
                 self.close();
}

///////////////////DEPARTMENT UPLOADS/////////////


function fileDepartmentLink(upload)
{
       var path=document.getElementById("HiddenField1").value;
        var index=-1;
        var cnt=0,i,filename;
      
        if(upload==0)
        {
            for(i=1;i<=document.form1.length-1;i++)
		    {			
                if(document.form1.elements[i].checked)
			    {	
			    
                    filename=document.form1.elements[i].value;
                    index=filename.lastIndexOf(".");
                  
    	        }	
		    }
		    if(checkFolder(index)==true)
		    {
		       getDepartmentLink(path,filename);
	        }
	    }
	    else
	    {
            filename=document.getElementById("HiddenField3").value;
            getDepartmentLink(path,filename);
	    }
}


 function selectFileDepartment(id,chkit)
 {
    var index,i,check=false;
    document.getElementById(chkit).checked=false;
  
    index=document.form1.txtPath.value.lastIndexOf("/");
    var file=document.form1.txtPath.value.substring(index+1,document.form1.txtPath.value.length);
  
  
    for(i=1;i<=document.form1.length-1;i++)
	{	
	   
		a=document.form1.elements[i].name
									
		if (a.indexOf("chkDLFile")>=0)
		{	
		    if(document.form1.elements[i].checked==true)
		    {
		        check=true;
		    }
			document.form1.elements[i].checked=false;
		}
	}
	
	document.getElementById(chkit).checked=true;
    if(check==true)
    {
        index=document.form1.txtPath.value.lastIndexOf("/");
        if(index>=0)
        {
        document.form1.txtPath.value=document.form1.txtPath.value.substring(0,index);
           var path=document.form1.txtPath.value;
          if(path.indexOf("DeptUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("DeptUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
 
        }
       
    document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
      var path=document.form1.txtPath.value;
          if(path.indexOf("DeptUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("DeptUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
    if(file==document.getElementById(chkit).value)
    {
        document.form1.txtPath.value=document.form1.txtPath.value;
          var path=document.form1.txtPath.value;
          if(path.indexOf("DeptUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("DeptUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    else
    {
        document.form1.txtPath.value=document.form1.txtPath.value+"/"+document.getElementById(chkit).value;	
          var path=document.form1.txtPath.value;
          if(path.indexOf("DeptUploads")!=-1)
           {
                  document.form1.txtPath1.value=path.slice(path.indexOf("DeptUploads"));
		   }
		   else if(path.indexOf("CustomerPortal")!=1)
           {
                 document.form1.txtPath1.value=path.slice(path.indexOf("CustomerPortal"));  
		   }
    }
    }

 }        
 
 
 
   
   
   
   
   
function getDepartmentLink(path,filename)
{
            path=path+"\\"+filename;
            // alert(path);
        		
	            var strReplaceAll = path;
                var intIndexOfMatch = strReplaceAll.indexOf( "\\" );

                while (intIndexOfMatch != -1)
                {

                     strReplaceAll = strReplaceAll.replace( "\\", "/" )
                     intIndexOfMatch = strReplaceAll.indexOf( "\\" );
                }
                path=strReplaceAll;
                     
                       //start replace more than one instance of \\

                var strReplaceAll = path;

                var intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                            // Loop over the string value replacing out each matching

                            // substring.

                while (intIndexOfMatch != -1)
                {
                            // Relace out the current instance.

                    strReplaceAll = strReplaceAll.replace( "\\\\", "\\" );

                            // Get the index of any next matching substring.

                   intIndexOfMatch = strReplaceAll.indexOf( "\\\\" );

                }
                path=strReplaceAll;

                            //end replace more than one instance of \\

                          if(path.indexOf("DeptUploads")!=-1)
                 {
                    if(path.indexOf("DeptUploads")<1)
                    {
                            path="DeptUploads"+path;

                    }

		            path=path.substr(path.indexOf("DeptUploads"));
		        }
		        else if(path.indexOf("CustomerPortal")!=1)
                 {
                    if(path.indexOf("CustomerPortal")<1)
                    {
                            path="CustomerPortal"+path;

                    }

		            path=path.substr(path.indexOf("CustomerPortal"));
		        }
		        
                  
                 var tt=document.getElementById("HiddenField2").value;
	            // alert(tt);
	            
	            window.opener.document.getElementById(tt).value=path;
                 self.close();
}
