/*
   Title     :  Sample Template JavaScript Library
   Author    :  Virage Inc.
   Generator :  Virage Application Server
   Copyright :  Copyright 2000 by Virage Inc.
   Date      :  2000-05-26T10:40:34-08:00
*/

/*
function viewer(URI)
{
  var viewer = window.open(URI, 'viewer',
    'directories=no,height=720,location=no,menubar=no,resizable=no,' +
    'scrollbars=auto,status=yes,toolbar=no,width=640,' +
    'screenX=10,screenY=0,left=10,top=0');
  viewer.focus();
}
*/

function viewer(URI, w, h)
{
  var viewer = window.open(URI, 'pviewer',
    'directories=no,height=' + h + ',location=no,menubar=no,resizable=no,' +
    'scrollbars=no,status=yes,toolbar=no,width=' + w + ',' +
    'screenX=10,screenY=0,left=10,top=0');
  viewer.focus();
}

function viewer(URI)
{
  var viewer = window.open(URI, 'pviewer',
    'directories=no,height=' + 590 + ',location=no,menubar=no,resizable=no,' +
    'scrollbars=no,status=yes,toolbar=no,width=' + 464 + ',' +
    'screenX=10,screenY=0,left=10,top=0');
  viewer.focus();
}


// P: Options dialog
function optsDialog(URI) {
    var optsd = window.open(URI, 'optsd', 'directories=no,height=180,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=340,screenX=30,screenY=30,left=30,top=30');
    optsd.focus();
}

/** LKF 1.0 This launches a small window that displays
 ** large keyframes
 **/
function viewer_large_kf(URI, width, height, win_name)
{
	width += 10;
	height += 30;
	if (window.screen.width > 640) {
		var viewer = window.open(URI, win_name, 'directories=no,height=' + height + ',width=' + width + ',location=no,menubar=no,resizable=no,' + 'scrollbars=no,status=no,toolbar=no');
	}
	else {
		var viewer = window.open(URI, win_name, 'directories=no,height=' + 300 + ',width=' + 400 + ',location=no,menubar=no,resizable=yes,' + 'scrollbars=yes,status=no,toolbar=no');
	}
	viewer.focus();
}

function label_editor(URI)
{
  var label_editor = window.open(URI, 'label_editor',
    'directories=no,height=480,location=no,menubar=no,resizable=yes,' +
    'scrollbars=yes,status=yes,toolbar=no,width=640,' +
    'screenX=10,screenY=10,left=10,top=10');
  label_editor.focus();
}

function editor_storyboard(URI)
{
  var editor_storyboard = window.open(URI, 'editor_storyboard',
    'directories=no,height=480,location=no,menubar=no,resizable=yes,' +
    'scrollbars=yes,status=yes,toolbar=no,width=640,' +
    'screenX=30,screenY=30,left=30,top=30');
  editor_storyboard.focus();
}

function text_editor(URI)
{
  var text_editor = window.open(URI, 'text_editor',
    'directories=no,height=718,location=no,menubar=no,resizable=yes,' +
    'scrollbars=yes,status=yes,toolbar=no,width=640,' +
    'screenX=10,screenY=0,left=10,top=0');
  text_editor.focus();
}

function help(URI)
{
  var help_offset = screen.width - 470;
  var help = window.open(URI, 'help',
    'directories=no,height=600,location=yes,menubar=yes,resizable=yes,' +
    'scrollbars=yes,status=yes,toolbar=yes,width=450,' +
    'screenX=' + help_offset + ',screenY=5,' +
    'left='    + help_offset + ',top=5');
  help.focus();
}

function ms2HMS(ms)
{
  var SS = ms / 1000;
  var MM = Math.floor(SS / 60);
  var HH = Math.floor(MM / 60);

  SS = SS - ( MM * 60 );
  MM = MM - ( HH * 60 );
  SS = Math.round(SS * 100) / 100;

  if ( HH < 10 ) HH = '0' + HH;
  if ( MM < 10 ) MM = '0' + MM;
  if ( SS < 10 ) SS = '0' + SS;

  return HH + ':' + MM + ':' + SS;
}

function URI_authority()
{
  var from = document.URL.indexOf("://") + 3;
  var to   = document.URL.indexOf("/", from);
  return document.URL.substring(from, to);
}
