﻿// JScript File

function showBg(state)
  {
   var dinamicBackground = document.getElementById('bg_img');
   if(state)
   {
	dinamicBackground.style.display = "block";
       }
   else
   {
  dinamicBackground.style.display = "none";
  }	}


function setOpacity(level) {
 var element = document.getElementById('bg_img');
  element.style.Opacity = level;
  element.style.MozOpacity = level;
  element.style.KhtmlOpacity = level;
  element.style.filter = "Alpha(Opacity=" + (level * 75) + ");";

 
}
var duration = 1000;  /* 1000 millisecond fade = 1 sec */
var steps = 30;       /* number of opacity intervals   */


function fadeIn(){
	//Filtra por navegador (document.all solo lo soporta IE)
	if(document.all) { 
		var finalValue = 1;	
	} else {
		//FF
		var finalValue = 0.75; 
	}


  for (i = 0; i <= finalValue; i += (finalValue / steps)) {
    setTimeout("setOpacity(" + i + ")", i * duration);
	showBg(true)
  }
 
 
}

function fadeOut() {
	//Filtra por navegador (document.all solo lo soporta IE)
	if(document.all) { 
		var finalValue = 1;	
	} else {
		//FF
		var finalValue = 0.75; 
	}
  for (i = 0; i <= finalValue; i += (finalValue / steps)) {
    setTimeout("setOpacity(" + (finalValue - i) + ")", i * duration);
	
	showBg(false)
	
  }
 
}
 /* start the effect */
   
  function resize_iframe()

{
	var width=window.innerWidth;//Firefox
	width=document.body.clientWidth;//IE
	
document.getElementById("bg_img").style.width=parseInt(width-document.getElementById("bg_img").offsetLeft)+"px";


	var height=window.innerHeight;//Firefox
	if (document.body.clientHeight > 730)
	{
		height=document.body.clientHeight;//IE
	}else{ height= 730}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	
	document.getElementById("bg_img").style.height=parseInt(height-document.getElementById("bg_img").offsetTop)+"px";
}
window.onresize=resize_iframe; 
