var num = 0;

var html_header1 = '<table WIDTH="100%" CELLSPACING="0" CELLPADDING="5" BORDER="0"> \
 <tr> \
  <td WIDTH="100%" HEIGHT="11" colspan="2"> \
   <h1>';
var html_header2 = '</h1> \
  </td> \
 </tr> \
 <tr> \
  <td WIDTH="100%" HEIGHT="11" colspan="2"> \
   <img SRC="/images/bar01.gif" alt="bar" WIDTH="100%" HEIGHT="11" BORDER="0"> \
  </td> \
 </tr> \
 <tr> \
  <td WIDTH="100%" HEIGHT="25px" style="background: transparent"> \
   <a href="/index.html" class="navigationtext">&nbsp;&nbsp;HOME&nbsp;&nbsp;</a> \
   <a href="/photos/index.html" class="navigationtext">&nbsp;&nbsp;Photos&nbsp;&nbsp;</a> \
   <a href="/videos/index.html" class="navigationtext">&nbsp;&nbsp;Videos (New)&nbsp;&nbsp;</a> \
   <a href="/research/index.html" class="navigationtext">&nbsp;&nbsp;Research&nbsp;&nbsp;</a> \
  </td> \
  <td align="right" class="navigationtext"><a href="mailto:hernan.badino@lelaps.de" class="navigationtext">&nbsp;&nbsp;hernan.badino@lelaps.de&nbsp;&nbsp;</a> \
  </td> \
 </tr> \
 <tr> \
  <td WIDTH="100%" HEIGHT="11" colspan="2"> \
   <img SRC="/images/bar01.gif" alt="bar" WIDTH="100%" HEIGHT="11" BORDER="0"> \
  </td> \
 </tr> \
</table>';

var html_research_header = '<center><table WIDTH="80%" CELLSPACING="0" CELLPADDING="0" BORDER="1"><tr><td><table WIDTH="100%" CELLSPACING="0" CELLPADDING="5" BORDER="0"> \
 <tr> \
  <td WIDTH="100%" HEIGHT="11" colspan="2" align="center" style="background: transparent">  \
   <h2>Research</h2> \
  </td> \
 </tr> \
 <tr> \
  <td WIDTH="100%" HEIGHT="25px" align="center" style="background: transparent"> \
   <a href="/research/index.html" class="navigationtext">&nbsp;&nbsp;Publications&nbsp;&nbsp;</a> \
   <a href="/research/videos.html" class="navigationtext">&nbsp;&nbsp;Videos&nbsp;&nbsp;</a> \
   <a href="/research/links.html" class="navigationtext">&nbsp;&nbsp;Links&nbsp;&nbsp;</a> \
   <a href="/research/bio.html" class="navigationtext">&nbsp;&nbsp;Bio &amp; CV&nbsp;&nbsp;</a> \
  </td> \
 </tr> \
 <tr> \
  <td WIDTH="100%" HEIGHT="11" colspan="2" style="background: transparent"> \
   <img SRC="/images/bar01.gif" alt="bar" WIDTH="100%" HEIGHT="11" BORDER="0"> \
  </td> \
 </tr> \
</table></tr></td></table></center>'

var html_header3 = '<!-- Start of StatCounter Code -->\n<script type="text/javascript" language="javascript">\n<!-- \nvar sc_project=931292; \nvar sc_click_stat=1; \nvar sc_invisible=0; \nvar sc_partition=7; \nvar sc_security="cd06a749"; \n//-->\n</script>\n\n<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img \
src="http://c8.statcounter.com/counter.php?sc_project=931292&java=0&security=cd06a749&invisible=0" alt="web metrics" border="0"></a> </noscript>\n<!-- End of StatCounter Code -->\n';

var html_header5 = '<!-- Start of StatCounter Code -->\n<script type="text/javascript" language="javascript">\n<!-- \nvar sc_project=931292; \nvar sc_invisible=0; \nvar sc_partition=7; \nvar sc_security="cd06a749"; \n//-->\n</script>\n\n<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img \
rc="http://c8.statcounter.com/counter.php?sc_project=931292&java=0&security=cd06a749&invisible=0" alt="web metrics" border="0"></a> </noscript>\n<!-- End of StatCounter Code -->\n';

var html_header6='<!-- Start of StatCounter Code --> \n\
<script type="text/javascript"> \n\
sc_project=3715391; \n\
sc_invisible=1; \n\
sc_partition=34; \n\
sc_click_stat=1; \n\
sc_security="6e9e57a5"; \n\
</script> \n\
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div \ class="statcounter"><a href="http://www.statcounter.com/free_web_stats.html" target="_blank"><img \ class="statcounter" src="http://c.statcounter.com/3715391/0/6e9e57a5/1/" alt="counters for web pages" \ ></a></div></noscript> \n\
<!-- End of StatCounter Code -->';

var html_header7='<!-- Start of StatCounter Code --> \n\
<script type="text/javascript"> \n\
sc_project=3715391;  \n\
sc_invisible=0;  \n\
sc_partition=34;  \n\
sc_click_stat=1;  \n\
sc_security="6e9e57a5";  \n\
</script> \n\
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div \ class="statcounter"><a href="http://www.statcounter.com/free_hit_counter.html" target="_blank"><img \  class="statcounter" src="http://c.statcounter.com/3715391/0/6e9e57a5/0/" alt="counter create hit" \ ></a></div></noscript> \n\
<!-- End of StatCounter Code -->';

var resizeWindowStr = '					\n \
function resizeMyWindow(element)			\n \
{							\n \
  document.close();					\n \
  if (window.innerWidth)				\n \
  {							\n \
    // Netscape						\n \
    window.innerWidth  = element.width  + 24;		\n \
    window.innerHeight = element.height + 24;		\n \
  }							\n \
  else 							\n \
    if (document.body && document.body.offsetWidth)	\n \
    {							\n \
      //IE						\n \
      window.resizeTo(1,1);				\n \
      window.resizeBy(element.width, element.height);	\n \
    }							\n \
  window.focus();					\n \
							\n \
  return true;						\n \
}							\n' ;


function windowOpener(photo) 
{
  var towrt;
  var w1, h1, w = 640, h = 640;
  var an_image = new Image();

  an_image.src = photo;

  w1 = w + 16;
  h1 = h + 16;

  num++;

  towrt   = '<HTML><HEAD><TITLE>' + photo + ' ' + num + '</TITLE></HEAD>\n';
  towrt  += '<BODY bgcolor="black"><SCRIPT language="JavaScript" onError="null">' + resizeWindowStr + '</SCRIPT>\n';
  towrt  += '\n<CENTER>\n<img id="Simage" onError="null" src="' + photo + '" alt="LOADING..." onLoad="resizeMyWindow(this)"> --> </CENTER>';
  towrt  += '\n</BODY></HTML>';

  var photoWindow;

  photoWindow = window.open('', 'myPhotoWindow','resizable=yes, menubar=yes, innerWidth=' + w1 + ', innerHeight=' + h1);

  photoWindow.document.myParent = photoWindow;
  photoWindow.document.open();

	//alert(towrt);
  photoWindow.document.writeln(towrt);

  photoWindow.focus();
  //photoWindow.document.close();

  return true;
}

function highlight(photo) 
{
  if (!photo || !photo.w)
    return false;

  photo.style.color  = '#FF0011'; 
  photo.style.border ='1px solid'
  photo.style.width  = photo.w + 16 + 'px';
  photo.style.height = photo.h + 16 + 'px';
  window.status = photo.src;
  return true;
}

function dehighlight(photo) 
{
  if (!photo || !photo.w)
    return false;

  photo.style.color  = '#000000'; 
  photo.style.border ='9px solid'
  photo.style.width  = photo.w + 'px';
  photo.style.height = photo.h + 'px';
  return true;
}

function iniDia(photo) 
{
  photo.style.width  = photo.width  + 'px';
  photo.style.height = photo.height + 'px';
  photo.w = photo.width;
  photo.h = photo.height;

  return true;
}

function bb(element)
{
alert(element);
}


function highlightMenu(elem)
{
  elem.style.border = '0px solid';
  elem.style.borderColor = '#888888';
  elem.style.backgroundColor ='#FFFFFF';
  elem.style.color ='#0000FF';
  elem.style.fontSize ='100%';
  elem.style.fontWeight = 'normal'; 

  return true;
}

function dehighlightMenu(elem)
{
  elem.style.border = '0px solid';
  elem.style.backgroundColor = 'transparent';
  elem.style.borderColor = elem.style.backgroundColor;
  elem.style.backgroundColor ='transparent';
  elem.style.color ='#000000';
  elem.style.fontSize ='100%';
  elem.style.fontWeight = 'normal'; 

  return true;
}


function addHeader(title)
{
  if (!title)
    document.writeln(html_header1 + 'Hern&aacute;n Badino\'s Homepage' + html_header2);
  else
    document.writeln(html_header1 + title + html_header2);
}

function addFoot()
{
  //document.writeln(html_header6);
  document.writeln(html_header3);
}

function addResearchHeader()
{
  document.writeln(html_research_header);
}

function windowResize()
{ 
  var obj = document.getElementById('everything');
  var newleft = window.innerWidth/2 - 400;

  if (newleft > 0)
    obj.style.left = newleft;
  else
    obj.style.left = 0;
}

function showDias(photo_array)
{ 
  var i;

  for (i = 0; i < photo_array.length; i++)
  {
    var wrt = '<img onload  = "iniDia(this);" \
                           onclick     = "windowOpener(\'' + photo_array[i] + '\');" \
                           onMouseOver = "highlight(this);" \
                           onMouseOut  = "dehighlight(this);" \
                           onError     = "null" \
                           style       = "border: 9px solid;" \
                           alt         = "error ' + i + '" \
                           src         = "' + photo_array[i] + '_kl.jpg">';
    document.writeln(wrt);
  }
}

function showVideos2(video_array)
{ 
  alert('Hello');
}

function showVideos(video_array, title_array)
{ 
  var i;

  var wrt = '<table style="text-align: left; position: relative; width: 440px;" border="2" cellpadding="2" cellspacing="2" align="center"> <tbody>';
  document.writeln(wrt);
  //alert(wrt);
  for (i = 0; i < video_array.length; i++)
  {
    wrt = '\
    <tr> \
      <td style="align: center"> \
        <br> ' + title_array[i] + ' <br> <br>\
        <center> \
        ' + video_array[i] + '\
        </center>	\
        <br> \
      </td> \
    </tr>';

    document.writeln(wrt);
    //alert(wrt);
  }

  wrt = '</tbody> </table>';
  document.writeln(wrt);
  //alert(wrt);
}

var g_classID_i = 0;
function addVideo(videoFile_str, width_i, height_i)
{
  var embwidth_i  = width_i + 10;
  var embheight_i = height_i + 10;
  var embheight2_i = height_i + 30;
  var classID_str = 'clsid' + g_classID_i + '00' + Math.random() ;
  ++g_classID_i;
  var ID_str = 'clsid' + g_classID_i + '00' + Math.random() ;

  var playRealFile_str='<table border="0" cellpadding="0" align="center"> \
        <tr><td> \
        <OBJECT id="' + ID_str + '" classid="' + classID_str + '" \
        width="' + embwidth_i + '" height="' + embheight_i + '"> \
        <param name="src" value="' + videoFile_str + '"> \
        <param name="autostart" value="true"> \
        <param name="controls" value="imagewindow"> \
        <param name="console" value="video"> \
        <param name="loop" value="false"> \
        <EMBED id="'+ID_str+'" src="' + videoFile_str + '" width="' + embwidth_i + '" height="' + embheight2_i + '"  \
        loop="false" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="video" autostart="true"> \
        </EMBED> \
        </OBJECT> \
        </td></tr> \
        <!-- ...end video window --> \
          <!-- begin control panel... --> \
          <tr><td> \
          <OBJECT id="' + ID_str + '" classid="' + classID_str + '" \
          width="' + embwidth_i + '" height="40"> \
          <param name="src" value="' + videoFile_str + '"> \
          <param name="autostart" value="true"> \
          <param name="controls" value="ControlPanel"> \
          <param name="console" value="video"> \
          <EMBED src="' + videoFile_str + '" width="' + embwidth_i + '" height="40"  \
          controls="ControlPanel" type="audio/x-pn-realaudio-plugin" console="video" autostart="true"> \
          </EMBED> \
          </OBJECT> \
          </td></tr> \
        <tr><td align="center"> \
        <!-- ...end link to launch external media player... --> \
        </td></tr> \
      </table>';

    ++g_classID_i;
    document.writeln(playRealFile_str);
}

var videoWindow = 0;

function videoOpener(video, w, h, title) 
{
  var towrt;
  var w1, h1;

  w1 = w + 16;
  h1 = h + 16;

  num++;

  towrt   = '<HTML><HEAD><TITLE>' + title + '</TITLE></HEAD>\n';
  towrt  += '<BODY bgcolor="black" onunload="markWindowClosed();"><SCRIPT language="JavaScript" onError="null" src="/funcs.js"></SCRIPT>\n';
  towrt  += '<SCRIPT language="javascript"> addVideo("' + video + '", ' + w + ', ' + h + ' ); </SCRIPT>';  towrt  += '<br><center><div style="color:white; width:' + w1 + '">In order to watch this video you need a high-speed internet connection and <a href="https://player.helixcommunity.org/" target="helixplayerwindow">Helix</a> or <a href="http://www.realplayer.com" target="realplayerwindow">Real</a> Player. You can also try to <a href="' + video + '" target="openinexternalplayerwindow">Launch in external player</a>.</div><br><br><div style="color:white; text-decoration:underline">© Hern&aacute;n Badino. All Rights Reserved.</div></center>';
  //towrt  += html_header6;
  towrt  += '\n</BODY></HTML>';

  if (videoWindow!=0)
     videoWindow.close();

  videoWindow = window.open('', 'MyVideoWindow','resizable=yes, menubar=yes');

  videoWindow.document.myParent = videoWindow;
  videoWindow.document.open();

  videoWindow.document.writeln(towrt);

  videoWindow.focus();

  return true;
}

function markWindowClosed()
{
  videoWindow=0;
}

function addLinkToVideo(video, width, height, title, text)
{
   var wrt;

   if (text==null)
     text=title;

   wrt = '<span onclick="javascript:videoOpener(\'' + video + '\',' +  width + ',' + height + ', \'' + title + '\')" style="color:blue; text-decoration:underline" onmouseover="this.style.cursor=\'pointer\';" onmouseout="this.style.cursor=\'default\';">' + text + '</span>';

   document.writeln(wrt);
}

function showVideosDias(videos_array, videos_title)
{
  var i, j;
 
  for (i = 0; i < videos_array.length; ++i)
  {
    var wrt = '<h3>' + videos_title[i] + '</h3>';
    document.writeln(wrt);
    var vArray = videos_array[i];

    for (j = 0; j < vArray.length; ++j)
    {
      wrt = '<br><img src="/videos/research/' + vArray[j] + '_thumb.jpg" onclick="javascript:videoOpener(\'/videos/research/' + vArray[j] + '.rmvb\',' +  640 + ',' + 480 + ', \'' + vArray[j] + '\')" onmouseover="this.style.cursor=\'pointer\';" onmouseout="this.style.cursor=\'default\';"><br>';
      document.writeln(wrt);
    }
  }
}
