///////////Modulo de Contacto //////////////

 function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
   return (true)
  } else {
   alert("La dirección de email es incorrecta.");
   return (false);
  }
 }
function sendContactF(){
		if(
		   (GetId('frmContactF').Nombre.value=='')||
		   (GetId('frmContactF').Apellido.value=='')||
		   (GetId('frmContactF').Telefono.value=='')||
		   (GetId('frmContactF').Email.value=='')||
		   (GetId('frmContactF').Id_Destino.value=='-1')||
		   (GetId('frmContactF').Mensaje.value=='')
		   ){
			alert('Por favor complete todos los campos.');
			}else{
				if (validarEmail(GetId('frmContactF').Email.value)){
					var xP=akiSfrm('frmContactF')+'&content=contact.form';
					goAJAX('ContactF','ajax.php', xP);
				}
				}
		}
function showContactF(){
		winajax('Cont&aacute;ctenos:','400','400','ajax.php?content=contact.form&ses=no','');
		}

//////////////////////////////////////////////
var MostrarOcultar='';
var	ClicId='';
var	clicaja='';
function sOcultarFade(element){
	if (MostrarOcultar!='sOcultarFade'){
	new Effect.Opacity(element, {duration:0.5, to:0.3});
	//document.getElementById(element).style.display='none';
	//document.getElementById(element).style.opacity='.3';
	MostrarOcultar='sOcultarFade';
	}
	
}

function sMostrarFade(element){
	if (MostrarOcultar!='sMostrarFade'){
	new Effect.Opacity(element, {duration:0.5, to:1.0});
	//	document.getElementById(element).style.display='';
	//	document.getElementById(element).style.opacity='.99';
	MostrarOcultar='sMostrarFade';
	}
}
//////////////////// estas funciones controlan el cambio de color hover y en el chick
function mOvr(obj) {//on mouse in
	if(ClicId == get(obj.id)){
		ClicId.style.background="#FFF2F2";
	}else{
		get(obj.id).style.background="#D2FDD0";
	}
}

function mOut(obj) {// on mouse out
	if(ClicId == get(obj.id)){
		ClicId.style.background="#FFF2F2";
	}else{
		if (get(obj.id)!=null){
			get(obj.id).style.background="#EDF7FC";	
		}
	}
}

function mClk(obj) {//on click
 var clic2=ClicId;
	ClicId=get(obj.id);
	get(obj.id).style.background="#FFF2F2";
	mOut(clic2);
}

function mClk2(obj) {//on click
	if(clicaja == get(obj.id)){
		clicaja.style.background="#ffffea";
	}else{
		get(obj.id).style.background="#ffffea";
		if(clicaja !=''){
			get(clicaja.id).style.background="#ffffff";
		}
		clicaja=obj;
	}
}

/////////////esta es una funcion que se encarga de ocultar o mostrar un determinado DIV
function VerSINO(oItems)
{
	var objDiv = document.getElementById(oItems);
    if (objDiv.style.display == "") {
		objDiv.style.display = "none";
	} else {

		objDiv.style.display = "";
	}
}

function activarCampo(id){
	get(id).disabled="";
	}
////////////////cambia los valores de la classe del objeto
function mostrarOcultar(id){
	if (GetId(id).className=='overno'){
		GetId(id).className='oversi';
		}else{
			GetId(id).className='overno';
				}
	}
function mostrarOcultarGrupo(id){
	if (GetId(id).className=='overnoGrupo'){
		GetId(id).className='oversiGrupo';
		}else{
			GetId(id).className='overnoGrupo';
				}
	}
/////////////// lista el los grupos por defecto ///////////////////
function derecha(){
	var	ID ='content=derecha/derecha'
	var	LD ='content=Reportes.ListaIzquierda'
	goAJAX('Derecha','ajax.php',ID);
	goAJAX('listareportes','ajax.php',LD);
	
}
//////////////////funcion para guardar datos cuando se edita el contenido de las cajas 
function saveVal(obj,T,N,G){
	/* desactivamos el campo */
	get(obj.id).disabled="disabled";
	get(obj.id).style.bgcolor="#FFFFFF";
	/* Quitamos el prefijo 'cID' del atributo id para obtener el valor de PK */
	var id = str_replace('cID','',obj.id);
	var	ob = document.getElementById('Errordelista' + G);
	/* construimos los parametros de la solicitud ajax */
	/* No se recomienda pasar la tabla como parametro en una web publica */
	var xP = 'logic=updateGeneric&table='+ T;
	xP += '&fila=' + N;
	xP += '&name=' + obj.name;
	xP += '&value=' + obj.value;
	xP += '&id=' + obj.id;
	xP += '&content=GuardarTex';
	/* hacemos la solicitud ajax pero sin reemplazar ni al inicio ni al final,
	 tambien llamamos a una funcion para reactivar el campo */
	 var exec = 'activarCampo(\'' + obj.id + '\')';
	 var content='GuardarTex';
	goAJAX('Errordelista' + G,'ajax.php',xP,exec,'','0','0');
	if (ob.style.display == "none"){
	 VerSINO('Errordelista' + G);
	}
	
 /* lo que sigue es solo el debug */
	/*var tmb = get('sDebug').innerHTML;
	get('sDebug').innerHTML='<b>Campo:</b> ' + obj.name + '<br />';
	get('sDebug').innerHTML+='<b>Valor:</b> ' + obj.value + '<br />';
	get('sDebug').innerHTML+='<b>ID:</b> ' + id + '<br />';
	get('sDebug').innerHTML+= '<hr />';*/

	}
	
///////////////// ////////////funcion encargada de borrar grupos de Link
function delGrup(i,preg){
	var confirmMsg  = ' Esta por Borrar Contenido de su sistema de Links... ';
    	ID ='ID='+i+'&content=BorrarGrupo';
	if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
	    }
    var is_confirmed = confirm(confirmMsg + ' \n   ' + preg);
    if (is_confirmed) {
		GetId('del'+i).style.display='none';
		
		goAJAX('mensajesyalertGlobales','ajax.php',ID);
		var	ob = document.getElementById('mensajesyalertGlobales');
			if (ob.style.display == "none"){
	 			VerSINO('mensajesyalertGlobales');
			}
	}
}
////////////////////////Para borrar un Link//////////////
function delLink(i,preg,G){
	var confirmMsg  = ' Esta por Borrar Contenido de su sistema de Links... ';
	var	ID ='ID='+i+'&content=BorrarLink';
	if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
	    }
    var is_confirmed = confirm(confirmMsg + ' \n   ' + preg);
    if (is_confirmed){
		GetId('ak_row'+i).style.display='none';
		goAJAX('Errordelista' + G,'ajax.php',ID);
		var	ob = document.getElementById('Errordelista' + G);
			if (ob.style.display == "none"){
	 			VerSINO('Errordelista' + G);
			}
	}
	}
////////////////////////recuperar datos anteriores de las cajas de Url Y titulo///////////////
function VolverLink(ID){
	var que='2';
	var caj='qcID'+ID;
		goAJAX('mensajesyalertGlobales','ajax.php','content=Udate.Link&que='+que+'&ID='+ID,'get(\''+caj+'\').value=respuesta');
}
///////////////////////Funcion que genera el codigo para las webs//////////////
function generarCodigo(i,q){
	winajax('C&oacute;digos para Tu Web','700','650','ajax.php?i='+i+'&q='+q + '&content=Codigos','');
	}
/////////////////musetra los anonimos/////////////////////
function linkanonimo(ID){
	var	i='i='+ID+'&content=anonimoAjaxa&ses=no';
	goAJAX('contenido','ajax.php',i);
}
/////////////// lista el los grupos paginada ///////////////////
function derechapag(b,a,gt,num){
	var	ID ='content=derecha/inc/ListadodelosGrupos&pagina='+b+'&ajax='+a+'&gt='+gt+'&num='+num;
	goAJAX('Derecha','ajax.php',ID);
}


///////////////crea el grupo///////////////
function NuevoGrupo(ID){
	var xp=akiSfrm(ID);
	var i=xp+'&content=derecha/derecha';
	
	goAJAX('Derecha','ajax.php',i);
		}
function BuscarCosas(ID){
	var xp=akiSfrm(ID);
	var i=xp+'&content=derecha/derecha';
	
	goAJAX('Derecha','ajax.php',i);
		}
function BuscarCosas2(cadena){
	var i='&content=derecha/derecha&boton=Buscar&BuscarTex='+cadena+'&tipoBuscar=1';
	
	goAJAX('Derecha','ajax.php',i);
		}

//////////////////seleccionar contenido de un Texarea///////////////
function selectAll(obj) {
	objDiv = document.getElementById(obj)
	objDiv.focus();
	objDiv.select();
}
function codLink(i){
	winajax('C&oacute;digo de Link','600','300','ajax.php?id='+i+'&content=Codlink','');
	}
	
//////////////////////////guardas mas link en un grupo creado//////////////////////////
function nuevolink(ID){
	winajax('A&ntilde;adir Links al Grupo','500','300','ajax.php?ID='+ID+'&content=UdateGrupo','');
}
function cernuevoslinkgrupoviejo(Fr,ID){
	var xp=akiSfrm(Fr);
	var i=xp+'&ID='+ID+'&content=UdateGrupo.guardar';
	goAJAX('listacajas'+ID,'ajax.php',i);
	OcultarVtna();
		}
////////////////////reportes de Grupo y de Links y la Vista de los Reportes///////////////////////////
function ReporteGrupo(ID){
		var i='ID='+ID+'&ses=no&content=reporte&que=G';
		goAJAX('Reporte'+ID,'ajax.php',i);
	}
function ReporteLink(ID,IG){
		var i='ID='+ID+'&ses=no&content=reporte&que=L&IG='+IG;
		goAJAX('Reporte'+ID,'ajax.php',i);
	}
function RepotesBorrar(ID,Q){
		var i='ID='+ID+'&content=RepotesBorrar.grupo&que='+Q;
		goAJAX('RepotesBorrar'+ID,'ajax.php',i);
	}
function RepotesVer(ID){
	var i='Listareporte=si&content=derecha/derecha&ID='+ID;
	
	goAJAX('Derecha','ajax.php',i);
	}
//////////////// Añadir comentario en un grupo ///////////////////
function ComentarGrupo(ID){
	winajax('A&ntilde;adir Comentario al Grupo','500','300','ajax.php?ID='+ID+'&content=ComentarGrupo','');
}
function cementarioG(Fr,ID){
	var xp=akiSfrm(Fr);
	var i=xp+'&ID='+ID+'&content=ComentarGrupo.guardar';
	var	ob = document.getElementById('Errordelista' + ID);
	goAJAX('Errordelista' + ID,'ajax.php',i);
	OcultarVtna();
	var	ob = document.getElementById('Errordelista' + ID);
			if (ob.style.display == "none"){
	 			VerSINO('Errordelista' + ID);
			}
}
function compartir(i){
	ID ='ID='+i+'&content=compartirLinks';
	goAJAX('mensajesyalertGlobales','ajax.php',ID);
}
function versicompartir(i){
	ID ='ID='+i+'&content=vercompartir&ses=SI';
	goAJAX('compartirgrupo','ajax.php',ID);
	}

function versicompartir2(i,s){
	ID ='ID='+i+'&server='+s+'&content=vercompartir&ses=SI';
	goAJAX('compartirgrupo','ajax.php',ID);
	}
	
function modoexperto(){
	var i='content=derecha/Exerto';
	goAJAX('Derecha','ajax.php',i);
}

