﻿        var imgs = new Array(), current=0, timer;

        function rotate_banner()
        {
            $('grande').src = fotos[current];

   	        var preloadimage = new Image();
            preloadimage.src = fotos[current+1];   // Preload Next Image
            
	        timer = setTimeout(xfade,4000);
        }

        function xfade()
        {
	        var nIndex = fotos[current+1]?current+1:0;
            $('grande').setOpacity(0);
            $('grande').src = fotos[nIndex];
            var myFx = new Fx.Tween('grande', {property: 'opacity',transition: Fx.Transitions.Sine.easeOut,duration: 2000});
            myFx.start(1);
	        current = nIndex;
   	        nIndex = fotos[current+1]?current+1:0;
   	        var preloadimage = new Image();
            preloadimage.src = fotos[nIndex];   // Preload Next Image
	        timer = setTimeout(xfade,4000);
        }
        function cambiar(imagen){
            clearTimeout(timer);
            current = fotos[imagen-1]?imagen-1:fotos.length-1;
	        var nIndex = fotos[current+1]?current+1:0;
            var myFx = new Fx.Tween('grande', {property: 'opacity'});
            $('grande').setOpacity(0);
            $('grande').src = fotos[nIndex];
            myFx.start(1);
	        current = nIndex;
   	        nIndex = fotos[current+1]?current+1:0;
   	        var preloadimage = new Image();
            preloadimage.src = fotos[nIndex];   // Preload Next Image
	        timer = setTimeout(xfade,4000);
        }
        function f_submenu(elem){
            $$('div.submenu').each(function(submenu) { 
                submenu.style.visibility = 'hidden';
            });
            $$('ul.visual').each(function(submenu) { 
                submenu.style.visibility = 'hidden';
            });
            $(elem).style.visibility='visible';
         }
         function f_visual(elem){
            $$('ul.visual').each(function(submenu) { 
                submenu.style.visibility = 'hidden';
            });
            $(elem).style.visibility='visible';
         }
         function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
                var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
                var slider = new Slider(scrollbar, handle, {   
                    steps: steps,
                    mode: (horizontal?'horizontal':'vertical'),
                    onChange: function(step){
                        // Scrolls the content element in x or y direction.
                        var x = (horizontal?step:0);
                        var y = (horizontal?0:step);
                        content.scrollTo(x,y);
                    }
                }).set(0);
                if( !(ignoreMouse) ){
                    // Scroll the content element when the mousewheel is used within the
                    // content or the scrollbar element.
                    $$(content, scrollbar).addEvent('mousewheel', function(e){ 
                        e = new Event(e).stop();
                        var step = slider.step - e.wheel * 30; 
                        slider.set(step);               
                    });
                }
                // Stops the handle dragging process when the mouse leaves the document body.
                $(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
            }

        function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
        {
           var arVersion = navigator.appVersion.split("MSIE")
           var version = parseFloat(arVersion[1])
           if ((version >= 5.5) && (document.body.filters)) 
           {
              for(var i=0; i<document.images.length; i++)
              {
                 var img = document.images[i]
                 var imgName = img.src.toUpperCase()
                 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
                 {
                    var imgID = (img.id) ? "id='" + img.id + "' " : ""
                    var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                    var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                    var imgStyle = "display:inline-block;" + img.style.cssText 
                    if (img.align == "left") imgStyle = "float:left;" + imgStyle
                    if (img.align == "right") imgStyle = "float:right;" + imgStyle
                    if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                    var strNewHTML = "<span " + imgID + imgClass + imgTitle
                    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
                    img.outerHTML = strNewHTML
                    i = i-1
                 }
              }
           }    
        }

        function getValue(varname)
        {
          // First, we load the URL into a variable
          var url = window.location.href;

          // Next, split the url by the ?
          var qparts = url.split("?");

          // Check that there is a querystring, return "" if not
          if (qparts.length == 0)
          {
            return "";
          }

          // Then find the querystring, everything after the ?
          var query = qparts[1];

          // Split the query string into variables (separates by &s)
          var vars = query.split("&");

          // Initialize the value with "" as default
          var value = "";

          // Iterate through vars, checking each one for varname
          for (i=0;i<vars.length;i++)
          {
            // Split the variable by =, which splits name and value
            var parts = vars[i].split("=");
            
            // Check if the correct variable
            if (parts[0] == varname)
            {
              // Load value into variable
              value = parts[1];

              // End the loop
              break;
            }
          }
          
          // Convert escape code
          value = unescape(value);

          // Convert "+"s to " "s
          value.replace(/\+/g," ");

          // Return the value
          return value;
        }
        
        // * sroller
        function scroller(){
        
            	var el = $('scroll'),
		            inner = $('inner');
	
	// Create the new slider instance
	            new Slider(el, el.getElement('.knob'), {

		        steps: 200,	// There are 200 steps
                mode:'vertical',
                onChange: function(pos){
                    inner.setStyle('top', pos);
                }
            }).set(inner.getStyle('top').toInt());

        }


