// JavaScript Document

var newsfont = 16;  
function changeFont(id) {  

if (document.getElementById) {  
        document.getElementById(id).style.fontSize = newsfont+"px";  
    } else {  
        if (document.layers) {  
            document.layers[id].fontSize = newsfont+"px";  
        } else {  
            if (document.all) {  
                eval("document.all." + id + ".style.fontSize = \"" + newsfont + "px \"");  
            }  
        }  
    }  
      
    // esto arregla scroll al utilizar layers  
//    updateHeight();   
    setCookie();  
}  
// aqui se produce el error  
function larger() {  
    if (newsfont < 20) {  
        newsfont= newsfont +3;  
        changeFont('cuerpocontenido');  
    }  
}  

function smaller() {  
    if (newsfont > 10) {  
    newsfont= newsfont -1;  
    changeFont('cuerpocontenido');  
    }  
}  

/**
 * Image src URLs
 **/
var imageList = [	 

				 "dos/img/carousel/relacionado-01.jpg"
				 , "dos/img/carousel/relacionado-02.jpg"
				 , "dos/img/carousel/relacionado-03.jpg"
				 , "dos/img/carousel/relacionado-04.jpg"
				  , "dos/img/carousel/cabecera2_r1_c1.jpg"
				  , "dos/img/carousel/otrositios.jpg"
				 ];
var urlList = [		
				 "http://www.oaxaca.gob.mx/"
				 ,"http://www.congresooaxaca.gob.mx/"
				  ,"http://www.scjn.gob.mx/"
				  ,"http://www.ordenjuridico.gob.mx/"
				  ,"http://www.amij.org.mx"
				  ,"ligas.html"
				 ];
var descurl = [		
				 "Gobierno del Estado de Oaxaca"
				 ,"Congreso de Estado de Oaxaca- LX1 Legislatura"
				 ,"Suprema Corte de Justicia de la Naci&oacute;n"
				  ,"Orden Jur&iacute;dico de la Naci&oacute;n"
				  ,'Asociaci&oacute;n Mexicana de la Impartici&oacute;n de Justicia'
				   ,'Otros Sitios...'
				 ];

var lastRan = -1;

/**
 * Since carousel.addItem uses an HTML string to create the interface
 * for each carousel item, this method formats the HTML for an LI.
 **/

var fmtItem = function(imgUrl, url, title) {

  	var innerHTML = 
  		'<a href="' + 
  		url + 
  		'"><img title="'+title+'" src="' + 
  		imgUrl +
		'" width="' +
		75 +
		'" height="' +
		75+
		'"/>' + 
  		title + 
  		'<\/a>';
  
	return innerHTML;
	
};

/**
 * Custom inital load handler. Called when the carousel loads the initial
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadInitHandler
 **/
var loadInitialItems = function(type, args) {
	var start = args[0];
	var last = args[1]; 
	load(this, start, last);	
};

/**
 * Custom load next handler. Called when the carousel loads the next
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadNextHandler
 **/
var loadNextItems = function(type, args) {	

	var start = args[0];
	var last = args[1]; 
	var alreadyCached = args[2];
	
	if(!alreadyCached) {
		load(this, start, last);
	}
};

/**
 * Custom load previous handler. Called when the carousel loads the previous
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadPrevHandler
 **/
var loadPrevItems = function(type, args) {
	var start = args[0];
	var last = args[1]; 
	var alreadyCached = args[2];
	
	if(!alreadyCached) {
		load(this, start, last);
	}
};

var load = function(carousel, start, last) {
	for(var i=start;i<=last;i++) {
		var randomIndex = getRandom(18, lastRan);
		lastRan = randomIndex;
	//	carousel.addItem(i, fmtItem(imageList[randomIndex], urlList[randomIndex], "Number " + i));
		carousel.addItem(i, fmtItem(imageList[i-1], urlList[i-1], descurl[i-1] ));
/*
		// Example of an alternate way to add an item (passing an element instead of html string)
		var p = document.createElement("P");
		var t = document.createTextNode("Item"+i);
		p.appendChild(t);
		carousel.addItem(i, p );
*/
	}
};

var getRandom = function(max, last) {
	var randomIndex;
	do {
		randomIndex = Math.floor(Math.random()*max);
	} while(randomIndex == last);
	
	return randomIndex;
};

/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 **/
var handlePrevButtonState = function(type, args) {

	var enabling = args[0];
	var leftImage = args[1];
	if(enabling) {
		leftImage.src = "images/left-enabled.gif";	
	} else {
		leftImage.src = "images/left-disabled.gif";
	}
	
};

var handleNextButtonState = function(type, args) {

 var enabling = args[0];
 var rightImage = args[1];

 if(enabling) {
 rightImage.src = "images/right-enabled.gif";
 } else {
 rightImage.src = "images/right-disabled.gif";
 }
}
/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'dhtml-carousel'.) See the
 * HTML code below.
 **/

var carousel; // for ease of debugging; globals generally not a good idea
var pageLoad = function() 
{
	carousel = new YAHOO.extension.Carousel("dhtml-carousel", 
		{
			numVisible:        2,
			animationSpeed:    0.25,
			scrollInc:         2,
			navMargin:         40,
			prevElement:       "prev-arrow",
			nextElement:       "next-arrow",
			loadInitHandler:   loadInitialItems,
			loadNextHandler:   loadNextItems,
			loadPrevHandler:   loadPrevItems,
			size: 6,
			prevButtonStateHandler:   handlePrevButtonState,
			nextButtonStateHandler: handleNextButtonState
		}
	);
};

YAHOO.util.Event.addListener(window, 'load', pageLoad);

