// Java Script Document

function favicon(){
    var ua      = navigator.userAgent.toLowerCase();
    var isOpera = ua.indexOf("opera") > -1;
    var isIE    = !isOpera && ua.indexOf("msie") > -1;

if (isIE) {
      document.write("<link href=\"S_icon.ico\" "+
                     "type='image/x-icon' rel='shortcut icon'/>");
      document.write("<link href=\"S_icon.ico\" "+
                     "type='image/x-icon' rel='icon'/>");
    } else {
      document.write("<link href=\"S_icon.gif\" "+
                     "type='image/gif' rel='shortcut icon'/>");
      document.write("<link href=\"S_icon.gif\" "+
                     "type='image/gif' rel='icon'/>");
    }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += 'O campo '+nm+' é requerido.\n'; }
  } if (errors) alert(errors);
  document.MM_returnValue = (errors == '');
}

Object.prototype.addEvent = function(evtType, func) {
	   if (this.addEventListener) {
	      this.addEventListener(evtType, func, true);
	   } else if (this.attachEvent) {
	      this.attachEvent('on' + evtType, func);
	   } else {
	      this['on' + evtType] = func;
	   }
	}

	function SlideShow(slideel, faddingSpeed, stopTime, stopOnMouseOver) { 
	        var mouseIsOver = false;
	       
	        if (stopOnMouseOver) {
	                slideel.addEvent('mouseover', function() {
	                        mouseIsOver = true;
	                });

	                slideel.addEvent('mouseout', function() {
	                        mouseIsOver = false;
	                        self.next();
	                });
	        }
	               
	        this.next = function() {
	                if (mouseIsOver)
	                        return;

	                this.current.fadeOut();
	                this.current = this.current.nextSlide;
	                this.current.fadeIn();
	        }
	       
	        function createSlides() {
	                var imgs = slideel.getElementsByTagName('img');
	                var slides = [];
	               
	                for (var i = 0; i < imgs.length; i++) {  
	                        slides[i] = new SlideShowImage(imgs[i], self);
	                }
	               
	                for (var i = 0; i < slides.length; i++) {
	                        if (i == slides.length - 1)
	                                slides[i].nextSlide = slides[0];
	                        else
	                                slides[i].nextSlide = slides[i + 1];
	                }
	               
	                self.current =  slides[0];
	                slides[0].fadeIn();
	               
	                function SlideShowImage(img, slideShow) {
	                        img.style.opacity = '0';
	       
	                        this.fadeIn = function() {
	                                var i = 0;
	                                while (++i <= 40) {
	                                        window.setTimeout(function() {
	                                                img.style.opacity = parseFloat(img.style.opacity) + 0.025;
	                                        }, i * faddingSpeed);
	                                }
	                               
	                                window.setTimeout(function() {
	                                        slideShow.next();
	                                }, 40 * faddingSpeed + stopTime);
	                        }
	       
	                        this.fadeOut = function() {
	                                var i = 0;
	                                while (++i <= 40) {
	                                        window.setTimeout(function() {
	                                                img.style.opacity = parseFloat(img.style.opacity) - 0.025;
	                                        }, i * faddingSpeed);
	                                }
	                        }
	                }
	        }
	       
	        var self = this;
	        createSlides(slideel);
	}

