<!--


// ---  Functions to manage the right column disappearing effect  --- //

function to_right () {

  if (img_big = document.getElementById ('news_image_big')) {

    img_small = document.getElementById ('image_0');
    img_small.style.display = 'block';

    img_big.style.display = 'none';

  }

  $('#column_right').css('display','none');
  $('#video_tabs_container').css('width','908px');
  $('#video_story').find('.story_item').css('width','282px');
  $('#column_left').addClass('full');

  marco = $('#infografia_frame');
  if (marco.length) {
    heights = marco.attr('rel').split('|');
    marco.css('height',heights[1]+'px');
  }

  $('#boundary').css('background-image','url(/2.0/images/bound_left.gif)').css('right','12px');
  document.getElementById ('boundary').onclick = to_left; //.attr('onclick','to_left');

}

function to_left () {

  if (img_big = document.getElementById ('news_image_big')) {

    img_small = document.getElementById ('image_0');
    img_small.style.display = 'none';

    img_big.style.display = 'block';

  }

  $('#column_left').removeClass('full');
  $('#video_tabs_container').css('width', '600px');
  $('#video_story').find('.story_item').css('width', '286px');
  $('#column_right').css('display','block');

  marco = $('#infografia_frame');
  if (marco.length) {
    heights = marco.attr('rel').split('|');
    marco.css('height',heights[0]+'px');
  }

  $('#boundary').css('background-image','url(/2.0/images/bound_right.gif)').css('right','320px');
  document.getElementById ('boundary').onclick = to_right;

}


// ---  Function to play video  --- //

function lateral_video_player (pos, autoplay) {

  $('#video_lateral').empty ();

  var tmp = video_list [pos].split ('||');
  flash_headline.innerHTML = tmp [1];
  flash_date.innerHTML = tmp [2];
  flash_title.innerHTML = tmp [3];
  document.getElementById ('video_lateral').style.backgroundImage = 'url(' + tmp [4] + ')';

  video_player (tmp [0], 'video_lateral', autoplay, 300);

}

function video_player (video_id, div_id, autoplay, player_width, player_height) {

  var div = document.getElementById (div_id);

  var box = document.createElement ('DIV');
  box.id = div_id + '_' + video_id;
  div.appendChild (box);

  var flashvars = {
    config: '/2.0/video_player_2.php?id=' + video_id,
    autoplay: (autoplay ? 'true' : 'false')
  };

  var params = {
    allowscriptaccess: 'sameDomain',
    allowfullscreen: 'true',
    quality: 'high',
    wmode: 'opaque'
  };

  if (!player_height) player_height = Math.round (player_width * 0.75) + 21;

  swfobject.embedSWF ('/player/flvplayer.swf', box.id, player_width, player_height, "8.0.0", null, flashvars, params, {} );

}

function lateral_video_player_3 (pos, autoplay) {

  $('#video_lateral').empty ();

  var tmp = video_list [pos].split ('||');
  flash_headline.innerHTML = tmp [1];
  flash_date.innerHTML = tmp [2];
  flash_title.innerHTML = tmp [3];
  document.getElementById ('video_lateral').style.backgroundImage = 'url(' + tmp [4] + ')';

  video_player_3 (tmp [0], 'video_lateral', autoplay, 300);

}

function video_player_3 (video_id, div_id, autoplay, player_width, player_height) {

  var div = document.getElementById (div_id);

  var box = document.createElement ('DIV');
  box.id = div_id + '_' + video_id;
  div.appendChild (box);

  swfPath = '/video_' + video_id + '/' + (player_width <= 300 ? 'medium' : 'large') + '.swf';

  var flashvars = {
    autoPlay: (autoplay ? 'true' : 'false')
  };

  var params = {
    allowscriptaccess: 'sameDomain',
    allowfullscreen: 'true',
    quality: 'high',
    wmode: 'transparent'
  };

  if (!player_height) player_height = Math.round (player_width * 0.75) + 28;

  swfobject.embedSWF (swfPath, box.id, player_width, player_height, "9.0.115", '/player/expressInstall.swf', flashvars, params, {} );
//  swfobject.embedSWF ('/player/efePlayer.swf', box.id, player_width, player_height, "9.0.115", '/player/expressInstall.swf', flashvars, params, {} );

}


// ---  Functions to manage the photo gallery  --- //

var gallery_shown = false;

function gallery_handler (data) {

  $('#overlayer_content').html(data).css('marginRight','25px');

  if (!gallery_shown) gallery_shown = $('#gallery_images').find('a:first').attr('id').substr(2);
  $.get ('/2.0/gallery.articulo.php', { load: gallery_shown }, gallery_news_handler);

  setTimeout ("  $('#gallery_close').fadeTo('150',0.15,function(){  $('#gallery_close').fadeTo('150',1);  });  ", 1000);

}

function gallery_news_handler (data) {

  document.getElementById ('gallery_shown').innerHTML = data;

  document.getElementById ('a_' + gallery_shown).className = 'shown';

  var g_image = document.getElementById ('img_' + gallery_shown);
  var img_pos = g_image.alt.split ('_');

  var g_images = $('#gallery_images img');
  var g_index = g_images.index (g_image);

  if (tmp = g_images.get(g_index - 1)) {
    tmp = tmp.alt.split ('_');
    img_pos [0] = tmp [0];
  }

  if (tmp = g_images.get(g_index + 1)) {
    tmp = tmp.alt.split ('_');
    img_pos [1] = tmp [1];
  }

  img_pos [0] = parseInt (img_pos [0], 10);
  img_pos [1] = parseInt (img_pos [1], 10);

  var divGallery = document.getElementById ('gallery_images');
  var divScroll =  parseInt (divGallery.scrollTop, 10);
  var divOffset =  parseInt (divGallery.offsetHeight, 10);

  if (divGallery.scrollTop > img_pos [0]) divGallery.scrollTop = img_pos [0];
  else if (divScroll + divOffset < img_pos [1]) divGallery.scrollTop = img_pos [1] - divOffset;

  $('#gallery_shown_real').hover(function(){
    $('#gallery_shown_descr').fadeTo('fast', 0.90);
  },function(){
    $('#gallery_shown_descr').fadeTo('fast', 0.33);
  });

}

function open_gallery (t, p, shown) {

  var OC = document.getElementById ('overlayer_content');
  OC.style.width = '975px';
  OC.style.height = '550px';
  OC.style.border = '1px solid #FFFFFF';

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  document.getElementById ('overlayer_mask').style.visibility = 'visible';
  document.getElementById ('overlayer').style.visibility = 'visible';

  gallery_shown = shown;
//  $.get ('/2.0/gallery.php', { t: t, p: p, rnd: Math.random() }, gallery_handler);
  $.get ('/2.0/gallery.php', { t: t, p: p }, gallery_handler);

}

function close_gallery () {

  document.getElementById ('overlayer').style.visibility = 'hidden';
  document.getElementById ('overlayer_mask').style.visibility = 'hidden';

  $('#video_lateral').children().show();
  $('.news_image').find('object,embed').show();

  $('#overlayer_content').html('').css('marginRight','0px').css('width','').css('border','');
//  var OC = document.getElementById ('overlayer_content');
//  OC.style.width = '';
//  OC.style.border = '';

}

function news_gallery (load) {

  document.getElementById ('a_' + gallery_shown).className = '';

  gallery_shown = load;
  document.getElementById ('a_' + gallery_shown).className = 'shown';

  $.get ('/2.0/gallery.articulo.php', { load: load }, gallery_news_handler);

}


// ---  Flash goals big version  --- //

function open_flash_goals () {

  var OC = document.getElementById ('overlayer_content');
  OC.style.width = '700px';
  OC.style.height = '536px';
  OC.style.border = '1px solid #C0C0C0';

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  document.getElementById ('overlayer_mask').style.visibility = 'visible';
  document.getElementById ('overlayer').style.visibility = 'visible';

  var inner = 'http://www.servidornoticias.com/2.0/include/box.flash_goals_big.php';
//  var inner = '/2.0/include/box.flash_goals_big.php';
  inner = '<iframe src="' + inner + '" scrolling="no" border="no" frameborder="no" width="698" height="510" style="margin: 1px;"></iframe>' + "\n"
  inner += '<div style="text-align: right; font-size: 130%; padding: 3px 6px;">[<a href="#" onclick="close_gallery ();" style="color: #000000;"> cerrar ampliado </a>]</div>';

  OC.innerHTML = inner;

}

function open_flash_oscar () {

  $('#overlayer_content').css({
    'width': '602px',
    'height': '476px',
    'border': '1px solid #C0C0C0'
  });

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  $('#overlayer_mask').css('visibility','visible');
  $('#overlayer').css('visibility','visible');

  var inner = 'http://www.servidornoticias.com/2.0/include/box.flash_oscar_big.php';
//  var inner = '/2.0/include/box.flash_oscar_big.php';
  inner = '<iframe src="' + inner + '" scrolling="no" border="no" frameborder="no" width="600" height="450" style="margin: 1px;"></iframe>' + "\n"
  inner += '<div style="text-align: right; font-size: 130%; padding: 3px 6px;">[<a href="#" onclick="close_gallery ();" style="color: #000000;"> cerrar </a>]</div>';

  $('#overlayer_content').html(inner);

}

function open_flash_guantanamo () {

  var OC = document.getElementById ('overlayer_content');
  OC.style.width = '602px';
  OC.style.height = '476px';
  OC.style.border = '1px solid #C0C0C0';

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  document.getElementById ('overlayer_mask').style.visibility = 'visible';
  document.getElementById ('overlayer').style.visibility = 'visible';

  var inner = 'http://www.servidornoticias.com/2.0/include/box.flash_guantanamo_big.php';
//  var inner = '/2.0/include/box.flash_guantanamo_big.php';
  inner = '<iframe src="' + inner + '" scrolling="no" border="no" frameborder="no" width="600" height="450" style="margin: 1px;"></iframe>' + "\n"
  inner += '<div style="text-align: right; font-size: 130%; padding: 3px 6px;">[<a href="#" onclick="close_gallery ();" style="color: #000000;"> cerrar </a>]</div>';

  OC.innerHTML = inner;

}

function open_flash_obama () {

  var OC = document.getElementById ('overlayer_content');
  OC.style.width = '602px';
  OC.style.height = '476px';
  OC.style.border = '1px solid #C0C0C0';

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  document.getElementById ('overlayer_mask').style.visibility = 'visible';
  document.getElementById ('overlayer').style.visibility = 'visible';

  var inner = 'http://www.servidornoticias.com/2.0/include/box.flash_obama_big.php';
//  var inner = '/2.0/include/box.flash_obama_big.php';
  inner = '<iframe src="' + inner + '" scrolling="no" border="no" frameborder="no" width="600" height="450" style="margin: 1px;"></iframe>' + "\n"
  inner += '<div style="text-align: right; font-size: 130%; padding: 3px 6px;">[<a href="#" onclick="close_gallery ();" style="color: #000000;"> cerrar </a>]</div>';

  OC.innerHTML = inner;

}

function open_flash_fidel () {

  var OC = document.getElementById ('overlayer_content');
  OC.style.width = '602px';
  OC.style.height = '476px';
  OC.style.border = '1px solid #C0C0C0';

  $('#video_lateral').children().hide();
  $('.news_image').find('object,embed').hide();

  document.getElementById ('overlayer_mask').style.visibility = 'visible';
  document.getElementById ('overlayer').style.visibility = 'visible';

  var inner = 'http://www.servidornoticias.com/2.0/include/box.flash_fidel_big.php';
//  var inner = '/2.0/include/box.flash_fidel_big.php';
  inner = '<iframe src="' + inner + '" scrolling="no" border="no" frameborder="no" width="600" height="450" style="margin: 1px;"></iframe>' + "\n"
  inner += '<div style="text-align: right; font-size: 130%; padding: 3px 6px;">[<a href="#" onclick="close_gallery ();" style="color: #000000;"> cerrar </a>]</div>';

  OC.innerHTML = inner;

}


// ---  Setup variables and functions  --- //

function imprimir (t, p, id) {

  var params = 'directories=0, resizable=0, scrollbars=1, status=0, menubar=0, toolbar=0, top=150, left=150, width=700, height=550';
  window.open ('/2.0/texto.php?t=' + t + '&p=' + p + '&id=' + id, null, params);

}

$(document).ready(function(){

  // Managing zoom layer effect
  $(".news_zoom").parent().hover(function(){
    $(this).find("a").fadeTo("fast", 0.80);
  },function(){
    $(this).find("a").fadeTo("fast", 0.33);
  }).find('img').each(function(i){
    var p = this.src.split ('&w=');
    if (p.length <= 1) return;
    p [p.length - 1] = 100;
    var q = new Image ();
    q.src = p.join ('&w=');
  });

  // Managing boundary effect
  $("#boundary").hover(function(){
    $(this).fadeTo("fast", 1.00);
  },function(){
    $(this).fadeTo("fast", 0.33);
  });

});

// -->
