var RutaImg = "http://192.168.1.201:8080/img/fla/";
var IE = navigator.appName.indexOf("Microsoft") != -1;
var Full = false;
var Margen = 70;
var WImgGrande = 739;
var HImgGrande = 1200;
var WTrama = 1955;
var HTrama = 1235;

function Medidas(){
  if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
  }else if( document.documentElement ){
    if ( document.documentElement.clientWidth || document.documentElement.clientHeight ){
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    }else if ( document.body.clientWidth || document.body.clientHeight ){
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
  }else if( document.body ){
    if( document.body.clientWidth || document.body.clientHeight ){
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
  }
}

function Reposicionar(){
  if (Full){
    Medidas();

    NewH = myHeight - Margen*2;
    NewW = Math.floor( NewH * WImgGrande / HImgGrande );
    
    var CF = document.getElementById("ContFoto").style;
    CF.width = myWidth+"px";
    CF.height = myHeight+"px";

    var CImgF = document.getElementById("CImgFull").style;
    CImgF.left = Math.floor(myWidth/2 - NewW/2) +"px";
    CImgF.width = NewW+"px";
    CImgF.height = NewH+"px";
    
    var ImgF = document.getElementById("ImgFull").style;
    ImgF.width = NewW+"px";
    ImgF.height = NewH+"px";
    
    var CTrama = document.getElementById("CFondo").style;
    CTrama.height = myHeight + "px";
    CTrama.width = myWidth + "px";
      
    NewW = myWidth;
    NewH = Math.floor( NewW * HTrama / WTrama );
    
    var T = document.getElementById("FImgFondo").style;
    T.width = NewW+"px";
    T.height = NewH+"px";

    var Trama = document.getElementById("CImgFondo").style;
    Trama.width = NewW+"px";
    Trama.height = NewH+"px";
    Trama.top = Math.floor(myHeight/2-NewH/2)+"px";
    Trama.left = Math.floor(myWidth/2-NewW/2)+"px";
    
  }
}

function Inicio(){
  if (window.captureEvents){
    window.captureEvents(Event.RESIZE);
    window.onresize = function(){
      Reposicionar();
    };
  }else{
    window.onresize = function(){
      clearTimeout(resizeDelay);
      resizeDelay = setTimeout("Reposicionar()", 200);
    }
  }
}

function CargarFotoFull( Foto ){
  Medidas();
  //alert(Foto.toLowerCase());
  var E = document.getElementById("ContFoto");
  E.style.background = "#000";
  E.style.top = "0px";
  E.style.left = "0px";
  E.style.height = myHeight + "px";
  E.style.width = myWidth + "px";
  E.style.cursor = "pointer";
  
  NewW = myWidth;
  NewH = Math.floor( NewW * HTrama / WTrama );
 
  var Fondo = '<div id="CFondo" style="z-index:1000;position:absolute;top:0px;left:0px;width:'+myWidth+'px;height:'+myHeight+'px;overflow:hidden;">';
    Fondo += '<div id="CImgFondo" style="position:absolute;top:'+Math.floor(myHeight/2-NewH/2)+'px;left:'+Math.floor(myWidth/2-NewW/2)+'px;height:'+NewH+'px;width:'+NewW+'px;">';
      Fondo += '<img id="FImgFondo" src="'+RutaImg+'trama'+Trama+'.gif" alt="" border="0" style="height:'+NewH+'px;width:'+NewW+'px;">';
    Fondo += '</div>';
  Fondo += '</div>';
  
  NewH = myHeight - Margen*2;
  NewW = Math.floor( NewH * WImgGrande / HImgGrande );
  
  var Foto_final = Foto.toLowerCase();
  var Img = '<div id="CImgFull" style="z-index:1001;position:absolute;top:'+Margen+'px;left:'+(Math.floor(myWidth/2 - NewW/2))+'px;width:'+NewW+'px;height:'+NewH+'px;">';
  Img += '<img id="ImgFull" src="'+RutaImg+'2011_pv/'+Foto_final+'" border="0" alt="" style="width:'+NewW+'px;height:'+NewH+'px;"/>';
  Img += '</div>';
  
  var Logo = '<div style="z-index:1002;position:absolute;top:15px;left:879px;width:143px;height:30px;">';
  Logo += '<img src="'+RutaImg+'logo.png" alt="Logo SE" border="0" style="width:143px;height:30px;"/>';
  Logo += '</div>';
  
  
  E.onclick = function(){
    Full = false;

    var F = document.getElementById("ContFoto");
    
    F.style.visibility = "hidden";
    F.style.display = "none";
    F.innerHTML = '';
  }
  
  E.innerHTML = Fondo + Logo + Img;
  E.style.display = "block";
  E.style.visibility = "visible";
  
  Full = true;
}

function Fla_DoFSCommand(command, args) {
  if (command == "Full"){
    CargarFotoFull( args );
  }
}

if (IE){
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub Fla_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call Fla_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
}

function showdetail(id,idfirst){
    if(!idfirst){idfirst=id;}
    jQuery('#'+idfirst).hide();
    jQuery('#'+id+'_detail').show();
}

function hidedetail(id,idfirst){
    if(!idfirst){idfirst=id;}
    jQuery('#'+id+'_detail').hide();
    jQuery('#'+idfirst).show();
    jQuery('#'+id+'_detail_img').css('top','0px');
}

var cangodown=true;
var maxdown = -1295;
function godown(id){
    if(cangodown){
        var top = jQuery('#'+id).css('top');
        top = top.substr(0,top.length-2);
        if(isNaN(top)){top=0;}
        top-=3;
        if(top>maxdown){
            jQuery('.down').show();
            if(top<=maxdown){top=maxdown;}
            jQuery('#'+id).css('top',top+'px');
        }else{jQuery('.down').hide();}
        setTimeout("godown('"+id+"');",10);
    }else{
        cangodown=true;
        jQuery('.down').hide();
    }
}

function stopdown(id){
    cangodown=false;
}

var cangoup=true;

function goup(id){
    if(cangoup){
        var top = jQuery('#'+id).css('top');
        top = Number(top.substr(0,top.length-2));
        if(top<0){
            jQuery('.up').show();
            top+=3;
            if(top>0){top=0;}
            jQuery('#'+id).css('top',top+'px');
        }else{jQuery('.up').hide();}
        setTimeout("goup('"+id+"');",10);
    }else{
        cangoup=true;
        jQuery('.up').hide();
    }
}

function stopup(id){
    cangoup=false;
}


