$(document).ready(function() {

$(window).resize(do_resize);
do_resize();


$("#MainImage").attr("nr", 0).css("cursor", "pointer").click(show_image);
$(".icon").click(function(){ChooseImg(this.id.replace("img", ""))});
$("#gallery .thumb").click(function(){ChooseImg(this.id.replace("img2", ""))});

});

function do_resize()
{

w = ($(window).width()>=1200) ? 1200 : 970;
$("#main").width(w);

if(w==1200) {
	$(".collage_big, .pos3").show(); 
	$(".collage_sm").hide();
} else {
	
	$(".collage_big, .pos3").hide(); 
	$(".collage_sm").show();
}

}



function menu_on()
{

	if(MenuImgs[this.id]) this.src = MenuImgs[this.id]["on"].src;
}

function menu_off()
{
	if(MenuImgs[this.id]) this.src = MenuImgs[this.id]["off"].src;
}


 function ChooseImg(nr) 
 {
 	
 	$("#MainImage").attr("src" , Images[nr].src ).attr("height" , Images[nr].height ).attr("width" , Images[nr].width).attr("nr", nr);
 	$(".active, #img"+nr).toggleClass("active");
	

 }


function show_image()
{
	nr = $(this).attr("nr");
	nr++;
	if(!Images[nr]) nr = 0;
	ChooseImg(nr); 
	
	//var win = window.open(Images[nr].src,"img"+nr, "height="+(Images[nr].height+20)+",width="+(Images[nr].width+20)+",status=no,toolbar=no,menubar=no,location=no");
	
}
