/*
 * jQuery Color Animations
 * Copyright 2008 David Dulak
 */

  attachRollOverEvent = function(itemId){
      $(itemId).mouseover(function(){
        $(this).animate({
          fontSize: "18px",
          color: "#FCBC5F"
        }, 15 );
      });
      $(itemId).mouseout(function(){
        $(this).animate({
          fontSize: "10px",
          color: "#000000"
        }, 250 );
      });
  }
  
  attachInnerRollOverEvent = function(itemId){
      $(itemId).mouseover(function(){
        $(this).animate({
          fontSize: "16px",
          color: "#cc3300"
        }, 15 );
      });
      $(itemId).mouseout(function(){
        $(this).animate({
          fontSize: "10px",
          color: "#000000"
        }, 250 );
      });
  }

  $().ready(function(){

    attachInnerRollOverEvent(".innerLinkBlock a");
    attachRollOverEvent(".linkBlock a");


    $('#navigationList>li>ul').hide();
    $('#navigationList>li').click(function(){
		// check that the menu is not currently animated
		if ($('#nav ul:animated').size() == 0) {
			// create a reference to the active element (this)
			// so we don't have to keep creating a jQuery object
			$heading = $(this);
			// create a reference to visible sibling elements
			// so we don't have to keep creating a jQuery object
			$expandedSiblings = $heading.siblings().find('ul:visible');
			if ($expandedSiblings.size() > 0) {
				$expandedSiblings.slideUp(250, function(){
					$heading.find('ul').slideDown(250);
				});
			}
			else {
				$heading.find('ul').slideDown(250);
			}
		}
    });


    $('#contentContainer>div').hide();
    var myFile = document.location.toString();
    if (myFile.match('#')) { // the URL contains an anchor
      // click the navigation item corresponding to the anchor
      var myAnchor = '#' + myFile.split('#')[1];
      $(myAnchor).animate({opacity: 'toggle', height: 'toggle'});
    }else{
      $('#Main').animate({opacity: 'toggle', height: 'toggle'});
    }
    
    $('a.siteContent').click(function(){
                var myAnchor = $(this).attr("href");
                $('#contentContainer>div').hide();
                $(myAnchor).animate({opacity: 'toggle', height: 'toggle'});

    });
	


    var configRed = {
         sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
         interval: 350, // number = milliseconds for onMouseOver polling interval
         over: overRed, // function = onMouseOver callback (REQUIRED)
         timeout: 300, // number = milliseconds delay before onMouseOut
         out: outRed // function = onMouseOut callback (REQUIRED)
    };
    var configGreen = {    
         sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
         interval: 350, // number = milliseconds for onMouseOver polling interval
         over: overGreen, // function = onMouseOver callback (REQUIRED)
         timeout: 300, // number = milliseconds delay before onMouseOut
         out: outGreen // function = onMouseOut callback (REQUIRED)
    };
    var configBlue = {    
         sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
         interval: 350, // number = milliseconds for onMouseOver polling interval
         over: overBlue, // function = onMouseOver callback (REQUIRED)
         timeout: 300, // number = milliseconds delay before onMouseOut
         out: outBlue // function = onMouseOut callback (REQUIRED)
    };
    var configYellow = {    
         sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
         interval: 350, // number = milliseconds for onMouseOver polling interval
         over: overYellow, // function = onMouseOver callback (REQUIRED)
         timeout: 300, // number = milliseconds delay before onMouseOut
         out: outYellow // function = onMouseOut callback (REQUIRED)
    };
    
    function overRed(){$('#redBlockText').animate({opacity: 'toggle'});}
    function outRed(){$('#redBlockText').hide();}
    
    function overGreen(){$('#greenBlockText').animate({opacity: 'toggle'});}
    function outGreen(){$('#greenBlockText').hide();}
    
    function overBlue(){$('#blueBlockText').animate({opacity: 'toggle'});}
    function outBlue(){$('#blueBlockText').hide();}
    
    function overYellow(){$('#yellowBlockText').animate({opacity: 'toggle'});}
    function outYellow(){$('#yellowBlockText').hide();}
    
    $("#redBlock").hoverIntent( configRed );
    $("#greenBlock").hoverIntent( configGreen );
    $("#blueBlock").hoverIntent( configBlue );
    $("#yellowBlock").hoverIntent( configYellow );


    //apply jqDock to each of the demo menus, setting varying options for each one...
    $('div.blockDock').each(function(i){ //opts updated so as not to use null as 'don't override default' - jQuery v1.2.5 changed extend() to not ignore nulls!
        var opts = { align:        'bottom' //default
                   , size:         30       //default
                   , distance:     25       //default
                   , coefficient : 1      //default
                   , labels:       false    //default
                   , duration:     500 //default
                     //for menu1 and menu7, set a function to use the 'alt' attribute if present, else construct a PNG path from the 'src'...
                   , source:       (i==0 || i==6) ? function(i){ return (this.alt) ? false : this.src.replace(/(jpg|gif)$/,'png'); } : false //default
                   };
        $(this).jqDock(opts);
      });


  });
