//Funciones JavaScript v 1. moises.rangel@gmail.com

function MR_openWindow(url,windowName,xtras) { 
  window.open(url,windowName,xtras);
}

function MR_openWindowNew(id) { 
  window.open("serviciosCadel/verNoticia.aspx?idNoticia="+id+"","Noticias","width=400,height=400,top=0,left=0,scrollbars=yes");
}

/*function MR_openCourse(id) { 

  window.open("asignaturas/default.aspx?idMateria="+id+"","materiaEnLinea","width=799,height=550,top=0,left=0,scrollbars=no");
}

function MR_openCoursePyme(id) { 

  window.open("../default.aspx?idMateria="+id+"","materiaEnLinea","width=799,height=550,top=0,left=0,scrollbars=no");
}*/

function MR_openCourse(id,mat) { 

window.open("asignaturas/default.aspx?idMateria="+id+"&clmateria="+mat,"materiaEnLinea","width=799,height=550,top=0,left=0,scrollbars=no");
  
}

function MR_openCourseMES(id,mat) { 

window.open("asignaturas/default.aspx?idMateria="+id+"&clmateria="+mat,"materiaEnLinea","width=990,height=650,top=0,left=0,scrollbars=no");
  
}

function MR_openCoursePyme(id) { 

  window.open("../default.aspx?idMateria="+id+"","materiaEnLinea","width=799,height=550,top=0,left=0,scrollbars=no");
}


function MR_openTool(id) { 

window.open("toolRedirect.aspx?idTool="+id+"","Herramienta","width=300,height=300,top=0,left=0,scrollbars=no");
}

function MR_openToolbyClass(id) { 

window.open("../../asignaturas/toolRedirect.aspx?idTool="+id+"","Herramienta2","width=300,height=300,top=0,left=0,scrollbars=no");
this.close()
}

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 TextPosition(objName, x, newText) 
{ //v4.01	
	if ((obj=MM_findObj(objName))!=null) 
		with (obj)
			if (document.layers) 
			{
				document.write(unescape(newText)); 
				document.close();
			}
			else 
			innerHTML = unescape(newText);
				//innerHTML = unescape(newText);
}
//onLoad="TextPosition('barraEstado?topFrame','','<%=session("estado")%>')"


function miniGlosDesarrollo(WordToSearch){

           var pop_win = window.open('', 'win', 'width=300,height=200,scrollbars=yes');
           pop_win.document.open('text/html', 'replace');
           pop_win.document.write('<SCRIPT>');
           //pop_win.document.write('parent.location.href = "http://moi5e5/portalPle/asignaturas/desarrolloEmprendedor/tools/glosario/miniGlosario.asp?palabra='+WordToSearch+'";');         
           //pop_win.document.write('parent.location.href = "http://cadel2.uvmnet.edu/portalPle/tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');         
          pop_win.document.write('parent.location.href = "../../../../../tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');          
           pop_win.document.write('</SCRIPT>');

//javascript:miniGlosDesarrollo('palabraBuscar')
}
function miniGlosPrincipios(WordToSearch){

           var pop_win = window.open('', 'win', 'width=300,height=200,scrollbars=yes');
          pop_win.document.open('text/html', 'replace');       
          pop_win.document.write('<SCRIPT>');
          //pop_win.document.write('parent.location.href = "http://moi5e5/portalPle/tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');         
          //pop_win.document.write('parent.location.href = "http://cadel2.uvmnet.edu/portalPle/tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');         
          pop_win.document.write('parent.location.href = "../../../../../../tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');
          pop_win.document.write('</SCRIPT>');

//javascript:miniGlosPrincipios('palabraBuscar')
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openChwPass(){

           var pop_win = window.open('', 'chPass', 'width=250,height=400,scrollbars=no,top=0,left=0');
          pop_win.document.open('text/html', 'replace');       
          pop_win.document.write('<SCRIPT>');
          pop_win.document.write('parent.location.href = "serviciosCadel/cambiarContraseña.aspx";');         
          pop_win.document.write('</SCRIPT>');

}


function openChwPass2(){

           var pop_win = window.open('', 'chPass', 'width=250,height=400,scrollbars=no,top=0,left=0');
          pop_win.document.open('text/html', 'replace');       
          pop_win.document.write('<SCRIPT>');
          pop_win.document.write('parent.location.href = "serviciosCadel/cambiarContraseña.aspx";');         
          pop_win.document.write('</SCRIPT>');

}



function MR_openEncuesta(id) { 

  window.open("tools/encuestaPEL/portada.aspx","encuesta","width=600,height=520,top=0,left=0,scrollbars=yes");
}



function miniGlosLMS(WordToSearch){

          var pop_win = window.open('', 'win', 'width=300,height=200,scrollbars=yes');
          //pop_win.document.open('text/html', 'replace');       
          pop_win.document.write('<SCRIPT>');   
          //pop_win.document.write('parent.location.href = "http://localhost/portalPle/tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');         
          pop_win.document.write('parent.location.href = "../../../../../tools/miniGlosario/miniGlosario.aspx?palabra='+WordToSearch+'";');
          pop_win.document.write('</SCRIPT>');

//javascript:miniGlosLMS('palabraBuscar')
}

function ventanaEncuesta(id, tipo) 
{ 
	/*window.open('http://cadel2.uvmnet.edu/encuesta/contenedor.aspx?id=' + id + '&tipo=' + tipo, 'Encuesta', 'width=799,height=550,top=0,left=0,scrollbars=no');*/
	window.open('http://10.51.39.62/encuesta/contenedor.aspx?id=' + id + '&tipo=' + tipo, 'Encuesta', 'width=799,height=550,top=0,left=0,scrollbars=no');
}

function ventanaEncuestaInforme(id, tipo) 
{ 
	/*window.open('http://cadel2.uvmnet.edu/encuesta/contenedor.aspx?id=' + id + '&tipo=' + tipo, 'Encuesta', 'width=799,height=550,top=0,left=0,scrollbars=no');*/
	window.open('http://10.51.39.62/encuesta/contenedor.aspx?id=' + id + '&tipo=' + tipo, 'Encuesta', 'width=799,height=550,top=0,left=0,scrollbars=no');
}

//EAH 20090716 funcion que codifica el codigo potencialmente peligroso
//para dejarlo pasar, del lado del server se le debe aplicar un decode para regresar al original
//así no desactivamos requestValidator
function encode()
{
	//if  (   document._ctl0.Etiqueta !=null)
	//var asd = document._ctl0.Etiqueta;
	//alert(typeof(document._ctl0.Etiqueta))
	
	if(document.forms[0].Etiqueta != null)
	{
	
 		var result = document.forms[0].Etiqueta.value;
		// ampersands (&)
		result = result.replace(/\&/g,'&amp;');
		// less-thans (<)
		result = result.replace(/\</g,'&lt;');
		// greater-thans (>)
		result = result.replace(/\>/g,'&gt;');

		document.forms[0].Etiqueta.value = result;
	}else{
	
		if (getElementByName('Etiqueta') != null) 
		{
 			var result = getElementByName('Etiqueta').value;
			// ampersands (&)
			result = result.replace(/\&/g,'&amp;');
			// less-thans (<)
			result = result.replace(/\</g,'&lt;');
			// greater-thans (>)
			result = result.replace(/\>/g,'&gt;');
			getElementByName('Etiqueta').value = result;
		}
	}
	
	
	if(document.forms[0].Etiqueta2 != null)
	{
	
 		var result = document.forms[0].Etiqueta2.value;
		// ampersands (&)
		result = result.replace(/\&/g,'&amp;');
		// less-thans (<)
		result = result.replace(/\</g,'&lt;');
		// greater-thans (>)
		result = result.replace(/\>/g,'&gt;');

		document.forms[0].Etiqueta2.value = result;
		
	}else{
	
		/*
		
		if (getElementByName('Etiqueta2') != null) 
		{
 			var result = getElementByName('Etiqueta2').value;
			// ampersands (&)
			result = result.replace(/\&/g,'&amp;');
			// less-thans (<)
			result = result.replace(/\</g,'&lt;');
			// greater-thans (>)
			result = result.replace(/\>/g,'&gt;');
			getElementByName('Etiqueta2').value = result;
		}
		*/
		
	}
	
}