///////////////////////////////////////////////////////////////////////
//     													    //
//                                                                   		    //
//     Scripts de La Jiribilla, Revista de Cultura Cubana           //
//                          lajiribilla@enet.cu                               //
//                                                                   		    //
///////////////////////////////////////////////////////////////////////

/*********************************************************************************
Adicionar al menú de enlaces Favoritos:
*********************************************************************************/
function AddBookmark() 
{
	if (document.all) {
		window.external.AddFavorite(document.location, document.title);
	}
}

/*********************************************************************************
Abrir ventanas Popup:
*********************************************************************************/
function openWin(page)
{
 var nw; 
 nw=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=600px,height=440,top=0,center=55',copyhistory=0);
 if (nw!=null) nw.opener=self;   
}

function openMuseos(page)
{
 var nwm; 
 nwm=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=720px,height=540,top=0,center=55',copyhistory=0);
 if (nwm!=null) nwm.opener=self;   
}

function openCinco(page)
{
 var nwc; 
 nc=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=600px,height=600,top=0,center=55',copyhistory=0);
 if (nc!=null) nc.opener=self;   
}

function openWinFeria(page)
{
 var nwf; 
 nwf=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=701px,height=512,top=0,center=55',copyhistory=0);
 if (nwf!=null) nwf.opener=self;   
}

function openWinLeer(page)
{
 var nww; 
 nww=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=701px,height=701,top=0,center=55',copyhistory=0);
 if (nww!=null) nww.opener=self;   
}

function openEspeciales(page)
{
 var nwe; 
 nwe=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=795px,height=238,top=0,center=55',copyhistory=0);
 if (nwe!=null) nwe.opener=self;   
}
function openPanoramica(page)
{
 var nwp; 
 nwp=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=620px,height=265,top=0,center=55',copyhistory=0);
 if (nwp!=null) nwp.opener=self;   
}

function openPanoramicaw(page)
{
 var nwp1; 
 nwp=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=780px,height=315,top=0,center=55',copyhistory=0);
 if (nwp!=null) nwp.opener=self;   
}

function openPrologo(page)
{
 var nwl; 
 nwl=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=410px,height=480,top=0,center=55',copyhistory=0);
 if (nwl!=null) nwl.opener=self;   
}

function openGuarandinga(page)
{
 var nwl; 
 nwl=window.open(page, null,'fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=720px,height=410,top=0,center=55',copyhistory=0);
 if (nwl!=null) nwl.opener=self;   
}

/*********************************************************************************
Búsquedas en Google:
*********************************************************************************/
function MyGoogle( Word ) 
{  
if(!Word) 
  { alert( "Por favor ingresa los topicos por los cuales buscar." ); return; } 
var MySite = "www.lajiribilla.cu"; 
window.open ("http://www.google.com/search?q=site:" + MySite + "+" + Word); 
}  

/*********************************************************************************
Fecha Actual:
*********************************************************************************/
 var months = new Array("Enero", "Feb.", "Marzo",
            "Abril", "Mayo", "Junio", "Julio", "Agosto", "Sept.",
            "Oct.", "Nov.", "Dic.");
 var months_comp = new Array("Enero", "Febrero.", "Marzo",
            "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
            "Octubre", "Noviembre", "Diciembre");
         var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
         var days = new Array("Domingo", "Lunes", "Martes",
            "Miércoles", "Jueves", "Viernes", "Sábado");

 function getToday() 
 {
            // Generate today's date.
            this.now = new Date();
            this.year = this.now.getYear(); // Returned relative
                                                   // to 1900
            this.month = this.now.getMonth();
            this.days = this.now.getDay();
            this.day = this.now.getDate();
  }

  // Start with a calendar for today.
  today = new getToday();     
  
  
 /*********************************************************************************
Enable drag image:
*********************************************************************************/
 function GoAviso()
 {   
   	img_aviso.className = 'aviso_inv';
 }
 
  function OutAviso()
 {   
   	img_aviso.className = 'aviso_vis';
 }

 var elDragged = null  // Element to drag.

  function doMouseMove() 
  {
            // Check whether mouse button is down and whether
            // an element is being dragged.
            if ((1 == event.button) && (elDragged != null)) 
            {
               // Move the element.
               // Save mouse's position in the document
               var intTop = event.clientY + document.body.scrollTop;
               var intLeft = event.clientX + document.body.scrollLeft;
               // Determine what element the mouse is really over.
               var intLessTop  = 0;
               var intLessLeft = 0;
               var elCurrent = elDragged.offsetParent;
               while (elCurrent.offsetParent != null) {
                  intLessTop += elCurrent.offsetTop;
                  intLessLeft += elCurrent.offsetLeft;
                  elCurrent = elCurrent.offsetParent;
               }
               // Set new position.
               elDragged.style.pixelTop =
                  intTop  - intLessTop - elDragged.y;
               elDragged.style.pixelLeft =
                  intLeft - intLessLeft  - elDragged.x;
               event.returnValue = false;
            }
   }

 function checkDrag(elCheck) 
 {
            // Check whether the mouse is over an element
            // that supports dragging.
            while (elCheck != null) {
               if (null != elCheck.getAttribute("dragEnabled")) 
                  return elCheck;
               elCheck = elCheck.parentElement;
            }      
            return null;
  }
  
  function doMouseDown() 
  {
            // Store element to be dragged.
            var elCurrent = checkDrag(event.srcElement);
            if (null != elCurrent) {
               elDragged = elCurrent;
               // Determine where the mouse is in the element.
               elDragged.x = event.offsetX;
               elDragged.y = event.offsetY;
               var op = event.srcElement;
               // Find real location with respect to element being
               // dragged.
               if ((elDragged != op.offsetParent) &&
                     (elDragged != event.srcElement)) {
                  while (op != elDragged) {
                     elDragged.x += op.offsetLeft;
                     elDragged.y += op.offsetTop;
                     op = op.offsetParent;
                  }
               }
            }
    }

 function doSelectTest() 
 {
 // Hook up mouse event handlers.
 document.onmousedown = doMouseDown;
 document.onmousemove = doMouseMove;

// Reset element when mouse button is released.
 document.onmouseup = new Function("elDragged = null;");
 document.ondragstart = doSelectTest;
 document.onselectstart = doSelectTest;
 
            // Don't start text selections in dragged elements.
            return (null == checkDrag(event.srcElement) &&
               (elDragged!=null));
 }




/**********************************************************************************   
     PageScroll 
*   Copyright (C) 2007, La Jiribilla
*   Author: Ing. René Hernández Cabrales
*   Email: reneh@enet.cu
*
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by CHR.sa
*********************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()


/*********************************************************************************
These are the variables you have to set:
*********************************************************************************/

//The speed of the timeout between each scroll.
timSpeed = 50

//The height of the container (change this when it scrolls to much or to little)
contHeight = 100

/*********************************************************************************
This is the object constructor function, which applies 
methods and properties to the Cross-browser layer object
*********************************************************************************/
function makeScrollObj(obj,nest){
	nest=(!nest) ? "":'document.'+nest+'.'		
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;		
	this.height=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.top=b_gettop										
	return this
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

//Getting the top for the top method
function b_gettop(){
	var gleft=(bw.ns4 || bw.ns6)?parseInt(this.css.top):eval(this.css.pixelTop);
	return gleft;
}
//Variables
var scrollTim = 1;
var active = 0;
/*********************************************************************************
The scroll function. Checks what way to scroll and checks if the
layer is not already on top or bottom.
*********************************************************************************/
function scroll(speed){
	clearTimeout(scrollTim)
	way = speed>0?1:0
	if ((!way && oScroll[active].top()>-oScroll[active].height+contHeight) || (oScroll[active].top()<0 && way)){
		oScroll[active].css.top = (oScroll[active].top()+speed)+px
		scrollTim = setTimeout("scroll("+speed+")",timSpeed)
	}
}
//Clears the timeout so the scroll stops, this is called onmouseout.
function noScroll(){
	clearTimeout(scrollTim)
}
/*********************************************************************************
Changes the active layer. Hides the one that's visible and
shows the "new" one. Also set's the new layers top to
0 so it starts at top.
*********************************************************************************/
function changeActive(num){
	oScroll[active].css.visibility = "hidden"
	active = num
	oScroll[active].css.top = 0+px
	oScroll[active].css.visibility = "visible"
}
/*********************************************************************************
Initilizes the page, makes a oScroll Array and calls the object constructor.
Here you can add as many scrollObjects as you want
*********************************************************************************/
function scrollInit(){
	oScroll = new Array()
	
	// You can add and remove scrollObjects here.
	oScroll[0] = new makeScrollObj('divScroll1','divCont')
		
	oScroll[0].css.left = 0+px
	oScroll[0].css.top = 0+px
	oScroll[0].css.visibility = "visible"
	oControl = new makeScrollObj('divControl')
	oControl.css.visibility = "visible"
	
}





