function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function popUp(url,w,h) {
   newWin = window.open(url,'_blank','width='+w+',height='+h+',menubar=no,scrollbars=1,status=yes,resizable=yes');
   newWin.focus();
}


/* start text scroll */

function initScroll() {

var currPos;
var scrLoop;
var scrHeight;

$(document).ready(function(){
	currPos = 0;
	scrHeight = $("#scroller").height() - $("#scroller_cnt").height();

	function scrollUp() {
		if (currPos < scrHeight) {
			currPos = currPos+1;
			$("#scroller").css("margin-top", "-" + currPos + "px");
		}
		else {
			clearInterval(scrLoop);
		}
	}

	function startScroll() {
		stopScroll();
		scrLoop = setInterval(scrollUp, 50);
	}

	function stopScroll() {
		clearInterval(scrLoop);
	}

	function resetScroll() {
		stopScroll();
		currPos = 0;
		$("#scroller").animate({marginTop: 0}, "fast");
	}

	$('#scroll_start').click(function() { startScroll(); return false; });
	$('#scroll_stop').click(function() { stopScroll(); return false; });
	$('#scroll_reset').click(function() { resetScroll(); return false; });

});

}
/* end text scroll */


/* start external links handler */

function externalLinks() {
   if (!document.getElementsByTagName) return;
   var anchors = document.getElementsByTagName("a");
   for (var i=0; i<anchors.length; i++) {
      var anchor = anchors[i];
      if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
         anchor.target = "_blank";
   }
}

// define onload events
addLoadEvent(externalLinks);

/* end external links handler */
