$(document).ready(function()
{
$(function() {
		
	var currentURL = window.location.toString().split("/");
	currentURL[currentURL.length-1] = currentURL[currentURL.length-1].length < 1 ? "index.php" : currentURL[currentURL.length-1];
	var currentID = currentURL[currentURL.length-1].substr(0,currentURL[currentURL.length-1].length-4);
			
	$('#menu a[href^='+currentID+']').filter(function() {				
		var position = $(this).css("backgroundPosition");	
		if (position == "undefined" || position == null) {
			x = $(this).css("backgroundPositionX"); // IE...
		} else {
			x = position.split(" ")[0];
		}
		$(this).css("backgroundPosition",x+" -33px")		
	});
	
	$("#footer .nappi").click(function() 
	{
	    $('#footer .sites').slideToggle();
		return false;
	});
	
	$('#haitari').accordion({
        effect: 'slide',
        alwaysOpen: 'true',
        header: 'a.head'
        //animated: 'easeslide'
        });
	
	//Qtip 2

   $('#mainnavi a[rel]').each(function()
   {
      $(this).qtip(
      {
		 content: {
			text: '<img class="throbber" src="common/images/qtip/throbber.gif" alt="Loading..." />',
			ajax: {
         	//url: '/path/to/file', // URL to the local file
		 	url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load
         	type: 'GET', // POST or GET
         	data: {} // Data to pass along with your request
      }
			
       },
         position: {
            at: 'bottom center', // Position the tooltip above the link
            my: 'top center',
            viewport: $(window), // Keep the tooltip on-screen at all times
            effect: false, // Disable positioning animation
			adjust: {
         		y: 10
      		}
         },
         show: {
            event: 'mouseenter',
            solo: true // Only show one tooltip at a time
         },
         hide: {
        event: 'unfocus'
    	},
         style: {
            classes: 'ui-tooltip-rounded ui-tooltip-light'
         }
      })
   })

   $('#content a[rel]').each(function()
   {

      $(this).qtip(
      {
		content: {
			text: '<img class="throbber" src="common/images/qtip/throbber.gif" alt="Loading..." />',
			ajax: {
		 	url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load
         	type: 'GET', // POST or GET
         	data: {} // Data to pass along with your request
      		}
       },
		position: {
			at: 'center right', // Position the tooltip above the link
            my: 'center left',
            viewport: $(window), // Keep the tooltip on-screen at all times
            effect: false, // Disable positioning animation
			adjust: {
         		x: 20,
				y: -100
      		}
         },
         show: {
            event: 'mouseenter',
            solo: true // Only show one tooltip at a time
         },
         hide: {
      		//event: 'unfocus'
			//event: 'mouseleave'
      		delay: 1000
  		 },
         style: {
            classes: 'ui-tooltip-rounded ui-tooltip-light'
         }
	
		})
	})
 $('#tuoteryhma area[rel]').each(function()
   {
      $(this).qtip(
      {
   		content: {
			text: '<img class="throbber" src="common/images/qtip/throbber.gif" alt="Loading..." />',
			ajax: {
		 url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load
         type: 'GET', // POST or GET
         data: {} // Data to pass along with your request
      }
			
       },
		position: {
			at: 'center right', // Position the tooltip above the link
            my: 'center left',
            viewport: $(window), // Keep the tooltip on-screen at all times
            effect: false, // Disable positioning animation
			adjust: {
				y: -100				
      		}
         },
           show: {
            event: 'mouseenter',
            solo: true // Only show one tooltip at a time
         },
         //hide: 'unfocus',
         hide: {
      		//event: 'unfocus'
			//event: 'mouseleave'
			delay: 1000
			},
		 style: {
            classes: 'ui-tooltip-rounded ui-tooltip-light'
         }
	
		})
	})  
});

});
