function imprimir() {
	window.print();
	return false;
}

function cambiarCamposTipoRecurso( select, idCapaVideo, idCapaResto, idCapaFlash ) {
	if ( select.selectedIndex != -1 ) {
		var tipo = select.options[ select.selectedIndex ].value;
		var capaVideo = document.getElementById(idCapaVideo);
		var capaResto = document.getElementById(idCapaResto);
		var capaFlash = document.getElementById(idCapaFlash);

		if ( tipo==3 ) {
			//Video
			capaVideo.style.display='block';
			capaResto.style.display='block';
			capaFlash.style.display='none';

		} else if ( tipo==4 ) {
			//Flash
			capaFlash.style.display='block';
			capaResto.style.display='block';
			capaVideo.style.display='none';

		} else {
			//Resto
			capaResto.style.display='block';
			capaVideo.style.display='none';
			capaFlash.style.display='none';
		}
	}
}

miPopup = '';

function openPopup( url, titulo, ancho, alto, scrolls, resize ) {
	var scrollable = 'scrollbars=';
	scrollable?scrollable += 'yes':scrollable += 'no'

	var resizable = 'resizable=';
	resize?resizable += 'yes':resizable += 'no'

    miPopup = window.open( url, titulo,'width=' + ancho + ',height=' +alto +"," + scrollable +", " + resizable );
    if (!miPopup.opener)
         miPopup.opener = self;
}

function closePopup() {
	self.close();
}

function clearPopup( field1, field2 ) {
	var field1 = document.getElementById( field1 );
	var field2 = document.getElementById( field2 );

	field1.value = "";
	field2.value  = "";
}


function openPreview( campo, ancho, alto, urlBase ) {
  var oWinPreview = window.open("", "Preview", "width=" + ancho +" ,height=" + alto + ",scrollbars=yes");
  var htmlContent = unescape( document.getElementById( campo ).value );
  oWinPreview.document.open();

  var js= '<html>\n';
  js+= '<head>\n';
  js+= '<link rel="stylesheet" href="' + urlBase + 'css/styles.css" type="text/css"/>\n';
  js+= '</head>\n';
  js+= '<body class="body_blanco">\n';
  js+='<script language="Javascript" src="' + urlBase + 'js/functions.js"></script>\n';
  js+='<script language="Javascript" src="' + urlBase + 'js/paginador.js"></script>\n';
  var rutaBase = urlBase.substring(0, urlBase.indexOf("/", 1));
  js+= '<script language="javascript">\n';
  js+= 'var rutaBase="' + rutaBase + '"';
  js+= '</script>';
  js+='<script src="' + urlBase + 'js/wz_tooltip.js" type="text/javascript"></script>\n';
  js+='<script src="' + urlBase + 'js/tip_balloon.js" type="text/javascript"></script>\n';

  js += '<table width="100%" cellspacing="0" cellspacing="0" border="0">';
  js += '<tr style="padding: 10px;">';
  js += '<td colspan="2"  class="contenidoStandard">';
  js += htmlContent;
  js += '</td>';
  js += '</tr>';
  js += '</table>';

  js += '</body>\n';
  js += '</html>\n';
  oWinPreview.document.write(js);

  oWinPreview.document.close();
}

function initSearch( doc ) {
	var lista = doc.getElementsByName("from");
	for (i=0; i < lista.length; i++) {
		lista[i].value="1";
	}
}



function openVideo( context, idRecurso ) {

    popupVideo = window.open( context + "/pages/recursos/video.do?idRecurso=" + idRecurso, "videoElearning", 'width=990,height=606,scrollbars=no,resizable=no');
    popupVideo.focus();
}


