var imgSizer = {
	Config : {
		imgCache : []
		,spacer : "./images/spacer.gif"
	}

	,collate : function(aScope) {
		var isOldIE = (document.all && !window.opera && !window.XDomainRequest) ? 1 : 0;
		if (isOldIE && document.getElementsByTagName) {
			var c = imgSizer;
			var imgCache = c.Config.imgCache;

			var images = (aScope && aScope.length) ? aScope : document.getElementsByTagName("img");
			for (var i = 0; i < images.length; i++) {
				images[i].origWidth = images[i].offsetWidth;
				images[i].origHeight = images[i].offsetHeight;

				imgCache.push(images[i]);
				c.ieAlpha(images[i]);
				images[i].style.width = "100%";
			}

			if (imgCache.length) {
				c.resize(function() {
					for (var i = 0; i < imgCache.length; i++) {
						var ratio = (imgCache[i].offsetWidth / imgCache[i].origWidth);
						imgCache[i].style.height = (imgCache[i].origHeight * ratio) + "px";
					}
				});
			}
		}
	}

	,ieAlpha : function(img) {
		var c = imgSizer;
		if (img.oldSrc) {
			img.src = img.oldSrc;
		}
		var src = img.src;
		img.style.width = img.offsetWidth + "px";
		img.style.height = img.offsetHeight + "px";
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
		img.oldSrc = src;
		img.src = c.Config.spacer;
	}

	// Ghettomodified version of Simon Willison's addLoadEvent() -- http://simonwillison.net/2004/May/26/addLoadEvent/
	,resize : function(func) {
		var oldonresize = window.onresize;
		if (typeof window.onresize != 'function') {
			window.onresize = func;
		} else {
			window.onresize = function() {
				if (oldonresize) {
					oldonresize();
				}
				func();
			}
		}
	}
}
addLoadEvent(function() {
        // resize images
	imgSizer.collate();
        //window.scrollTo(0,1);
    var browserHeight = 0;
    var browserWidth = 0;
    if ($.browser.msie) {
        browserHeight = document.documentElement.clientHeight;
        browserWidth = document.documentElement.clientWidth;
    }
    else {
        browserHeight = window.innerHeight;
        browserWidth = window.innerWidth;
    }
    $('#bg').css({'height': browserHeight+'px'});
    $('#main').css({'height': browserHeight-231+'px'});
    $('#bg').css({'width': browserWidth+'px'});
    if (browserHeight > 530){
        $('#iconbar_bottom').css({'top': browserHeight-61+'px'});
    }
		//imgFader
	var imgNo = 1;
	var imgOld = 0;
	var imgCount = $('#slide img').length;
	var SlideInterval = window.setInterval(imgFader, 4000);
	function imgFader () {
		if (imgNo < imgCount){
			imgOld = imgNo;
			imgNo = imgNo + 1;
			$('#image'+imgNo).fadeTo(800,1,function () {
			$('#image'+imgOld).fadeTo(0,0);
		});
		} else  {
			$('#image1').fadeTo(0,1,function () {
			$('#image'+imgNo).fadeTo(800,0);
			});
			imgNo = 1;
		}
	}
		//resizeFunction
    $(window).resize(function(){
        var browserHeight = 0;
        var browserWidth = 0;
        if ($.browser.msie) {
            browserHeight = document.documentElement.clientHeight;
            browserWidth = document.documentElement.clientWidth;
        }
        else {
            browserHeight = window.innerHeight;
            browserWidth = window.innerWidth;
        }
    $('#bg').css({'height': browserHeight+'px'});
    $('#main').css({'height': browserHeight-231+'px'});
    $('#bg').css({'width': browserWidth+'px'});
    if (browserHeight > 530){
        $('#iconbar_bottom').css({'top': browserHeight-61+'px'});
    }
    });
});
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
$(document).ready(function() {

});
$(document).ready(function() {
$("a.grouped_elements").fancybox({
'padding'	:	'0',
'margin'	:	'30',
'transitionIn'	:	'elastic',
'transitionOut'	:	'elastic',
'speedIn'	:	600,
'speedOut'	:	200,
'overlayShow'	:	true
});
});


