var fontSize = 11; // zmienna globalna - moze przyjac jedna z 3-ech wartosci: small, normal, big
var fontSizeCookieName = 'orlenpl_font_size'; //nazwa cookie dla rozmiaru czcionki

function changeFontSize(newSize) {

    var elements = new Array();
    elements.push(
		'.content  h3 , .newsList .oneNews h3.title, .newsList .oneNews h3.title a',
		'.content .news h4.newsDateAndCategory, .content .news2 h4, table.tableLight td, table.tableLight th, table.tableFull td, table.tableFull th, table.ms-rteTable-OrlenLight td, table.ms-rteTable-OrlenLight th, table.ms-rteTable-OrlenFull td, table.ms-rteTable-OrlenFull th, #TableJobs table td, #TableJobs table th, #tradeContactQueryControl .regulationChb label, .newsList .oneNews .date, .investorRelationsContact .chbRegulation .label, .investorRelationsContact .addInfo, .pressCenterVideoConferences .list .date',
		'.content .col720, .content .col720 p, .content .news_container a, .content td, .content li, .content .news_text p, .content .box220 .content, .content .news p,.content .news2 p, #leftNavigation a, .newsPage .newsContent, .newsPage .newsContent p, .mainContentThin, .mainContentThin p, .mainContentWide, .mainContentWide p, .mainPage, .sideBox .content h4, .sideBox .contentGray h4, .sideBox .content, .carrerPage, .SA-F0, .SA-F1, .SA-F2, .SA-F3, .SA-F4, .SA-F5, #JDescContent h4, table.produkty a, .ms-WPBody, .ms-WPBody td, .newsList .oneNews .teaser, .pressCenterVideoConferences .mainVideoDesc, .pressCenterVideoConferences .list .desc, .latestVideoConferences .list .titleAndDate, .latestVideoConferences .list .titleAndDate a',
		'table.tableLight tr.hdRow *, table.tableFull tr.hdRow *, table.ms-rteTable-OrlenLight tr.ms-rteTableHeaderRow-OrlenLight *, table.ms-rteTable-OrlenFull tr.ms-rteTableHeaderRow-OrlenFull *, #TableJobs table tr.Lst-Header *, #JDescContent h5, #tradeContactQueryControl .oneLine, .latestVideoConferences .list .desc',
		'#JDescContent h3, .pressCenterVideoConferences .mainVideoTitleAndDate, .pressCenterVideoConferences .list .title, .pressCenterVideoConferences .list .title a'
	);

    var normalSizes = new Array();
    normalSizes.push(
	  '15px',
	  '10px',
	  '13px',
	  '11px',
	  '14px'
	);
    var smallSizes = new Array();
    smallSizes.push(
	  '13px',
	  '9px',
	  '11px',
	  '10px',
	  '12px'
	);
    var bigSizes = new Array();
    bigSizes.push(
	  '16px',
	  '11px',
	  '14px',
	  '12px',
	  '15px'
	);


    var boxes = new Array();
    boxes.push(
		'.box230 .content',
		'#forDriversMainPageInfoGate #infoGate .box230 .content',
		'.mainPage .box230 .content'
	  );


    var smallHeights = new Array();
    smallHeights.push(
	  '90px',
	  '243px',
	  '90px'
	);
    var normalHeights = new Array();
    normalHeights.push(
	  '130px',
	  '243px',
	  '110px'
	);
    var bigHeights = new Array();
    bigHeights.push(
	  '150px',
	  '270px',
	  '120px'
	);

    var widthElements = new Array();
    widthElements.push(
		'.macroDataYearTableLabelsContainer, .macroDataQuarterTableLabelsContainer, table.macroDataYearTableLabels',
		'.macroDataYearTableContainer, .macroDataQuarterTableValuesContainer',
		'table.macroDataYearTableValues'
	  );

    var smallWidth = new Array();
    smallWidth.push(
	  '390px',
	  '320px',
	  '1000px'
	);
    var normalWidth = new Array();
    normalWidth.push(
	  '430px',
	  '280px',
	  '960px'
	);
    var bigWidth = new Array();
    bigWidth.push(
	  '465px',
	  '245px',
	  '925px'
	);


    var sizeArray, heightsArray, widthArray;

    if (fontSize != newSize) {
        fontSize = newSize;

       // createCookie(fontSizeCookieName, fontSize, 7);

        switch (fontSize) {
            case 'small':
                sizeArray = smallSizes;
                heightsArray = smallHeights;
                widthArray = smallWidth;
                jQuery("#fontSmall").css('font-weight', 'bold');
                jQuery("#fontNormal").css('font-weight', 'normal');
                jQuery("#fontBig").css('font-weight', 'normal');
                break;
            case 'normal':
                sizeArray = normalSizes;
                heightsArray = normalHeights;
                widthArray = normalWidth;
                jQuery("#fontSmall").css('font-weight', 'normal');
                jQuery("#fontNormal").css('font-weight', 'bold');
                jQuery("#fontBig").css('font-weight', 'normal');
                break;
            case 'big':
                sizeArray = bigSizes;
                heightsArray = bigHeights;
                widthArray = bigWidth;
                jQuery("#fontSmall").css('font-weight', 'normal');
                jQuery("#fontNormal").css('font-weight', 'normal');
                jQuery("#fontBig").css('font-weight', 'bold');
                break;
        }

        for (i = 0; i < elements.length; i++) {
            jQuery(elements[i]).css('font-size', sizeArray[i]);
        }
        for (i = 0; i < boxes.length; i++) {
            jQuery(boxes[i]).css('height', heightsArray[i]);
        }
        for (i = 0; i < widthElements.length; i++) {
            jQuery(widthElements[i]).css('width', widthArray[i]);
        }
    }
}


function checkFontSize() {
    var fontSizeCookie;
    fontSizeCookie = "small";
    if (fontSizeCookie != null) {
        if (fontSizeCookie != 'small') {
            changeFontSize(fontSizeCookie);
        }
        else {
            jQuery("#fontSmall").css('font-weight', 'bold');
        }
        fontSize = fontSizeCookie;
    }
    else {
        fontSize = 'small';
        jQuery("#fontSmall").css('font-weight', 'bold');
        createCookie(fontSizeCookieName, fontSize, 7);
    }
}


