var PST_PR = {
		_capadesc : null,
		_capavent : null,
		_capacond : null,	
		_capamenu	: null,
		_infogeneral	: null,
		
		init : function(){
			try{
				PST_PR._capadesc = document.getElementById('cont_descripcion');
				PST_PR._capavent = document.getElementById('cont_ventajas');
				PST_PR._capacond = document.getElementById('cont_condiciones');
				PST_PR._capamenu = document.getElementById('tabproductos');
				PST_PR._infogeneral = document.getElementById('infogeneral');
				
		
				if  (PST_PR._capavent || PST_PR._capacond) {
					PST_PR.insertaCont();
				}	
				
				var param_uri = self.location.href.split('#')[1];
				if (param_uri){
					switch(param_uri){
						case 'ventajas':
								PST_PR.muestra('_capavent');
								break;														
						case 'condiciones': 
								PST_PR.muestra('_capacond');
								break;														
					}
				}
				
			}catch (e){
				//alert(e.message);
			}	
		},
		insertaCont: function (){
			
			PST_PR._infogeneral.onclick = function() {PST_PR.muestra('_capadesc');}
			
			if (PST_PR._capavent){
				var _pestvent = document.createElement('li');
				_pestvent.className = "noactiva enlace condiciones";
				_pestvent.id = "liventajas";
				_pestvent.style.display = "inline";
				_pestvent.onclick = function() {PST_PR.muestra('_capavent');}
				_pestvent.appendChild(document.createTextNode('Ventajas'));
				
				PST_PR._capavent.style.display = "none";
				try{
					PST_PR._capavent.getElementsByTagName('h5')[0].style.display = "none";
				}catch(e)	{
					PST_PR._capavent.getElementsByTagName('h3')[0].style.display = "none";
				}
				if(PST_PR._capamenu.childNodes.length == 1){
					PST_PR._capamenu.appendChild(_pestvent);			
				}else{
					PST_PR._capamenu.insertBefore(_pestvent,PST_PR._capamenu.childNodes[1]);			
				}						
			}
			
			if (PST_PR._capacond){
				var _pestcond = document.createElement('li');
				_pestcond.className = "noactiva enlace condiciones";
				_pestcond.id = "licondiciones";
				_pestcond.style.display = "inline";
				_pestcond.onclick = function() {PST_PR.muestra('_capacond');}
				_pestcond.appendChild(document.createTextNode('Condiciones'));
				
				PST_PR._capacond.style.display = "none";
				try{
					PST_PR._capacond.getElementsByTagName('h5')[0].style.display = "none";
				}catch(e)	{
					PST_PR._capacond.getElementsByTagName('h3')[0].style.display = "none";
				}
					
				if(PST_PR._capavent){
					if(PST_PR._capamenu.childNodes.length == 2){
						PST_PR._capamenu.appendChild(_pestcond);	
					}else{	
						PST_PR._capamenu.insertBefore(_pestcond,PST_PR._capamenu.childNodes[2]);
					}				
				}else {
					if(PST_PR._capamenu.childNodes.length == 1){
						PST_PR._capamenu.appendChild(_pestcond);	
					}else{	
						PST_PR._capamenu.insertBefore(_pestcond,PST_PR._capamenu.childNodes[1]);			
					}	
				}
			}
				
		},
		muestra : function (capa){
			switch(capa){
				case '_capacond': 
					PST_PR._capacond.style.display = "block";
					
					try{	PST_PR._capadesc.style.display = "none"; }catch(e)	{}
					try{	PST_PR._capavent.style.display = "none"; }catch(e)	{}
					
					try{	document.getElementById('licondiciones').className = "elegida bold"; }catch(e)	{}					
					try{	document.getElementById('liventajas').className = "noactiva enlace"; }catch(e)	{}										
					try{	PST_PR._infogeneral.className = "noactiva enlace no_grande"; }catch(e)	{}					
					
					break;
					
				case '_capadesc':
					PST_PR._capadesc.style.display = "block";
					try{ PST_PR._capavent.style.display = "none"; }catch(e)	{}
					try{ PST_PR._capacond.style.display = "none";	}catch(e)	{}
										
					try{	document.getElementById('licondiciones').className = "noactiva enlace"; }catch(e)	{}					
					try{	document.getElementById('liventajas').className = "noactiva enlace";}catch(e)	{}	 				
					try{	PST_PR._infogeneral.className = "elegida grande"; }catch(e)	{}
					
					break;
					
				case '_capavent': 
					PST_PR._capavent.style.display = "block";
					try{ PST_PR._capadesc.style.display = "none"; }catch(e)	{}
					try{ PST_PR._capacond.style.display = "none"; }catch(e)	{}
					
					try{	document.getElementById('liventajas').className = "elegida";	}catch(e)	{}				
					try{	document.getElementById('licondiciones').className = "noactiva enlace"; }catch(e)	{}
					try{	PST_PR._infogeneral.className = "noactiva enlace no_grande"; }catch(e)	{}
					break;
					
			}
		},
		addLoadEvent : function (func) {
		  var oldonload = window.onload;
		  if (typeof window.onload != 'function') {
		    window.onload = func;
		  } else {
		    window.onload = function() {
		      if (oldonload) {
		        oldonload();
		      }
		      func();
		    }
	  }
	}
}	

PST_PR.addLoadEvent(PST_PR.init);
