/*
window.onload = function() {
    
}
*/

function scrheight(){
	if((screen.width)<=1024){
		//document.getElementById("container").style.position='static';
		jQuery("#center").css("margin-top","-74px");
	}
}

jQuery(document).ready(function($) {
    $("a[rel=gallery]").fancybox({
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		      return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
    });
scrheight();	
	
});

function dialogDisclaimer() {
    if (!jQuery.cookie('disclaimer')) {
			embeds = document.getElementsByTagName('embed');
			for(i = 0; i < embeds.length; i++) {
				embeds[i].style.visibility = 'hidden';
			}
				
			objects = document.getElementsByTagName('object');
			for(i = 0; i < objects.length; i++) {
				objects[i].style.visibility = 'hidden';
			}

			iframes = document.getElementsByTagName('iframe');
			for(i = 0; i < iframes.length; i++) {
				iframes[i].style.visibility = 'hidden';
			}
            
			jQuery("#dialogDisclaimer").dialog({
				bgiframe: true,
				resizable: false,
				draggable: false,
                autoOpen: true,
				height:600,
				width:600,
				closeText: 'hide',
				modal: true,
                closeOnEscape: false,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					 'NIE AKCEPTUJĘ': function() {
						window.location.href = '/';
					},
					'AKCEPTUJĘ': function() {
						jQuery.cookie('disclaimer', '1');
						embeds = document.getElementsByTagName('embed');
						for(i = 0; i < embeds.length; i++) {
							embeds[i].style.visibility = 'visible';
						}
						
						objects = document.getElementsByTagName('object');
						for(i = 0; i < objects.length; i++) {
							objects[i].style.visibility = 'visible';
						}

						iframes = document.getElementsByTagName('iframe');
						for(i = 0; i < iframes.length; i++) {
							iframes[i].style.visibility = 'visible';
						}
						jQuery(this).dialog('close');
					}
				}
			});
            
            jQuery('.ui-dialog-titlebar-close').hide();
		}
}

function indicatorChanger(column_id, indicator_id) {
    var sendPOST = 'id='+indicator_id;
    
    jQuery.post(base_uri('ajax/indicator'), sendPOST, function(result){
        if (result.status == 'error') {
            alert(response.message);
        }
        else if (result.status == 'ok') {
            jQuery('#clickmenu_year_'+column_id).empty();
            jQuery('#clickmenu_year_'+column_id).append(result.year);
            
            jQuery('#indicator_'+column_id+'_1').empty();
            jQuery('#indicator_'+column_id+'_1').append(result.profit_sales);
            
            jQuery('#indicator_'+column_id+'_2').empty();
            jQuery('#indicator_'+column_id+'_2').append(result.current_ratio);
            
            jQuery('#indicator_'+column_id+'_3').empty();
            jQuery('#indicator_'+column_id+'_3').append(result.debt_ratio);
            
            jQuery('#indicator_'+column_id+'_4').empty();
            jQuery('#indicator_'+column_id+'_4').append(result.assets_return);
        }
    }, "json");
    
    return false;
}

function financeChanger(column_id, finance_id) {
    var sendPOST = 'id='+finance_id;
    
    jQuery.post(base_uri('ajax/finance'), sendPOST, function(result){
        if (result.status == 'error') {
            alert(response.message);
        }
        else if (result.status == 'ok') {
            jQuery('#clickmenu_year_'+column_id).empty();
            jQuery('#clickmenu_year_'+column_id).append(result.year);
            
            jQuery('#finance_'+column_id+'_1').empty();
            jQuery('#finance_'+column_id+'_1').append(result.income);
            
            jQuery('#finance_'+column_id+'_2').empty();
            jQuery('#finance_'+column_id+'_2').append(result.operating_profit);
            
            jQuery('#finance_'+column_id+'_3').empty();
            jQuery('#finance_'+column_id+'_3').append(result.profit_brutto);
            
            jQuery('#finance_'+column_id+'_4').empty();
            jQuery('#finance_'+column_id+'_4').append(result.profit_netto);
            
            jQuery('#finance_'+column_id+'_5').empty();
            jQuery('#finance_'+column_id+'_5').append(result.total_assets);
            
            jQuery('#finance_'+column_id+'_6').empty();
            jQuery('#finance_'+column_id+'_6').append(result.liab_provisions);
            
            jQuery('#finance_'+column_id+'_7').empty();
            jQuery('#finance_'+column_id+'_7').append(result.longterm_liab);
            
            jQuery('#finance_'+column_id+'_8').empty();
            jQuery('#finance_'+column_id+'_8').append(result.current_liab);
            
            jQuery('#finance_'+column_id+'_9').empty();
            jQuery('#finance_'+column_id+'_9').append(result.own_capital);
            
            jQuery('#finance_'+column_id+'_10').empty();
            jQuery('#finance_'+column_id+'_10').append(result.share_capital);
            
            jQuery('#finance_'+column_id+'_11').empty();
            jQuery('#finance_'+column_id+'_11').append(result.shares);
            
            jQuery('#finance_'+column_id+'_12').empty();
            jQuery('#finance_'+column_id+'_12').append(result.payed);
        }
    }, "json");
    
    return false;
}

