﻿
//function reloadPage(init) {  //reloads the window if Nav4 resized
//  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
//    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
//  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
//}
//reloadPage(true);

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImageFirst(id, p){
	var element;
	if((element = document.getElementById(id)) != null){
		element.src = p;
	}
}

function swapImageBack(id,p){
	var element;
	if((element = document.getElementById(id)) != null){
		element.src = p;
	}
}

// sets the default style to the editor's content on its loading
function OnRadEditorLoad(editor)
{   
	if (editor)
	{
//	   var html = editor.GetHtml(true);
//	   if (html == "")
//	   {	
//	  		editor.SetHtml("<span class='ArticleText'>&nbsp;</span>");
//	   }	   
	   	   
	   // this is done in order to disable the default parent div css class when the radeditor is loading
	   // unfortunately, this is the best solution I found
	   if (document.getElementById('TheVeryEasyIdWhichCanBeFoundByJavascript'))
	   {
	       document.getElementById('TheVeryEasyIdWhichCanBeFoundByJavascript').className = "ArticleMainContainerEdit";	
	   }	   	
	}
}

// a small anti-spam function (taken from old website)
function sendTo(sName, sDomain)
{ 
	document.location.href = "mailto:" + sName + "@" + sDomain
}


// used to assign a default button to a textbox
function clickButton(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){
                bt.click();
                return false;
          }
      }
}	

function getHelpImage() {
  var url = "http://pro.unibz.it/opacuni/help_card.asp";
  var width = 560;
  var height = 300;
  var x = (window.screen.availWidth-width)/2;
  var y = (window.screen.availHeight-height)/2;
  window.open(url, "Fenster", "width=" + width + ", height=" + height + ", top=" + y +", left=" + x + ", scrollbars=no, toolbar=NO, menubar=NO, status=no, resizable=no");
}

function getPasswordHelp() {
  var url = "https://pro.unibz.it/illordering/passwordhelp.aspx";
  var width = 560;
  var height = 300;
  var x = (window.screen.availWidth-width)/2;
  var y = (window.screen.availHeight-height)/2;
  window.open(url, "Fenster", "width=" + width + ", height=" + height + ", top=" + y +", left=" + x + ", scrollbars=no, toolbar=NO, menubar=NO, status=no, resizable=no");
}

function performLibrarySearch(sOpacUrl, textboxid, performEscaping, language)
{
   var textbox = document.getElementById(textboxid);
   var textValue = "";
   var myUrl = "";
   var languageId = 2;
   
   if (language == "IT") {
     languageId = 3;
   } else if (language == "DE") {
     languageId = 1;
   } else if (language == "RM") {
     languageId = 4;   
   }
   
   if (textbox)
    {
        if (textbox.value != null && textbox.value.length>0)
        {
            if (performEscaping)
            {
               textValue = escape(textbox.value);
            }
            else
            {
               textValue = textbox.value;
            }            
        }       
    }    
    
    myUrl = stringFormat(sOpacUrl, textValue, languageId);
    
    window.open(myUrl);
    return false;
}

function performJournalSearch(sJournalUrl, ddlId, txttitleId, txtissnId)
{
    var textboxTitle = document.getElementById(txttitleId);
    var textboxIssn = document.getElementById(txtissnId);
    var ddl = document.getElementById(ddlId);

    if (textboxTitle && textboxIssn && ddl)
    {
        var selIndex = ddl.selectedIndex;
        var myUrl = stringFormat(sJournalUrl, textboxTitle.value, ddl[selIndex].value, textboxIssn.value, '', '', '', '');
        window.open(myUrl);
    }
    return false;
}

function stringFormat(inputString)
{
    for(i = 1; i < arguments.length; i++)
    {
        inputString = inputString.replace('{' + (i - 1) + '}', arguments[i]);
    }
    return inputString;
}

function clearTextbox(textboxid)
{
   var textbox = document.getElementById(textboxid);
   if (textbox)
    {
        if (textbox.value != null && textbox.value.length>0)
        {
            textbox.value='';   
        }
    }    
    return false;
}

function resetDropdown(dropdownid)
{
    var dropdown = document.getElementById(dropdownid);
    if (dropdown)
    {
        if (dropdown.selectedIndex != null)
        {
            dropdown.selectedIndex = 0;
        }
    }    
    return false;
}

function modifyEventsHref(txtDateId, ddlCategoryId, oldHref)
{

    var dropdown = document.getElementById(ddlCategoryId);
    if (dropdown)
    {
        if (dropdown.selectedIndex != null)
        {
            var myIndex = dropdown.selectedIndex;
            var myValue = dropdown[myIndex].value;
            oldHref+= '&Classes=' + myValue;
        }
    }
    
    if (txtDateId != '')
    {
        var textbox = document.getElementById(txtDateId);
        if (textbox)
        {
            if (textbox.value != null && textbox.value.length>0)
            {
                oldHref+= '&Date=' + textbox.value;   
            }
        } 
    }    

    return oldHref;
}

function myServicesRedirect(ddlId)
{
    var dropdown = document.getElementById(ddlId);
    if (dropdown)
    {
         if (dropdown.selectedIndex != null)
         {
                var myIndex = dropdown.selectedIndex;
                var myValue = dropdown[myIndex].value;
                var myId = dropdown[myIndex].id;
                if (myId == '1')
                {
                    window.open(myValue);
                }
                else
                {
                   window.location.href = myValue;
                }                               
         }
    }
}

// the function is referenced in all masterpages, so DO NOT DELETE until you 
// don't remove the references from masterpages
function replaceOnKeyPress()
{
 var theFunction = "S6F789EBA_Submit();";
 var theInputID = "ctl00_SearchBox_S6F789EBA_InputKeywords";

 var txt = document.getElementById(theInputID);
 var browser=navigator.appName;

 if (txt && (browser == "Netscape"))
 {
  txt.onkeypress = function(e)
  { 
   var key = String.fromCharCode(e.keyCode);
  
   if (key == "\n" || key == "\r")
   {
    eval(theFunction);
    return false;     
   }  
  }
 }
}

// delays the menu expansion of myservices 
var sendingCel; 
var outID;

//Two javascript funcions

function CallMenuDelayed(sender) 

{ 
   sendingCel = sender;

   outID = setTimeout('Menu_HoverStatic(sendingCel)',400); 
}

function CloseMenuDelayed(sender) 
{

   clearTimeout(outID);

   Menu_Unhover(sender); 

}
// end delay myservices


var subLevel;

function MyServicesDelay(sender) 
{
  var tmpNode;

  for (i=0;i<=sender.childNodes.length;i++)
  {
    if ((sender.childNodes[i] != undefined) && (sender.childNodes[i].nodeName === 'LI') && (tmpNode === undefined)) {
      tmpNode = sender.childNodes[i]
    }
  }
  
  if (tmpNode != undefined) 
  {
    subLevel = tmpNode.childNodes[1];
   
    //if((subLevel.className.substr(('sVisible MyServices '.length)) != 'sVisible MyServices ' ) &&
    //(subLevel.className.substr(('sHidden MyServices '.length)) != 'sHidden MyServices ' ))
    if (subLevel.className === 'subLevelContainer')
    {
      subLevel.className = subLevel.className.replace(/^(sVisible|sHidden) ?/,'');
      subLevel.className = 'sHidden ' + subLevel.className;
      //subLevel.className = 'sHidden ';
    } 
  
    outID = setTimeout('AddDelay(subLevel)', 600); 
  }
   
}

function AddDelay(subLevel)
{
  subLevel.className = subLevel.className.replace(/^(sVisible|sHidden) ?/,'');
  subLevel.className = 'sVisible ' + subLevel.className;
  //subLevel.className = 'sVisible';
}

function MyServicesDelayOut(sender) 
{
  clearTimeout(outID);
  subLevel.className = subLevel.className.replace(/^(sVisible|sHidden) ?/,'');
  subLevel.className = 'sHidden ' + subLevel.className;
  //subLevel.className = 'sHidden';
}

function MyServicesSubLevel(sender)
{
  subLevel.className = subLevel.className.replace(/^(sVisible|sHidden) ?/,'');
  subLevel.className = 'sVisible ' + subLevel.className;
  //subLevel.className = 'sVisible';
}

// end delay myservices