/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};

xtnv = document;        //parent.document or top.document or document         
xtsd = "http://logi151";
xtsite = "369365";
xtdi = "";        //implication degree

$(document).ready(function(){   

	$('div').pngFix();
	
	if($.cookie('apartado')){
		if($.cookie('apartado').indexOf("html")!=-1){
			$("a[@href='"+$.cookie('apartado')+"']").addClass("activo");
		}else{
			$("a[@rev='"+$.cookie('apartado')+"']").addClass("activo");
		}
	}else{
		$("a[@rev='1']").addClass("activo");
	}
 
	
	$('#pestanas').tabs(parseInt($.cookie('seccion')),{ fxSlide: true, fxFade: true, fxSpeed: 'fast' });
	$('#container').triggerTab(parseInt($.cookie('seccion')));
	
	$("#not1").click(function () {
	  $("#not1_a").slideToggle("slow");
	});
	$("#not2").click(function () {
	  $("#not2_a").slideToggle("slow");
	});
	$("#nov1").click(function () {
	  $("#nov1_a").slideToggle("slow");
	});
	
	$("#printt").click(function () {
	  window.print();
	  return false;
	});
	
	$("a[@rel='home']").click(function(){
		$.cookie('seccion', '1'); 
		$.cookie('apartado', '1'); 
	});
	
	$("a[@rel='idiomas']").click(function(){				  
		if($.cookie('apartado')=="" || $.cookie('apartado')==undefined){
			var urll="presentacion.html";
		}else if($.cookie('apartado').indexOf(".html")==-1){
			var urll=$("a[@rev='"+$.cookie('apartado')+"']").attr("href");
		}else{
			var urll=$.cookie('apartado');
		}
		if(urll.indexOf("_i.")==-1){
			urll=urll.replace(".html","_i.html");
			location.href="default_i.html";
		}else{
			urll=urll.replace("_i.html",".html");
			location.href="default.html";
		}
		return false;
	});
	/*$(".fade").click(function(){
		$('#col_der').fadeOut("fast",function(){
			$('#col_der').fadeIn("def");
		});
	});*/
	$("a[@rel='1']").click(function(){
		//$('#col_der').fadeOut("fast");
		if(this.href.indexOf("http")==-1){
			$.cookie('seccion', '1'); 
			$.cookie('apartado', this.rev); 
		}
		//recorre los elementos del array
		$(".activo").removeClass();
		$("a[@rev='"+$.cookie('apartado')+"']").addClass("activo");	
		//$('#col_der').fadeIn("def");
	});
	$("a[@rel='2']").click(function(){
		//$('#col_der').fadeOut("fast");
		if(this.href.indexOf("http")==-1){
			$.cookie('seccion', '2'); 
			$.cookie('apartado', this.rev); 
		}
		$(".activo").removeClass();
		$("a[@rev='"+$.cookie('apartado')+"']").addClass("activo");
		//$('#col_der').fadeIn("def");
	});
	$("a[@rel='3']").click(function(){
		//$('#col_der').fadeOut("fast");
		if(this.href.indexOf("http")==-1){
			$.cookie('seccion', '3'); 
			$.cookie('apartado', this.rev); 
		}
		$(".activo").removeClass();
		$("a[@rev='"+$.cookie('apartado')+"']").addClass("activo");
		//$('#col_der').fadeIn("def");
	});
	$("a[@rel='4']").click(function(){
		//$('#col_der').fadeOut("fast");
		if(this.href.indexOf("http")==-1){
			$.cookie('seccion', '4'); 
			$.cookie('apartado', this.rev); 
		}
		$(".activo").removeClass();
		$("a[@rev='"+$.cookie('apartado')+"']").addClass("activo");
		//$('#col_der').fadeIn("def");
	});
	
	
	var urll=document.location.href;
	var secc=$.cookie('apartado');
	
	if(secc=="" || secc==undefined){
		var secc="presentacion.html";
	}else if($.cookie('apartado').indexOf(".html")==-1){
		secc=$("a[@rev='"+$.cookie('apartado')+"']").attr("href");
	}else if(urll.indexOf("_i.html")!=-1){
		if(secc.indexOf("_i.html")==-1){
			secc=secc.replace(".html","_i.html");
		}
	}else if(urll.indexOf(".html")!=-1){
		if(secc.indexOf("_i.html")!=-1){
			secc=secc.replace("_i.html",".html");
		}
	}
	
	$.cookie('apartado',secc);
	$('#mi_iframe').attr("src",secc);	

});

