function MostrarVideo(video)
{  
	var navegador = navigator.appName
	if (navegador == "Microsoft Internet Explorer")
		window.open('mostrar_video.php?video='+video, 'video', 'width = 440, height = 300')
	else
		window.open('artefactos/foro/presentacion/mostrar_video.php?video='+video, 'video', 'width = 440, height = 300')
}	

function CierraVentana()
{
	window.parent.opener.location.reload();
	window.close();
}

function irA(URL)
{
  if(URL != "") {
    window.location.href = URL;
  }
  else {
    CierraVentana();
  }
}

function AbreVentana(){
	window.open("", "popup", "width = 750, height = 310");
}

function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ValidaFormulario() {
  var Error = "Debe indicar:\n";
  var nError = 0;	
  var flag = 0;
  var diainicio = "";
  var mesinicio = "";
  var anoinicio = "";
  fechainicio = new Date();
  var diafin = "";
  var mesfin = "";
  var anofin = "";
  fechafin = new Date();
  var x = document.getElementById("formulario");
	  for (var i = 0; i < x.length; i++) {
		  if(x.elements[i].value == "" && x.elements[i].title && !x.elements[i].disabled) {
			  if(flag == 0)
			  {
				x.elements[i].focus();
				flag = 1;
			  }	
			  Error += x.elements[i].title + ".\n";
			  nError += 1;
		  }
		  if(x.elements[i].name == "-Video" && x.elements[i].value!="http://") { 
			if (isUrl(x.elements[i].value))
			{
			}
			else
			{
			  Error += "- una URL de vídeo válida" + ".\n";
			  nError += 1;
			}  
		  }
		  if (x.elements[i].name == "finiciod")
		  {
			diainicio= x.elements[i].value+"/";
		  }
		   if (x.elements[i].name == "finiciom")
		  {
			mesinicio= x.elements[i].value+"/";
		  }
		   if (x.elements[i].name == "finicioa")
		  {
			anoinicio= x.elements[i].value;
		  }
		   if (x.elements[i].name == "ffind")
		  {
			diafin= x.elements[i].value+"/";
		  }
		   if (x.elements[i].name == "ffinm")
		  {
			mesfin= x.elements[i].value+"/";
		  }
		   if (x.elements[i].name == "ffina")
		  {
			anofin= x.elements[i].value;
		  }
	  }
	   fechainicio = Date.parse(mesinicio + diainicio + anoinicio);
	   fechafin = Date.parse(mesfin + diafin + anofin);
		   if (fechafin < fechainicio)
		   {
				 Error += "- la fecha de finalización debe ser mayor o igual a la fecha de inicio" + ".\n";
				 nError += 1;
		   }
	if (nError > 0)
	{
	  alert(Error);  
	  return false;
	} 
	else
	{
	  return true;
	} 
}	

function VerComentario(i,j){
	if (i == 'a')
	{
		document.getElementById(i+j).style.display = 'none';
		i = 'b';
		document.getElementById(i+j).style.display = '';
	}
	else
	{	
		document.getElementById(i+j).style.display = 'none';
		i = 'a';
		document.getElementById(i+j).style.display = '';
	}
}

function onlytext(box) {
  regexp = /\D/g;
  if(box.value.search(regexp) >= 0)
    box.value = box.value.replace(regexp, '');
}


/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2003-5 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}

/*** este es el efecto etiqueta (tooltip) sobre enlace  ***/

/* *************************************************************************************
 * JavaScript para validar la fecha de los formularios
 * *************************************************************************************/
/*
Client side scripts required to support the date selection dropdowns
Author: Michael McLain
Note: These scripts must be placed prior to calling the GenDateDropDown subroutine
Return number of days in a month
Parameters: lnMonth: month (1-12)
            lnYear:  year => 1970
*/
function daysinmonth(lnMonth, lnYear) {
  var dt1, cmn1, cmn2, dtt, lflag, dycnt, lmn
  lmn = lnMonth-1
  dt1 = new Date(lnYear,lmn,1)
  cmn1 = dt1.getMonth()
  dtt=dt1.getTime()+2332800000
  lflag = true
  dycnt=28
  while (lflag) {
    dtt = dtt + 86400000
    dt1.setTime(dtt)
    cmn2 = dt1.getMonth()
    if (cmn1!=cmn2) {
      lflag = false
    }
    else {
      dycnt = dycnt + 1
    }
  }
  if (dycnt > 31) {
    dycnt = 31
  }
  return dycnt
}

function setdays(sobjname) {
  var dobj = eval(sobjname + "d")
  var mobj = eval(sobjname + "m")
  var yobj = eval(sobjname + "a")
  var monthdays = daysinmonth(mobj.options[mobj.selectedIndex].value,yobj.options[yobj.selectedIndex].value)
  var selectdays = dobj.length - 1
  var curdy = dobj.options[dobj.selectedIndex].value
  if (curdy.length==1) {
    curdy = "0"+curdy
  }
  var curmn = mobj.options[mobj.selectedIndex].value
  if (curmn.length==1) {
    curmn = "0"+curmn
  }
  var curyr = yobj.options[yobj.selectedIndex].value
  if (selectdays > monthdays) {
    for (var dlp=selectdays; dlp > monthdays; dlp--) {
      dobj.options[dlp] = null
    }
  }
  else if (monthdays > selectdays) {
    for (var dlp=selectdays; dlp <= monthdays; dlp++) {
      dobj.options[dlp] = new Option(dlp,dlp) 
    }
  }       
  if (curdy > monthdays) {
    dobj.options[monthdays].selected = true
    curdy = monthdays
  }
}



var winName="titulo"
function Abrir_Ventana(theURL,w,h) {
	var windowprops ="top=0,left=0,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h;
	window.open(theURL,winName,windowprops);
}



var upload_number = 2;
function addFileInput() {
	var d = document.createElement("div");
	var file = document.createElement("input");
	file.setAttribute("type", "file");
	file.setAttribute("name", "attach[]");
	d.appendChild(file);
	document.getElementById("moreUploads").appendChild(d);
	upload_number++;
}
function setBlock() {
   document.getElementById('moreLink').style.display = 'block';
}
		
/* *************************************************************************************/

