var menuHeight = 0;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jQuery.fn.centerElement = function(leftFix,topFix,parent){
	var sizeSample;
	if(parent){
		sizeSample = parent;
	}else{
		sizeSample = $(window);
	}
	// - - -
	var lf = 0;
	var tf = 0;
	if(leftFix){
		lf = leftFix;
	}
	if(topFix){
		tf = topFix;
	}	
	// - - -
	var thisH = this.height();
	var thisW = this.width();
	// - - -
	var windW = sizeSample.width();
	var windH = sizeSample.height();
	// - - -
	this.css('top',((windH/2 - thisH/2) + tf) +'px');
	this.css('left',((windW/2 - thisW/2) + lf) +'px');
	return this;
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function resizeCallback(){
	var windH = $(window).height();
	var windW = $(window).width();
	$('#content').css('width',windW);
	$('#content').css('height',windH);
	// - - -
	if(menuHeight > windH){
		$('#bc-main-menu').css('height',windH);
	}else{
		$('#bc-main-menu').css('height',menuHeight);
	}
	// - - -
	$('#bc-main-menu').css('top',(windH/2) - ($('#bc-main-menu').height()/2));
	$('#bc-main-menu2').css('top',(windH/2) - ($('#bc-main-menu2').height()/2));
	$('#bc-main-background').css('height',windH);
	$('#bc-main-background').css('width',windW);	
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setMenuEvents(){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) && Number(RegExp.$1) == 6){
		
		$('.bc-main-menu-button').each(function(){
			var name = $(this).children('img').attr('alt');
			$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'.png\')');
			$(this).mouseout(function(){
				$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'.png\')');
			});
			$(this).mouseover(function(){
				$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'-over.png\')');
			});
		});		
	}else{
		$('.main-menu-img').show();
		$('.bc-main-menu-button').mouseover(function(){
			var name = $(this).children('img').attr('alt');
			$(this).children('img').attr('src','/images/'+name+'-over.png');
		});
		$('.bc-main-menu-button').mouseout(function(){
			var name = $(this).children('img').attr('alt');
			$(this).children('img').attr('src','/images/'+name+'.png');
		});
		// - - -		
	}	

	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) && Number(RegExp.$1) == 6){
		
		$('.bc-main-menu-button2').each(function(){
			var name = $(this).children('img').attr('alt');
			$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'.png\')');
			$(this).mouseout(function(){
				$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'.png\')');
			});
			$(this).mouseover(function(){
				$(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/'+name+'-over.png\')');
			});
		});		
	}else{
		$('.main-menu-img').show();
		$('.bc-main-menu-button2').mouseover(function(){
			var name = $(this).children('img').attr('alt');
			$(this).children('img').attr('src','/images/'+name+'-over.png');
		});
		$('.bc-main-menu-button2').mouseout(function(){
			var name = $(this).children('img').attr('alt');
			$(this).children('img').attr('src','/images/'+name+'.png');
		});
		// - - -		
	}

}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
$(document).ready(function(){
	// - - -
	menuHeight = $('#bc-main-menu').height();
	// - - -
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) && Number(RegExp.$1) == 6){
		$('#bc-title-bt').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/label.png\')');		
		// - - -
		var background = $('<div style="overfloat: hidden; position:absolute; top:0px; left:0px; z-index: -1;"></div>');
		$('#bc-foot').append(background);		
		// - - -
		var winW = $(window).width();
		var footW = background.width();
		var times = winW/298;
		for(f = 0; f < times; f++){
			// - - -
			var pos = f * 298;
			var t = $('<div class="foot-bg-peace" style="position: absolute; top:0px; left: '+pos+'px; width: 298px; height: 54px;"><!-- --></div>');
			background.append(t);
			$('.foot-bg-peace').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/foot.png\')');
		}
	}else{
		$('#bc-foot').css('background','url("/images/foot.png") repeat-x');
		$('#title-img').show();
	}
	// - - -
	resizeCallback();
	setMenuEvents();
	// - - -
	$(window).resize(function(){
		resizeCallback();		
	});
	// - - -	
});
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//$(window).load(function(){
	
//});

