function Reload()
{
    window.location.href = window.location.href
}
window.onresize = Reload;

var window_width = getClientWidth();
var window_height = getClientHeight();

function ajustar() {
	if (parseInt(getClientWidth())>800) {window_width=getClientWidth()} else {window_width=800};
	if (parseInt(getClientHeight())>600) {window_height=getClientHeight()} else {window_height=600};
	fixBackground();
	if (id_cont!=''){desplaza_transparencia(id_cont,id_fnd)};
	if (id_cont2!=''){desplaza_transparencia(id_cont2,id_fnd2)};
	desplaza_pie();
	desplaza_facebook();
}
function fixBackground() {
	if(img_width == 0 || img_height == 0) {	return;	}
	var new_width = img_width*window_height/img_height;
	var new_height = img_height*window_width/img_width;
	if(new_width > window_width) {
		document.getElementById('background_img').style.width=new_width+"px";
		document.getElementById('background_img').style.height=window_height+"px";
		document.getElementById('background_img').style.left=(0-(new_width-window_width)/2)+"px";
		document.getElementById('background_img').style.top=0+"px";
	}
	else {
		document.getElementById('background_img').style.width=window_width+"px";
		document.getElementById('background_img').style.height=new_height+"px";
		document.getElementById('background_img').style.left=0+"px";
		document.getElementById('background_img').style.top=(0-(new_height-window_height)/2)+"px";
	}
	document.getElementById('background_img').style.display='block';
};

function getClientWidth()
{
  var x = window.innerWidth ||
          document.documentElement.clientWidth ||
          document.body.clientWidth;

  return x ? x : 0;
};

function getClientHeight()
{
  var x = window.innerHeight ||
          document.documentElement.clientHeight ||
          document.body.clientHeight;


  return x ? x : 0;
};


function desplaza_transparencia(a,b) {
	var tam_height
	var donde = document.getElementById(a);
	var cual = document.getElementById(b);
	if (ajustar_width)	{
	  donde.style.width = parseInt(window_width-300)+'px';
	  cual.style.width = parseInt(window_width-300)+'px';
	} else {
	  cual.style.width = donde.offsetWidth+'px';
	}
	if (ajustar_height)	{
	  if (parseInt(donde.clientHeight)<parseInt(window_height-150)) {
		  donde.style.height = donde.clientHeight+'px'; 
		  tam_height = donde.offsetTop + donde.clientHeight
	  } else {
		  donde.style.height = parseInt(window_height-150)+'px';
		  tam_height = donde.offsetTop +  parseInt(window_height-150)
	  }
	}
	cual.style.height = donde.style.height;
	cual.style.top = donde.offsetTop+'px';
	cual.style.left = donde.offsetLeft+'px';

	if (window_height<tam_height)
	{
		window_height = tam_height;
		fixBackground();
	}

}

function desplaza_pie() {
	var cual = document.getElementById(id_pie);
	cual.style.top = (window_height-20)+'px';
	cual.style.left = '10px';
	cual.style.width = (window_width-20)+'px';
}

function desplaza_facebook() {
	var cual = document.getElementById(id_facebook);
	cual.style.top = (window_height-50)+'px';
	cual.style.left = (window_width-70)+'px';
}
