window.onerror=err;
var brName = navigator.appName;
var brVer = parseInt(navigator.appVersion);
var brVendor = brName.substring(0,9);
var brUA = navigator.userAgent.toLowerCase();

function err() {return false;}

function wopen(item,pwidth,pheight,usetoolbar,uselocationbar,usemenubar,rndURL) {
   if( (brVendor=='Microsoft' && brVer < 4) || (typeof item.href == 'undefined')) {return true;}

   if(typeof(usetoolbar) == 'undefined') {
      usetoolbar = "1";
   }
   if(typeof(uselocationbar) == 'undefined') {
      uselocationbar = "1";
   }
   if(typeof(usemenubar) == 'undefined') {
      usemenubar = "1";
   }
   if(typeof(pwidth) == 'undefined') {
      pwidth = (typeof(screen.width) == 'undefined') ? "800" : Math.round(screen.width * 0.75);
   }
   if(typeof(pheight) == 'undefined') {
      pheight = (typeof(screen.height) == 'undefined') ? "560" : Math.round(screen.height * 0.75);
   }

   var URL = item.href;

   if(rndURL) {
      if(URL.indexOf('?') > 0) {
			URL += '&RandKey=';
      } else {
			URL += '?RandKey=';
      }
      URL += Math.floor(Math.random() * 1000000);
   }

   if(typeof(Session) != 'undefined') {
      if(URL.indexOf('?') > 0) {
			URL += '&Session=';
      } else {
			URL += '?Session=';
      }
      URL += Session;
   } 

	window.open(URL,'_blank','toolbar=' + usetoolbar + ',location=' + uselocationbar + ',directories=0,status=1,menubar=' + usemenubar + ',scrollbars=1,resizable=1,width='+pwidth+',height='+pheight);
	
	return false;
}

function ao(obj) {
	return wopen(obj,720,480,1,0,0,1);
}

function fao(obj) {
	return wopen(obj,640,500,0,0,0,0);
}

function oao(obj) {
	return wopen(obj,640,570,1,1,1,0);
}

function fo(obj) {
	return wopen(obj,640,550,0,0,0,0);
}


var boxtext;

function box_focus(item) {
	if(typeof(boxtext) == 'undefined') {
		boxtext = item.value;
		item.value = '';
		return;
	}
	if(item.value == boxtext) {
		item.value = '';
	}
}

function box_blur(item) {
	if(item.value == '') {
		item.value = boxtext;
	}
}

function dd_check(item,text, check) {
   if(check) {
	   if(item.value == text) {
		   alert('"' + text + '" is not a newswire. Please select a newswire from the list.');
			return false;
		}
	}
	
	return true;
}


if (!document.layers&&!document.all&&!document.getElementById)
event="test"

function showTip(current,e,text){

if (document.all||document.getElementById){
thetitle=text.split('<br>')
if (thetitle.length>1){
thetitles=''
for (i=0;i<thetitle.length;i++)
thetitles+=thetitle[i]
current.title=thetitles
}
else
current.title=text
}

else if (document.layers){
document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;color:black">'+text+'</layer>')
document.tooltip.document.close()
document.tooltip.left=e.pageX+5
document.tooltip.top=e.pageY+5
document.tooltip.visibility="show"
}
}
function hideTip(){
if (document.layers)
document.tooltip.visibility="hidden"
}

function showRegTip(current,e) {
   showTip(current, e, 'To read this, first register with this publication');
}

function showSubTip(current,e) {
   showTip(current, e, 'To read this, first pay and subscribe to this publication');
}

function change_location (address) {
   location.href=address;
}

function set_window_status (text) {
   window.status=text;
   return true;
}
         
	 
function dupbut(i) {
   var g_el = document.getElementById('g' + i);
   var b_el = document.getElementById('a' + i);
	
	if( g_el.className == 'dupOn' ) {
		g_el.className = 'dupOff';
		b_el.innerHTML = 'Show duplicates';
	}
	else {
		g_el.className = 'dupOn';
		b_el.innerHTML = 'Hide duplicates';
	}
	
   return false;
}
	 
var ADS_tag = new Array(6);
var ADSc = 0;
var ADSenabled = 0;

// Set one of these to true to enable the delayed ad load technology

var delayedAdUntilOnLoad = 0;
var delayedAdLoad = 0;

// Disable delayed ad load technology for Opera
if( brUA.indexOf("opera") != -1 ) {
   delayedAdLoad = 0;
}

function insertAdDest(pos, tag, width, height, attr) {
   if(delayedAdLoad) {
      ADS_tag[pos] = tag; ADSc++;
      document.write('<span id="d' + tag + '"><img src="/ico/1.gif" border="0" width="' +
		     width + '" height="' + height + '"/></span>');
   }
   else {
      insertAdSrc(-1, tag, width, height, attr);
   }
}

function insertAdSrc(pos, tag, width, height, attr) {
   if(delayedAdLoad || (pos == -1)) {
      var myDate = new Date();
      AT_MISC = myDate.getTime();

      document.write('<scr' + 'ipt src="http://adserver.adtech.de/?addyn|2.0|' +
		     tag + '|target=_blank;loc=100;misc=' + AT_MISC + ';">');
      if (navigator.userAgent.indexOf("Mozilla/2.") >= 0 || navigator.userAgent.indexOf("MSIE") >= 0) {
	 document.write('<a href="http://adserver.adtech.de/?adlink|2.0|' + tag +
			'|ADTECH;loc=200;" target="_blank"><img ' + attr +
			' src="http://adserver.adtech.de/?adserv|2.0|' + tag +
			'|ADTECH;loc=200;" border="0" width="' + width +
			'" height="' + height + '"></a>');
      }
      document.write('</scr' + 'ipt>');
   }
}

function enableAd(i) {
   if( !delayedAdLoad || delayedAdUntilOnLoad ) return;
   onAd(i);
}

function onAd(i) {
   if(!ADS_tag[i]) return true;

   var s = document.getElementById('s' + ADS_tag[i]);
   var d = document.getElementById('d' + ADS_tag[i]);

   d.parentNode.replaceChild(s,d);
   s.className = 'on';
   
   ADS_tag[i] = '';
   ADSenabled++;
}

function enableAds() {
   if( (ADSc == 0) || (ADSenabled == ADSc) ) return true;
   var i;
   for(i = 0; i < ADSc; i++) {
      // onAd(i);
      setTimeout("onAd(" + i + ")",i*2000);
   }
   return true;
}

function scroll(noflip) {
  var el = document.getElementById('topstories');
  var ps = el.getElementsByTagName('p');
  var psh;
  if(ps[0].style.height != '') psh = parseInt(ps[0].style.height)
  else psh = 0;
  if(psh >= ps[0].scrollHeight) { // Expanded full
   if(timerID) clearInterval(timerID);
   if(noflip) {
     return timerID = setInterval("scroll(0)", 4000);
	}
   ps[ps.length-1].style.height = '0px';
   el.insertBefore(ps[ps.length-1], ps[0]);
   timerID  = setInterval("scroll(1)", 50);
  }
  else {
     ps[0].style.height = (psh+1) + 'px';
	  }
}

function scrollOn() {
  timerID  = setInterval("scroll(1)", 50);
}

function RedoPageBottom() {
 return 0 - page_bottom.offsetHeight + (
														document.documentElement.clientHeight ?
														document.documentElement.clientHeight : document.body.clientHeight ) +
	  ( ignoreMe = document.documentElement.scrollTop ?
		 document.documentElement.scrollTop : document.body.scrollTop ) +
  'px';
}

