/********************************************************************************************/
/* 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('script/reto.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Enfréntese a los nuevos retos". Por favor, espere...', 'Información no disponible en este momento.<br> Disculpe las molestias. <img src=script/images/error_caution.gif />');
		}else if(tab == 2){
		callPage('script/c5501.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C5501". Por favor, espere...', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 3){
		callPage('script/c6501.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C6501"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 4){
		callPage('script/c65hc.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C65hc"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 5){
		callPage('script/cp2020.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Intec CP2020"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 6){
		callPage('script/c5501flash.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C5501 - FLASH"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 7){
		callPage('script/c6501flash.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C65hc"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else if(tab == 8){
		callPage('script/c65hcflash.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Konica Minolta bizhub PRO C65hc"', 'Error in Loading page <img src=script/images/error_caution.gif />');
		}else
		callPage('script/cp2020.htm', 'content', '<img src=script/images/loading.gif /> Cargando información "Intec CP2020"', 'Error in Loading page <img src=script/images/error_caution.gif />');
	}