function swapImage(imgSrc, imgName) { 
	if (is.comp) {
		var img = document.getElementsByName(imgName);
		img[0].src = imgSrc;
	}
}

function preloadImages() { 
	if (document.images) {
		var imgStr = preloadImages.arguments;
		if (!document.preloadArray) document.preloadArray = new Array();
		var n = document.preloadArray.length;
		for (var i=0; i<preloadImages.arguments.length; i++) {
			document.preloadArray[n] = new Image;
			document.preloadArray[n].src = imgStr[i];
			n++;
		} 
	}
}

preloadImages('../images/buttons/button_home_ro.gif');
preloadImages('../images/buttons/button_location_ro.gif');
preloadImages('../images/buttons/button_contact_ro.gif');
preloadImages('../images/buttons/button_help_ro.gif');
preloadImages('../images/buttons/button_sitemap_ro.gif');

preloadImages('../images/menu/menu_bullet_home_ro.gif');
preloadImages('../images/menu/menu_bullet_ro.gif');
preloadImages('../images/menu/submenu_bullet_ro.gif');
preloadImages('../images/menu/menu_bullet.gif');

preloadImages('../images/icons/icon_link.gif');
preloadImages('../images/icons/icon_link_visited.gif');
preloadImages('../images/icons/icon_download.gif');
preloadImages('../images/icons/icon_top.gif');
preloadImages('../images/icons/icon_bullet_home_ro.gif');

preloadImages('../images/general/link_bullet_home.gif');
preloadImages('../images/general/link_bullet_home_ro.gif');
preloadImages('../images/general/spacer.gif');

preloadImages('../images/headers/h_home_corporate.gif');
preloadImages('../images/headers/h_home_institutional.gif');
preloadImages('../images/headers/h_home_sme.gif');
preloadImages('../images/headers/h_home_individuals.gif');
preloadImages('../images/headers/h_home_newsandevents.gif');
preloadImages('../images/headers/h_home_features.gif');
preloadImages('../images/headers/h_home_reports.gif');
preloadImages('../images/headers/h_contact.gif');
preloadImages('../images/headers/h_location.gif');
preloadImages('../images/headers/h_sitemap.gif');

function openFunctions( uri ) {
	parent.focus(); // remove ant-trail IE
	var props = 'width=666,height=550,resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes';
	var newWindow = window.open( '' ,'functionspopup', props);
	newWindow.focus();
	newWindow.location = uri ;
	
	if (newWindow.opener == null) newWindow.opener = window; 
    newWindow.opener.name = "opener";
}


function openSearch( caller ) {
	if ((caller == null) || (caller.q == null) || (caller.action == null)) return false;
	if (caller.q.value == '') return false; //do nothing when no search is committed
	
	parent.focus(); // remove ant-trail IE
    var searchWin = window.open('','searchwindow','width=616,height=550,resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes');
    searchWin.location.href = caller.action + '?ps=10&q=' +  caller.q.value.replace(/\s+/g,'+');
	searchWin.focus();
    if (searchWin.opener == null) searchWin.opener = window; 
    searchWin.opener.name = "opener";
	/* reminder:
	add the following parameters to all links in the opened window :
	target="opener" onClick="opener.focus();"
	*/
	return false; // do not submit the form
}

// --- CLIENTSNIFFER ---
function getClient() {
    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()
	var apv=navigator.appVersion.toLowerCase()
	this.major = parseInt(navigator.appVersion)
	// browserversion
    this.ns  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)))
   	this.gecko = (this.ns && (this.major >= 5))
    this.ie   = (agt.indexOf("msie") != -1)
    this.ie4  = (this.ie && (this.major == 3))
	this.ie45 = (agt.indexOf('msie 4.5') != -1);
    this.ie5  = (this.ie && (this.major == 4))
	// platform
	this.mac = (apv.indexOf("macintosh")>0);
	// compatible browsers
	this.ie4comp = ((this.ie4 && !this.mac) || this.ie45 || this.ie5)
	this.comp = (this.ie4comp || this.gecko);
	return (this)
}

var is = new getClient();

/* Netscape Resize Bug */
function nsResizeBug() {
	if (innerWidth!=document.originalPageWidth || innerHeight!=document.originalPageHeight) location.reload();
}

if (document.layers) {
	document.originalPageWidth = innerWidth;
	document.originalPageHeight = innerHeight;
	onresize = nsResizeBug;
}

