// Centered Pop-Up Window (v1.0)
// (C) 2002-2003 www.smileycat.com
// Free for all users, but leave in this header

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL ,winName,features);
}

function getGente() { 
	document.location = '/gente_del_turf/' + document.getElementById('idGalNews').value + '-';
}

var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function correctPNG()
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()

      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText

         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

         var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;"
             + imgStyle + ";"      + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"

         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
//window.attachEvent("onload", correctPNG);

function setStyle(cssname)
{
	document.getElementById('sizeCss').disabled = true;
	document.getElementById('sizeCss').href = '/css/' + cssname + '.css';
	document.getElementById('sizeCss').disabled = false;
}

function increaseFontSize()
{
	var size;
	if (parseInt(document.getElementById("sizeInterior").value)<4)
	{
		size = parseInt(document.getElementById("sizeInterior").value) + 1;
		setStyle('size' + size);
		document.getElementById("sizeInterior").value = size;
	}
}

function decreaseFontSize()
{
	var size;
	if (parseInt(document.getElementById("sizeInterior").value)>1)
	{
		size = parseInt(document.getElementById("sizeInterior").value) - 1;
		setStyle('size' + size);
		document.getElementById("sizeInterior").value = size;
	}
}

var galEl = null;
var numPh = null;
var visCount = 6;		//Cantidad de fotos visibles
var phWidth = 46;		//Ancho  de la foto
var velInit = 150;		//Velocidad de timeout inicial
var razon = null;

function slide(dire)
{
	if(dire == 1 && galEl.style.marginLeft == '0px') return;
	if(dire == -1 && parseInt(galEl.style.marginLeft) == ((numPh - visCount) * (-phWidth))) return;
	razon = 1;
	softSlide(dire, (parseInt(galEl.style.marginLeft) + (dire * phWidth)), velInit);
}

function softSlide(dire, mod, to)
{
	if(mod == parseInt(galEl.style.marginLeft)) {
		return;
	}
	
	if((dire == -1 && (parseInt(galEl.style.marginLeft) - razon) > mod) ||  
		(dire == 1 && (parseInt(galEl.style.marginLeft) + razon) < mod))
			galEl.style.marginLeft = (parseInt(galEl.style.marginLeft) + (dire * razon)) + 'px';
	else galEl.style.marginLeft = mod + 'px';
	
	razon = parseInt(phWidth/(Math.abs(mod - parseInt(galEl.style.marginLeft))+1)) + razon;
	setTimeout("softSlide(" + dire + ", " + mod + ", " + (parseInt(to * .5) + 1) + ")", to);
}

function initSlide()
{
	galEl = document.getElementById('gal');
	galEl.style.marginLeft = '0px';
	numPh = galEl.getElementsByTagName('td').length;
}

function chgPhoto(id, idNews)
{
	document.getElementById('galPpal').src = '/img/photos/' + id + "_2.JPG";
	document.getElementById('idGal').value = id;
	document.getElementById('idGalNews').value = idNews;
	document.getElementById('titleGallery').innerHTML = document.getElementById('pnt' + idNews).value;
}

/* para la galeria interior */
var galElInt = null;
var numPhInt = null;
var visCountInt = 9;		//Cantidad de fotos visibles
var phWidthInt = 56;		//Ancho  de la foto
var velInitInt = 150;		//Velocidad de timeout inicial
var razonInt = null;

function slideInt(dire)
{
	if(arrPhotos.length <= visCountInt) {
		return;
	}
	if(dire == 1 && galElInt.style.marginLeft == '0px') return;
	if(dire == -1 && parseInt(galElInt.style.marginLeft) == ((numPhInt - visCountInt) * (-phWidthInt))) return;
	razonInt = 1;
	softSlideInt(dire, (parseInt(galElInt.style.marginLeft) + (dire * phWidthInt)), velInitInt);
}

function softSlideInt(dire, mod, to)
{
	if(mod == parseInt(galElInt.style.marginLeft)) {
		return;
	}
	
	if((dire == -1 && (parseInt(galElInt.style.marginLeft) - razonInt) > mod) ||  
		(dire == 1 && (parseInt(galElInt.style.marginLeft) + razonInt) < mod))
			galElInt.style.marginLeft = (parseInt(galElInt.style.marginLeft) + (dire * razonInt)) + 'px';
	else galElInt.style.marginLeft = mod + 'px';
	
	razonInt = parseInt(phWidthInt/(Math.abs(mod - parseInt(galElInt.style.marginLeft))+1)) + razonInt;
	setTimeout("softSlideInt(" + dire + ", " + mod + ", " + (parseInt(to * .5) + 1) + ")", to);
}

function initSlideInt()
{
	galElInt = document.getElementById('gal');
	galElInt.style.marginLeft = '0px';
	numPhInt = galElInt.getElementsByTagName('td').length;
}

function chgPhotoInt(id)
{
	document.getElementById('pInteriorPpal').src = "/img/photos/" + id + "_3.JPG";
	document.getElementById('pEpigraph').innerHTML = document.getElementById('pEpigraph' + id).value;
}

var indPhoto = 0;
function chgPhotoOrd()
{
	if(arrPhotos.length == (indPhoto+1)) indPhoto = 0;
	else indPhoto++;
	chgPhotoInt(arrPhotos[indPhoto]);
}
/* fin galeria interior*/

var limitNum = 300;

function limitText(obj) {
    if (obj.value.length > limitNum) {
        obj.value = obj.value.substring(0, limitNum);
    } 
}

// Collapse divs

var openObj = null;
function collapse(targetname)
{
if (document.getElementById('d' + targetname).style.display != 'block')
 { 
 	if(openObj!=null) openObj.style.display = 'none';
 	document.getElementById('d' + targetname).style.display = 'block'; 
 	openObj = document.getElementById('d' + targetname);
	//document.location = '#' + targetname;
 } 
else 
 { document.getElementById('d' + targetname).style.display = 'none'; 
 	openObj = null;
	}
} 

