﻿function url(anchoPantalla,altoPantalla){
	url_aux = anchoPantalla+"x"+altoPantalla;
	if(url_aux!="1024x768"  && url_aux!="1280x800"  && url_aux!="1280x1024"  && url_aux!="1440x900" && url_aux!="1680x1050" && url_aux!="1950x1200" && url_aux!="2048x1536"){
		if(anchoPantalla>2048) url_aux = "2048x1536";
		if(anchoPantalla<1024) url_aux = "1024x768";
		if(anchoPantalla>1024 && anchoPantalla<1280)
			url_aux = "1024x768";
		else if(anchoPantalla>1280 && anchoPantalla<1024)
				if(altoPantalla>800 && altoPantalla<1024)
					url_aux = "1280x800";
				else
					url_aux ="1280x1024";
		else if(anchoPantalla>1440 && anchoPantalla<1680)
			url_aux ="1680x1050";
		else if(anchoPantalla>1680 && anchoPantalla<1950)
			url_aux ="1950x1200";
	}
	return url_aux;
}



function aleatorio(inferior,superior){ 
   	numPosibilidades = superior - inferior 
   	aleat = Math.random() * numPosibilidades 
   	aleat = Math.round(aleat) 
   	return parseInt(inferior) + aleat 
} 

function no_repeat_ids(array_ids,id){
	for(var i=1;i<=array_ids.length;i++){
		if(array_ids[i] == id)
			return true;
	}
	
	return false;
}

function effects(){
	$('#content').fadeTo('slow',0.5).fadeTo('slow',1);
}


var ancho = $(window).width();
var alto = $(window).height();

altoPantalla 	= 	screen.height;
anchoPantalla 	= 	screen.width;



var ruta = url(anchoPantalla,altoPantalla);

// Analytics

///////////////////////////////////////////


//document.getElementById("web").style.height = parseInt(alto)+"px";
document.getElementById("banner").style.height = parseInt(alto)+"px";
var altura_aux = altoPantalla - 310;
document.getElementById("content").style.height = altura_aux+"px";


var html = "";
var imgs_ids = new Array() ;
var aux_id = "";
var img_dimensiones = new Array();
var imagen = new Image();
var num_img = 4;



for(var i=1;i<=num_img;i++){
	
	aux_id = aleatorio(1,num_img);
	while(no_repeat_ids(imgs_ids,aux_id)){
		aux_id = aleatorio(1,num_img);
	}
	imgs_ids[i] = aux_id;
	imagen = new Image();
	imagen.src = "../images-web/"+ruta+"/xornaga-"+imgs_ids[i]+".jpg";

	html = html.concat("<img src='"+imagen.src+"' alt='' title='' style='left:0px; top:0px;'/>");
}

document.getElementById('img').innerHTML = html;


//document.getElementsByTagName("html")[0].style.overflow = "hidden";




