// JavaScript Document
$(document).ready(function(){
	$('#strefa-menuG').cien();
	//Cufon.refresh('#flagi a, #menuSL a, #cz-podmenu a, .menuGL a', {hover: true});
	$('.info span.img img').hide();
	
	$('#gora-home td.pierwsza').css({'padding-left': '49px'});
	$('.curInfo .link').html('<img src="/img/ico-wejdz-on.jpg" alt="zobacz szczegóły" />');
	for (i=1;i<=4;i++) {
		var a = $('#p'+i).find("img").attr("src");
		$('#p'+i).cien();
		$('#p'+i).find('span.img').css({'background' : 'url(' + a + ') no-repeat center bottom'});
	}
	
    $('#gielda table:not(.kInstal) tbody tr').hide();
	    $('#gielda table:not(.kInstal) tbody tr:eq(1)').show();
		$('#gielda table:not(.kInstal) tbody tr:eq(2)').show();
		$('#gielda table:not(.kInstal) tbody tr:contains(WIG-BUDOW)').show();

	$('#gielda table:not(.kInstal)').css({
						'border': 'none',
						});
	$('#gielda table:not(.kInstal) td').css({
						'background': '#FFF',
						'font-size': '10px',
						'font-family': 'Tahoma, Arial, Helvetica, sans-serif',
						'padding': '4px 0 3px',
						'border': 'none',
						//'border-top': '1px dotted #999'
						});
	$('#gielda table:not(.kInstal) td:eq(1)').css({
						'border-bottom': '1px dotted #999',
						'padding': '5px 0'
						});

$(".info").delegate("a","click", function(e) {
										 
        if ( !$(this).parent().parent().parent().parent().hasClass("curInfo") ) {         
            e.preventDefault(); 
            $(this).parent().click(); 
        } 
        
    });

$("#gora-home").delegate('.info','click', function(e){
			$el = $(this);
 $('#gora-home td.pierwsza').animate({'padding-left': '3px'});
		if ($el.hasClass('curInfo')){
			$mhref= $(this).find("a.link").attr("href");
			if ($(this).find("a.link").attr("target")=='_blank'){
				window.open($mhref); 
			} else {
				window.location=$mhref;
			}
			return false;	
		} else {
			
		
		$in = $el.parent().parent().find('.info').not($el);
		$in.animate({
                width: '174px',
				'font-size': '0.9em',
				'margin-top': '28px'
            }).removeClass('curInfo');
		$in.find('span.img img').hide();
		$in.find('.link').html('<img src="/img/ico-wejdz-off.jpg" alt="wejdź" />');
		$in.find('h2').animate({
				height: '28px',
				'font-size': '1.2em'
				});	
		Cufon.replace('.info h2');

		$el.animate({
                width: '272px',
				'font-size': '1.1em',
				'margin-top': '0'
            }, function(){
			//		$el.addClass('curInfo');
					$el.addClass('curInfo');
					$el.find('.link').html('<img src="/img/ico-wejdz-on.jpg" alt="zobacz szczegóły" />');
					$el.find('span.img img').css('margin-left','0').show();
					Cufon.replace('.info h2');
			});
			$el.find('span.img img').css('margin-left','0').show();
			$el.find('h2').animate({
				height: '55px',
				'font-size': '1.5em'
				});	
	
		}

});

$("#gora-home").delegate('.info','mouseover', function(e){
    
	if (!$(this).hasClass('curInfo')) {
		$(this).find('span.img img').css('margin-left','-52px').show();
	}
	
	//$in = $el.parent().parent().find('.info').not($el);
	//if (!$in.hasClass('curInfo')) $in.find('span.img img').fadeTo('normal', 0).show().stop();

		
});

$("#gora-home").delegate('.info','mouseout', function(e){
	if (!$(this).hasClass('curInfo')) {
		$(this).find('span.img img').hide();
		}
	//$in = $el.parent().parent().find('.info').not($el);
	//$in.find('span.img img').fadeTo('normal', 0).show();

		
});

/*

$("#gora-home").delegate('.info','mouseover', function(e){
    
	$el = $(this);
		
		$in = $el.parent().parent().find('.info').not($el);
		$in.animate({
                width: '174px',
				'font-size': '0.9em'
            }).removeClass('curInfo');
		$in.find('span.img img').fadeTo('normal', 0).show();
		$in.find('.link').html('<img src="/img/ico-wejdz-off.jpg" alt="wejdź" />');
		Cufon.replace('.info h2');

		$el.animate({
                width: '272px',
				'font-size': '1.1em'
            }, function(){
					$el.addClass('curInfo');
					$el.find('span.img img').fadeTo('normal', 1).show();
					$el.find('.link').html('<img src="/img/ico-wejdz-on.jpg" alt="zobacz szczegóły" />');
					Cufon.replace('.info h2');
			});
		
		
});

$("#gora-home").delegate('.info','click', function(e){
    
	$el = $(this);
		
		if ($el.hasClass('curInfo')){
			$mhref= $el.find("a.link").attr("href");
			if ($el.find("a.link").attr("target")=='_blank'){
				window.open($mhref); 
			} else {
				window.location=$mhref;
			}
			return false;	
		}
		
		$in = $el.parent().find('.info').not($el);
		$in.animate({
                width: '174px',
				'font-size': '0.9em'
            }).removeClass('curInfo');
		$in.find('span.img img').fadeTo('normal', 0).show();
		$in.find('.link').html('<img src="/img/ico-wejdz-off.jpg" alt="wejdź" />');
		

		$el.animate({
                width: '272px',
				'font-size': '1.1em'
				//fontSize: '1.1em;'
            }, function(){
					$el.addClass('curInfo');
					$el.find('span.img img').fadeTo('normal', 1).show();
					$el.find('.link').html('<img src="/img/ico-wejdz-on.jpg" alt="zobacz szczegóły" />');
			});
		
		
});*/

$('.curInfo img').fadeTo('normal', 1).show();


$('#logotypy-klienci').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

});


