function send(obj) {
	document.location.href=obj.value;
}

jQuery("document").ready( function() {

	$.each( ['birth_date','info_able_date'], function( index, fieldName ) {
		$('input[name='+fieldName+']').datepicker({
			showOn: 'both',
			buttonImage: 'webapps/front/html/img/ico_calendar.gif',
			buttonImageOnly: true,
			dateFormat: 'yy-mm-dd',
			dayNamesMin: ['Nd', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
			monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
			monthNamesShort: ['Sty','Lut','Mar','Kwi','Maj','Cze','Lip','Sie','Wrz','Paź','Lis','Gru'],
			changeMonth: true,
			changeYear: true,
			yearRange: '-70:+5',
			nextText: '',
			prevText: '',
			firstDay: 1
		});
	});

    var fontSizesMap = {

            fs09: {
                selectors: [
                    '#header *', '#path #pathContent', '.content h4'
                ],
                newSize: {
                    fontSmall:  '9px',
                    fontNormal: '10px',
                    fontBig:    '12px'
                }
            },
            fs11: {
                selectors: [
                    'body', 'input', 'select', 'textarea', '.relacje h4', '.boxProdukty .box h4', '.tagCloud h4'
                ],
                newSize: {
                    fontSmall:  '11px',
                    fontNormal: '12px',
                    fontBig:    '14px'
                }
            },
            fs12: {
                selectors: [
                    '#topNavigation li', '.table02 .header .title', '.table05 strong', '.table05 .kurs'
                ],
                newSize: {
                    fontSmall:  '12px',
                    fontNormal: '13px',
                    fontBig:    '16px'
                }
            },
            fs13: {
                selectors: [
                    'h3'
                ],
                newSize: {
                    fontSmall:  '13px',
                    fontNormal: '14px',
                    fontBig:    '17px'
                }
            },

            fs15: {
                selectors: [
                    'h2'
                ],
                newSize: {
                    fontSmall:  '15px',
                    fontNormal: '16px',
                    fontBig:    '18px'
                }
            },
            fs18: {
                selectors: [
                    'h1'
                ],
                newSize: {
                    fontSmall:  '18px',
                    fontNormal: '20px',
                    fontBig:    '24px'
                }
            }
    };

    var fontClassMap = {
           /* h115px: {
                fontSmall:  '115px',
                fontNormal: '115px',
                fontBig:    '130px'
            },
            */
    };

    function setFont() {
        var fontSize = readCookie('fontCookie');
        if( !fontSize ) {
            fontSize = 'fontSmall';
        }
        $('#' + fontSize).click();
    }

    function changeFont( element ) {
        if( readCookie('siteTheme') == 'contrast' ) {
            return false;
        }
        $(element).addClass('on').siblings().removeClass('on');
        var newFontName = $(element).attr('id');
        $.each( fontSizesMap, function( fontName, newFont ) {
            $.each( newFont.selectors, function( index, selector ) {
                $(selector).each( function() {
                    $(this).css('font-size', newFont.newSize[ newFontName ] );
                });
            });
        });

        $.each( fontClassMap, function( hClass, hValue ) {
            $('.' + hClass).each( function() {
                $(this).css('height', hValue[ newFontName ] );
            });
        });
        createCookie( 'fontCookie', $(element).attr('id'), 15 );
    }

    $('#changeFontSize').find('span').not('.prefix').each( function() {
        $(this).bind('click', function() { changeFont(this); } );
    } );

    setFont();
});

//cookie

function createCookie( name, value, days ) {
    if( days ) {
        var date = new Date();
        date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) );
        var expires = "; expires=" + date.toGMTString();
    }
    else
        var expires = "";

    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');

    for( var i=0; i < ca.length; i++ ) {
        var c = ca[i];
        while( c.charAt(0) == ' ' ) {
            c = c.substring( 1, c.length );
        }
        if( c.indexOf( nameEQ ) == 0 ) {
            return c.substring(nameEQ.length,c.length);
        }
    }

    return null;

}

function eraseCookie( name ) {
    createCookie( name, "", -1 );
}


