

$(document).ready(function(){

//	$('a.lightbox').lightBox(); // Select all links with lightbox class

//INITIALIZE SLIDESHOW AS HIDDEN	
$("div#slideshow").hide();
    		
//LEFT NAV MENU
 var $_GET = getUrlVars();
 $('ul[parent='+$_GET['lp']+']').show();
 $('ul[parent='+$_GET['lp']+']').parent('li').prev('li.link').children('span.expand').html('-');

 $('span.expand').click(function(){
  var childNav = $(this).attr('child');
  if($('ul[parent='+childNav+']').is(':hidden')){
    $('span.expand').html('+');
    $(this).html('-');
    $('ul.childnav').slideUp();
    $('ul[parent='+childNav+']').slideDown();
  }
 }); 

var p = $_GET['p'];
if(!p)p=2;
var op = $_GET['op'];
$("ul#s"+p).show();
$("ul#s"+op).show();

$.ajax({
  type: "GET",
  url: "./draw/banner.draw.php",
  data: "p="+p,
  success: function(msg){
    if(msg.length>2){
      $("div#slideshow").show();
	    $("div#main").css("position","relative").css("top","0px").css("padding-bottom","0");   	
      var slide = new Array();
      var slide = msg.split(';');
      $("#slideshow").append(slide[1]);
      if(slide[0]==0){
        $('#slideshow').cycle({ 
          fx:     'fade',
          speed:   1000,
          timeout: 7000
        });
      }else if(slide[0]==1){
        $('#slideshow').cycle({ 
          fx:     'scrollDown',
          speed:   1000,
          timeout: 7000
        });
      }else if(slide[0]==2){
        $('#slideshow').cycle({ 
          fx:     'turnUp',
          speed:   1000,
          timeout: 7000
        });
      }else if(slide[0]==3){
        $('#slideshow').cycle({ 
          fx:     'fadeZoom',
          speed:   1000,
          timeout: 7000
        });
      }
    } else {
    	$("div#slideshow").hide();
    }
  }
});	

 //BUSINESS DIRECTORY
 $('select#busselect').change(function(){

	 $.ajax({
  type: "GET",
  url: "./include/getcat.php",
  data: "cat="+$(this).val(),
  success: function(msg){
  	$("div#businesslisting").html(msg);
		}
 	});
 	 
 	  });

 
 $('ul#buslet li').click(function(){
	 $.ajax({
  type: "GET",
  url: "./include/getcat.php",
  data: "let="+$(this).attr("name"),
  success: function(msg){
  	$("div#businesslisting").html(msg);
		}
 	});
 	 
	  });



  
 $('a.eventtoday').click(function(){
	 $.ajax({
  type: "GET",
  url: "./include/dayevent.php",
  data: "d="+$(this).attr("name"),
  success: function(msg){
  	$("div.eventlist").html(msg);
		}
 	});
 	 
	  });

});

  
  	  
function getUrlVars(){
 var vars = [], hash;
 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 for(var i = 0; i < hashes.length; i++){
  hash = hashes[i].split('=');
  vars.push(hash[0]);
  vars[hash[0]] = hash[1];
 }
 return vars;
}