



 /*

window.onload = function(){

    var i;

   

    for(i=1;i<=6;i++){

        $("."+Boxes[i]).hover(

          function () {                                                

            $("#ButtonsTitle").html(Boxes_Words[$(this).attr('class')]);      

          }, 

          function () {

            $("#ButtonsTitle").html(''); 

          }

        );

    }

    

}

   */

var page;

var Boxes = new Array();

    

    Boxes[1] = 'menu';

    Boxes[2] = 'music';

    Boxes[3] = 'time';

    Boxes[4] = 'star';

    Boxes[5] = 'mapButton';

    Boxes[6] = 'inter';
    
    Boxes[7] = 'info';



    //// CIRCLE PROPERTIES FOR GMAP

    var fillColor = "#0055ff";

    var liColor = "#ff0000";

    var liWidth = 1;

    var liOpa = 1;

    var fillOpa = 0.3;

    var givenRad = 0.7*1;

    var givenQuality = 60;

    //// CIRCLE PROPERTIES FOR GMAP

function transform_search(what){
    if(what == 1){
        $("#search_small").fadeOut(800, function () {
            $("#search_full").fadeIn(800);
        });    
    }else{
        $("#search_full").fadeOut(800, function () {
            $("#search_small").fadeIn(800);
        }); 
    }
    
}    
    
function Clear_Search() {
	$('#Place_Form')[0].reset();
	alert(SeacgClearMsg);
}

function activate_deliveries(id){

    if(id == 1){

       $("#diliveries_box").slideDown(500);

       $("#del_available").val("2");

    }

    else{

       $("#diliveries_box").slideUp(500);

       $("#del_available").val("1");

    }

}        

            

function Box_activate(id){

    var i;

    for(i=1;i<=6;i++){

        $('#Search_'+Boxes[i]).css({display: 'none'});    

    }

    $('#Search_'+Boxes[id]).show("slow");

    $('#SearchBox').show("slow");

}



function Box_Deactivate(id) {   

    $('#Search_'+Boxes[id]).fadeOut();

    $('#SearchBox').fadeOut();

}



function Find_Place(curpage, what){ 
   $.scrollTo( 100, 300 ); 

   page = curpage;  
   
   for(i=1;i<=6;i++){
	   if($('#Search_'+Boxes[i]).css('display') == 'block') {
		   Box_Deactivate(i);
	   }
   }

   $.post("ajax_places.php?page="+page, 

            $('#Place_Form'+what).serialize()+'&what='+what,

            function(response){
	   				
                    var res = eval('('+ response + ')');

                    $("#map_browse").hide(900);

                    $("#browseLeft").hide(800, function () {

                       

                      $("#browseLeft").html(res.msg);

                      $("#map_browse").css({display : "none"}); 

                      $("#Browse_info_all").html(res.all);

                      $("#Browse_info_perpage").html(res.perpage);

                      $("#Browse_info_pages").html(res.pages);

                      $("#browseLeft").show(800, function() {

                        //because of the IE design Bug!

                        $("#map_browse").slideDown(200, function(){

                            var markers = res.markers;
                            if(res.all > 0)
                            	load_browse_res(markers,12);
                            
                        });

                      }); 

                    });                   

                    

                }          

                );

}



/*function Show_Descr(id){   
	
   $.post("ajax_description.php", 

            {id : id},

            function(response){
            		  var res = eval('('+response+')');
                      //putting into Containers!
                      $("#Res_Container").html($("#ControlDiv").html());

                      $("#Nav_Container").html($("#ControlNav").html());

                      //end putting into Containers!
                      
                      //because of the IE design Bug! 

                      $("#map_browse").hide(900);

                      $("#ControlDiv").hide(800, function () {

                          $("#ControlDiv").html(res.msg);

                          $("#ControlDiv").show(800);

                      });    

                      $("#ControlNav").fadeOut(800, function () {
                          $("#ControlNav").html(res.box);

                          $("#ControlNav").fadeIn(800); 
                          $(function() {
                            
                            $('#gallery a').lightBox({fixedNavigation:true});
                            $('#logo a').lightBox({fixedNavigation:true});
                            
                          });
                          
                      });
                      

                }          

                );

}*/

function Show_Descr(id, what){   
    
   $.post("ajax_description.php", 

            {
             id : id,
             what: what
            },

            function(response){
                      var div;
                      var res = eval('('+response+')');
                      //putting into Containers!
                      
                      $("#Res_Container").html($("#ControlDiv").html());
                       
                       if(what == 1){
                           div = "#search_small";
                       }else{
                           div = "#search_full";
                       }                                                   
                      //end putting into Containers!

                      //because of the IE design Bug! 

                      $("#map_browse").hide(900);

                      $("#ControlDiv").hide(800, function () {

                          $("#ControlDiv").html(res.msg);

                          $("#ControlDiv").show(800);

                      });    
                      
                      $(div+'').hide(800, function () {

                          $("#Nav_Container").html(res.box);

                          $("#Nav_Container").fadeIn(800); 
                      });
                      $(function() {   
                          $('#gallery a').lightBox({fixedNavigation:true});
                          $('#logo a').lightBox({fixedNavigation:true});
                      });
                          
            
                      

                }          

                );

}



function BackToSearch(what) {
    var div;
    if(what == 1){
        div = "#search_small";
    }else{
        div = "#search_full";
    }
    $("#Nav_Container").fadeOut(800, function () {

                      $(div+"").fadeIn(800);

                      $("#browseLeft").html(' ');
                    });  
    $("#ControlDiv").fadeOut(800, function() {
  	  	$("#ControlDiv").html($("#Res_Container").html()); 
  	  	$("#ControlDiv").fadeIn(800);
        $("#Res_Container").html(' ');  

        $("#Nav_Container").html(' ');

        Find_Place(page, what);
    });

}



window.onload = function(){

    //gSearch();   

        map = new GMap2(document.getElementById("map"));

        $("#city").change(function () {

          var str = "";

          $("#city option:selected").each(function () {

                if($(this).val() != ''){

                    $('#city_google').val($(this).text());

                    Load_District($(this).val(), 2);
                    
                    if($(this).text().search('-') == -1){
                    	gSearch2();
                    }
                }

              });

        })

        .change();
        
        
        
        $("#city_small").change(function () {
            var str = "";
            

            $("#city_small option:selected").each(function () {

                if($(this).val() != ''){
                    Load_District($(this).val(), 3);    
                }else{
                    $('#district_small').html('');
                }

             });
        });
        
                           

        var sp;

        

        for(sp=1;sp<=6;sp++){                                                             

            $("."+Boxes[sp]).wTooltip({content: Boxes_Words[Boxes[sp]]}); 

        }   

        

        $("#lat").change(function () {



            if($("#lat").val() != 0) {

                Draw_Circle();

            }  

        })

        .change();

        

    };
    
    
    
    function PlaceVote(vote, placeId){
    	
 	   $.post("ajax_vote.php", 

 	            {vote : vote,
 	             placeId: placeId},

 	            function(response){
 	            		  var res = eval('('+response+')');
 	                      //putting into Containers!
 	            		  alert(res.msg);
 	                });
 	}
    
