//--------------------------------------------------------------------------------------  
// Ted41
function onMenuItemSelect(objList)
{
    var nStart, nPos, sMenuItemType, sCmd;
   
    sCmd = objList.options[objList.selectedIndex].value;
   
    objList.selectedIndex=0;  // Restore selection to the first item in the list - category name 
      
    if(sCmd.length==0)
        return;

    if(sCmd == 'NothingToDo')
        return;

    //alert(sCmd);
    eval(sCmd);
    
    return;
}

//--------------------------------------------------------------------------------------  
function openExternalAppND(name, link, path, standalone, extra)
{
     var today=new Date();
     var expires=new Date(today.getTime()+(10000)); //add ten sec to expire fromportal_ cookie
     
     var url_match = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;
     var rr = url_match(link);
     if(rr!=null)
     {
       //if we are going to a different domain, setup alternative login param
       if(rr[1]!=location.host)
       {
         if(typeof(rr[5])!='undefined' && rr.length!=0)
           link+='&'; //We already have some request string, let's add another param
         else
           link+='?'; //No query string yet, add q-mark and then param
         
         link += 'ucb='+encodeBase64(Get_Cookie("CAMUSR")+':'+Get_Cookie("CAMPWD"));
         //alert(link);
       }
     }  


     if(path && path.length > 0)
     {
         var td = new Date();
	 td.setTime(td.getTime()-24*3600*1000);
	 
         //Set_Cookie("CAMPWD", "", td, path);
         //Set_Cookie("CAMUSR", "", td, path);
	   
	 if(path!="/biancoresearch")
	 {
           Set_Cookie("CAMPWD", Get_Cookie("CAMPWD"), null, path);
           Set_Cookie("CAMUSR", Get_Cookie("CAMUSR"), null, path);
           Set_Cookie("fromportal_", "yes", expires, path);
	 }
	 else
	 {
	   //If user has keep password switched on, let's also store
	   //name/password pair for biancoresearch, so that even
	   //if the browser was closed after login, user will be able to 
	   //open links to bianco research site.
	   if(Get_Cookie("CAMSPWD") == "true")
	     pwdExpDate = new Date(2020, 11, 31);
	   else
	     pwdExpDate=null;  
	     
          //cg031126
	  if(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.test(location.hostname))
          {
	   Set_Cookie("CAMPWD", Get_Cookie("CAMPWD"), pwdExpDate, path);
          }
	  else
	  {
	   Set_Cookie("CAMPWD", Get_Cookie("CAMPWD"), pwdExpDate, path,location.host);//ROMA-TEST, location.hostname);
	  } 
	  Set_Cookie("CAMUSR", Get_Cookie("CAMUSR"), pwdExpDate, path);
	 }  
     }
  
     if(extra)
        Set_Multiple_Cookies(extra, path);

     if(standalone && standalone=="yes")
     {
       //Roma - added code to make sure window is opened wide enough to show Bianco header.
       //This is basically only need for Bianco site, but I didn't want to find out
       //how to detect if this is Bianco site being opened.
      
       wname="";
       //uncomment the following to make all bianco links open in the same window.
       if(path=="/biancoresearch")
          wname="BiancoPage";
       
       p="location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=850";
       
       //rg - special for Charting -no menu, no toolbar, no bookmarks... nothing needed for this window
       if(link.match(/\/rms\/rms_charting\.html$/))
         p="location=no,menubar=no,scrollbars=no,status=yes,toolbar=no,resizable=yes";
       
       if(self.outerHeight) //NN
	 o=window.open(link,wname,p+",height="+self.outerHeight); // open external app in a separate window
       else
         o=window.open(link,wname,p);
	 
	o.focus(); 
	 
     }	
     else
     {
        top.frmWork.location=link;
     }
}

//--------------------------------------------------------------------------------------  
function openInternalAppND(link)
{
    top.frmWork.location=link;
}

//--------------------------------------------------------------------------------------  

function superOpenLink(li, di, pdfi, modei, can_publicate)
{
    var fullLink="";
    needFocus=false;
    
    li=unescape(li);
    li=li.replace(/%20/g,' ');
    di=unescape(di);
    nm=normalizeName(di);
    
    if(modei==1) //our resource - open in the window without toolbar, menu, etc...
    {
	params = 'height=650,width=950,toolbar=no,location=no,resizable=yes';
	wndParams='link='+escape(li)+'&name='+escape(di)+'&pub='+can_publicate+'&pdf="'+pdfi+'"';
	fullLink='objFrameSet.html?'+wndParams+'';
	needFocus=true;
    }
    else if(modei==2) //external url, open in the normal browser window
    {
        params = 'height=650,width=950,toolbar=yes,location=yes,menubar=yes,status=yes,resizable=yes,scrollbars=yes';
	li=li.replace(/ /g,'+');
	fullLink=li;
    }
    // Ted35 start------------------------------------------------------------	
    else if(modei==3) // PlPal reports version 2
    {
	params = 'height=650,width=950,toolbar=no,location=no,resizable=yes';
	li=li.replace(/ /g,'+');
	fullLink=li;
    }	
    // Ted35 end--------------------------------------------------------------	
    
    var w = window.open(fullLink,nm,params);

    if(needFocus)
    {
	//w.focus();
	//w.bdy.focus();
	//w.focus();
    }
    
    //var w = window.open(l,'','toolbar=no,locationbar=no');
}


function normalizeName(d)
{
    //replace all non-alpha and non-digit and not underscore with underscore.
    var t=d;
    tt=/\W/g; //see help for RegEx in Javascript reference.
    t=t.replace(tt,'_');
    return t;
}


