//maked all added functions work onload. at the end of each function you want to work onload add addLoadEvent(function); to the end of the function.
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// The following two functions make it possible to have web standard popups
window.onload = function() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].className == "popup") {
      lnks[i].onclick = function() {
        popUp(this.getAttribute("href"));
        return false;
      }
    }
  }
}

function popUp(winURL) {
  window.open(winURL,"popup");
}

function flowplayerSetup(){
  if(typeof(jQuery) == 'undefined'){ return; }
  if(jQuery('div[data-video]').length > 0){
    jQuery.getScript('/js/flowplayer-3.2.6.min.js', function(){
      jQuery('div[data-video]').flowplayer('/swf/flowplayer.commercial-3.2.5-4.swf', 
        { clip: { autoPlay: jQuery('div[data-video]').hasClass('autoplay'), url: jQuery('div[data-video]').attr('data-video') } }
      );
    });
  }
}

//add print link
function addPrintLink() {
  if(!document.getElementById) return false;
  if(!document.getElementById('ptplnk')) return false;
	var printButton = document.getElementById('ptplnk');
	printButton.onclick=function() {
		window.print(); return false;
	}
}
addLoadEvent(addPrintLink);
addLoadEvent(flowplayerSetup);
