// JavaScript Document
// Funciones Macromedia  para intercambiar imágenes
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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//Función Macromedia para validar formularios
function MM_validateForm() { //v4.0
  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=MM_findObj(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+' debe contener una dirección de e-mail válida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un entero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
		  if (max==0 && num<min) errors+='- '+nm+' debe ser mayor a 0.\n';
          else {if (num<min || max<num && max!=0) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';}
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
  } if (errors) alert('Ocurrieron los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

//Función Macromedia para abrir pop ups
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Script para Slide show delas imagenes del banner de segusino
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'imaBanner/01.jpg'
Pic[1] = 'imaBanner/02.jpg'
Pic[2] = 'imaBanner/03.jpg'
Pic[3] = 'imaBanner/04.jpg'
Pic[4] = 'imaBanner/05.jpg'

// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}



//Función para imprimir
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
			 window.close();
}

// Función para convertir Letras primarias a mayúsculas
function cambia(formObj) {
var inicio;
var tempStr;
var tempChar;
var preString;
var postString;
var strlen;
tempStr = formObj.value.toLowerCase();
strLen = tempStr.length;
if (strLen > 0)  {
for (inicio = 0; inicio < strLen; inicio++)  {
if (inicio == 0)  {
tempChar = tempStr.substring(0,1).toUpperCase();
postString = tempStr.substring(1,strLen);
tempStr = tempChar + postString;
}
else {
tempChar = tempStr.substring(inicio, inicio+1);
if (tempChar == " " && inicio < (strLen-1))  {
tempChar = tempStr.substring(inicio+1, inicio+2).toUpperCase();
preString = tempStr.substring(0, inicio+1);
postString = tempStr.substring(inicio+2,strLen);
tempStr = preString + tempChar + postString;
         }
      }
   }
}
formObj.value = tempStr;
}

//Para navegacion interna de Oferta Educativa

var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 	try {
 		 xmlhttp = new XMLHttpRequest();
 	} catch (e) {
 		 xmlhttp=false;
 	}
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// Para versiones anteriores al IE 7
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}



var please_wait = "";

function openUrl(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);
	if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(null);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("fallo en la petición"));
  }
}

function response(url, e) {
  if(xmlhttp.readyState != 4)return;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "La liga ya no existe contacte al administrador del sitio: " + xmlhttp.status+" "+xmlhttp.statusText;
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}

//Div's ocultos que se despliegan y contraen en historia, LDG. Erika Nolasco

function cambiaDiv(a){
  var sDiv=document.getElementById(a);
  if(!sDiv)return true;
  if(sDiv.style.display=="none"){
    sDiv.style.display="block"
  } else {
    sDiv.style.display="none"
  }
  return true;
}

//Función que obtiene el valor del area para desplegar o no el campo de licenciatura, LDG. Erika Nolasco
function validaArea(){ //v3.0
	var	seleccion = document.getElementById ('lic')
	var selectedValue = document.escucha.area[document.escucha.area.selectedIndex].value;	
	if (selectedValue != ""){
		if (selectedValue == "Licenciatura"){
		seleccion.style.display = "block"
		} else {
			seleccion.style.display = "none"
			document.escucha.licenciatura.value = ""			
		}
		
	}
}
