//Abrir Ventana Centrada 
//Variables Ventana Valores obligatorios*
//   *PaginaURL = Nombre del fichero que se abrira
//   VentanaNombre= Nombre de la ventana
// Barras=1 Muestra las barras desplazables
// opciones='channelmode,scrollbars' / opciones='fullscreen' pantalla completa
// Tiempo=Milisegundos


function AbrirVentana(PaginaURL,VentanaNombre,ancho,alto,Barras)
// Verifica variables obligatorias y asigna valore predeterminados=0
{
if (VentanaNombre=='')
	{	
	VentanaNombre='MiVentana';
	}	
if (alto=='')
	{	
	alto=300;
	}
if (ancho=='')
	{	
	ancho=500;
	}
if (VentanaNombre=='channelmode')
	{		
	opciones='channelmode,scrollbars';
}
	else
{
	IzquierdaPosicion=(screen.width)?(screen.width-ancho)/2:100;
	ArribaPosicion=(screen.height)?(screen.height-alto)/2:100;
	opciones='location=0,dependent=0,directories=0,status=0,width='+ancho+',height='+alto+',top='+ArribaPosicion+',left='+IzquierdaPosicion+',scrollbars='+Barras+',toolbars=0,menubar=0,resizable=1';
}


  	window.open(PaginaURL,VentanaNombre,opciones);

}


//Ventana Cromeless

//Abrir Ventana Centrada
function openWin(theURL,winName,alto,ancho){
LeftPosition=(screen.width)?(screen.width-ancho)/2:100;
TopPosition=(screen.height)?(screen.height-alto)/2:100;
setting='dependent=1,width='+ancho+',height='+alto+',top='+TopPosition+',left='+LeftPosition+',scrollbars=0,toolbars=0,menubar=0,resizable=1';

  	window.open(theURL,winName,setting);
}

	
	function ChkEmail(strTemp) {
		var check = false;
		if (strTemp.length > 0) {	
			if (strTemp.indexOf("@") > 0) {		
				if (strTemp.indexOf(".") > 0 && strTemp.indexOf(".") < strTemp.length - 1) {
					check = true;
				}
			}
		}
		return check;
	}
	
	function GetToPage(nombrepagina) {
		var pageno = document.paginas.pagina.value;
		document.location.href = nombrepagina + pageno;
	}
	function GetToPageCategoria(nombrepagina) {
		var pageno = document.paginasCategoria.paginaCategoria.value;
		document.location.href = nombrepagina + pageno;
	}	
	function GetToPageSubCategoria(nombrepagina) {
		var pageno = document.paginasSubCategoria.paginaSubCategoria.value;
		document.location.href = nombrepagina + pageno;
	}		
	function Preview() {
		var VistaPreviaCookie = "VistaPreviaTitular=" + escape(document.Noticia.Titular.value);
		document.cookie = VistaPreviaCookie;
		var VistaPreviaCookie = "VistaPreviaNoticia=" + escape(document.Noticia.texto.value);
		document.cookie = VistaPreviaCookie;
		PreviewWin = window.open('NoticiaEnviarVP.asp', 'Preview', 'dependent=yes,resizable=yes,scrollbars=yes')
	}

	function CalculaCaducidd() {	
		var selMonth = document.Noticia.CaducidadMes.value; 
		var selDay = document.Noticia.CaducidadDia.value;
		var selYear = document.Noticia.CaducidadAno.value;
		var intMaxDay = 31;
		var intDay = 1;
		var dayHTML = "";
		var arrDays = new Array();		
		if (selMonth != 0 && selMonth != null && selYear != 0 && selYear != null) {			
			switch (selMonth) { 
			   case "1":
			   case "3":
			   case "5":
			   case "7":
			   case "8":
			   case "10":
			   case "12": 
			      {
					intMaxDay = 31;
			      }
			      break; 
			   case "4":
			   case "6":
			   case "9":
			   case "11": 
			      {
					intMaxDay = 30; 
			      }
			      break; 				      
			   case "2": 
			      {
					if (selYear % 4 == 0 && (selYear % 1000 == 0 || selYear % 100 != 0)) {
						intMaxDay = 29;
					} else {
						intMaxDay = 28;
					}
			      }
			      break; 
			   default: 
				  {
					intMaxDay = 31;
				  }
			}
			while (document.Noticia.CaducidadDia.length > 1) {
				document.Noticia.CaducidadDia.options[document.Noticia.CaducidadDia.length-1] = null;
			}
			for (intDay=1; intDay<=intMaxDay; intDay++) {
				var Eintrag = new Option(intDay);
				document.Noticia.CaducidadDia.options[document.Noticia.CaducidadDia.length] = Eintrag;
				document.Noticia.CaducidadDia.selectedIndex = intDay;
				document.Noticia.CaducidadDia.options[document.Noticia.CaducidadDia.selectedIndex].value = intDay;	
			}
			document.Noticia.CaducidadDia.selectedIndex = selDay;
		}
	}
	
	function IsFutureExpireDate() {
		var selMonth = document.Noticia.CaducidadMes.value; 
		var selDay = document.Noticia.CaducidadDia.value;
		var selYear = document.Noticia.CaducidadAno.value;
		var currentDate = new Date();
		var currentDay = currentDate.getDate();
		var currentMonth = currentDate.getMonth() + 1;
		var currentYear = currentDate.getYear();
		var FutureExpireDate = true;	
		if (selMonth != 0 && selMonth != null) {
			if (selDay == 0 || selDay == null) {
				alert("Por favor selecciona el dia de caducidad!");
				FutureExpireDate = false;
			} else {
				if (selYear == 0 || selYear == null) {
					alert("Por favor selecciona el año !");
					FutureExpireDate = false;
				} else {
					if (selYear <= currentYear) {
						if (selMonth <= currentMonth) {
							if (selDay < currentDay) {
								alert("Selecciona la fecha de caducidad -proxima-!");
								FutureExpireDate = false;
							}
						}
					}
				}
			}
		}
		return FutureExpireDate;
	}
	
	function CalculaPublicacion() {	
		var selMonth = document.Noticia.PublicacionMes.value;
		var selDay = document.Noticia.PublicacionDia.value;
		var selYear = document.Noticia.PublicacionAno.value;
		var intMaxDay = 31;
		var intDay = 1;
		var dayHTML = "";
		var arrDays = new Array();		
		if (selMonth != 0 && selMonth != null && selYear != 0 && selYear != null) {			
			switch (selMonth) { 
			   case "1":
			   case "3":
			   case "5":
			   case "7":
			   case "8":
			   case "10":
			   case "12": 
			      {
					intMaxDay = 31;
			      }
			      break; 
			   case "4":
			   case "6":
			   case "9":
			   case "11": 
			      {
					intMaxDay = 30; 
			      }
			      break; 				      
			   case "2": 
			      {
					if (selYear % 4 == 0 && (selYear % 1000 == 0 || selYear % 100 != 0)) {
						intMaxDay = 29;
					} else {
						intMaxDay = 28;
					}
			      }
			      break; 
			   default: 
				  {
					intMaxDay = 31;
				  }
			}
			while (document.Noticia.PublicacionDia.length > 1) {
				document.Noticia.PublicacionDia.options[document.Noticia.PublicacionDia.length-1] = null;
			}
			for (intDay=1; intDay<=intMaxDay; intDay++) {
				var Eintrag = new Option(intDay);
				document.Noticia.PublicacionDia.options[document.Noticia.PublicacionDia.length] = Eintrag;
				document.Noticia.PublicacionDia.selectedIndex = intDay;
				document.Noticia.PublicacionDia.options[document.Noticia.PublicacionDia.selectedIndex].value = intDay;	
			}
			document.Noticia.PublicacionDia.selectedIndex = selDay;
		}
	}
	
	function IsReleaseDate() {
		var selMonth = document.Noticia.PublicacionMes.value; 
		var selDay = document.Noticia.PublicacionDia.value;
		var selYear = document.Noticia.PublicacionAno.value;
		var expMonth = document.Noticia.CaducidadMes.value; 
		var expDay = document.Noticia.CaducidadDia.value;
		var expYear = document.Noticia.CaducidadAno.value;		
		var ReleaseDate = true;
		if (selMonth != 0 && selMonth != null) {
			if (selDay == 0 || selDay == null) {
				alert("Por favor selecciona el día de publicacion!");
				ReleaseDate = false;
			} else {
				if (selYear == 0 || selYear == null) {
					alert("Por favor selecciona el año de publicacion!");
					ReleaseDate = false;
				}
			}
			if (expMonth != 0 && expMonth != null) {
				if (selYear > expYear || (selYear == expYear && selMonth > expMonth) || (selYear == expYear && selMonth == expMonth && selDay > expDay)) {
					alert("Fecha de Caducidad debe ser posterior a la fecha de publicacion!");
					ReleaseDate = false;
				}
			}
		}
		return ReleaseDate;
	}	
	
	function CheckAndSubmit() {
		Noticia.texto.value = idContenido.document.body.innerHTML;
		var chkExpire = IsFutureExpireDate();
		var chkRelease = IsReleaseDate();
		if (chkExpire == true && chkRelease == true) {
			document.Noticia.submit();
		} else {
			alert("Por favor corrige la fecha de caducidad o de publicacion!")
		}		
	}

	
	function CalculaFechaHoy(SelectBox) {
		var currentDate = new Date();
		if (SelectBox == "Publicacion") {
			document.Noticia.PublicacionMes.value = currentDate.getMonth() + 1; 
			document.Noticia.PublicacionDia.value = currentDate.getDate();
			document.Noticia.PublicacionAno.value = currentDate.getYear();
		}		
		if (SelectBox == "Caducidad") {
			document.Noticia.CaducidadMes.value = currentDate.getMonth() + 1; 
			document.Noticia.CaducidadDia.value = currentDate.getDate();
			document.Noticia.CaducidadAno.value = currentDate.getYear();
		}
	}
	

	function FormatText(Tag) {
		tmpStartTag = "<" + Tag + ">";
		tmpEndTag = "</" + Tag + ">";
		GetSelection(tmpStartTag, tmpEndTag, null);
	}
	
	function GetSelection(strBefore, strAfter, strContent) {
		var Selection = document.selection.createRange();
		if (Selection.text != "" && Selection.text != null) {
			Selection.text = strBefore + Selection.text + strAfter;
		} else {
			document.Noticia.texto.value = document.Noticia.texto.value + strBefore + strContent + strAfter;
		}
	}	
		


<!-- Funcion de Abrir foto en ventana nueva dependiendo del tamaño del grafico.Calcula x,y
function AbirFoto(img){
  foto1= new Image();
  foto1.src=(img);
  CalcularFoto(img);
}
function CalcularFoto(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    VerFoto(img);
  }
  else{
    funzione="CalcularFoto('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function VerFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"foto",stringa);
}
//  Fin Funcion de Abrir -->
