function getWinSize() {
	 var viewportwidth;
	 var viewportheight;
	 
	 if (typeof window.innerWidth != 'undefined') {
	      // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 } else if (typeof document.documentElement != 'undefined'
	     && typeof document.documentElement.clientWidth !=
	     'undefined' && document.documentElement.clientWidth != 0) {
	       // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 } else {
	       // older versions of IE
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	
	var size_array = new Array();
	size_array['width'] = viewportwidth;
	size_array['height'] = viewportheight;
	
	return size_array;
}

function getElementSize(element) {
	var size_array = new Array();
	size_array['width'] = element.width();
	size_array['height'] = element.height();
	
	return size_array;
}

function changeWindowSize() {
		var myarr = getElementSize($("#main-content"));	
		imagewidth  = myarr['width'];
		imagescount = Math.floor(imagewidth/212);
		$("#counter").html(imagewidth + ' ' + imagescount);
		
		switch(imagescount) {
			case 2:
						$("ul#layouts-list").find("li").each(function(i) {
							if(i>=2) {		
								$(this).hide();
							}
						})
						$("div#layouts-container").width(424);
						break;				
			case 4:
						$("ul#layouts-list").find("li").each(function(i) {
							if(i>=2) {			
								$(this).show();
							}
						})
						$("div#layouts-container").width(848);			
						break;
			default:
						$("ul#layouts-list").find("li").each(function(i) {
							if(i>=3) {			
								$(this).hide();
							} else {
								$(this).show();
							}
						})

						$("div#layouts-container").width(636);	
						break;		
		
		}
};


$(document).ready(function() {	
	changeWindowSize();
	$(window).bind('resize', changeWindowSize);
});

