// JScript File

var doValidateForm = true;
var functionArray = new Array(extLinks());
//var functionArray = new Array(hideDropdowns(),SetDropdownMenus(),extLinks());

// EVENT HANDLER CODE - WINDOW.ONLOAD

LoadEventHandlers = function() {
    for(i = 0; i< functionArray.length;i++){
      if( typeof functionArray[i] == "function" )  functionArray[i](); 
    }
		
}

function FindPosY(obj){
var curTop = 0
     if(obj.offsetParent){
           while(obj.offsetParent){
             curTop += obj.offsetTop
            obj = obj.offsetParent
           
           }
      }
	  else if(selectmenu.y){
            curTop += selectmenu.y
           }
           return  curTop;
			                       
}



function FindPosX(obj){
var curTop = 0
     if(obj.offsetParent){
           while(obj.offsetParent){
             curTop += obj.offsetLeft
            obj = obj.offsetParent
           
           }
      }
	  else if(selectmenu.x){
            curTop += selectmenu.x
           }
           return  curTop;
			
}

function SetDropdownMenus(){

  
    var appstring = navigator.userAgent.toLowerCase(); 
  
        if( document.all && appstring.indexOf('opera') == -1){
            var ieUls = document.getElementById('menuItemsUl')
            if(ieUls != null){
	            var ieLIs = ieUls.getElementsByTagName('LI');
	            for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
		            ieLIs[i].onmouseover=function() {
            			

			            this.className="over";
            			
			            }
	                ieLIs[i].onmouseout=function() {
		            this.className="";
		            }
	            }
	        }
        }
   
}





function hideDropdowns(){

   
    var appstring = navigator.userAgent.toLowerCase(); 
  
        if( document.all && appstring.indexOf('opera') == -1){
                var ieULParent = document.getElementById('menuItemsUl')
                if(ieULParent != null){
                
               
                    ieULs = ieULParent.getElementsByTagName('UL');
                    /** IE script to cover <select> elements with <iframe>s **/
                    for (j=0; j<ieULs.length; j++) {
                    ieULs[j].innerHTML = ('<iframe  scrolling="no" frameborder="0"></iframe>' + ieULs[j].innerHTML);
                  
	                    var ieMat = ieULs[j].firstChild;
            	    
		                    ieMat.style.width=ieULs[j].offsetWidth+"px";
		                    ieMat.style.height=ieULs[j].offsetHeight+"px";	
		                    ieULs[j].style.zIndex="99";
            		    
                    }
                 }
        }
 

}




// for strict compliant new window targets
function extLinks(){
    return function(){
    
        var anchors = document.links, i=0, currentLink;
      /*  while(currentLink = anchors[i++]){

	        if( currentLink.rel.toLowerCase() == 'external'){
		        currentLink.target = "_blank";
		        currentLink.title += 'This link will open in a new window'
	        }
        }
        */
        var Image, j=0, Images;
        Images = document.images;
        while(Image = Images[j++]){
            if(Image.src.indexOf("doubleclick") > -1){
                if(Image.width == 1 && Image.height == 1){
                    Image.className = "filler";
                }
            }
        }
        
       /* if(document.getElementById){
        alert(document.getElementById('ExternalAdverts').childNodes(0).childNodes.length);
            var Adverts = document.getElementById('ExternalAdverts').images, j=0, advert;
            alert(Adverts.length);
            while(advert = Adverts[j++]){
                if(advert.height == advert.width && advert.height == 1){
                    advert.className='filler';
                }
            }
        
        }
        */
	}
	
}

window.onload=LoadEventHandlers;

//END WINDOW.ONLOAD FUNCTIONS

//OTHER COMMON FUNCTIONS

function popUpHelp(href,name,features,width,height){
if( name == null)name = 'popup';
if(width == null) width = 300;
if(height == null) height = 250;
if(features == null) features = 'status=0,toolbar=0,menubar=0,location=0,scrollbars=1,resizable=1,left=100,top=120';
    window.open(href,name,features + ',height=' + height + ',width=' + width);
    return false;
}

var changeKey = null;
function ChangeFocus(objID, e){
var obj = null;
if( e == null)e = window.event;
   if(document.getElementById){
       obj = document.getElementById(objID)

    }
  
if(e!= null){

if( e.type == "keydown")changeKey = (e.which == null)?e.keyCode:e.which;


if(changeKey == 13){
    changeKey = null;
    obj.click()
}
 else{

    if(changeKey != 40 && changeKey != 38 && changeKey !=9){
        changeKey = null;
        obj.focus();
        
    }
 }
 
}

}

function SearchBarRedirect(sReportType){
var oForm = document.forms[document.forms.length -1];
var sReportPage = "mbkhof";
if( sReportType != null){
    switch(sReportType){
        case 'D':
        sReportPage = "mbkddrm";
        break;
        case 'I':
        sReportPage = "mbkinst";
        break;
        case 'S':
        sReportPage = "mbkssi";
        break;
        default:
        sReportPage = "mbkhof";
    }
}


if( oForm.SearchText.value != 'Enter Search Term(s)' && oForm.SearchText.value !=''){
    switch(document.forms[document.forms.length -1].SearchType.value){
    case 'fid':
    top.location = '/private/' + sReportPage + '.aspx?fid=' + oForm.SearchText.value.replace(/^\s*|\s*$/g,"") + '&searchtype=fid';
    
    break;
    case 'institution':
    top.location = '/private/qsresults.aspx?name=' + urlencode(oForm.SearchText.value.replace(/^\s*|\s*$/g,"")) + '&searchtype=institution';
    
    break;
    case 'swift':
    top.location = '/private/qsresults.aspx?swfcode=' + oForm.SearchText.value.replace(/^\s*|\s*$/g,"") + '&searchtype=swift';

    break;
    case 'iban':
    top.location = '/private/qsresults.aspx?iban=' + oForm.SearchText.value.replace(/^\s*|\s*$/g,"") + '&searchtype=iban';
   
    break;

    }
 }
 else{
 alert('Please enter a search term');
 }
return false;
}

function PostForm(formID){
var oForm
if( formID != null){

    if(document.getElementById){
        oForm = document.getElementById(formID);
    }
    else{
        oForm = eval('document.' + formID);
    }
}
if (oForm == null ) oForm = document.forms[0];
if (oForm != null) oForm.submit();

}

function SetPrint(SectionName){

var PrintSection = document.styleSheets[document.styleSheets.length -1] //printstylesheet should be the last sheet in the link list.

    if(ClearPrint != null){
      
        //clearTimeout(ClearPrint);
    }
   
    if(PrintSection.cssRules){
    

        for(i=PrintSection.cssRules.length -1;i>-1;i--){
        
            PrintSection.deleteRule(i);
        }
        PrintSection.insertRule('.printsection{display:none}',0)
        PrintSection.insertRule('.' + SectionName + '{display:block}',1);
    }
    else if(PrintSection.rules){
        for(i=PrintSection.rules.length - 1;i>-1;i--){
         
            PrintSection.removeRule(i);
         }
         PrintSection.addRule('.printsection','display:none');
         PrintSection.addRule('.' + SectionName,'display:block');
    }
   
 
    print();

   
    //document.body.onfocus = ClearPrintRules;
    //document.body.onmousemove = ClearPrintRules;

    return false;
}

var ClearPrint = null


function ClearPrintRules(){
    ClearPrint = setTimeout("DoClearPrintRules()", 15000);
}

function DoClearPrintRules(bool){
    var PrintSection = document.styleSheets[document.styleSheets.length -1] //printstylesheet should be the last sheet in the link list.
    if(PrintSection.cssRules){
    if(PrintSection.cssRules[0].cssText.indexOf('.javadummy') == 0){
       PrintSection.deleteRule(1);
        PrintSection.deleteRule(0);
    }
    }
    else if(PrintSection.rules){
   
        for(i = 0; i < PrintSection.rules.length;i++){
             PrintSection.removeRule(i);
        }
        for(i = 0; i< PrintSection.imports.length;i++){
            PrintSection.removeImport(PrintSection.imports(i));
        }
    
   
    }
    //document.body.onfocus = null;
   // document.body.onmousemove = null;
}

function ResetForm(formID,doReset){
    try{
        var oForm

        if( formID != null){

            if(document.getElementById){
                oForm = document.getElementById(formID);
            }
            else{
                oForm = eval('document.' + formID);
            }
        }
        
        if (oForm == null ) oForm = document.forms[0];
        if (oForm != null) {
            if(doReset == null | doReset == ''){
                var i = 0

                while(element = oForm.elements[i++]){
                    if( element.type == 'image') break;
                    switch (element.tagName){
                        case 'SELECT':
                  
                        if (element.id.indexOf("Searchtypes") == -1){
                            element.selectedIndex = 0;
                            }
                        break;
                        case 'TEXTAREA':
                        element.value = "";
                        break;
                    case 'INPUT':
                    
                        switch(element.type){
                            case 'text':
                            case 'password':
                            element.value = '';
                            break
                            case 'checkbox':
                            element.checked = false;
                            break;
                            case 'radio':
                           
                            element.checked = false;
                           
                            if (element.name != null && element.name != ''){
                                if(oForm(element.name).length > 1){
                                 oForm(element.name)[0].checked = true;}
                                else{
                                    oForm(element.name).checked = true;
                                }
                            }
                            
                            
                        }
               
                    }//switch
                }//while
             }//if
             else{
                oForm.reset();
            }
        }//if not null
    }//try
    catch(er){

        return false;
    }
    return false;
}

function ShowLocs(hiddenDivID,blnShow)
{
    x=document.getElementsByTagName('DIV');
    for (i=0;i<x.length;i++){
        if (x[i].id == hiddenDivID){
            if (blnShow){
                x[i].className = 'IBANShow'
            }else{
                x[i].className = 'IBANHide'
            }
        }
    }
}

function urlencode(text) {
    text = text.replace(/\//g,"%2F");
    text = text.replace(/\?/g,"%3F");
    text = text.replace(/=/g,"%3D");
    text = text.replace(/&/g,"%26");
    return text;
}

