/**
* xmachina external link modifier (popup pre-site)
* @version 0.3
* @package Abbott.de
* @copyright 2008 xmachina Gmbh, cw.
* @license Alle Rechte vorbehalten. All rights reserved.
* Oficial website: http://www.xmachina.de
* -------------------------------------------
* Mofifies all external links to open a popup window, showing 
* a generell corporate statement about external links.
* Creator: cw
* Email: deus@xmachina.de
*/

// config ( all )
// host
var exceptionHosts = new Array('www.abbott.de','abbott.de','www.abbott-diabetes-care.de','www.abbottdiagnostics.de','www.abbottmedicaloptics.de','international.abbottmolecular.com','www.abbottpointofcare.com','www.soliqs.com','www.abbottvascular.com','www.abbott.com','www.42kmplus.de','www.kaletra.de','www.humira.de','www.synagis.de','www.hyperpara.de','corpdeluas10','corpdeluas10.international.intra.abbott.com','abbott-corpdeluas10.xmachina.de','abbott2009.dev.xmachina.de','abbott2009.stage.xmachina.de','sibutramine.com','www.abbottcareers.com','sjobs.brassring.com');
// language
var liabilityStatement = 'Sie haben einen externen Link gew&auml;hlt. Wenn Sie auf "Weiter" klicken, verlassen Sie die Homepage von Abbott GmbH & Co. KG. Bitte beachten Sie, dass die Abbott GmbH & Co. KG f&uuml;r den Inhalt der verlinkten Seite nicht verantwortlich ist.';
// var langStatement = '';
var confirmRequest = 'Wollen Sie die externe Seite betreten?';
var no = 'nein';
var yes = 'ja';
var confirmTitle = 'Externer Link';

// document locations
var stylesheetUrl = '/common/css/style.css';
// var scriptUrl = 'externalLinkNotification.js';


// config ( popup )

// dimension
// notice
var winw = 500;
var winh = 300;

// target
var targetWidth = 800;
var targetHeight = 600;
  
// position
var screenw = screen.availWidth;
var screenh = screen.availHeight;
   
// notice
var pre_posx = (screenw / 2) - (winw / 2);
var pre_posy = (screenh / 2) - (winh / 2);

// target
var targetLeft = (screenw / 2) - (targetWidth / 2);
var targetTop = (screenh / 2) - (targetHeight / 2);


// main function

function main () {
  // process
  if ( document.links ) {
for ( var i = 0; i < document.links.length; ++i ) {
  var current = document.links[i];
  
  // check for external href
  var isExternal = true;
  
  for ( var j = 0; j < exceptionHosts.length; ++j ) {
if ( current.hostname == exceptionHosts[j] ) {
  isExternal = false;
}
  }  

  // check for protocol (no mailto)
  if ( current.protocol != 'http:' && current.protocol != 'https:' ) {
isExternal = false;
  }
  
  // attach onclick event
  if ( isExternal == true ) {
current.addEventListener?current.addEventListener("click", showLinkNotification, false):current.attachEvent("onclick", showLinkNotification);
  }
}
  }
}


// helper functions
// popup function

function showLinkNotification(e) {
  // prevent default (open href)
  e.preventDefault?(e.preventDefault()):(e.returnValue=false);
   
  // get crossbrowser event target element ( srcElement )
  var targ;
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (targ.nodeType == 3) // defeat Safari bug
  targ = targ.parentNode;
  
  // fix linked images
  if ( targ.tagName == 'IMG' ) {
  targ = targ.parentNode;
  }
  
  // get targetUrl
  var targetUrl = targ.href;

  // build popup
  NotificationWin = window.open( '', 'NotificationWin', 'width='+winw+', height='+winh+', left='+pre_posx+', top='+pre_posy+', resizable=yes ' );
  NotificationWin.document.write('<html>');
  NotificationWin.document.write('<head>');
  NotificationWin.document.write('  <link rel="stylesheet" href="'+ stylesheetUrl +'" type="text/css" />');
  NotificationWin.document.write('</head>');
  NotificationWin.document.write('<body>');
  NotificationWin.document.write('<div class="linkNotification">');
  NotificationWin.document.write('  <h3>'+confirmTitle+'</h3>');
  NotificationWin.document.write('  <p>'+liabilityStatement+'</p>');
  NotificationWin.document.write('  <p class="title_confirm">'+confirmRequest+'</p>');
  NotificationWin.document.write('  <p class="url">'+targetUrl+'</p>');
  NotificationWin.document.write('  <p class="confirm"><a onclick="window.open( \''+ targetUrl +'\', \'targetWin\', \'resizable=yes, scrollbars=yes, toolbar=yes, menubar=yes, width='+targetWidth+', height='+targetHeight+', left='+targetLeft+', top='+targetTop+' \' ); self.close(); return false;" target="_blank" href="'+ targetUrl +'">'+ yes +'</a> <a class="maincontentlink" href="javascript:self.close()">'+ no +'</a></p>');
  NotificationWin.document.write('</div>');
  NotificationWin.document.write('</body>');
  NotificationWin.document.write('</html>');
  NotificationWin.document.close();
  NotificationWin.focus();
}
  
  
// start main function onload  
window.addEventListener?window.addEventListener("load", main, false):window.attachEvent("onload", main);



