var ratePages = new Array();
ratePages[0] = 'kursy';
ratePages[1] = 'stopy';

$(document).ready(

    function() {
        $('#rate-menu').children('.position').each(
            function(i) {
                $(this).click (
                    function () {
                        $('#rate-menu').children('.position').each(
                            function(i) {
                                $(this).removeClass('select');
                                $(this).children('a').blur();
                            }
                        )
                        $('#rate-pages').children('div').each( function(i) { $(this).hide(); } )
                        $('#rate-load').show();

                        hash   = $(this).children('a').attr('href');
                        tmpId  = $(this).attr('id');
                        tmpId  = tmpId.split('-');
                        thisId = tmpId[1];
                        location.hash = hash;
                        hash = hash.replace("#", "");

                        if (ratePages[thisId]!= null) {
                            $('#subpage-' + thisId + '').addClass('select');
                            $('#rate-load').hide();
                            $('#rate-' + thisId + '').show();
                            return false;
                        } else {
                            $('#subpage-0').addClass('select');
                            $('#rate-load').hide();
                            $('#rate-0').show();
                            return false;
                        }
                        return false;
                    }
                )
            }
        )


		$('a.curr-date').each(
            function(i) {
                $(this).click (
					function () {

						tmpId  = $(this).attr('id');
                        tmpId  = tmpId.split('-');
                        thisId = tmpId[1];
						
						display = $('#curr-' + thisId + '').css('display');

						$('div.curr').each(
                            function(i) {
                                $(this).hide();
                            }
                        )

						if (display == 'none') {
							$('#curr-' + thisId + '').show();
						} else {
							$('#curr-' + thisId + '').hide();
						}

						return false;

					}
				)
			}
		)

		
		$('a.date-m').each(
            function(i) {
                $(this).click (
					function () {

						tmpId  = $(this).attr('id');
                        tmpId  = tmpId.split('-');
                        thisId = tmpId[2];
						
						display = $('#curr-m-' + thisId + '').css('display');

						$('div.curr-m').each(
                            function(i) {
                                $(this).hide();
                            }
                        )
						$('div.curr').each(
                            function(i) {
                                $(this).hide();
                            }
                        )

						if (display == 'none') {
							$('#curr-m-' + thisId + '').show();
						} else {
							$('#curr-m-' + thisId + '').hide();
						}

						return false;

					}
				)
			}
		)
		

       if  (location.hash != '') {
            hash   = location.hash;
            thisId = 0;
            $('#rate-menu').children('.position').each(
                function(i) {
                    mHash   = $(this).children('a').attr('href');
                    mTmpId  = $(this).attr('id');
                    mTmpId  = mTmpId.split('-');
                    mThisId = mTmpId[1];
                    if (mHash == hash) { thisId = mThisId; }
                }
            )
            hash = hash.replace("#", "");

            if (hash == ratePages[thisId]) {
                $('#subpage-' + thisId + '').addClass('select');
                $('#rate-load').hide();
                $('#rate-' + thisId + '').show();
            } else {
                urlToLoad = location.href;
                urlToLoad = urlToLoad.replace(".html", "");
                urlToLoad = urlToLoad.replace("#", "/");

            }
        } else {
            //location.hash = '#' + ratePages[0] + '';
            $('#subpage-0').addClass('select');
            $('#rate-load').hide();
            $('#rate-0').show();
        }
        /* */
    }





);


function send_mail () {

}



/*
$(document).ready(

    function() {
        $('#rate-menu').children('.position').each(
            //
            function(i) {
                $(this).click (
                    function () {

                        hash   = $(this).children('a').attr('href');
                        tmpId  = $(this).attr('id');
                        tmpId  = tmpId.split('-');
                        thisId = tmpId[1];
                        location.hash = hash;
                        hash = hash.replace("#", "");

                        urlToLoad = location.href;
                        urlToLoad = urlToLoad.replace(".html", "");
                        urlToLoad = urlToLoad.replace("#", "/");


                        $('#rate-menu').children('.position').each(
                            function(i) {
                            $(this).removeClass('select');
                            $(this).children('a').blur();
                            }
                        )
                        $('#newscat-' + thisId + '').addClass('select');
                        urlToLoad = location.href;
                        urlToLoad = urlToLoad.replace(".html", "");
                        urlToLoad = urlToLoad.replace("#", "/");
                        return false;
                    }
                )
            }
        )

        if  (location.hash != '') {
            hash   = location.hash;
            thisId = 0;
            tmpHash = hash.split(',')
            $('#news-category').children('.position').each(
                function(i) {
                    mHash   = $(this).children('a').attr('href');
                    mTmpId  = $(this).attr('id');
                    mTmpId  = mTmpId.split('-');
                    mThisId = mTmpId[1];
                    if (mHash == tmpHash[0]) { thisId = mThisId; }
                }
            )
            hash = hash.replace("#", "");

            urlToLoad = location.href;
            urlToLoad = urlToLoad.replace(".html", "");
            urlToLoad = urlToLoad.replace("#", "/");
            $.get(
                urlToLoad,
                function(data){
                    if (data.search('error') != -1) {
                        $('#news-load').hide();
                        $('#news-list').show();
                    } else {
                        $('#news-list').html(data);
                        $('#news-load').hide();
                        $('#news-list').show();
                        addClickEvent();
                    }
                }
            );
            $('#newscat-' + thisId + '').addClass('select');
            return false;
        } else {
            $('#news-load').hide();
            $('#news-list').show();
            $('#newscat-0').addClass('select');
            addClickEvent();
        }

    }

);

addClickEvent = function () {
    $('#page-list').children('a').each(
        function(i) {
            $(this).click (
                function () {
                    $('#news-list').hide();
                    $('#news-load').show();

                    hash = $(this).attr('href');
                    location.hash = hash;
                    hash = hash.replace("#", "");

                    urlToLoad = location.href;
                    urlToLoad = urlToLoad.replace(".html", "");
                    urlToLoad = urlToLoad.replace("#", "/");

                    $.get(
                        urlToLoad,
                        function(data){
                            if (data.search('error') != -1) {
                                $('#news-load').hide();
                                $('#news-list').show();
                            } else {
                                $('#news-list').html(data);
                                $('#news-load').hide();
                                $('#news-list').show();
                                addClickEvent();
                            }
                        }
                    );
                    return false;
                }
            )
        }
    );
}
*/
