var sel = false;
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function expandImg(imgName) {
document.getElementById("bigImg").style.visibility = "visible"	
if (ns3up || ie4up) {
imgOn = document.getElementById(imgName).src;
document.bigpic.src = imgOn;
}
}

function showExplanation(divName,btn,mensaje) {
if (document.getElementById(divName).style.visibility == "hidden")
{
buttonhtml=document.getElementById(btn).innerHTML;
document.getElementById(divName).innerHTML= mensaje + "<br>" + buttonhtml;
document.getElementById(divName).style.visibility = ""	
}
else
{
document.getElementById(divName).innerHTML='';
document.getElementById(divName).style.visibility = "hidden"
}
}

function showDiv(divName) {
document.getElementById(divName).style.visibility = ""	
}

function hideDiv(divName) {
document.getElementById(divName).style.visibility = "hidden"	
}

function redirectXLS(url){

			var cf = confirm("Desea exportar a excel esta información?");
			if(cf==true)
			{	
				document.location = url;
			}
	}

function cambiaColorOver(id)
	{
		if(sel==false)
		{
			document.getElementById("tr"+id).style.backgroundColor = "#d7d6ae"
		}
	}
	
	function resetColorOver(id)
	{
		if(sel==false)
		{
			document.getElementById("tr"+id).style.backgroundColor = "transparent"
		}
	}
	
function redirect (url){
	window.location.href=(url);
}

function joinTeam(tid){
	jtwindow=dhtmlmodal.open('uep', 'div', 'modalalertdiv'+tid, 'unoespro.com', 'width=400,height=350;left=0,top=0,resize=1,scrolling=0')
}

function process_joinTeam(team,uid,whichbutton,orig){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		//alert("nada");
		xmlHttp2=GetXmlHttpObject();
		if (xmlHttp2==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="UEPJoinTeam.asp";
		url=url+"?uid="+uid+"&tid="+team+"&orig="+orig;
		xmlHttp2.onreadystatechange=stateChanged2;
		xmlHttp2.open("GET",url,true);
		xmlHttp2.send(null);
		jtwindow.hide();
	}
}

function deleteNot(notid,uid)
{
var c = confirm("Estás seguro que deseas eliminar esta publicación?")
if(c)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Tu navegador no es compatible con AJAX!");
	  return;
	  } 
	var url="UEPAddWall.asp";
	url=url+"?uid="+uid+"&nid="+notid+"&tm=pub";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}	
}

function deletePrivateNot(notid,uid)
{
var c = confirm("Estás seguro que deseas eliminar esta publicación?")
if(c)
{ 
	xmlHttp5=GetXmlHttpObject();
	if (xmlHttp5==null)
	  {
	  alert ("Tu navegador no es compatible con AJAX!");
	  return;
	  } 
	var url="UEPAddWall.asp";
	url=url+"?uid="+uid+"&nid="+notid+"&tm=pri";
	xmlHttp5.onreadystatechange=stateChanged5;
	xmlHttp5.open("GET",url,true);
	xmlHttp5.send(null);
}	
}

function suscribe(eid){
	jtwindow=dhtmlmodal.open('uep', 'div', 'inscripcion'+eid, 'unoespro.com', 'width=400,height=350;left=0,top=0,resize=1,scrolling=0')
}

function process_suscribe(eid,uid,whichbutton,orig){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		//alert("nada");
		xmlHttp3=GetXmlHttpObject();
		if (xmlHttp3==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="UEPSuscribe.asp";
		url=url+"?uid="+uid+"&eid="+eid+"&orig="+orig;
		xmlHttp3.onreadystatechange=stateChanged3;
		xmlHttp3.open("GET",url,true);
		xmlHttp3.send(null);
		jtwindow.hide();
	}
}

function teamAction(tid,uid,action){
	switch(action)
	{
	case "a"://aceptar invitacion
	  document.getElementById('teamAction'+uid).innerHTML= document.getElementById('aceptar'+uid).innerHTML;
	  break;
	case "e"://eliminar
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('eliminar'+uid).innerHTML;
	  break;
	case "ret"://retirar equipo
	   document.getElementById('teamAction2'+uid).innerHTML=document.getElementById('retirar'+uid).innerHTML;
	  break;
	case "ec"://eliminar capitan
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('eliminarc'+uid).innerHTML;
	  break;  
	case "r"://rechazar invitacion
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('rechazar'+uid).innerHTML;
	   break;
	case "n"://añadir
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('aniadir'+uid).innerHTML;
	  break;  
	case "c"://establecer como capitán
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('capitan'+uid).innerHTML;
	  break;  
	 case "p"://pagar
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('pago'+uid).innerHTML;
	  break;  
	 case "f"://receptar formularios
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('formulario'+uid).innerHTML;
	  break;  
	 case "q"://quitar cupo
	   document.getElementById('teamAction'+uid).innerHTML=document.getElementById('quitar'+uid).innerHTML;
	  break;  
	}
	if(action=='ret')
	{
		jtwindow=dhtmlmodal.open('uep', 'div', 'teamAction2'+uid, 'unoespro.com', 'width=400,height=350;left=0,top=0,resize=1,scrolling=0')
	}
	else
	{
		jtwindow=dhtmlmodal.open('uep', 'div', 'teamAction'+uid, 'unoespro.com', 'width=400,height=350;left=0,top=0,resize=1,scrolling=0')
	}
}

function process_teamAction(team,uid,whichbutton,action){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		xmlHttp4=GetXmlHttpObject();
		if (xmlHttp4==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="UEPActionTeam.asp";
		url=url+"?uid="+uid+"&tid="+team+"&action="+action;
		xmlHttp4.onreadystatechange=stateChanged4;
		xmlHttp4.open("GET",url,true);
		xmlHttp4.send(null);
		jtwindow.hide();
	}
}

function process_adminAction(team,uid,eid,filtro,whichbutton,action){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		xmlHttp7=GetXmlHttpObject();
		if (xmlHttp7==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="VACActionProfile.asp";
		url=url+"?uid="+uid+"&tid="+team+"&eid="+eid+"&filtro="+filtro+"&action="+action;
		xmlHttp7.onreadystatechange=stateChanged7;
		xmlHttp7.open("GET",url,true);
		xmlHttp7.send(null);
		jtwindow.hide();
	}
}

function showpic(uid)
	{
		var url = "asynUEP.asp?TO=1&uid="+uid;
		envioInfo(url, "dvMsg", callback_showpic);
	}
function callback_showpic(resp)
	{
		if(!(resp==""))
		{
			var cadena = resp;
			var valores = cadena.split('*-*');
			document.getElementById("profilePic").innerHTML = valores[0];
			document.getElementById("myMenu").innerHTML = valores[1];
			
		}
		else
		{
			document.getElementById("profilePic").innerHTML = '';	
		}
	}
	
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function ValidateCaptcha(url,formname,responsediv)
{
		
		// we can use other domain to perform this task, 
		// for example, this page (index.asp) sit in domain www.encelabs.com
		// and captcha.asp sit in www.smartplanetcms.com
		// we can use url as below, this is because we are using cross domain ajax
		// $.getJSON("www.smartplanetcms.com/captcha.asp?validateCaptchaCode=" +  $("#captchacode").val() + "&format=json&jsoncallback=?", function(data){
		
		$.getJSON("captcha.asp?validateCaptchaCode=" +  $("#captchacode").val() + "&format=json&jsoncallback=?", function(data){
		if (data.status == "1")
			{
				//alert("verified and submit.");
				//if (formValidation() == true)
				//{
					xmlhttpPost(url, formname, responsediv, 'Procesando...', 'captchacode', '', 1);
					//$("#form").submit();
				//}
				
				
				result = true;
				
			}
		
			else
			{
				if (data.session == "0")
					RefreshImage("imgCaptcha");
				
				alert("El código de seguridad no es válido");
				$("#captchacode").focus();
				document.getElementById(responsediv).innerHTML = '';
		
				result = false;
				
			}
			
		});
																																					}
																																					
function ValidateCaptcha2(url,formname,responsediv)
{
		
		// we can use other domain to perform this task, 
		// for example, this page (index.asp) sit in domain www.encelabs.com
		// and captcha.asp sit in www.smartplanetcms.com
		// we can use url as below, this is because we are using cross domain ajax
		// $.getJSON("www.smartplanetcms.com/captcha.asp?validateCaptchaCode=" +  $("#captchacode").val() + "&format=json&jsoncallback=?", function(data){
		
		$.getJSON("../captcha.asp?validateCaptchaCode=" +  $("#captchacode").val() + "&format=json&jsoncallback=?", function(data){
		if (data.status == "1")
			{
				//alert("verified and submit.");
				//if (formValidation() == true)
				//{
					xmlhttpPost(url, formname, responsediv, 'Procesando...', 'captchacode', '', 1);
					//$("#form").submit();
				//}
				
				
				result = true;
				
			}
		
			else
			{
				if (data.session == "0")
					RefreshImage("imgCaptcha");
				
				alert("El código de seguridad no es válido");
				$("#captchacode").focus();
				document.getElementById(responsediv).innerHTML = '';
		
				result = false;
				
			}
			
		});
																																					}																																					
																																					
																																					function cuenta(yo, texto,mostrarboton) {
 x = yo.form[yo.name];
 t = "";
 nt= "";
 var leng=x.length;
 if (leng>=2)
 {
 //leng=1;
 }
 else
 {
 leng=1;
 }
 if (leng==1)
 {
	   if (x.checked==true)
	   {
	   t += "," + x.value;
	   }
	   yo.form[texto].value = (t == "") ? t : t.substring(1);
	   if (yo.form[texto].value=='')
	   {
			document.getElementById(mostrarboton).style.display='none';
	   }	
	   else
	   {	
			document.getElementById(mostrarboton).style.display='';
		}
 }
 else
 {
	 for (i = 0; i < leng; i ++)
	   if (x[i].checked==true)
	   {
	   t += "," + x[i].value;
	   }
	   yo.form[texto].value = (t == "") ? t : t.substring(1);
	   if (yo.form[texto].value=='')
	   {
			document.getElementById(mostrarboton).style.display='none';
	   }	
	   else
	   {	
			document.getElementById(mostrarboton).style.display='';
		}
 }
}

function openWindow (URL){
	window.open(URL,"ventana1","width=600,height=700,scrollbars=YES,menubar=NO");
}

function printme(el)
	{
		document.getElementById(el).style.visibility = "hidden"
		window.print()
		document.getElementById(el).style.visibility = "visible"
	}
		
function openLinkAjax(url)
{ 
xmlHttp8=GetXmlHttpObject();
if (xmlHttp8==null)
  {
  alert ("Tu explorador no es compatible con AJAX!");
  return;
  } 
xmlHttp8.onreadystatechange=stateChanged8;
xmlHttp8.open("GET",url,true);
xmlHttp8.send(null);
}
																																					//Vuelta al Cotopaxi
																																					function process_teamActionVAC(team,uid,eid,whichbutton,action){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		xmlHttp6=GetXmlHttpObject();
		if (xmlHttp6==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="VACActionTeam.asp";
		url=url+"?uid="+uid+"&tid="+team+"&eid="+eid+"&action="+action;
		xmlHttp6.onreadystatechange=stateChanged6;
		xmlHttp6.open("GET",url,true);
		xmlHttp6.send(null);
		jtwindow.hide();
	}
}

function process_adminActionVAC(team,uid,eid,filtro,cp,whichbutton,action){
	if (whichbutton=="no")
	{
		jtwindow.hide();
	}
	else
	{
		xmlHttp7=GetXmlHttpObject();
		if (xmlHttp7==null)
		  {
		  alert ("Tu navegador no es compatible con AJAX!");
		  return;
		  } 
		var url="VACActionTeam.asp";
		url=url+"?uid="+uid+"&tid="+team+"&eid="+eid+"&filtro="+filtro+"&action="+action+"&cp="+cp;
		xmlHttp7.onreadystatechange=stateChanged7;
		xmlHttp7.open("GET",url,true);
		xmlHttp7.send(null);
		jtwindow.hide();
	}
}

function changePageWall(url)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange=jumptopageWall;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function jumptopageWall() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtWall").innerHTML=xmlHttp.responseText;
}
}

function deleteQuestion(qid){
	var c = confirm("Seguro que deseas eliminar esta pregunta?")
		if(c)
		{
			document.location= "uepEliminarPregunta.asp?q="+ qid +"";
		}
}

																																					
																																																																							



