/* Escribe flash embed para evitar bloqueo de IE*/
/*
Se llama de la siquiente forma
<script language="JavaScript" type="text/javascript">
	writeFlash('texto alt','ancho','alto','7,0,19,0','URL','transparencia','texto dinamico si lo tiene');
</script>
*/


document.write('<script language="javascript" type="text/javascript" src="/js/global.js"></script>' + 
'<script language="javascript" type="text/javascript" src="/js/validaciones.js"></script>' + 
'<script language="javascript" type="text/javascript" src="/admin/global/inc.global.js"></script>');

function MM_checkPlugin(plgIn, autoGo) { 
    var ok=false; 
	//document.MM_returnValue = false; 
    with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) { 
       ok=(plugins && plugins[plgIn]); 
    } else if (appVersion.indexOf('3.1')==-1) { 
       if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash; 
       else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir; 
       else ok=autoGo; } 
    return ok;
} 


function writeFlash(tag_alt,ancho_flash,alto_flash,version_flash,src, opacidad, alternateText, alternateimg) {
	// Construye el Flash Embed
	ok = MM_checkPlugin('Shockwave Flash', true);
	if (!ok)
	{
	document.write('<strong>CARGA IMAGEN ESTATICA</strong>');
	//document.write('<img src="/images/html/logo_im_header.gif" alt="" />');
	//document.write('<img src="'+alternateimg+'" alt="" />');
	return;
	}
	var param1 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_flash+'" width="'+ancho_flash+'" height="'+alto_flash+'" title="'+tag_alt+'">';
	var param2 = '<param name="movie" value="'+src+'" />';
	var param3 = '<param name="quality" value="High" />';
	if(!alternateText) 
	{	
		var param4='';
	}
	else
	{
		var param4 = '<PARAM NAME="FlashVars" VALUE="'+ alternateText +'"/>';
	}
	var param5 = '<param name="wmode" value="'+opacidad+'" />'
	var param6 = '<param name="menu" value="false" />'
	var param7 = '<embed swLiveConnect="true" FlashVars="'+ alternateText +'" src="'+src+'" quality="High" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" salign="lt" bgcolor="#251207" wmode="'+opacidad+'" allowScriptAccess="sameDomain" width="'+ancho_flash+'" height="'+alto_flash+'"></embed>'
	var param8 = '</object>'

	// Escribe las lineas
	document.write(param1+param2+param3+param4+param5+param6+param7+param8)
}



/* Funcion GoLink: usada casi siempre en popups, haciendo que al clickear el link dentro */
/* del popup, éste se cierre y abra el enlace en otra ventana. */

function golink() {
   window.opener.location="http://direccion.web.com"; /* poner ahi la dirección real */
   window.close();
   return 1;
}



/*Funcion carga textos en TIPS*/

function tips(texto) {
	var pelicula=document.all? document.tip : document.embeds["tip"]; 
	pelicula.SetVariable('txt_tip',texto);
}




/* Funcion Precarga de imagenes */

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Funciones para cambiar de comportamiento (colores de fondo) en TD's. Por ejemplo en titulos, menus. */

function mOvr(src,clrOver){ 
 if (!src.contains(event.fromElement)){ 
  src.style.cursor = 'hand'; 
  src.className = clrOver; 
 } 
} 
function mOut(src,clrIn){ 
 if (!src.contains(event.toElement)){ 
  src.style.cursor = 'hand'; 
  src.className = clrIn; 
 } 
}
function mClk(src) 
{
if(event.srcElement.tagName=='TD')
	{
 	src.children.tags('A')[0].click();
	}
}



/*Funcion pulldown menu*/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/* Funcion Volver a la página anterior */

function volver(pag){
	window.history.go(pag)
	}

/* Funcion abre un popup */

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

/* Funcion para limpiar un formulario */

function limpia_form(nombre){
	alert(nombre)
	//window.document[nom].reset();
}

/* Funcion para imprimir */

function imprimir(){
	window.print();
}

/* Funcion para introducir la fecha en una pagina */

function fecha(){
	mes = new Array();
/*	diasem = new Array();*/
	fechas = new Date();
	diasemana = fechas.getDay();
/*	diasem[0] = "Domingo";
	diasem[1] = "Lunes";
	diasem[2] = "Martes";
	diasem[3] = "Miercoles";
	diasem[4] = "Jueves";
	diasem[5] = "Viernes";
	diasem[6] = "Sabado";*/
	dia = fechas.getDate();
	nomes = fechas.getMonth();
	anio = fechas.getYear();
	mes[0] = '01';
	mes[1] = '02';
	mes[2] = '03';
	mes[3] = '04';
	mes[4] = '05';
	mes[5] = '06';
	mes[6] = '07';
	mes[7] = '08';
	mes[8] = '09';
	mes[9] = '10';
	mes[10] = '11';
	mes[11] = '12';
	if (anio < 1000) anio = anio + 1900;
	document.write(/*diasem[diasemana]+*/" "+ dia +" | "+ mes[nomes] +" | "+ anio);
}

/* Funcion Random para imágenes - J. Yevenes */

function img_random() { 
var imgs = ["img1.gif", "img2.gif", "img3.gif"]; 
document.getElementById("foto").src = imgs[Math.floor(Math.random()*imgs.length)]; 
}

function cerrar(){
	window.close();
	}


/* Funcion Go To */
function go_to(pag){
 window.location=pag

}
//Para el buscador: Cuando haces click se limpian los campos
function limpiar(){
	if(document.busqueda.palabra.value=="¡ Busque Aquí !"){
		document.busqueda.palabra.value="";
	}
}

function llenar(){
	if(document.busqueda.palabra.value==""){
		document.busqueda.palabra.value="¡ Busque Aquí !";
	}
}

//Funcion pull down vitas
function gothere() {	
    var index=document.corporacion.vitas.selectedIndex;
    
    if (index !=0) {
		var remote=document.corporacion.vitas.options[index].value.substring(0,1);
	    var url=document.corporacion.vitas.options[index].value.substring(1);		
		if (remote == "a") {
			window.open(url,"newwindow","toolbar=yes,location=yes,derectories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes");
		} else {				
			document.location.href = document.corporacion.vitas.options[index].value;
		}
	}
}

/*Búsqueda en Google*/
get0='google.com/';
get1='?ie=ascii&safe=';
function ges(){
if(document.gef.q.value=='') {
	alert('Ingrese texto de búsqueda por favor');
	document.gef.q.focus();
	return false;
}
gev=escape(document.gef.q.value);
{if (document.gef.p[0].checked==true)
{ge1='w';gep='http://www.google.cl/custom?sa=B%FAsqueda&client=pub-2657561339527273&forid=1&ie=ISO-8859-1&oe=ISO-8859-1&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%233165CE%3BVLC%3A52188C%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3AFFFFFF%3BALC%3A0000CC%3BLC%3A0000CC%3BT%3A000000%3BGFNT%3A7375CE%3BGIMP%3A000000%3BFORID%3A1%3B&hl=es&num=20&';}
else if (document.gef.p[1].checked==true)
{ge1='i';gep='http://images.'+get0+'images'+get1+'images&hl=es&'}
else {ge1='n';gep='http://news.'+get0+'news'+get1+'off&num=30&'}}
{
	gec='';
	//gec='cr=countryCL&'	//chile
}
{
	gel='';
	gel='lr=lang_es&' 	//espanol
}
{
	
	ger='q=';
	/*if (document.gef.r.checked==false){
		ger='q='
	}else {
		ger='as_epq='
	}*/
}
var geu=gep+gec+gel+ger+gev;
window.open(geu);
return false;
{
}
}


/*CARGA FECHAS EN LOS FORMULARIOS*/
function load_year(){
	var mydate=new Date();
	var year=mydate.getYear() - 14;
	var cantidad=year-1939;
	document.formulario.year.length=cantidad;
	var j=0;
	var ll;
	var a;
	for(i=year;i>=1940;i--){
		a=''+i;
		document.formulario.year.options[j].value=i;//a.substring(2,4);
		document.formulario.year.options[j].text=i;
		j++;
	}
}


function populate(objForm,selectIndex) {
timeA = new Date(objForm.year.options[objForm.year.selectedIndex].text, objForm.month.options[objForm.month.selectedIndex].value,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
var daysInMonth = timeB.getDate();
objForm.day.length=daysInMonth;
//for (var i = 0; i < objForm.day.length; i++) {
//	objForm.day.options[0] = null;
//}
for (var i = 0; i < daysInMonth; i++) {
	//objForm.day.options[i] = new Option(i+1);
	objForm.day.options[i].value = i + 1;
	objForm.day.options[i].text = i + 1;
}
document.formulario.day.options[0].selected = true;
}
function getYears() {

var years = new Array(1997,1998,1999,2000,2001,2005)

for (var i = 0; i < document.formulario.year.length; i++) {
document.formulario.year.options[0] = null;
}
timeC = new Date();
currYear = timeC.getFullYear();
for (var i = 0; i < years.length; i++) {
document.formulario.year.options[i] = new Option(years[i]);
}
document.formulario.year.options[2].selected=true;
}
window.onLoad = getYears;



