function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   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
	     }
      }
   }


function gmtClock(){
			time = new Date()
			localMS = time.getTime() + ((time.getTimezoneOffset()-300) * 60000)
			gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
			localTime = new Date(localMS)
			gmtTime =  new Date(gmtMS)
			hour = gmtTime.getHours()
			minute = gmtTime.getMinutes()
			second = gmtTime.getSeconds()
			lhour = localTime.getHours()
			lminute = localTime.getMinutes()
			lsecond = localTime.getSeconds()
			ltemp = "" + ((lhour < 10) ? "0" : "") + lhour
			ltemp += ((lminute < 10) ? ":0" : ":") + lminute
			ltemp += ((lsecond < 10) ? ":0" : ":") + lsecond
			temp = "" + ((hour < 10) ? "0" : "") + hour
			temp += ((minute < 10) ? ":0" : ":") + minute
			temp += ((second < 10) ? ":0" : ":") + second
			document.getElementById("GMTTime").innerHTML = temp
			document.getElementById("EcuadorTime").innerHTML = ltemp
			setTimeout("gmtClock()",1000)
		}  

function PopUp(url,winName,features) {
	window.open(url,winName,features);
}

function zoom(image,winName,width,height) {
	Pop('/zoom.aspx?image=' + image + '&width=' + width + '&height=' + height + '&name=' + winName, winName, width + 3, height +3);
}
function PhotoZoom(imageId, footNote) {
	Pop('/zoom.aspx?imageId=' + imageId + '&f=' + footNote, 'FotoZoom', 600, 550);
}
function BlogPhotoZoom(imageId, footNote) {
	Pop('/BlogZoom.aspx?imageId=' + imageId + '&f=' + footNote, 'FotoZoom', 600, 510);
}
function SendtoFriend(entryId) {
	Pop('/sendtofriend.aspx?e=' + entryId, 'SendToFriend', 450, 480);
}
function GallerySendtoFriend(entryId) {
	Pop('/sendtofriend.aspx?e=' + entryId + '&t=1', 'SendToFriend', 450, 480);
}
function BlogSendtoFriend(entryId) {
		Pop('/sendtofriend.aspx?e=' + entryId + '&t=2', 'SendToFriend', 450, 480);
}

function Print(entryId) {
	//Pop('/print.aspx?e=' + entryId, 'Print', 500, 640);
	window.open('/print.aspx?e=' + entryId,'Print','height=500,width=640,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no');
}

function Pop(URL, WinName, x , y) {
window.open(URL,WinName,'height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no');
}
function PopStatus(URL, WinName, x , y) {
	window.open(URL,WinName,'height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=yes,titlebar=no,toolbar=no');
}

// Gallery
function OpenGallery(gallery, entryId, fileId){
	PopStatus('/NewsGallery/' + gallery + '.aspx?e=' + entryId + '&f=' + fileId,'NewsGallery',750,565);
}
function OpenFileGallery(gallery, fileId){
	PopStatus('/file.aspx?f=' + fileId,'FileGallery',750,565);
}

// ThemesGallery
function OpenThemeGallery(gallery, entryId, fileId){
	PopStatus('/ThemesGallery/' + gallery + '.aspx?e=' + entryId + '&f=' + fileId,'ThemeGallery',750,565);
}

//Tournament Objects
function OpenTournamentObjects(webform, objectId, objectName){
	if (objectId!=0)
	PopStatus('/Tournaments/' + webform + '.aspx?e=' + objectId,objectName,600,450);
}

function OpenMatchInfo(webform, objectId, objectName){
	//window.location.href='/Desktop.aspx?Id=200&m=' + objectId;
	window.location.href='/Desktop.aspx?Id=200&m=' + objectId;
}


function fnTrapKD1(btn, event){
	if (document.all){
		if(event.keyCode==13){
				event.returnValue=false;
				event.cancel=true;
				btn.click();
			}
	}
	else if (document.getElementById){
		if(event.wich==13){
				event.returnValue=false;
				event.cancel=true;
				btn.click();
			}
	}
	else if (document.layers){
		if(event.wich==13){
				event.returnValue=false;
				event.cancel=true;
				btn.click();
			}
	}

	//var subBtn = document.getElementById(btn);
	
}


function fnTrapKD(btn, event){
	var subBtn = document.getElementById(btn);
	if(event.keyCode==13){
		event.returnValue=false;
		event.cancel=true;
		subBtn.click();
	}
}

function GoScore() {								
	 window.open('/data/html/popCalificacion.htm','Score','height=250, width=310, location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no');

}

// ----------------------------------------------------------
// Funciones para Rounded Corners ---------------------------
// ----------------------------------------------------------

function NiftyCheck()
{
if(!document.getElementById || !document.createElement)
    return(false);
var b=navigator.userAgent.toLowerCase();
if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
return(true);
}

function Rounded(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    AddTop(v[i],bk,color,size);
    AddBottom(v[i],bk,color,size);
    }
}

function RoundedTop(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddTop(v[i],bk,color,size);
}

function RoundedBottom(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className==selclass){
        objlist.push(v[i]);
        }
    }
return(objlist);
}
function ValidarCheck()
{
	if (!document.getElementById("chkPoliticas").checked)
	{
			Visibilidad("divCheckPoliticas","block");
			window.event.returnValue = false;
	}
	else
		Visibilidad("divCheckPoliticas","none");
	
}
function Visibilidad(nombre,valor){  
	document.getElementById(nombre).style.display=valor;  
} 
function setVisibility(WhichDiv, value) {
	var identif = WhichDiv + "SearchCriteria"
	document.getElementById(identif).style.display=value;
}

Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //NS

function DaysInMonth(WhichMonth, WhichYear) {
  var DaysInMonth = 31;
  if (WhichMonth == "Abril" || WhichMonth == "Junio" || WhichMonth == "Septiembre" || WhichMonth == "Noviembre") DaysInMonth = 30;
  if (WhichMonth == "Febrero" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Febrero" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

function ChangeOptionDays(Which)
{
  DaysObject = eval("document.Desktop." + Which + "Day");
  MonthObject = eval("document.Desktop." + Which + "Month");
  YearObject = eval("document.Desktop." + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0; }

function SetDate(Which,m,d,y)
{
  DaysObject = eval("document.Desktop." + Which + "Day");
  MonthObject = eval("document.Desktop." + Which + "Month");
  YearObject = eval("document.Desktop." + Which + "Year");

  YearObject[y - NowYear].selected = true;
  MonthObject[m-1].selected = true;

  ChangeOptionDays(Which);

  DaysObject[d-1].selected = true;
}

function WriteYearOptions(YearsBefore)
{
  line = "";
  for (i=0; i<YearsBefore; i++)
  {
    line += "<OPTION>";
    line += NowYear - i;
  }
  return line;
}

function increaseText() {
	increaseElementText("PublishDate",12,16);
	increaseElementText("dPreTitle",12,16);
	increaseElementText("h3Title",18,22);
	increaseElementText("summary",12,16);
	increaseElementChildrenText("dlitText",12,16);
}
function decreaseText() {
	decreaseElementText("PublishDate",12,8);
	decreaseElementText("dPreTitle",12,8);
	decreaseElementText("h3Title",18,14);
	decreaseElementText("summary",12,8);
	decreaseElementChildrenText("dlitText",12,8);
	
}
function increaseElementText(elementID, defSize, maxSize) {
	if (document.all || document.getElementById) {
		var el = document.all ? document.all[elementID] : document.getElementById(elementID);
		if (el){
			if (el.style.fontSize == "") el.style.fontSize = defSize;
			if ((parseInt(el.style.fontSize) + 1) == maxSize) el.style.fontSize = maxSize - 2;
			el.style.fontSize = (parseInt(el.style.fontSize) + 1) + 'px';
		}
	}
}
function increaseElementChildrenText(elementID, defSize, maxSize) {
	if (document.all || document.getElementById) {
		var el = document.all ? document.all[elementID] : document.getElementById(elementID);
		if (el) {
			for (i=0; i<=el.children.length-1; i++) {
				if (el.children(i).style.fontSize == "") el.children(i).style.fontSize = defSize;
				if ((parseInt(el.children(i).style.fontSize) + 1) == maxSize) el.children(i).style.fontSize = maxSize - 2;
				el.children(i).style.fontSize = (parseInt(el.children(i).style.fontSize) + 1) + 'px';
			}
		}
	}
}
function decreaseElementText(elementID, defSize, minSize) {
	if (document.all || document.getElementById) {
		var el = document.all ? document.all[elementID] : document.getElementById(elementID);
		if (el) {
			if (el.style.fontSize == "") el.style.fontSize = defSize;
			if ((parseInt(el.style.fontSize) - 1) == minSize) el.style.fontSize = minSize + 2;
			el.style.fontSize = (parseInt(el.style.fontSize) - 1) + 'px';
		}
	}
}
function decreaseElementChildrenText(elementID, defSize, minSize) {
	if (document.all || document.getElementById) {
		var el = document.all ? document.all[elementID] : document.getElementById(elementID);
		if (el) {
			for (i=0; i<=el.children.length-1; i++) {
				if (el.children(i).style.fontSize == "") el.children(i).style.fontSize = defSize;
				if ((parseInt(el.children(i).style.fontSize) - 1) == minSize) el.children(i).style.fontSize = minSize + 2;
				el.children(i).style.fontSize = (parseInt(el.children(i).style.fontSize) - 1) + 'px';
			}
		}
	}
}

function detect() {
	// simplify things
	var agent 	= navigator.userAgent.toLowerCase();
	
	// detect platform
	this.isMac		= (agent.indexOf('mac') != -1);
	this.isWin		= (agent.indexOf('win') != -1);
	this.isWin2k	= (this.isWin && (
			agent.indexOf('nt 5') != -1));
	this.isWinSP2	= (this.isWin && (
			agent.indexOf('xp') != -1 || 
			agent.indexOf('sv1') != -1));
	this.isOther	= (
			agent.indexOf('unix') != -1 || 
			agent.indexOf('sunos') != -1 || 
			agent.indexOf('bsd') != -1 ||
			agent.indexOf('x11') != -1 || 
			agent.indexOf('linux') != -1);
	
	// detect browser
	this.isSafari	= (agent.indexOf('safari') != -1);
	this.isSafari2 = (this.isSafari && (parseFloat(agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).substring(0,agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).indexOf(' '))) >=  300));
	this.isOpera	= (agent.indexOf('opera') != -1);
	this.isNN		= (agent.indexOf('netscape') != -1);
	this.isIE		= (agent.indexOf('msie') != -1);
	
	// itunes compabibility
	this.isiTunesOK	= this.isMac || this.isWin2k;
}
var browser = new detect();

function GuardarCookie (nombre, valor, caducidad) {
		if(!caducidad)
			caducidad = Caduca(0)

		//crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
		//cada valor esta separado por ; y un espacio
		document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
	}
function Caduca(dias) {
		var hoy = new Date()										//coge la fecha actual
		var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000	//pasa los dias a mseg.

		hoy.setTime(hoy.getTime() + msEnXDias)			//fecha de caducidad: actual + caducidad
		return (hoy.toGMTString())
}