//usa prototype.js 
var bN=true;
var bOP=true;
var $CE = function(tagName, attributes, styles){ //short for create element
      var el = document.createElement(tagName);
      if (attributes)
            $H(attributes).each(function(pair){
                  eval("el." + pair.key + "='" + pair.value + "'");
            });
      if (styles)
            $H(styles).each(function(pair){
                  el.style[pair.key] = pair.value;
            });

      return $(el);
};

Element.addMethods({
	clearChildren: function(element) {
		element = $(element);
		$A(element.childNodes).each(function(e){
			 if(e.innerHTML!="Inicio"){
			  e.parentNode.removeChild(e);
			 }
		});
		return element;
	},
	//method that creates a new element and appends to the current element
	// example: <div id="myDiv">Please</div>
	//          $('myDiv').append('A',{href:'otherpage.html', className:'red'}).update('Continue...');
	//     ==>  <div id="myDiv">Please<a href="otherpage.html" class="red">Continue...</a></div>
	append: function(element, tagName, attributes, styles) {
		element = $(element);
		var newEl = $CE(tagName, attributes, styles);
		element.appendChild(newEl);
		return newEl;//<-- this one returns the new element
	},
	//appends a text node to the element
	// example: <div id="myDiv"><b>hello</b></div>
	//          $('myDiv').appendText(', John');
	//      ==> <div id="myDiv"><b>hello</b>, John</div>
	appendText: function(element, text){
		element = $(element);
		var t = document.createTextNode(text);
		element.appendChild(t);
		return element;
	  }
});


Event.observe(window, 'load', page_loaded, false);
	function page_loaded(evt) {
	  //Event.observe(document, 'click', item_clicked, false);
	  mySlideShow1.play();
	}
	function item_clicked(evt){
		var child = Event.element(evt);
						 
		if(child.tagName=="A" && child.protocol!="javascript:" && child.protocol!="mailto:" && child.tagName!="IMG" && child.className!="externo")
		 {
		   if(child.id=="")
		   {
			if($('last'))
			{
		     var asd=$('last').previousSiblings();
		     $('seguimiento').clearChildren();
		     new Insertion.After('inicio',"<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
		     new Insertion.After('inicio',"|<a href="+asd[0].href+" id="+asd[0].id+">"+asd[0].innerHTML+"</a>"); 
		     new Insertion.After('inicio',"|<a href="+asd[1].href+" id="+asd[1].id+">"+asd[1].innerHTML+"</a>"); 
			 bN=false;
			}
			else
			{
			 var asd=$('inicio').nextSiblings();
			 $('seguimiento').clearChildren();
			 if(child.innerHTML.indexOf("&gt;")==-1)
			  new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
			 else
			  new Insertion.After('inicio',"<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
			 if(child.id=="idProPre")
			 {
			  new Insertion.After('inicio',"|<a href=\"serviciosvaloranadido.htm\" id=\"idProPre\">Productos Premiun</a>"); 
		     }
			
			 if(asd.length>=2)
			 {
		      new Insertion.After('inicio',"|<a href="+asd[1].href+" id="+asd[1].id+">"+asd[1].innerHTML+"</a>");				 
			 }
		     new Insertion.After('inicio',"|<a href="+asd[0].href+" id="+asd[0].id+">"+asd[0].innerHTML+"</a>"); 
		     bN=false;
			}
			var pagina=child.href;
		    var ajax = new Ajax.Updater('principal', pagina, {method:'get', onComplete: function(req){$('principal').innerHTML = req.responseText;}});
		 
		   }
		   else
		   {
			   bN=true;
		    if(child.id!="")
		      {
				  var asd=$(child.id).previousSiblings();
				  if (child.id!="last")
			        $('seguimiento').clearChildren();
				  
			  }
		   }//else
		  
		   if(child.id!="last" && bN)
		   {
			$('seguimiento').clearChildren();
			if(child.textContent!='Inicio' || child.innerHTML!="Inicio")
			{
				if(child.innerHTML.indexOf("&gt;")==-1)
				{
					if(asd.length>2 || child.id=="idPro" || child.id=="idDom" || child.id=="idQui" || child.id=="idNot" || child.id=="idPar" || child.id=="idCon" || child.id=="idBus")
				      {new Insertion.After('inicio',"|<a href="+child.href+" id="+child.id+">"+child.innerHTML+"</a>");}
				    else
					{
					 if(child.id=="")
					 {
					   new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   bOP=false;
					 }
					 if(child.id=="idSerPre")
					 {
					   new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolPre";
					   bOP=false;
					 }
					 if(child.id=="idSerMar")
					 {
					   new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolMar";
					   bOP=false;
					 }
					 if(child.id=="idSerPro")
					 {
					   new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolPro";
					   bOP=false;
					 }
					}
				}
				else 
				{
                  new Insertion.After('inicio',"<a href="+child.href+" id="+child.id+">"+child.innerHTML+"</a>");
			     //if(child.id.indexOf("idSer")==-1)
				  $('seguimiento').clearChildren();
				   if(child.id=="idSerPre")
					 {
					   new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolPre";
					   bOP=false;
					 }
					 if(child.id=="idSerMar")
					 {
						 if(child.innerHTML.indexOf("&gt;")==-1)
					      new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					     else
						  new Insertion.After('inicio',"<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolMar";
					   bOP=false;
					 }
					 if(child.id=="idSerPro")
					 {
						 if(child.innerHTML.indexOf("&gt;")==-1)
					      new Insertion.After('inicio',"|<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					     else
						 new Insertion.After('inicio',"<a href="+child.href+" id=\"last\">"+child.innerHTML+"</a>");
					   child.id="idSolPro";
					   bOP=false;
					 }
				  
				}
			}
			if(child.id!=""){
				
			   if(asd.length>=2 && asd[1].id!="inicio" && bOP){
		          new Insertion.After('inicio',"|<a href="+asd[0].href+" id="+asd[0].id+">"+asd[0].innerHTML+"</a>"); 
			   }
			   if(child.id=="idSolPre")
			   {
				   new Insertion.After('inicio',"|<a href=\"serviciosvaloranadido.htm\" id=\"idSolPre\">Soluciones Premiun</a>"); 
	     	       new Insertion.After('inicio',"|<a href=\"productos.htm\" id=\"idPro\">Productos</a>"); 
			   }
			   if(child.id=="idSolMar")
			   {
				   new Insertion.After('inicio',"|<a href=\"distribucioncontenidos.htm\" id=\"idSolMar\">Soluciones Marketing</a>"); 
	     	       new Insertion.After('inicio',"|<a href=\"productos.htm\" id=\"idPro\">Productos</a>"); 
			   }
			   if(child.id=="idSolPro")
			   {
				   new Insertion.After('inicio',"|<a href=\"micropagos.htm\" id=\"idSolPro\">Soluciones Profesionales</a>"); 
	     	       new Insertion.After('inicio',"|<a href=\"productos.htm\" id=\"idPro\">Productos</a>"); 
			   }
			}
            var pagina=child.href;
			 $('principal').replace('<div id="principal" style="vertical-align:top;"></div>'); 
		    var ajax = new Ajax.Updater('principal', pagina, {method:'get', onComplete: function(req){$('principal').innerHTML = req.responseText;}});
		   }
		   Event.stop(evt); //avoid another call related to 'parent_node' itself
		 }
				
	}//function
	
function cargar(pagina,idSeg)
{
	location.href=pagina;
}
function cargarRuta(pagina,idSeg)
{			 
 $('seguimiento').clearChildren();
 var sPar=idSeg.split("/");
 new Insertion.After('inicio',"|<a href="+pagina+" id=last>"+sPar[sPar.length-1]+"</a>");
 for(var i=sPar.length-2;i>0;i--)
 {
  new Insertion.After('inicio',"|"+sPar[i-1]+"/a>");
  //new Insertion.After('inicio',"/<a href="+pagina+">"+idSeg+"</a>");
  i--;
 }
}

//cabecera
 var mySlideList1=['cobertura-internacional.jpg','futboline.jpg','partyline.jpg','SMSPUSH.jpg','videollamadaspush.jpg'];
var mySlideShow1=new SlideShow(mySlideList1,'slide1',10000,"mySlideShow1");
var urlpath="images/cabecera/";
function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = urlpath+imgSrc;
      var handler=document.getElementById("linkslide");
	  if(imgSrc == "cobertura-internacional.jpg") {
	  	handler.href = "http://www.froggie-mm.com/index.html";
	  	handler.target = "_self";
	  }
	  else if((imgSrc=="futboline.jpg") || (imgSrc=="partyline.jpg")){
	  	handler.href="http://www.froggie-mm.com/partyline3g.html";
		handler.target="_self";
	  }
	  else{
	  	handler.href = "http://www.froggie-mm.com";
	  	handler.target = "_self";
	  }
	}
  }
}

function SlideShow(slideList, image, speed, name)          
{
  this.slideList = slideList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}
SlideShow.prototype.play = SlideShow_play;  
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) 
	 current = 0;
    switchImage(image, slideList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}