/**
 * Common JS
 * Copyright (c) 2007, MediaEvent Services GmbH & Co. KG
 * http://mediaeventservices.com
 */

function isWin() {
  return (navigator.platform.indexOf('Win') != -1);
}

function isMac() {
  return (navigator.platform.indexOf('Mac') != -1);
}

function isIE() {
  return (navigator.userAgent.indexOf("MSIE") != -1);
}

function isFF() {
  return (navigator.userAgent.indexOf("Firefox") != -1);
}

/**
 * http://support.microsoft.com/kb/191434
 */
function parseDecimal(val) {
   if (typeof val != 'string')
   	return parseInt(val);

   if (val.length == 0)
   	return NaN;

   while (val.charAt(0) == '0')
      val = val.substring(1, val.length);

   if (val.length == 0)
   		return 0;
   else
   		return parseInt(val);
}

/**
 * function tcToSec
 *
 * Wandelt übergebenen Timecode im Format hh:mm:ss in Sekunden um
 * und gibt diesen Wert zurück
 *
 * return time
 */
function tcToSec(tc) {
	var hour;
	var min;
	var sec;

	hour = parseDecimal(tc.slice(0,2));
	min = parseDecimal(tc.slice(3,5));
	sec = parseDecimal(tc.slice(6));

	hour_to_sec = hour * 3600;
	min_to_sec = min * 60;

	return hour_to_sec + min_to_sec + sec;
}

/* öffnet neues Browserfenster mit allen Controls und Toolsbars aus Popup */
function newBrowserWindow(url,name) {
	window.open(url, name, "location=yes,scrollbars=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes");
}

function createPopupLinks() {
	$$('a[target="_blank"]').each(function (element) {
			element.onclick= function() { newBrowserWindow(this.href, null); return false;};
			});
}

