function preload(images) {
	$('<div><img src="' + images.join('" /><img src="') + '" /></div>')
		.appendTo(document.body)
		.css({
			position: 'absolute',
			top: 0,
			left: 0,
			visibility: 'hidden'
		})
		.find('img')
		.css({ position: 'absolute' })
	;
}

$(document).ready(function(){

setTimeout(function() {
	if ( $(".scrollme").length>0 ) {
		$(".scrollme").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			circular: false,
			visible: 4,
			speed:500
		});
		var images = [];
		$('.scrollme a').each(function() {
			images.push(this.href);
		});
		preload(images);
		$('.scrollme a').click(function(e) {
			e.preventDefault();
			var param = '';
			if ( $(this).attr('param') ) {
				param = $(this).attr('param');
			}
			textt = '<img '+param+' src="'+$(this).attr('href')+'" alt="" /><p> </p>';
			$('.loaded').html(textt);
			return false;
		});
		if ( $('.scrollme img').length <= 4 ) {
			$('.scrollable .next, .scrollable .prev').hide();
		}
		if ( $('.scrollme img').length <= 1 ) {
			$('.scrollable').hide();
		} 
		$('.scrollable .next, .scrollable .prev').click(function(e) {
			e.preventDefault();
		});
	}
}, 100);
});



var d = document;
var winIE = (navigator.userAgent.indexOf('Opera')==-1 && (d.getElementById && d.documentElement.behaviorUrns)) ? true : false;

function bodySize(){
if(winIE && d.documentElement.clientWidth) {
		sObj = d.getElementsByTagName('body')[0].style;
				sObj = d.getElementById('page').style;
		wid = d.documentElement.clientWidth;
		//sObj.width = (d.documentElement.clientWidth>1280) ? "1280px" : "100%";
		if(wid>990){sObj.width = "990px";} else{sObj.width = "100%";}
		if(wid<990){sObj.width = "990px";} else{sObj.width = "100%";}
	}
}
function init(){
	if(winIE) { bodySize(); }
}
onload = init;

if(winIE) { onresize = bodySize; }



/*$(window).resize(function(){
 	var minWidth = 990;
	var maxWidth = 1300;
	if ( $('#page').width() > maxWidth ) $('#page, #footer').width(maxWidth);
	else if ( $('#page').width() < minWidth ) $('#page, #footer').width(minWidth);
	else{
		$('#page, #footer').width('auto');
	}
});
*/

