
function makearray(n) {
  this.length = n;
  for(var i = 1; i <= n; i++)
   	this[i] = 0;
  	return this;
}

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

function hex(i) {
  if (i < 0)
     return "00";
  else if (i > 255)
     return "ff";
  else
     return "" + hexa[Math.floor(i/16)] + hexa[i%16];}

function setbgColor(r, g, b, element) {
  var hr = hex(r); var hg = hex(g); var hb = hex(b);
  element.style.backgroundColor = "#"+hr+hg+hb;
}

function fade(sr, sg, sb, er, eg, eb, step, direction, element){
  for(var i = 0; i <= step; i++) {
setTimeout("setbgColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+ ")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
    }
		
}
function fadeout(element,textcolor) {
  fade(85,85,85, 255,255,255, 40, 1, element);
	var myelement = document.getElementById(element);
	//myelement.style.color = textcolor;     
}
function fadein(element, textcolor) {
  fade(255,255,255, 85,85,85, 20, 1, element);
	var myelement = document.getElementById(element);
	//myelement.style.color = textcolor;    
}

function fadeout2(element, textcolor) {
  fade(85,85,85, 245,245,245, 40, 1, element);
	var myelement = document.getElementById(element);
	//myelement.style.color = textcolor;  
}
function fadein2(element, textcolor) {
  fade(245,245,245, 85,85,85, 20, 1, element);
	var myelement = document.getElementById(element);
	//myelement.style.color = textcolor;  
}
function fadeout3(element, textcolor) {
	var myelement = document.getElementById(element);
  fade(85,85,85, 236,237,241, 40, 1, element);
	
	myelement.style.color = textcolor;  
}
function fadein3(element, textcolor) {
	var myelement = document.getElementById(element);
  fade(236,237,241, 85,85,85, 20, 1, element);
	myelement.style.color = textcolor;  
}
function fadeout4(element, textcolor) {
	var myelement = document.getElementById(element);
  fade(85,85,85, 255,255,255, 40, 1, element);
	
	myelement.style.color = textcolor;  
}
function fadein4(element, textcolor) {
	var myelement = document.getElementById(element);
  fade(255,255,255, 85,85,85, 20, 1, element);
	myelement.style.color = textcolor;  
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; 
		}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
////// FADE IMAGE
function high(which2){
  theobject=which2
  highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
  clearInterval(highlighting)
  if (which2.style.MozOpacity)
	which2.style.MozOpacity=0.80
  else if (which2.filters)
  	which2.filters.alpha.opacity=80
}
function highlightit(cur2){
  if (cur2.style.MozOpacity<1)
	cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
  else if (cur2.filters&&cur2.filters.alpha.opacity<100)
	cur2.filters.alpha.opacity+=10
  else if (window.highlighting)
	clearInterval(highlighting)
}

// POPUP MIDDEN PAGINA
function sf_popup(url) {
    if (document.getElementById || document.layers || document.all) {
        if (screen.height <= 480) {
            var window_width = screen.width;
            var window_height = screen.height;
        } else {
            var window_width = screen.width - 60;
            var window_height = screen.height - 200;
        }
        var window_left = (screen.width - window_width ) / 2;
        var window_top = (screen.height - window_height) / 3;
        window.open(url, "sfpopup", "scrollbars=yes,resizable=yes,location=1,width=" + window_width + ",height=" + window_height + ",top=" + window_top + ",left=" + window_left + "");
    }
	
}

function email(name, domain, text) {
   var address = name + "\u0040" + domain;
   var url = "mailto:" + address;
   if( ! text )   {
      text = address;
   }
   document.write("<a href=\"" + url + "\">" + text + "</a>");
}

function confirmDelete(msg) {
	return confirm(msg);
} 

