/********************************************************************************************/
/* AJAX Simple Tabs by developersnippets, This code is intended for practice purposes.      */
/* You may use these functions as you wish, for commercial or non-commercial applications,  */
/* but please note that the author offers no guarantees to their usefulness, suitability or */
/* correctness, and accepts no liability for any losses caused by their use.                */
/********************************************************************************************/

var req;
function callPage(pageUrl, divElementId, loadinglMessage, pageErrorMessage) {
     document.getElementById(divElementId).innerHTML = loadinglMessage;
     try {
     req = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
     req.onreadystatechange = function() {responsefromServer(divElementId, pageErrorMessage);};
     req.open("GET",pageUrl,true);
     req.send(null);
  }

function responsefromServer(divElementId, pageErrorMessage) {
   var output = '';
   if(req.readyState == 4) {
      if(req.status == 200) {
         output = req.responseText;
         document.getElementById(divElementId).innerHTML = output;
         } else {
         document.getElementById(divElementId).innerHTML = pageErrorMessage+"\n"+output;
         }
      }
  }
  
/* This Function is for Tab Panels */
function activeTab(tab)
	{   
		document.getElementById("tab1").className = "";
		document.getElementById("tab2").className = "";
		document.getElementById("tab3").className = "";
		document.getElementById("tab"+tab).className = "active";
		if(tab == 1) // If your tabs are more, then you can use 'switch' condition instead of 'if' condition for better practice
		{callPage('biblio.html', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else if(tab == 2){
		callPage('univ.html', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else{
		callPage('gov.html', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}
	}

function tabsMult(num) {
	document.getElementById("hizq1").className = "";
	document.getElementById("hizq2").className = "";
	document.getElementById("hizq3").className = "";
	document.getElementById("envolturaizq1").className = "";
	document.getElementById("envolturaizq2").className = "";
	document.getElementById("envolturaizq3").className = "";
	document.getElementById("hizq"+num).className = "active";
	document.getElementById("envolturaizq"+num).className = "active";
	if(num == 1) // If your tabs are more, then you can use 'switch' condition instead of 'if' condition for better practice
		{callPage('notimain.php', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else if(num == 2){
		callPage('galeria.html', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else{
			//alert(numlocal);
		callPage('mapamain.php?nloc='+numlocal, 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}
}

function psicMult(num) {
	/*document.getElementById("hizq1").className = "";
	document.getElementById("hizq2").className = "";
	document.getElementById("hizq3").className = "";
	document.getElementById("envolturaizq1").className = "";
	document.getElementById("envolturaizq2").className = "";
	document.getElementById("envolturaizq3").className = "";
	document.getElementById("hizq"+num).className = "active";
	document.getElementById("envolturaizq"+num).className = "active";*/
	if(num == 1) // If your tabs are more, then you can use 'switch' condition instead of 'if' condition for better practice
		{callPage('carreras1.html', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else if(num == 2){
		callPage('eleccion.html', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}else{
			//alert(numlocal);
		callPage('tips.html', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
		}
}

function next_page(num) {
	callPage('carreras'+num+'.html', 'cizq', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
}
