﻿ $(document).ready(function() {
       loadFunctions();//load everything required
       loadMenuSlides(); //loads just in document.ready
    });
    
    //functions to call on page load
    function loadFunctions() {
     showHideFunctions();//call show hide text segements 
     popUpBubble();//not currently in use         
    };
    
     //functions to call on page load not on secondary load
    function loadMenuSlides() {
     slide("#nav-Home", 25, 15, 150, .8);
     slide("#nav-Rehoming", 25, 15, 150, .8);
     slide("#nav-Fundraising", 25, 15, 150, .8);
     slide("#nav-Greyhounds", 25, 15, 150, .8);
     slide("#nav-Factsheets", 25, 15, 150, .8);
     slide("#nav-Links", 25, 15, 150, .8); 
    };
    
 
    //handles accordion menu click events
	$(function() {
		$("#accordion").accordion({header: "h2",active: false,alwaysOpen: false});
	});
	
	
	
	//show hide text code, multiple instances on single page
	function showHideFunctions() {
               // choose text for the show/hide link
            var showText=" read more... ";
            var hideText=" hide content ";

            // append show/hide links to the element directly preceding the element with a class of "toggle"
            $(".toggle").prev().append('(<a href="#" class="toggleLink">'+showText+'</a>)');

            // hide all of the elements with a class of 'toggle'
            $('.toggle').hide();

            // capture clicks on the toggle links
            $('a.toggleLink').click(function() {

            // change the link text depending on whether the element is shown or hidden
            if ($(this).text()==showText) {
            $(this).text(hideText);
            }
            else {
            $(this).text(showText);
            }

            // toggle the display
            $(this).parent().next('.toggle').toggle('blind'); //.toggle('slow')//.toggle('blind')//.toggle('fast')

            // return false so any link destination is not followed
            return false;

            });
     };
      //pop Up bubble
       	function popUpBubble() {
            $(".rss-popup a").hover(function() { 
            $(this).next("em").stop(true, true).animate({opacity: "show", top: "-60"}, "slow"); 
            }, function() { 
            $(this).next("em").animate({opacity: "hide", top: "-70"}, "fast"); 
            });

        }; 
      
      //slide menu
      
      function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li"; //.sliding-element
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		$(this).css("margin-left","-180px");
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ marginLeft: "0" }, timer);
		$(this).animate({ marginLeft: "15px" }, timer);
		$(this).animate({ marginLeft: "0" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i)
	{
		$(this).hover(
		function()
		{
			$(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			$(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
}
      
      
      
      //Fix for .net update panel jQuery failing
      
       function load(){
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        };

        function EndRequestHandler(){
        // call functions that should be in document.ready()

            loadFunctions();//load everything required

        };
        //end fix
              
        
        
        //normalPopUpWindow 
			function showContactUs()
            {
                   var name = "Contact Us";
                   var url = "contactUs.aspx";
                   var dsettings = "dialogHeight:280px,dialogWidth:460px,resizable:yes,center:yes";
                   var settings = "height=280, width=460, resizable=no,status=no,top=100,left=100";
                    // to handle in IE 7.0          
                    if (window.showModalDialog)
                    {      
                        retVal = window.showModalDialog(url, name, dsettings);
                        
                    }
                    // to handle in Firefox
                    else
                    {     
                        retVal = window.open(url, name, settings);
                        retVal.focus();           
                    }         
            }; 
            