// JavaScript

// set browser cookie
if (getCookie("showCalendar") == null){
	setCookie('showCalendar', is_ie5_5up, 3, 'year')
}

// popup windows
var a_opened_window;
function openWindow(url, width, height, title){
  if(!a_opened_window || a_opened_window.closed){
    var window_attributes = "height=" + height + ",width=" + width + ",resizable=yes,scrollbars=yes,menubar=yes"
    if(openWindow.arguments.length > 4){
    var i=4
      for(i; i < openWindow.arguments.length; i++){
        window_attributes += openWindow.arguments[i]
      }
    }
    if(!title || title.length == 0){
      title = "subwindow"
    }
    a_opened_window = window.open(url,title,window_attributes);
  }else{
    a_opened_window.location.href = url
  }
  a_opened_window.focus();
}

// close window, used to close popup windows
  function closeWindow(){       // taken from CORE
    if(a_opened_window){
      a_opened_window.close();
    }
  } 

  function openNewWindow(theUrl, theName, theProperties){ // lihaze: open up a new window
    window.open(theUrl, theName, theProperties);    
  }

/*    lihaze: 09 Auguest 2004:
*       toggleFundCurrencyDisplay and toggleAccountDisplay are almost the same. 
*       toggleFundCurrencyDisplay is for fund and currency drop downs as there is no check for whether "mulitple accounts"
*         has been selected.
*       toggleAccountDisplay is for the accounts selection as this looks for whehter mulitple is selected. 
*       Not put in the subit action as a shared as it muti selected it would re-submit and then open the page which is no hard
*         to the user, but it basically goes and processes the page when there is no reason to
*/  
  
//  lihaze: FUND and CURRENCY dropdown 
  function toggleFundCurrencyDisplay(){        
      var form = document.getElementById("accountSelectorDropdownForm");
      form.submitAccountAction.value = "SAVE";    // Taken from CORE
      form.submit();    
    }
  
//  lihaze: ACCOUNT dropdown ONLY 
  function toggleAccountDisplay(){  
    var form = document.getElementById("accountSelectorDropdownForm");
    var accountSelectValue = form.clientAccount.value   // the value of select as 'accountSelectValue'. If its the multi select thing open in new window.
    if(accountSelectValue == "SELECTMULTIPLE") {  // if its multi-select then call the openNewWindow function
      openNewWindow("/accounts/accounts_selector.do", "accountsSelector", 
                     "height=500, width=700, top=0, left=0, ScrollBars=yes, resizable=yes, status=yes");
    }
    else{
      form.submitAccountAction.value = "SAVE";    // Taken from CORE
      form.submit();    
    }
  }  
  
  
  
// lihaze: Close the account selector pop-up and get the parent window to re-load itself  
  function updateAccSelectorParent(){    
    window.close(); 
    opener.document.accountSelectorDropdownForm.submitAccountAction.value = "SAVE";    // Taken from CORE
    opener.document.accountSelectorDropdownForm.submit(); 
  }

//  lewic: fund detail fund dropdown toggle
  function toggleFundDetail(){
  	document.fundDetailDropdownForm.submit();
  }

//highlight row - for the reportInfo table roll-overs. As pinched from core. Remember to update the colours

  function highlightRow(trObj) {
    trObj.bgColor = "#00ff00";
  }
  
  function unhighlightRow(trObj) {
  	trObj.bgColor = "#FFFFFF";
  }
 
 
//lewic: landscape layout for print
function notifyLandscape(){
	alert("For proper printing, please change your page layout orientation to landscape.");
}

function unicaTrack(slinkname){
    linkname = slinkname;
    if (linkname != ''){
        ntptEventTag ('pv=0&ev=link&linkname='+escape(linkname));
    }
}
