/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//CORE FUNCTIONs GAINED FROM jquery





 var content;
  var time;
        var secondTime;
        var inPop = false;
        function startHover()
        {
           
            $('area').mouseover(function()
            {
                  var county = this.id;
                  var special="";
                 clearTimeout(secondTime);
                 time = setTimeout(function()
                 {$('#popup').animate(
                     {
                       height:"150px",
                       width:"110px"
                     },500);
                 $('#map-slide').animate({
                     width:"231px",
                     height:"160px"
                 },500);
                $.post("/includes/getCountyInfo.php",{place: county},function(data){
                    if(data != ""){
                      $('#map-slide').html(headText+"<span class=\"ireland-links-text\">"+data+"</span>");
                    }
                    else $('#map-slide').html(headText+html);
                 });
                    setTimeout(function(){$('#popup').html(headText+html)
                                          }
                               ,500);
                 },250);

                   
               var headText = "<div id=\"popup-head\"> Co."+county+"</div>";
               var html = " <br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-hotels/\">Hotels in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-hostels/\">Hostels in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-bed-and-breakfasts/\">B&Bs in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/dublin-car-hire-form/\">Car hire in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-restaurants/\">Restaurants in "+this.id+"</a><br/>"+special+"";

                   //      document.getElementById("popup").innerHTML = "<a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-hotels/\">Hotels in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-hostels/\">Hostels in "+this.id+"</a><br/><a class=\"popup\" href=\"http://www.dublinks.com/"+this.id+"-bed-and-breakfasts/\">B&Bs in "+this.id+"</a>";


            });
        }



        function stopHover(){

            $('area').mouseout(
                function(){
                    clearTimeout(time);
                    secondTime= setTimeout(
                        function(){
                            $('#popup').animate(
                            {
                                height:"0px",
                                width:"0px"
                            },
                            500
                            );
                            $('#map-slide').animate({
                             width:"0px",
                              height:"0px"
                             },500);
                              $('#map-slide').html("");
                              $('#map-slide').attr('class','hidden');
                             $('#popup').html("");
                             $('#popup').attr('class','hidden');
                        },
                        450
                    );
                }
            );
        }


        function popupHover(){
        $('#popup').mouseover(function(){
           clearTimeout(secondTime);});
         $('#map-slide').mouseover(function(){
           clearTimeout(secondTime);

        });
          $('#map-slide').mouseout(function(){
           clearTimeout(secondTime);
             clearTimeout(time);
             secondTime= setTimeout(
                        function(){
                            $('#popup').animate(
                            {
                                height:"0px",
                                 width:"0px"
                            },
                            400
                            );
                             $('#map-slide').animate({
                                 width:"0px",
                                height:"0px"
                                 },400);
                             $('#map-slide').html("");
                             $('#map-slide').attr('class','hidden');
                             $('#popup').html("");
                             $('#popup').attr('class','hidden');
                        },
                        450
                    );
        });
        $('#popup').mouseout(function(){
            clearTimeout(secondTime);
            clearTimeout(time);
                secondTime= setTimeout(
                        function(){
                            $('#popup').animate(
                            {
                                height:"0px",
                                 width:"0px"
                            },
                            400
                            );
                             $('#map-slide').animate({
                                 width:"0px",
                                height:"0px"
                                 },400);
                             $('#map-slide').html("");
                             $('#map-slide').attr('class','hidden');
                             $('#popup').html("");
                             $('#popup').attr('class','hidden');
                        },
                        450
                    );
            });

        }


        $(document).ready(function(){
           startHover();
           stopHover();
           popupHover();

        });
