$(function()
{
    /*OBJEDNAVKA */
    
     $(".m7").click(function () { 
        $("#index .content").html($("#formular").html()).css({opacity: 0}).animate({opacity: 1},function(){
        $("#index .content").delegate('#tlacitko', 'click', function(){
           if(!$("#osoba")[0].value || !$("#fon")[0].value || !$("#email")[0].value){
               alert("Polia s hviezdičkou musia byť vyplnené.");
               return false;
           }
           else{
               return true;
           }
              
        });
        });
        $(".m7").attr({'class': "m7a"});
        $(this).css({'background':'url(./images/menu_active_07.png)'});
        $("#ponuka a").removeAttr("id");
      
        clearAll();
        mCustomScrollbars();
        return false;
      });
    
    $("#tlacitko").click(function(){
       alert("sak OK");
    });
    
    
    
    
    /*INDEX PAGE*/
    $('.menu a').each(function(){
        $(this).mouseover(function(e){
          $(this).css({"background-image" : "url(./images/menu_active_0"+e.currentTarget.className[1]+".png)"});  
        });
        
         $(this).mouseleave(function(e){
          if($(this).context.className[2]!="a")
          $(this).css({"background-image" : "url(./images/menu_0"+e.currentTarget.className[1]+".png)"});  
        });
    });
    
$('.menuIndex a').each(function() {
        $(this).click(function(){
           obj = $(".m7a");
           obj2 = $(".m7");
           obj.removeAttr('class');
           obj.attr({'class':'m7'});
           obj2.removeAttr('class');
           obj2.attr({'class':'m7'});
        });
        
        var pole2=new Array();
        pole2[0]="catering2";
        pole2[1]="event";
        pole2[2]="priestory";
        pole2[3]="referencie";
       /* pole2[6]="objednavka";*/
        pole2[4]="galeria";
        pole2[5]="kontakt";
        
        var elop2=new Array();
        elop2["catering2"]=1;
        elop2["event"]=2;
        elop2["priestory"]=3;
        elop2["referencie"]=4;
      /*  elop2["objednavka"]=7;*/
        elop2["galeria"]=5;
        elop2["kontakt"]=6;
        
     
        $(this).mouseover(function(e) {
          if($(this).context.className == "m7") return;
             $("."+pole2[e.currentTarget.className[1]-1]).fadeIn();
           $(this).css({"background-image" : "url(./images/menu_active_0"+e.currentTarget.className[1]+".png)"});

        });

        $(this).mouseleave(function(e) {
            
          if($(this).context.className == "m7") return;
          
        var is=$("#ilustr").find("img#active").length;

              for(i=1;i<7;i++){
                  
              if(is!=0){
              
              if(elop2[$("#ilustr").find("img#active")[0].className] != i)
               {
               $(".m"+i).css({"background-image" : "url(./images/menu_0"+i+".png)"})
              }
              }
              else{
                 $(".m"+i).css({"background-image" : "url(./images/menu_0"+i+".png)"})  
              }
           }          
           if( $("."+pole2[e.currentTarget.className[1]-1])[0].id != "active"){
               
             $("."+pole2[e.currentTarget.className[1]-1]).fadeOut(); 
             $(this).css({"background-image" : "url(./images/menu_0"+e.currentTarget.className[1]+".png)"});
          }
          else{
              return false;
          }
        });

    });
    

        
        $('#ilustr area').each(function() {
            
            var elop2=new Array();
                elop2["catering2"]=1;
                elop2["event"]=2;
                elop2["priestory"]=3;
                elop2["referencie"]=4;
                elop2["galeria"]=5;
                elop2["kontakt"]=6;

                // Assigning an action to the mouseover event
                $(this).mouseover(function(e) {
                        var name=e.target.attributes.getNamedItem("name").value;
                        $(".m"+elop2[name]).css({"background-image" : "url(./images/menu_active_0"+elop2[name]+".png)"});
                        $("."+name).fadeIn();
                });

                // Assigning an action to the mouseout event
                $(this).mouseleave(function(e) { 
                    
                    var name=e.target.attributes.getNamedItem("name").value;
                     
                     if( $("."+name)[0].id != "active"){
                         $(".m"+elop2[name]).css({"background-image" : "url(./images/menu_0"+elop2[name]+".png)"});
                          $("."+name).fadeOut();
                     }
                     else{
                         return false;
                     }
                });
                
                
               /* $(this).click(function(e){
                 
                 $('#eveilustr img').each(function() {
                      $(this).not("#event").removeAttr("id");
                      $(this).not("#event").hide();
                  });
                  console.log();
                    for(i=1;i<6;i++){
                      if(elop2[$(this).context.attributes.getNamedItem("name").value] != i)
                       {
                       $(".eSub"+i).css({"background-image" : "url(./images/submenu/event/sub_0"+i+".png)"})
                      }
                   }          
      
      
                  
                 var id=e.target.attributes.getNamedItem("name").value;

                 $("#eventContent #text").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
                 $("."+id).show();
                 $('.'+id).attr({id: "active"})
                  return false;
                });*/
        
        
        });
    
    
      /*CATERING PAGE*/
    $('.submenu a').each(function() {
        var pole=new Array();
        pole[0]="recepcie";
        pole[1]="ples";
        pole[2]="coctail";
        pole[3]="home";
        pole[4]="office";
        pole[5]="gril";
        pole[6]="bar";
        
        var elop=new Array();
        elop["recepcie"]=1;
        elop["ples"]=2;
        elop["coctail"]=3;
        elop["home"]=4;
        elop["office"]=5;
        elop["gril"]=6;
        elop["bar"]=7;
        
      //  $(this).css({"background-image" : "url(./images/submenu/submenu_0"+$(this).currentTarget.className[3]+".png)"})
     
        $(this).mouseover(function(e) {
             $("."+pole[e.currentTarget.className[3]-1]).fadeIn();
             $(this).css({"background-image" : "url(./images/submenu/submenu_hover_0"+e.currentTarget.className[3]+".png)"});

        });

        // Assigning an action to the mouseout event
        $(this).mouseleave(function(e) {
        var is=$("#indilustr").find("img#active").length;

              for(i=1;i<8;i++){
                  
              if(is!=0){
              
              if(elop[$("#indilustr").find("img#active")[0].className] != i)
               {
               $(".sub"+i).css({"background-image" : "url(./images/submenu/submenu_0"+i+".png)"})
              }
              }
              else{
                 $(".sub"+i).css({"background-image" : "url(./images/submenu/submenu_0"+i+".png)"})  
              }
           }          
      
            if( $("."+pole[e.currentTarget.className[3]-1])[0].id != "active"){
               
             $("."+pole[e.currentTarget.className[3]-1]).fadeOut(); 
             $(this).css({"background-image" : "url(./images/submenu/submenu_0"+e.currentTarget.className[3]+".png)"});
          }
          else{
              return false;
          }
        });
        
        $(this).click(function(e){
          $('#indilustr img').each(function() {
              $(this).not("#catering").removeAttr("id");
              $(this).not("#catering").hide();
          });
          
         var id=pole[e.currentTarget.className[3]-1];
         
         $("#body .content").html($("#cateringTexts #"+id).html()).css({opacity: 0}).animate({opacity: 1});
         $("#body .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});});$("."+id).show();
         $('.'+id).attr({id: "active"})
         $("#ponuka a").removeAttr("id");
         $(".l1").removeAttr("id");
	 mCustomScrollbars();
        
          return false;
        });
        
    });

        var elop=new Array();
        elop["recepcie"]=1;
        elop["ples"]=2;
        elop["coctail"]=3;
        elop["home"]=4;
        elop["office"]=5;
        elop["gril"]=6;
        elop["bar"]=7;
        
        $('#indilustr area').each(function() {

                // Assigning an action to the mouseover event
                $(this).mouseover(function(e) {
                        var name=e.target.attributes.getNamedItem("name").value;
                        $(".sub"+elop[name]).css({"background-image" : "url(./images/submenu/submenu_hover_0"+elop[name]+".png)"});
                        $("."+name).fadeIn();
                });

                // Assigning an action to the mouseout event
                $(this).mouseleave(function(e) { 
                    
                    var name=e.target.attributes.getNamedItem("name").value;
                     
                     if( $("."+name)[0].id != "active"){
                         $(".sub"+elop[name]).css({"background-image" : "url(./images/submenu/submenu_0"+elop[name]+".png)"});
                          $("."+name).fadeOut();
                     }
                     else{
                         return false;
                     }
                });
                
                
                $(this).click(function(e){
                 
                 $('#indilustr img').each(function() {
                      $(this).not("#catering").removeAttr("id");
                      $(this).not("#catering").hide();
                  });
                  console.log();
                    for(i=1;i<8;i++){
                      if(elop[$(this).context.attributes.getNamedItem("name").value] != i)
                       {
                       $(".sub"+i).css({"background-image" : "url(./images/submenu/submenu_0"+i+".png)"})
                      }
                   }          
      
      
                  
                 var id=e.target.attributes.getNamedItem("name").value;

                 $("#body .content").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
                 $("#body .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});}); $("."+id).show();
                 $('.'+id).attr({id: "active"})
                 $("#ponuka a").removeAttr("id");
                 $(".l1").removeAttr("id");
                 mCustomScrollbars();
                  return false;
                });
        
        
        });
        
   
        
$(".l1").click(function () {
        $("#index .content").html($("#cateringTexts #reklamne").html()).css({opacity: 0}).animate({opacity: 1});
        $(".l1").attr({id: "active"});
        $("#ponuka a").removeAttr("id");
        clearAll();
                 mCustomScrollbars();
        return false;
      });
     
    


 
  function clearAll(){
       $('#indilustr img').each(function() {
       $(this).not("#catering").hide();
       $(this).not("#catering").removeAttr("id");
       });
       for(i=1;i<8;i++){
           $(".sub"+i).css({"background-image" : "url(./images/submenu/submenu_0"+i+".png)"});
       }
       
  }
  
     $('#ponuka a').each(function(){
         $(this).click(function(){
                
              $("#ponuka a").removeAttr("id");
              $("a.l1").removeAttr("id");
             
              $("#body .content").html($("#cateringTexts #"+$(this).context.className).html()).css({opacity: 0}).animate({opacity: 1});
              $(this).attr({id: "active"});
                 mCustomScrollbars();
              clearAll();
              return false;
         });
         
     });
  
  
    $(".hl1").click(function(){
       clearAll();
       $("#ponuka a").removeAttr("id");
       $("a.l1").removeAttr("id");
       $("#index .content").html($("#cateringTexts #"+$(this).context.className).html()).css({opacity: 0}).animate({opacity: 1});
           
       return false;
    });


/*EVENTS PAGE*/


 $('.EveSubmenu a').each(function() {
        var pole2=new Array();
        pole2[0]="vip";
        pole2[1]="sport";
        pole2[2]="kultura";
        pole2[3]="team";
        pole2[4]="konf";
        
        var elop2=new Array();
        elop2["vip"]=1;
        elop2["sport"]=2;
        elop2["kultura"]=3;
        elop2["team"]=4;
        elop2["konf"]=5;
        
     
        $(this).mouseover(function(e) {
            console.log(e.currentTarget.className[4]);
             $("."+pole2[e.currentTarget.className[4]-1]).fadeIn();
             $(this).css({"background-image" : "url(./images/submenu/event/sub_hover_0"+e.currentTarget.className[4]+".png)"});

        });

        // Assigning an action to the mouseout event
        $(this).mouseleave(function(e) {
        var is=$("#eveilustr").find("img#active").length;

              for(i=1;i<6;i++){
                  
              if(is!=0){
              
              if(elop2[$("#eveilustr").find("img#active")[0].className] != i)
               {
               $(".eSub"+i).css({"background-image" : "url(./images/submenu/event/sub_0"+i+".png)"})
              }
              }
              else{
                 $(".eSub"+i).css({"background-image" : "url(./images/submenu/event/sub_0"+i+".png)"})  
              }
           }          
      
            if( $("."+pole2[e.currentTarget.className[4]-1])[0].id != "active"){
               
             $("."+pole2[e.currentTarget.className[4]-1]).fadeOut(); 
             $(this).css({"background-image" : "url(./images/submenu/event/sub_0"+e.currentTarget.className[4]+".png)"});
          }
          else{
              return false;
          }
        });
        
        $(this).click(function(e){
          $('#eveilustr img').each(function() {
              $(this).not("#event").removeAttr("id");
              $(this).not("#event").hide();
          });
          
         var id=pole2[e.currentTarget.className[4]-1];
                  
         $("#eventContent .content").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
         $("#eventContent .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});});$("."+id).show();
         $('.'+id).attr({id: "active"});
	 mCustomScrollbars();
        
          return false;
        });
        
    });
    

var elop2=new Array();
        elop2["vip"]=1;
        elop2["sport"]=2;
        elop2["kultura"]=3;
        elop2["team"]=4;
        elop2["konf"]=5;
        
        $('#eveilustr area').each(function() {

                // Assigning an action to the mouseover event
                $(this).mouseover(function(e) {
                        var name=e.target.attributes.getNamedItem("name").value;
                        $(".eSub"+elop2[name]).css({"background-image" : "url(./images/submenu/event/sub_hover_0"+elop2[name]+".png)"});
                        $("."+name).fadeIn();
                });

                // Assigning an action to the mouseout event
                $(this).mouseleave(function(e) { 
                    
                    var name=e.target.attributes.getNamedItem("name").value;
                     
                     if( $("."+name)[0].id != "active"){
                         $(".eSub"+elop2[name]).css({"background-image" : "url(./images/submenu/event/sub_0"+elop2[name]+".png)"});
                          $("."+name).fadeOut();
                     }
                     else{
                         return false;
                     }
                });
                
                
                $(this).click(function(e){
                 
                 $('#eveilustr img').each(function() {
                      $(this).not("#event").removeAttr("id");
                      $(this).not("#event").hide();
                  });
                  console.log();
                    for(i=1;i<6;i++){
                      if(elop2[$(this).context.attributes.getNamedItem("name").value] != i)
                       {
                       $(".eSub"+i).css({"background-image" : "url(./images/submenu/event/sub_0"+i+".png)"})
                      }
                   }          
      
      
                  
                 var id=e.target.attributes.getNamedItem("name").value;

                 $("#eventContent .content").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
                 $("#eventContent .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});});
                $("."+id).show();
                 $('.'+id).attr({id: "active"});
                  mCustomScrollbars();
                  return false;
                });
        
        
        });
        
/*PRIESTORY SKRIPTS :) */


 $('.priestorySubmenu a').each(function() {
        var pole2=new Array();
        pole2[0]="rafinery";
        pole2[1]="factory";
        pole2[2]="dalsie";
        
        var elop2=new Array();
        elop2["rafinery"]=1;
        elop2["factory"]=2;
        elop2["dalsie"]=3;
     
        $(this).mouseover(function(e) {
            console.log(e.currentTarget.className[4]);
             $("."+pole2[e.currentTarget.className[4]-1]).fadeIn();
             $(this).css({"background-image" : "url(./images/submenu/priestory/sub_hover_0"+e.currentTarget.className[4]+".png)"});

        });

        // Assigning an action to the mouseout event
        $(this).mouseleave(function(e) {
        var is=$("#priestoryilustr").find("img#active").length;

              for(i=1;i<4;i++){
                  
              if(is!=0){
              
              if(elop2[$("#priestoryilustr").find("img#active")[0].className] != i)
               {
               $(".pSub"+i).css({"background-image" : "url(./images/submenu/priestory/sub_0"+i+".png)"})
              }
              }
              else{
                 $(".pSub"+i).css({"background-image" : "url(./images/submenu/priestory/sub_0"+i+".png)"})  
              }
           }          
      
            if( $("."+pole2[e.currentTarget.className[4]-1])[0].id != "active"){
               
             $("."+pole2[e.currentTarget.className[4]-1]).fadeOut(); 
             $(this).css({"background-image" : "url(./images/submenu/priestory/sub_0"+e.currentTarget.className[4]+".png)"});
          }
          else{
              return false;
          }
        });
        
        $(this).click(function(e){
          $('#priestoryilustr img').each(function() {
              $(this).not("#priestors").removeAttr("id");
              $(this).not("#priestors").hide();
          });
          
         var id=pole2[e.currentTarget.className[4]-1];
                  
         $("#priestory .content").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
         $("#priestory .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});});
         $("."+id).show();
         $('.'+id).attr({id: "active"});
	 mCustomScrollbars();
        
          return false;
        });
        
    });
    

var elop2=new Array();
        elop2["rafinery"]=1;
        elop2["factory"]=2;
        elop2["dalsie"]=3;
        
        $('#priestoryilustr area').each(function() {

                // Assigning an action to the mouseover event
                $(this).mouseover(function(e) {
                        var name=e.target.attributes.getNamedItem("name").value;
                        $(".pSub"+elop2[name]).css({"background-image" : "url(./images/submenu/priestory/sub_hover_0"+elop2[name]+".png)"});
                        $("."+name).fadeIn();
                });

                // Assigning an action to the mouseout event
                $(this).mouseleave(function(e) { 
                    
                    var name=e.target.attributes.getNamedItem("name").value;
                     
                     if( $("."+name)[0].id != "active"){
                         $(".pSub"+elop2[name]).css({"background-image" : "url(./images/submenu/priestory/sub_0"+elop2[name]+".png)"});
                          $("."+name).fadeOut();
                     }
                     else{
                         return false;
                     }
                });
                
                
                $(this).click(function(e){
                 
                 $('#priestoryilustr img').each(function() {
                      $(this).not("#priestors").removeAttr("id");
                      $(this).not("#priestors").hide();
                  });
                  console.log();
                    for(i=1;i<4;i++){
                      if(elop2[$(this).context.attributes.getNamedItem("name").value] != i)
                       {
                       $(".pSub"+i).css({"background-image" : "url(./images/submenu/priestory/sub_0"+i+".png)"})
                      }
                   }          
      
      
                  
                 var id=e.target.attributes.getNamedItem("name").value;

                 $("#priestory .content").html($("#"+id).html()).css({opacity: 0}).animate({opacity: 1});
                 $("#priestory .content").delegate('a', 'mousedown', function(){$("a#single").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic'});});
                 $("."+id).show();
                 $('.'+id).attr({id: "active"});
                 mCustomScrollbars();
                  return false;
                });
        
        
        });
        
       


});        
 
    function form(){
        $(".m7").click(function () {
        $("#index .content").html($("#cateringTexts #reklamne").html()).css({opacity: 0}).animate({opacity: 1});
        $(".m7").attr({'class': "m7a"});
        $(this).css({'background':'url(./images/menu_active_07.png)'});
        $("#ponuka a").removeAttr("id");
        clearAll();
        mCustomScrollbars();
        return false;
      });}
  
function hover(id){
        document.getElementById("img"+id).style.width="288px";
        document.getElementById("img"+id).style.backgroundPosition="-144px 0px";
        document.getElementById("img"+(id+1)).style.display="none";
      }

function out(id){

        document.getElementById("img"+id).style.width="144px";
        document.getElementById("img"+id).style.backgroundPosition="0px 0px";
        document.getElementById("img"+(id+1)).style.display="block";
      }
function hover2(id){
        document.getElementById("img"+id).style.width="288px";
        document.getElementById("img"+id).style.backgroundPosition="-144px 0px";
        document.getElementById("img"+(id-1)).style.display="none";
      }

function out2(id){

        document.getElementById("img"+id).style.width="144px";
        document.getElementById("img"+id).style.backgroundPosition="0px 0px";
        document.getElementById("img"+(id-1)).style.display="block";
      }
      
/*EVENTY*/
function Ehover(id){
        document.getElementById("Eimg"+id).style.width="288px";
        document.getElementById("Eimg"+id).style.backgroundPosition="-144px 0px";
        document.getElementById("Eimg"+(id+1)).style.display="none";
      }

function Eout(id){

        document.getElementById("Eimg"+id).style.width="144px";
        document.getElementById("Eimg"+id).style.backgroundPosition="0px 0px";
        document.getElementById("Eimg"+(id+1)).style.display="block";
      }
function Ehover2(id){
        document.getElementById("Eimg"+id).style.width="288px";
        document.getElementById("Eimg"+id).style.backgroundPosition="-144px 0px";
        document.getElementById("Eimg"+(id-1)).style.display="none";
      }

function Eout2(id){

        document.getElementById("Eimg"+id).style.width="144px";
        document.getElementById("Eimg"+id).style.backgroundPosition="0px 0px";
        document.getElementById("Eimg"+(id-1)).style.display="block";
      }




function Animate2id(id,ease){ //the id to animate, the easing type
	var animSpeed=800; //set animation speed
	var $container=$("#main"); //define the container to move
	if(ease){ //check if ease variable is set
		var easeType=ease;
	} else {
    	var easeType="easeOutQuart"; //set default easing type
	}
	//do the animation
    $container.stop().animate({"left": -($(id).position().left)}, animSpeed, easeType);
}
function Test(){
  $("#main").css({"left": -($("#c3").position().left)});

}

$("#map1").mouseover(function (){
document.getElementById("img2").style.display="none";
document.getElementById("img1").src="./images/galeria/2010/2010_active_01.png";
});

$("#map1").mouseout(function(){
document.getElementById("img2").style.display="block";
document.getElementById("img1").src="./images/galeria/2010/2010_01.png";
});

$("#map2").mouseover(function (){
document.getElementById("img1").style.display="none";
document.getElementById("img2").src="./images/galeria/2010/2010_active_02.png";
});

$("#map2").mouseout(function(){
document.getElementById("img1").style.display="block";
document.getElementById("img2").src="./images/galeria/2010/2010_02.png";
});



$("#map3").mouseover(function (){
document.getElementById("img4").style.display="none";
document.getElementById("img3").src="./images/galeria/2010/2010_active_03.png";
});

$("#map3").mouseout(function(){
document.getElementById("img4").style.display="block";
document.getElementById("img3").src="./images/galeria/2010/2010_03.png";
});

$("#map4").mouseover(function (){
document.getElementById("img3").style.display="none";
document.getElementById("img4").src="./images/galeria/2010/2010_active_04.png";
});

$("#map4").mouseout(function(){
document.getElementById("img3").style.display="block";
document.getElementById("img4").src="./images/galeria/2010/2010_04.png";
});



$("#map5").mouseover(function (){
document.getElementById("img6").style.display="none";
document.getElementById("img5").src="./images/galeria/2010/2010_active_05.png";
});

$("#map5").mouseout(function(){
document.getElementById("img6").style.display="block";
document.getElementById("img5").src="./images/galeria/2010/2010_05.png";
});

$("#map6").mouseover(function (){
document.getElementById("img5").style.display="none";
document.getElementById("img6").src="./images/galeria/2010/2010_active_06.png";
});

$("#map6").mouseout(function(){
document.getElementById("img5").style.display="block";
document.getElementById("img6").src="./images/galeria/2010/2010_06.png";
});





$("#eve1").mouseover(function (){
document.getElementById("Eimg1").src="./images/galeria/2007_active_04.png";
});

$("#eve1").mouseout(function(){
document.getElementById("Eimg1").src="./images/galeria/2007_04.png";
});


/*AJAX*/

function nextPictures(k){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("test").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","pictures.php?p="+k,true);
xmlhttp.send();
return false;
}


function getGallery(r){

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("kontajner").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","gallery.php?r="+r,true);
xmlhttp.send();
return false;
}

function nextGallery(r,k){

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("kontajner").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","gallery.php?r="+r+"&p="+k,true);
xmlhttp.send();
return false;
}



function getEvents(r){

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("kontajner2").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","events.php?r="+r,true);
xmlhttp.send();
return false;
}

function nextEvents(r,k){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("kontajner2").innerHTML=xmlhttp.responseText;
    }
}
Gallery(r);
xmlhttp.open("GET","events.php?r="+r+"&p="+k,true);
xmlhttp.send();
return false;
}


function Gallery(r){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("anchor").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","celagaleria.php?r="+r,true);
xmlhttp.send();
return false;
}

function show(){
document.getElementById("anchor").style.display="block";
}

function getS(){

$.getScript("./gallery.js");
}

