// JavaScript Document



function oficial(cual,id,sec){

		if(typeof(sec)=="undefined"){sec=1;}

var va = new Array();

if (cual == 0) cual = "0000";

va["Accion"]="oficial";

va["gen"]=cual;

va["id"]=id;

va["sec"]=sec;

//AbreRetro("Getting data...",0,0);

crearCapa("divCapa2");

Ajax_enviar(va,"ajax_officialcontent.php","POST","hazContenido");

}



function comunidad(cual,id,sec, inverse){
	
	if (cual == 0) cual = "0000";

	if(typeof(sec)=="undefined"){sec=1;}

	if(typeof(cual)=="undefined"){cual=miGeneracion;}

	if(typeof(id)=="undefined"){id=0;}
	
	if(typeof(inverse)=="undefined"){inverse=0;}

	//alert(cual);

var va = new Array();

va["Accion"]="community";

va["gen"]=cual;

va["id"]=id;

va["sec"]=sec;

va["inverse"] = inverse;

//AbreRetro("Getting data...",0,0);

crearCapa("divCapa2");



Ajax_enviar(va,"ajax_communitycontent.php","POST","hazContenido");

}



function formametecomunidad(cual,id){

	if(typeof(cual)=="undefined"){cual = miGeneracion;}

	if(typeof(id)=="undefined"){id = 0;}

	if(typeof(retro)=="undefined"){retro = 0;}	

var va = new Array();

va["Accion"]="forma";

va["gen"]=cual;

va["id"]=id;

crearCapa("divCapa3");

Tarea[0]=1;Tarea[1]="newcomm";

Ajax_enviar(va,"ajax_metecomunidad.php","POST","hazContenidoNuevo");

}



function editanota(id){

var va = new Array();

va["Accion"]="formaedita";

va["id"]=id;

AbreRetro("Getting data...",0,0);

Ajax_enviar(va,"ajax_editacomunidad.php","POST","hazContenido");

}



function updatenota(id){

var va = new Array();

va["Accion"]="updatenota";

va["id"]=id;

va["Nombre"]=document.getElementById("Nombre").value;

va["Texto"]=document.getElementById("Texto").value;

va["FechaVence"]=document.getElementById("FechaVence").value;

//va["Importante"]=document.getElementById("Importante").value;

va["Generacion"]=document.getElementById("Generacion").value;

//AbreRetro("Getting data...",0,0);

Ajax_enviar(va,"ajax_editacomunidad.php","POST","hazContenido");

}



function eliminanota(id){

		if(!confirm("Confirm you wish to delete this note.")){return false;}

var va = new Array();

va["Accion"]="eliminacomunidad";

va["id"]=id;

AbreRetro("Getting data...",0,0);

Ajax_enviar(va,"ajax_communitycontent.php","POST","hazContenido");

}



function anadenota(){

var va = new Array();

va["Accion"]="insertcomunidad";

va["Nombre"]=document.getElementById("Nombre").value;

va["Texto"]=document.getElementById("Texto").value;

va["Cuando"]=document.getElementById("Cuando").value;

va["FechaVence"]=document.getElementById("FechaVence").value;

/*va["Importante"]=document.getElementById("Importante").value;*/

va["Generacion"]=document.getElementById("Generacion").value;

//va["Imagen"]=document.fmetecomunidad.Imagen.value;
//va["Imagen"]=document.getElementById("Imagen").value;

limpiaTarea();

Ajax_enviar(va,"ajax_metecomunidad.php","POST","compruebaContenidoNuevo");

}



function hazContenido(){ 

var PP = AjaxText;

var nuevo = document.createElement("div");

$(nuevo).html(PP);

$(nuevo).preload({

	onFinish:function(){

		$("#divCapa2").html($(nuevo).html());

		Retro();

		}	

});

}







function hazContenidoNuevo(){ 

	//if(typeof(retro)=="undefined"){retro=0;}

var PP = AjaxText;

var nuevo = document.createElement("div");

$(nuevo).html(PP);

$(nuevo).preload({

	onFinish:function(){

		$("#divCapa3").html($(nuevo).html());

		Retro();

		}	

});

}





function compruebaContenidoNuevo(){ 

var PP = AjaxText; 

	if(PP!="0"){ 

	document.fmetecomunidad.id.value = PP;

var generox = $('#Generacion2').val();

	//document.fmetecomunidad.submit();
	
	chingada.setData({
					  'Accion' : 'unofficial',
						'Param' : 'Imagen',
						'Param2' : 'Adjunto',
						'id' : PP,
						'Paso' : 1,
						'Generacion2' : generox
					 });
	
	
	chingada.submit();
	chingada = null;
	//document.fmetecomunidad.submit();
	//document.dummy.submit();
	
	archivo.setData({
					  'Accion' : 'unofficial',
						'Param' : 'Imagen',
						'Param2' : 'Adjunto',
						'id' : PP,
						'Paso' : 1,
						'Generacion2' : generox
					 });
	
	
	archivo.submit();
	archivo = null;
	
	document.fmetecomunidad.submit();
	
	
	}

	else{	

	Retro();

	limpiaTarea();

	}

}



function verContenidoNuevo(){

cerrarCapa("divCapa2");

cerrarCapa("divCapa3");

comunidad();		

}



lastAccordion=new Array();

function help(paso,id){

		if(typeof(id)=="undefined"){id=0;}

var va = new Array();

va["Paso"]=paso;

va["id"]=id;

//cerrarCapa("divCapa2");

crearCapa("divCapa2");

Ajax_enviar(va,"ajax_help.php","POST","hazHelp");



}



function hazHelp(){ 

var PP = AjaxText;

var nuevo = document.createElement("div");

$(nuevo).html(PP);

$(nuevo).preload({

	onFinish:function(){$("#divCapa2").html($(nuevo).html());}	

});

	if(lastAccordion.length>0){

	myAccordion(lastAccordion[0],lastAccordion[1]);	

	}

}



function myAccordion(name,id){

var uls = document.getElementsByTagName("ul");

var temas = new Array();

	for(u in uls){

		if(uls[u].name==name){temas.push(uls[u]);}	

	}

	for(i=0;i<temas.length;i++){

	temas[i].style.display='none';	

	}

document.getElementById(id).style.display="inline";

lastAccordion[0]=name;lastAccordion[1]=id;

}



function seeHelp(id){

$(".helpcontent").hide();

$("#"+id).show();	

}



function groupswap(name,id){

	if(typeof(name)=="undefined" || typeof(id)=="undefined"){return false;}

$("div[name='"+name+"']").hide();

$("#"+id).show();	

}