$(document).ready(function() {
	
	$('#sidebar').css('width', $('#navigation').width() - 30)

	 if (window.PIE) {
        $('#navigation, #navigation ul ul, #sidebar').each(function() {
            PIE.attach(this);
        });
    }

	$("body").ezBgResize({
		img     : "image/ny.jpg",
		opacity : 1, 
		center  : true 
	});

	$('input[type="text"], textarea')
		.focus(function() { if(this.title==this.value) { this.value = ''; } })
		.blur(function(){ if(this.value=='') {this.value = this.title; } });

	setBar();

	if( $('.solutions').length ){
		preload([
			'image/ico-services-h.png',
			'image/ico-management-h.png',
			'image/ico-economic-h.png',
			'image/ico-management02.png'
		])
	}

	$('.solutions li a').hover(function(){
		$('img', this).data('src', $('img',this).attr('src'));
		var img = $('img', this).attr('src');
		var imgName = img.split('/');
		var realImgName = imgName[1].split('.')
		$('img', this).attr('src', imgName[0] + '/' +realImgName[0]+'-h.' + realImgName[1]);
	},function(){
		$('img', this).attr('src', $('img', this).data('src'));
	})

});

$(window).scroll(function() {
	setBar();
}).trigger('scroll');

$(window).resize(function() {
	setBar();
}).trigger('resize');

$(window).load(function(){
	var liOffset = $('#navigation .news').position().left;
	var liWidth = $('#navigation .news').width();
	var newLeft = ($('#navigation').width() - liOffset) - $('#navigation .news ul').outerWidth(true) - 22;
	$('#navigation .news ul').css('left', newLeft);
})

function setBar(){
	
	var wH = $(window).height(),
		barH = $('.fixed-bar').height(),
		wS = $(window).scrollTop();
			
	$('.fixed-bar').css({
		top: (wH - barH - 14) + wS
	});

}

function preload(array){
	for( i=0; i< array.length; i++){
		$('<img />')[0].src = array[i];
	}
}

