//--------------------------
//--- Mostrar demandas
//--------------------------
function demAso(opc){
	var mosDiv = idGui("tbDem");
	mosDiv.style.display = ""+opc;
}

var opcVis = 0;
var opcVisAux = 0;
function mosTabDem(opc){
	var opcVis = opc;
	var mosDiv = idGui("tab"+opc);

	if(mosDiv.style.display == "block"){
		mosDiv.style.display = "none";	
	}else{
	mosDiv.style.display = "block";	}
}


//--------------------------
//--- Abrir Ventana de pass
//--------------------------
DocAbrAux=""
function acceso2(Que,abrcer){	
	var proAux = idGui("protegido");
	var accAux = idGui("acceso");
	var accIfr = idGui("ifr_usu");
	var froAux = idGui("forAux");
	
	if(abrcer==0){ DocAbrAux=""; }
	//---
	if(Que =="Abrir"){
		proAux.style.display="block";
		accAux.style.display="none";
		if(DocAbrAux!=""){
			froAux.action=DocAbrAux;
			froAux.submit();
			DocAbrAux="";
			location.reload();
		}
	}
	else{
		DocAbrAux=Que;			
		proAux.style.display="none";
		accAux.style.display="block";
		document.all["ifr_usu"].src="usuario2.php?abropc="+DocAbrAux;
	}
}
function abrDoc(){
	parent.acceso2('Abrir',1);
}
function accCer(){
	parent.acceso2('Abrir',0);
}
//--------------------------
//--- Almacenar Cookie
//--------------------------
function createCookie(name,value,seg) {
	if (seg) {
		var date = new Date();
		//date.setTime(date.getTime()+(days*24*60*60*1000));
		//date.setTime(date.getTime()+(hr*60*60*1000));
		//date.setTime(date.getTime()+(minutos*60*1000));
		date.setTime(date.getTime()+(seg*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

//------------------------------------
//--- Cargamos las noticia, calendario, usuario
//------------------------------------
function carPag1(){
	var pagNot1 = idGui("ifr_not1");
	var pagNot3 = idGui("ifr_not3");
	pagNot1.src = "internas/noti_intitucional.php";	
	
	pagNot3.style.display="none"; 
}

function carPag2(){ // si hay noticia institucional
	var institucional = "?institucional=true";
	var pagNot1 = idGui("ifr_not1");
	var pagNot2 = idGui("ifr_not2");
	var pagCal = idGui("ifr_cal");
	var pagBot = idGui("verTodos1");
	var pagEmp = idGui("ifr_emp");
	var rubEmp = idGui("titcont");
	
	rubEmp.style.width = "493px";

	if(readCookie('ventGui') == null){ 
		createCookie('ventGui','true',10);
	}
	pagNot2.src = "internas/noticias.php"+institucional;
	pagCal.src = "internas/calendario.php";
	pagEmp.src="internas/emphom.php";
	pagBot.className = "movBot1";
	pagNot1.style.display="block"; 
	pagNot2.style.display="block";
}

function carPag3(){// si No hay noticia institucional
	var pagNot1 = idGui("ifr_not1");
	var pagNot2 = idGui("ifr_not2");
	var pagNot3 = idGui("ifr_not3");
	var pagCal = idGui("ifr_cal");
	var pagEmp = idGui("ifr_emp");
	var pagBot = idGui("verTodos1");

	pagNot3.src = "internas/noticias.php";
	pagCal.src = "internas/calendario.php";
	pagEmp.src="internas/emphom.php";
	pagBot.className = "movBot2";
	pagNot1.style.display="none"; 
	pagNot2.style.display="none";
	pagNot3.style.display="block";
}

function carPag(){
	var regPag = new Array("ifr_usu");
	var regDir = new Array("usuario1.php","calendario.php");
	for(j=0; j<1; j++){
		var pag = idGui(regPag[j]);
		pag.src = "internas/"+regDir[j];		
	}	
}

function carInstitucional(opc){
	location.href = "../ci5_posinstitucional.php?opc="+opc;
}
//------------------------------
function Rec_Not_Cal(){
	parent.carPag1();
}
//----------------------------------------
function logAbr(wpag){
	window.location.replace(wpag);	
}

//----------------------------------------
function busPartida(){
		var partida = idGui("textfield");
		var parAux = idGui("ifrmPartida");
		//parAux.src = "internas/conspreferencial.php?partida="+partida.value;
		document.all["ifrmPartida"].src = "internas/conspreferencial.php?partida="+partida.value;
}

//----------------------------------------
function idGui(movieName)
{
	  if (window.document[movieName]) 
	  { return window.document[movieName]; }
	  if (navigator.appName.indexOf("Microsoft Internet")==-1)
	  {	if (document.embeds && document.embeds[movieName])
			{ return document.embeds[movieName]; }
	  }
	  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	  { return document.getElementById(movieName); }
	  return document.getElementById(movieName);
}

function rewriteObject(containerId) {

	if((containerId!=undefined && containerId!='')&&(navigator.appName.indexOf('Internet Explorer')>0)) {

		var objectTag = document.getElementById(containerId).getElementsByTagName('object')[0];
		var paramTagArray = document.getElementById(containerId).getElementsByTagName('param');

		//STRING CON LOS PARAMETROS DEL OBJECT
		var paramString = "";
		for(var i=0;i<paramTagArray.length;i++) {
			paramString += "<param name='" + paramTagArray[i].name + "' value='" + paramTagArray[i].value + "' />\n";
		}

		//CREA EL STRING CON EL OBJETO Y SUS PARAMETROS PARA DEVOLVER
		var returnString = "<object classid='" + objectTag.classid + "' codebase='" + objectTag.codeBase + "' width='" + objectTag.width + "' height='" + objectTag.height + "' id='" + objectTag.id + "' align='" + objectTag.align + "'>\n";
		returnString += paramString;
		returnString += "</object>\n";

		//RETURN: Pega el string en el container
		document.getElementById(containerId).style.display="block";
		document.getElementById(containerId).innerHTML = returnString;		
	}
	var imgGuib = idGui(containerId);
	imgGuib.style.display="block";	
}
//-----------------------------------------------------
function btnover(tdval)
{	tdval.style.backgroundColor='#FFFFFF'; tdval.style.cursor='hand'; }
function btnout(tdval)
{	tdval.style.backgroundColor='#F2F3ED'; tdval.style.cursor='default'; }
//-----------------------------------------------------
var CarFot="";
function CamImg(Nom,NDes,Cant)
{
	document.getElementById('Imag').src = Carpeta+Nom;
	CarFot = Nom;
	for(i=1; i<=Cant; i++)
		{
			NumDes = "camtxt"+i;
			if(NDes == i)
			{ document.getElementById(NumDes).style.display="block"; }
			else
			{ document.getElementById(NumDes).style.display="none"; }
		} 
}
function MM_openBrWindow(theURL,winName,features,tip) { //v2.0
 theURL = theURL+"?foto="+CarFot+"&tip="+tip;
 window.open(theURL,winName,features);
}
function MM_openBrWindow2(theURL,winName,features,tip) { //v2.0
 theURL = theURL+"&tip="+tip;
 window.open(theURL,winName,features);
}
function abrPopup(Opc) { //v2.0
	if(Opc == "consultas"){
		winName = 'consulta';
		features = 'width=463,height=325';
	    theURL = 'internas/popup/consulta.php';
	}
	if(Opc == "InsCal"){
		winName = 'Inscribirme';
		features = 'width=463,height=275';
	    theURL = 'internas/popup/calactividades.php';
	}
	if(Opc == "monedas"){
		winName = 'Inscribirme';
		features = 'width=483,height=275, scrollbars=yes';
	    theURL = 'internas/popup/monedas.php';
	}
 window.open(theURL,winName,features);
}
function abrPopup2(Opc) { //v2.0
	if(Opc == "monedas"){
		winName = 'Inscribirme';
		features = 'width=483,height=275, scrollbars=yes';
	    theURL = '../internas/popup/monedas.php';
	}
 window.open(theURL,winName,features);
}
//-------------------
//--- visualizar fotos de productos
//-------------------
function MM_openBrWindow3(theURL,winName,features,tip,foto) { //v2.0
 theURL = theURL+"?foto="+foto+"&tip="+tip;
 window.open(theURL,winName,features);
}

//-----------------------------------------------------
function mosOpc(Opc2, Cnt){
	var Gui = "opc"+Opc2;
	var OpcAux = parseInt(Opc2);
	for(j=1; j<=Cnt; j++){
		if(Opc2 == j){			
				document.getElementById("o"+j).style.display="block";
				if(j == 5){
					document.getElementById("o_b"+j).style.display="block";	
				}
			}
			else
			{
				document.getElementById("o"+j).style.display="none";
				if(j == 5){
					document.getElementById("o_b"+j).style.display="none";	
				}
			}
	}	

}
//------------------------------
//--- Buscar Empresa ---
//------------------------------
var Busopcaux = 0;
function sel_subopc(opc, cargar){
	var pathOpc="internas/bus_dirempresarial.php";
	if(cargar != "true"){ subopcsel = parseInt(opc.value); opcaux = subopcsel;	}
	else{ if(opc == 0 ){ subopcsel = opcaux; }else{ subopcsel = opc; } }
	
	
	
	var sub_txt		= idGui("cadena");
	
	var sub_rubro 	= idGui("bus_rubro");	var bot_rubro = idGui("bot_rubro"); 
	var sub_rubro2 	= idGui("rubro");	
	
	var sub_alfabetico 	= idGui("bus_alfabetico");	var bot_alfabetico	= idGui("bot_alfabetico");	
	var sub_alfabetico2 = idGui("alfabetico");
	
	var sub_cadena 		= idGui("bus_cadena");	var bot_cadena = idGui("bot_cadena");
	
	switch(subopcsel){
		case 4: 
			sub_txt.style.display="none";
			sub_cadena.style.display="none"; sub_alfabetico.style.display="none"; sub_rubro.style.display="block";
			bot_cadena.style.display="none"; bot_alfabetico.style.display="none"; bot_rubro.style.display="block";
			
			if(sub_rubro2.options[sub_rubro2.selectedIndex].value != 0){
				sub_txt.value = sub_rubro2.options[sub_rubro2.selectedIndex].value;
			}else{sub_txt.value=0; }
			carpag = pathOpc +"?tipo="+subopcsel+"&val="+sub_txt.value;
		break;
		case 5:
			sub_txt.style.display="none";
			sub_cadena.style.display="none"; sub_rubro.style.display="none"; sub_alfabetico.style.display="block";
			bot_cadena.style.display="none"; bot_rubro.style.display="none"; bot_alfabetico.style.display="block";
			
			if(sub_alfabetico2.options[sub_alfabetico2.selectedIndex].value != 0){
				sub_txt.value = sub_alfabetico2.options[sub_alfabetico2.selectedIndex].value;
			}else{sub_txt.value=0; }
			carpag = pathOpc +"?tipo="+subopcsel+"&val="+sub_txt.value;
		break;
		default:
			sub_txt.style.display="block";
			sub_cadena.style.display ="block"; sub_rubro.style.display ="none"; sub_alfabetico.style.display="none";
			bot_cadena.style.display ="block"; bot_rubro.style.display ="none"; bot_alfabetico.style.display="none";
			carpag = pathOpc +"?tipo="+subopcsel+"&val="+sub_txt.value;
		break;
	}
	
	if(cargar == "true"){
		var ifrmAux = idGui("ifr_dirempresas");
		ifrmAux.src = ""+carpag;
		if(subopcsel>3) {sub_txt.value ="Cadena a buscar"; }
	}	
}

function carBus(opc){
	var sub_txt	= idGui("cadena");
	if(sub_txt.value.length>=2){ sel_subopc(opc,'true'); Busopcaux=opc;}			
	
}
function carTxt(Obj,opc){
	var sub_txt	= idGui("cadena");
	sub_txt.value = Obj.value;		
}

//------------------------------
//--- TEMAS - Cambiar Tamaņo del Iframe 
//------------------------------
function getDocHeight(doc) {  
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + "px";
  }
}

//-------------------------------
//--- Visualizar TODAS: Calendario - Noticia
//-------------------------------
function vertodas(opc, reg) { 
	if(opc == 1){ window.open('ci8_noticias.php','_self'); } else{ window.open('ci8_calendarios.php','_self'); }	
}

//------------------------------
//--- Ocultar fondo boton ---
//--- opc = boton activo ; tip:string(a o b)   => a = mostrar , b = ocultar
//------------------------------
function B_fnd(opc,ocumos, tip){
	var paramTagArray =document.getElementById("res"+opc).getElementsByTagName('div');
	for(var i=0;i<paramTagArray.length;i++) {
		 if(ocumos == "a"){ paramTagArray[i].className="B_fnd"+tip+"_"+(i+1)+ocumos; }
		 else{ paramTagArray[i].className="B_fnd"+(i+1)+ocumos; }
   }	
}
//------------------------------
//--- RESUMEN DE PRENSA ---
//---  Cargar Pag al Iframe ---
//------------------------------
function actRes(Opc, Cnt){

	for(j=1; j<=Cnt; j++){
		var res_prensa = idGui("res"+j);
		var res_prensa_link = idGui("res"+j+"_a");
		if(j == Opc){ 
			B_fnd(j, "a", 2); 
			var ifrmAux = idGui("ifrm");
			//ifrmAux.src = "internas/resprensa.php?periodico="+Opc;
			document.all["ifrm"].src = "internas/resprensa.php?periodico="+Opc;
			res_prensa_link.className = "";
		}
		else{
				B_fnd(j, "b", 2);
				res_prensa_link.className = "ocuOpc";
		}
	}	
}
//------------------------------
//--- visualizar ---
//------------------------------
function actServ(Opc, Cnt){

	for(j=1; j<=Cnt; j++){
		var res_serv = idGui("res"+j);
		var cnt = idGui("cnt"+j);

		if((j == Opc)&&(j<Cnt)){ 
			B_fnd(j, "a", 1); //visualizar fondo
			cnt.className='';
			
		}
		else{ 
			cnt.className='ocuOpc';
			if(j<Cnt){
				B_fnd(j, "b", 1); //oculta fondo				
			}
		}
	}	
}
//-------------------------------
function actServ2(Opc, Cnt, Serv){ // 4, 1
	actServ(Opc, Opc)
	var cnt = idGui("cnt"+Opc);
	cnt.className='';
	
	var ifrmAux = idGui("ifrm");
	document.all["ifrm"].src = "internas/servcompleta.php?serv="+Serv+"&opc="+Cnt;
}

function actServ3(Opc, Cnt, Serv){ // 4, 1
	actServ(Opc, Opc)
	var cnt = idGui("cnt"+Opc);
	cnt.className='';
	
	var ifrmAux = idGui("ifrm");
	document.all["ifrm"].src = "internas/publicaciones.php?serv="+Serv+"&opc="+Cnt;
}

//------------------------------
//--- Validar Formularios ---
//------------------------------
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' No es un correo valido.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' debe ser un numerico.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
    } if (errors) alert('Los siguientes errores fueron identificados:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_validateForm2() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm2.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue2 = (errors == '');
} }

//------------------------------
//--- Limpiar los campos ---
//------------------------------
function clear1(campo,op){
	if (campo.value==op){
		campo.value = '';
	}
return true
}

//------------------------------
//--- Usuario ---
//------------------------------
function IngUsu(){
	var socio = document.ingresar.socio.value;
	if(socio == "Socio"){
		errors = "Ingrese el nombre y contraseņa de su cuenta";		
		if(errors) alert("Error: \n"+errors);	
		document.MM_returnValue =(errors=='');
	}else{
		MM_validateForm('socio','','R','contrasena','','R');	
	}
}

//------------------------------
//--- Recargar las paginas HOME ---
//--- Cargar Pag al Iframe      ---
//------------------------------
function loadIframe(iframeName, url, opc, cantaux) {
 if ( window.top.frames[iframeName] ) {
    	window.top.frames[iframeName].location = url;		
    return false;
  }
}

//------------------------------
//--- Ver Noticia completa ---
//--- y Ocultar ver todas ---
//------------------------------
function cargar_not_cal(Opc, seccion){
var ifrmAux = idGui("ifrm");
document.all["ifrm"].src = "internas/"+seccion+"completa.php?opc="+Opc;
}
function cargar_not_cal2(Opc, seccion){
var ifrmAux = idGui("ifrmcompleta");
document.all["ifrmcompleta"].src = "internas/"+seccion+"completa.php?opc="+Opc+"&areSer=true";
}


function visualizar_not_cal(seccion){
	var verTodas = idGui("infor_interna"); 
	var verTodasAux = idGui("ServOcuMos");
	var verUno	 = idGui("infor_interna3"); 
	var botTodas = idGui("verTodos3");
	
	
	if(verTodasAux != null)
		{ verTodas = verTodasAux; }
	
	
	if(seccion != "todas"){	
		verTodas.style.display = "none"; 
		verUno.style.display = "block"; 
		botTodas.style.display = "block"; }
	else {
		verTodas.style.display = "block"; verUno.style.display = "none"; botTodas.style.display = "none"; 
		setIframeHeight('ifrm');	
	}	
}

function visualizar_not_cal2(seccion){
	var verTodas = idGui("ServOcuMos"); var verUno 	 = idGui("infor_interna3"); var botTodas = idGui("verTodos3");

	if(seccion != "todas"){	
		verTodas.style.display = "none"; verUno.style.display = "block"; botTodas.style.display = "block"; }
	else {
		verTodas.style.display = "block"; verUno.style.display = "none"; botTodas.style.display = "none";
	}	
}
//------------------------------
//--- Menu - RUBRO ---
//------------------------------
var ActRubro = 0;
function actRubro(Obj, Estilo, Opc, Cant){
	if(Estilo == 3){   // Desactivar
		for(i=1; i<=Cant; i++){
			var auxRubro = idGui("rubro"+i);
			var ifrmAux = idGui("ifr_dirempresas");
			var paramTagArray = document.getElementById("rubro"+i).getElementsByTagName('div');
			if((i+"") == Opc){
				ActRubro = Opc;
				auxRubro.style.color = "#3C73ED"; auxRubro.className = "mnu_de2"; auxRubro.style.background = "#FFFFFF";
				paramTagArray[0].className="mnu_de3"; 
				if(i<10){
					ifrmAux.src = "internas/dirempresarial.php?sector=0"+Opc;
				}else{ ifrmAux.src = "internas/dirempresarial.php?sector="+Opc; }
			}	
			else{
				auxRubro.style.color = "#929391"; auxRubro.className = "mnu_de"; auxRubro.style.background = "#E8EAE0";
				paramTagArray[0].className=""; 
			}
		}
		return;
	}	
	//--------------------------
	if(ActRubro != Opc){
			if(Estilo == 1){   // Activar
				Obj.style.color = "#3C73ED"; Obj.style.background = "#FFFFFF";
			}
			if(Estilo == 2){   // Desactivar
				Obj.style.color = "#929391"; Obj.style.background = "#E8EAE0";
			}	
	}
}
//------------------------------
//--- Menu - RUBRO ---
//-------------------------------
function carEmp(Empresa){
	var ifrmAux = idGui("ifrm2");
	//ifrmAux.src
	document.all["ifrm2"].src = "internas/direcompleta.php?empresa="+Empresa;	
}


function visEmp(seccion){
	var verTodas = idGui("infor_interna"); 
	var verUno 	 = idGui("infor_interna3"); 
	var botTodas = idGui("verTodos3");
	
	if(seccion != "todas"){	
		verTodas.style.display = "none"; verUno.style.display = "block"; botTodas.style.display = "block"; }
	else {
		verTodas.style.display = "block"; verUno.style.display = "none"; botTodas.style.display = "none"; }	
}
function ocuFot(){
	var galFot = idGui("ocuGal");
	galFot.style.display = "none";
}
//------------------------------
//--- Demandas - Ocultar ---
//-------------------------------
function oculRegDem(OcuMos){
	var regDat = idGui('infor_interna2');
	regDat.style.display=OcuMos;	
}
//------------------------------
//--- Solo Numeros ---
//-------------------------------
var nav4 = window.Event ? true : false;
function soloNumeros(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57, '.' = 46
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) || key == 46);
}

//------------------------------
//--- Solo letras ---
//-------------------------------
/*var isIE = document.all?true:false; 
var isNS = document.layers?true:false; 

function soloLetras(evt) { 
	var key = (isIE) ? window.event.keyCode : evt.which; 
	var obj = (isIE) ? event.srcElement : evt.target; 
	var isNum = ((key > 64 && key < 91) || (key > 96 && key < 123) || (key==165) || (key==164) || (key==32)) ||(key==209) || (key==241)) ? true:false; 
	window.event.keyCode = (!isNum && isIE) ? 0:key; 
	evt.which = (!isNum && isNS) ? 0:key; 
	return (isNum); 
} 
*/



