$(document).ready(function(){

     // SET DROP DOWN NAV MENU STUFF
     $("#nav li").hover(
	 		function(){ $("ul", this).hide().fadeIn(200);},
     		function(){}
	 );
     if (document.all) {
     	$("#nav li").hoverClass ("sfHover");
     }
	 
	 // FADE EFFECT WHEN HOVERING BUTTON IMAGE
	 $("a.button").hover(
	 		function(){ $("img", this).fadeOut(300).fadeIn(300);},
     		function(){}
	 );
	 
     // RUN HOME IMAGE ROTATOR
	 $('#slideshow-big').cycle({
          fx:  'fade',
			timeout: 5000,
          speed: 2500
     });
	 
     // RUN HOME TESTIMONIALS ROTATOR
	 $('#testimonials').cycle({
          fx:  'scrollDown',
			cleartype:  1,
			timeout: 9000,
          speed: 2000,
			delay: 3000
     });
	 
     // RUN HOME IMAGES ROTATOR
	 $('#slideshow-small').cycle({
          fx:  'fade',
			timeout: 5000,
          speed: 2500,
			delay: 5000
     });
	 
     // SET UP FLASH VIDEO ON HOME PAGE
	 $('#video-holder').flash(
	    { src: '/wp-content/themes/open_door_big_blue/flash/open_door_video.swf',
          width: 320,
          height: 275,
			base: '/wp-content/themes/open_door_big_blue/flash/',
		   flashvars: {autoplay: false}
		 },
		 {
		 	expressInstall: true,
			version: '8'
		 }
    );	 
	 
     // SET UP SUBTLE HOVER FADE ON RIGHT NAVIGATION LISTS
	 $("ul.generic-right li a").hover(
          function () {
               $(this).animate({ backgroundColor: "#6CC751" }, "1500");
          }, 
          function () {
               $(this).animate({ backgroundColor: "#8CD377" }, "fast");
          }
     );
	 
     // SET UP SUBTLE HOVER FADE ON RIGHT NAVIGATION LISTS
	 $("ul.subnav a").hover(
          function () {
               $(this).animate({ backgroundColor: "#023b93" }, "1500");
          }, 
          function () {
               $(this).animate({ backgroundColor: "#024fc5" }, "fast");
          }
     );
	 
     // SET UP GOOGLE MAP
     var v_title = 'Open Door Care';
     var v_adr = '518 Virginia Avenue';
     var v_stzip = 'Towson, Maryland 21286';
     var WINDOW_HTML = '<div style="width: 15em; height: 4em;"><p><strong>' + v_title + '<\/strong><br \/>' + v_adr + '<br \/>' + v_stzip + '<\/p><\/div>';
     $('#map').jmap('init', {mapCenter:[39.401299, -76.599696], mapZoom: 15});
     $('#map').jmap('addMarker', {pointLatLng:[39.401299, -76.599696], pointHTML: WINDOW_HTML});
	  
     // SET UP LOCATIONS PAGE STUFF
     var schoollist = [
          {'When':'baltimore','Value':'bear-creek','Text':'Bear Creek Elementary'},
          {'When':'baltimore','Value':'carney','Text':'Carney Elementary'},
          {'When':'baltimore','Value':'chapel-hill','Text':'Chapel Hill Elementary'},
		  {'When':'baltimore','Value':'fullerton','Text':'Fullerton Elementary'},
          {'When':'baltimore','Value':'gunpowder','Text':'Gunpowder Elementary'},
          {'When':'baltimore','Value':'harford-hills','Text':'Harford Hills Elementary'},
          {'When':'baltimore','Value':'joppa-view','Text':'Joppa View Elementary'},
          {'When':'baltimore','Value':'kingsville','Text':'Kingsville Elementary'},
          {'When':'baltimore','Value':'lutherville','Text':'Lutherville Laboratory'},
          {'When':'baltimore','Value':'mccormick','Text':'McCormick Elementary'},
          {'When':'baltimore','Value':'oakleigh','Text':'Oakleigh Elementary'},
          {'When':'baltimore','Value':'oliver-beach','Text':'Oliver Beach Elementary'},
          {'When':'baltimore','Value':'pine-grove','Text':'Pine Grove Elementary'},
          {'When':'baltimore','Value':'riderwood','Text':'Riderwood Elementary'},
          {'When':'baltimore','Value':'baltimore-seven-oaks','Text':'Seven Oaks Elementary'},
          {'When':'baltimore','Value':'shady-spring','Text':'Shady Spring Elementary'},
          {'When':'baltimore','Value':'st-james','Text':'St. James Academy'},
          {'When':'baltimore','Value':'villa-cresta','Text':'Villa Cresta Elementary'},
          {'When':'baltimore','Value':'wellwood','Text':'Wellwood International School'},
          {'When':'baltimore','Value':'westchester','Text':'Westchester Elementary'},
          {'When':'baltimore','Value':'woodbridge','Text':'Woodbridge Elementary'},
          {'When':'baltimore','Value':'woodholme','Text':'Woodholme Elementary'},
		  {'When':'baltimore-city','Value':'greenmount','Text':'The Greenmount School'},
          {'When':'anne-arundel','Value':'arundel-middle','Text':'Arundel Middle'},
          {'When':'anne-arundel','Value':'central','Text':'Central Elementary'},
          {'When':'anne-arundel','Value':'crofton','Text':'Crofton Elementary'},
          {'When':'anne-arundel','Value':'crofton-woods','Text':'Crofton Woods Elementary'},
          {'When':'anne-arundel','Value':'ft-smallwood','Text':'Ft. Smallwood Elementary'},
          {'When':'anne-arundel','Value':'jacobsville','Text':'Jacobsville Elementary'},
		  {'When':'anne-arundel','Value':'monarch','Text':'Monarch Academy'},
          {'When':'anne-arundel','Value':'odenton','Text':'Odenton Elementary'},
          {'When':'anne-arundel','Value':'piney-orchard','Text':'Piney Orchard Elementary'},
          {'When':'anne-arundel','Value':'ridgeway','Text':'Ridgeway Elementary'},
          {'When':'anne-arundel','Value':'riviera-beach','Text':'Riviera Beach Elementary'},
          {'When':'anne-arundel','Value':'anne-arundel-seven-oaks','Text':'Seven Oaks Elementary'},
          {'When':'harford','Value':'forest-hill','Text':'Forest Hill Elementary'}			
     ];
     
     function commonTemplate(item) {
     		return "<option value='" + item.Value + "'>" + item.Text + "</option>"; 
     };
     
     function commonMatch(selectedValue) {
     		return this.When == selectedValue; 
     };
     
     $("#selectschool").cascade("#selectcounty",{					
          list: schoollist,			
          template: commonTemplate,
          match: commonMatch 			
     });
	 

	// scroll to school when school option is changed
	$("#selectschool").change(function () {
          var selected = ($(this).val());
			$("#all-schools-holder").scrollTo($('a[@name='+selected+']'), {duration:2000});
     });
	 
	// scroll to first school when school option is changed
	$("#selectcounty").change(function () {
          var selected = ($(this).val());
			if(selected == 'baltimore')
			{
				$("#all-schools-holder").scrollTo($('a[@name=bear-creek]'), {duration:2000});
			}
			else if(selected == 'baltimore-city')
			{
				$("#all-schools-holder").scrollTo($('a[@name=greenmount]'), {duration:2000});
			}
			else if(selected == 'anne-arundel')
			{
				$("#all-schools-holder").scrollTo($('a[@name=arundel-middle]'), {duration:2000});
			}
			else if(selected == 'harford')
			{
				$("#all-schools-holder").scrollTo($('a[@name=forest-hill]'), {duration:2000});
			}			
     });	 
 
	
}); 	

// MORE DROP DOWN MENU STUFF
$.fn.hoverClass = function(c) {
     return this.each(function(){
          $(this).hover(
               function() { $(this).addClass(c);  },
               function() { $(this).removeClass(c); }
          );
     });
};