/*
Description: Plugin para jquery que expande una imagen al fondo de pantalla
Author: www.desarrollocreativo.es
Version: 1.0.1
*/

function getId(id){
	if(!document.getElementById)
		id = document.all[id];
	else
		id = document.getElementById(id);
	return id;
}

function getWinSize(){
	var size = new Object();
	size.w = document.documentElement.clientWidth;
	size.h = document.documentElement.clientHeight;
	return size;
}

function cambiarTamanyoImagen(){

	var size = getWinSize();
	ancho_ventana = size.w;
	alto_ventana = size.h;
	var imagen = new Image();
	imagen.src = fotoEnPantallaPath;

	ancho_imagen = imagen.width;
	alto_imagen = imagen.height;

	ratio_ancho = ancho_ventana / ancho_imagen;
	ratio_alto = alto_ventana / alto_imagen;

	if(ratio_alto <= ratio_ancho){
		alto_imagen = alto_imagen * ratio_alto;
		ancho_imagen = ancho_imagen * ratio_alto;
	}else{
		alto_imagen = alto_imagen * ratio_ancho;
		ancho_imagen = ancho_imagen * ratio_ancho;
	}

	getId("imgPpal").width = ancho_imagen;
	getId("imgPpal").height = alto_imagen;
}

function cambiarTamanyoImagenCompleta(){

	var size = getWinSize();
	ancho_ventana = size.w;
	alto_ventana = size.h;
	var imagen = new Image();
	imagen.src = fotoEnPantallaPath;

	ancho_imagen = imagen.width;
	alto_imagen = imagen.height;

	ratio_ancho = ancho_ventana / ancho_imagen;
	ratio_alto = alto_ventana / alto_imagen;

	if(ratio_alto <= ratio_ancho){
		alto_imagen = alto_imagen * ratio_ancho;
		ancho_imagen = ancho_imagen * ratio_ancho;
	}else{
		alto_imagen = alto_imagen * ratio_alto;
		ancho_imagen = ancho_imagen * ratio_alto;
	}

	getId("imgPpal").width = ancho_imagen;
	getId("imgPpal").height = alto_imagen;

}

window.onresize = cambiarTamanyoImagen;
