
// Creates dynamically an email address field on screen
function crAddr(id,ida,recipient,domain)
{

var o = document.getElementById(id);
var s = recipient + '\u0040' + domain;
while (s.match('#') == '#')
	  s = s.replace('#','.');
	  
if (o.innerText)
  o.innerText = s;
else
	o.textContent = s;
	
o = document.getElementById(ida);
s = "mailto:" + s;
	  
o.href=s;
}

// for forcing a link to open in a new target window
// <a href="xxx" onClick="javascript:fnLinkNewWindow(this);">aaa</a>
function fnLinkNewWindow(o)
{
  o.setAttribute('target','_blank');
}

var winPopup = null;
function ShowPopupWindow(pg,title,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
winPopup = window.open(pg,title,settings)
}

 
 
function addBookmark(url, title) 
{
    // user agent sniffing is bad in general, but this is one of the times 
    // when it's really necessary
    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';
 
    if(window.external && (!document.createTextNode ||
      (typeof(window.external.AddFavorite)=='unknown'))) 
	 {
        // IE4/Win generates an error when you
        // execute "typeof(window.external.AddFavorite)"
        // In IE7 the page must be from a web server, not directly from a local 
        // file system, otherwise, you will get a permission denied error.
        window.external.AddFavorite(url, title); // IE/Win
    } else if(isKonq) {
      alert('You need to press CTRL + B to bookmark our site.');
    } else if(window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      alert('You need to press '+buttonStr+' + D to bookmark our site.');
    } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('You need to press Command/Cmd + D to bookmark our site.');    
    } else {
      alert('In order to bookmark this site you need to do so manually '+
        'through your browser.');
    }
}
 
function initAddBookmark(aid)
{
 var a = document.getElementById(aid);
 
 if (a)
 {
  	a.href=location.href
    if(window.opera) {
      a.rel='sidebar'; // this makes it work in Opera 7+
	  a.title=document.title;
    } else {
      // this doesn't work in Opera 7+ if the link has an onclick handler,
      // so we only add it if the browser isn't Opera.
      a.onclick=function() {
        addBookmark(this.href,document.title);
        return false;
      }
    }
  }
}
