
var last = '1';
function changePromo(val){
    var selektor = '#' + last;
    $(selektor).attr("class", "");
    $(selektor).attr("onMouseOver", 'changePromo('+ last +')');
    selektor = '#pro' + last;
    $(selektor).hide();
    selektor = '#' + val;
    last = val;
    $(selektor).attr("class", "active");
    $(selektor).attr("onMouseOver", '');
    selektor = '#pro' + val;
    $(selektor).show();
}



function changeTable(val){
    $('#news_content').load("http://ik.org.pl/choiceTable/getChoiceTable/"+val.toString()+"/");
    
    if( val.toString() ==  'publikacja')
    {
        $('#homepagination').load("http://ik.org.pl/choiceTable/getPag/"+val.toString()+"/"+publikacja+"/");
    }
    else if(  val.toString() ==  'wydarzenie')
    {
        $('#homepagination').load("http://ik.org.pl/choiceTable/getPag/"+val.toString()+"/"+wydarzenie+"/");
    }else if(  val.toString() ==   'projekt')
     {
        $('#homepagination').load("http://ik.org.pl/choiceTable/getPag/"+val.toString()+"/"+projekt+"/");
     }else{
         alert('nie ma takiego');
     }
    
}

var wydarzenie = '0';
var lastPageWyd = '0';
function changePageWyd(val){
        $('#wyd').children().removeClass('active');
   $('#wyd').children().eq(val).addClass('active');
    var selektor = '#wyd' + lastPageWyd;
    $(selektor).hide();
    selektor = '#wyd' + val;
    $(selektor).show();
    lastPageWyd = val;
  
}

var lastPageEks = '0';
function changePageEks(val){
        $('#eks').children().removeClass('active');
   $('#eks').children().eq(val).addClass('active');
    var selektor = '#eks' + lastPageEks;
    $(selektor).hide();
    selektor = '#eks' + val;
    $(selektor).show();
    lastPageEks = val;
}

var projekt = '0';
var lastPageProj = '0';
function changePageProj(val){
        $('#proj').children().removeClass('active');
   $('#proj').children().eq(val).addClass('active');
    var selektor = '#proj' + lastPageProj;
    $(selektor).hide();
    selektor = '#proj' + val;
    $(selektor).show();
    lastPageProj = val;
}

var publikacja = '0';
var lastPagePubl = '0';
function changePagePubl(val){
        $('#publ').children().removeClass('active');
   $('#publ').children().eq(val).addClass('active');
    var selektor = '#publ' + lastPagePubl;
    $(selektor).hide();
    selektor = '#publ' + val;
    $(selektor).show();
    lastPagePubl = val;
}

var lastPart = '0';
function changePart(val){
        $('#part').children().removeClass('active');
   $('#part').children().eq(val).addClass('active');
    var selektor = '.part' + lastPart;
    $(selektor).hide();
    selektor = '.part' + val;
    $(selektor).show();
    lastPart = val;
}

var lastScr = 0;
function scroll(val, cat){
    if( cat ==  'publikacja')
    {
        publikacja = val / 300;
    }
    else if(  cat ==  'wydarzenie')
    {
        wydarzenie = val / 300 ;
    }else if( cat ==   'projekt')
     {
        projekt = val / 300;
     }
    var selektor = '#link' + lastScr;
    lastScr = val/300;
    $(".over").removeClass('over');
    selektor = '#link' + lastScr;
    $(selektor).addClass('over');
    $('#news_content').animate({scrollTop: val}, 1);
}

function changeMenu(val){
    scroll(0, val.toString());
    changeTable(val);
    $('#news').load("http://ik.org.pl/choiceTable/getMenu/"+val.toString()+"/");
    
    lastScr = 0;
}

function start(){
    jQuery("a[href^='http:']").not("[href*='ik.org.pl']").attr('target','_blank');
    changePromo(1);
    changeTable('wydarzenie');
    changeMenu('wydarzenie');
    $('#boxy').load("/obszary/getObszary/");
    $('#homepagination').load("http://ik.org.pl/choiceTable/getPag/wydarzenie");
    $('#jsmenu > li').bind('mouseover', jsmenu_open);
    $('#jsmenu > li').bind('mouseout',  jsmenu_timer);
    

}
function startKarta(){
    jQuery("a[href^='http:']").not("[href*='ik.org.pl']").attr('target','_blank');
    $('#boxy').load("http://ik.org.pl/obszary/getObszary/");
    $('#jsmenu > li').bind('mouseover', jsmenu_open);
    $('#jsmenu > li').bind('mouseout',  jsmenu_timer);
    $('ul.details > li:last').addClass('last');
}

function boxOver(val){
    var id = "box_bg" + val;
    document.getElementById(id).className = "box_empty";
    
}

function boxOut(val){
    var id = "box_bg" + val;
    document.getElementById(id).className = "box_bg";
}

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsmenu_open()
{jsmenu_canceltimer();
   jsmenu_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsmenu_close()
{if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsmenu_timer()
{closetimer = window.setTimeout(jsmenu_close, timeout);}

function jsmenu_canceltimer()
{if(closetimer)
   {window.clearTimeout(closetimer);
      closetimer = null;}}



document.onclick = jsmenu_close;








