var c = 1;
var t;
var menuid = 1

function timedCount() {
	setTimeout("setImage(menuid, c)",0);
	c = c + 1;
	
	if ( c == 4 ) {
		c = 1;
	}
	
	t = setTimeout("timedCount()",2000);
}


function setImage(menuid, image) {
	//alert(menuid);
	
	var imgsrc = 'images/header_' + menuid + '_' + image + '.jpg';
	//$('#main_img').html('<img src="' + imgsrc + '" \/>');
	$('#main_img').fadeTo('fast', 0.60).css({'background': 'url(' + imgsrc + ')'}).fadeTo('fast', 1)	
}

$(document).ready(function(){
	$(".lightbox").lightbox({ fitToScreen : true });
	$(document).pngFix({blankgif: 'images/blank.gif'}); 
	

	$('#menu ul li').hover(function() {
		$(this).find('ul').show();
		$(this).find('a:first').css('color','#777'); 
	},function() { 
		$(this).find('ul').hide();
		$(this).find('a:first').css('color','#00a8ec'); 
	});

	$('a.media').media();
	
	$('#last_gallery ul li img').mouseover( function() {
		var title = $(this).attr('alt');
		$('#image_name').html(title + '&nbsp;');
	});

	$("#to_header").scrollToTop();
	
	var left_height = $('#left').height();
	var main_height = $('#maincoll').height();
	
	if ( left_height > main_height ) {
		$('#maincoll').height(left_height);
	} else {
		$('#left').height(main_height);
	}
	
	$('#topmenu li a').mouseover( function() {
		menuid = $(this).attr('href').split('/')[2];
		timedCount();
		
	}).mouseout( function(){
		clearTimeout(t);
	});
	
	
});



var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


