// Proyecto: Aguirre Soluciones Integrales
// Desarrollo: Tabs para contenidos HTML. En base XML + JS
//
// Javier Brizuela

//Inicialización
var xmlData = null;
var tabsObj = null;
var tab_selected = null;
var content_folderPath = null;
var content_titulo = null;
var content_visualPath = null;

//Creacion del objeto
if(window.ActiveXObject){
	browser = 1;
	var content_xml = new ActiveXObject("Microsoft.XMLDOM");
}else{
	browser = 2;
	var content_xml = document.implementation.createDocument("","",null);
}

//Verifico el estado de carga del xml
content_verify = function(){
	if(content_xml.readyState == 4){
		getContent(content_xml.documentElement);
	}
}

loadContent = function(folderPath, tabObj, tituloObj, visualPathObj){
	tab_selected = tabObj;
	content_folderPath = folderPath;
	content_titulo = tituloObj;
	content_visualPath = visualPathObj;
	if(browser == 1){
		//Si es iexplore
		content_xml.async="false";
		content_xml.onreadystatechange = content_verify;
		content_xml.load(folderPath+"tabs.xml");
	}else if(browser == 2){
		//Si es Mozilla, Firefox, Opera
		content_xml.async="false";
		content_xml.load(folderPath);
		xmlData = content_xml.documentElement;
	}else{
		alert("Su navegador no puede correr este script.");
	}
}

getContent = function(xmlObj){
	tabsObj = xmlObj.childNodes;
	for(i=0; i < tabsObj.length; i++){
		if(i!=tab_selected){
			if(tabsObj[i].getAttribute("nombre")!="presupuesto"){
				document.write('<td>');
				document.write('<a href="'+content_folderPath+'?titulo='+content_titulo+'&tab='+i+'&folder_path='+tabsObj[i].getAttribute("nombre")+'&visual_path='+content_visualPath+'">');
				document.write('<img src="imgs/sk1nv7/tabs/tab_idle_'+tabsObj[i].getAttribute("nombre")+'.gif" border="0">');
				document.write('</a>');
				document.write('</td>');
			}else{
				document.write('<td>');
				document.write('<a href="'+content_folderPath+'?titulo='+content_titulo+'&tab='+i+'&folder_path='+tabsObj[i].getAttribute("nombre")+'&visual_path='+content_visualPath+'&action=redactar">');
				document.write('<img src="imgs/sk1nv7/tabs/tab_idle_'+tabsObj[i].getAttribute("nombre")+'.gif" border="0">');
				document.write('</a>');
				document.write('</td>');
			}
		}else{
			document.write('<td><img src="imgs/sk1nv7/tabs/tab_selected_'+tabsObj[i].getAttribute("nombre")+'.gif"></td>');
		}
	}
}

getHeader = function(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="751" height="243" style="z-index:10">');
	document.write('<param name="movie" value="media/header.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="media/header.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="751" height="243" style="z-index:10"></embed>');
	document.write('</object>');
}

getIntro = function(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="751" height="243" style="z-index:10">');
	document.write('<param name="movie" value="media/intro.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="media/intro.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="751" height="243" style="z-index:10"></embed>');
	document.write('</object>');
}
