﻿$(document).ready
(
	function()
	{

			/*
		==============================================
			Rotating banners
		==============================================
	

		if($("#promotional_banner.rotating").length > 0)
		{
			$('#promotional_banner.rotating a:first').css("display","block");
			$('#promotional_banner').cycle (
				{
					fx: 'fade',
					pause: 14,
					pager: '#banner_pagination'
				} );
		};

$("#main_content table tr:even").addClass('SF_even');

		$('#practitioners').hover(function() {
        DD_belatedPNG.fix('#promotional_banner .practitioners-hover');
        $(this).addClass('practitioners-hover');
      }, function() {
        $(this).removeClass('practitioners-hover');
      });
      $('#practitioners').focus(function() {
        $(this).addClass('practitioners-hover');
      }, function() {
        $(this).removeClass('practitioners-hover');
      });
      $('#practitioners').blur(function() {
        $(this).addClass('practitioners-hover');
      }, function() {
        $(this).removeClass('practitioners-hover');
      });

*/	
	if($("#home-page").length)
	  {
	  $('<img />')
    .attr('src', 'http://coru.ie/images/public-rollover.png')
    .load(function(){
        $('.profile').append( $(this) );
    });
$('<img />')
    .attr('src', 'http://coru.ie/images/practitioners-rollover.png')
    .load(function(){
        $('.profile').append( $(this) );

    });

	  }
	
	
	
      $('ul#primary-nav li a').hover(function() {
        $(this).parent().addClass('internet_hover');
      }, function() {
        $(this).parent().removeClass('internet_hover');
      });
      $('ul#primary-nav ul li a').focus(function() {
        $(this).addClass('internet_hover');
      }, function() {
        $(this).removeClass('internet_hover');
      });
      $('ul#primary-nav ul li a').blur(function() {
        $(this).addClass('internet_hover');
      }, function() {
        $(this).removeClass('internet_hover');
      });
	
	$("table tr:even td").addClass('SF_even');

/*
====================================
  Style switcher
====================================
*/
 $('.styleswitch').click(function()
	{
	relattrib = this.getAttribute("rel");
	switchStylestyle(this.getAttribute("rel"));
	return false;
	}
	);
	var style = readCookie('style');
	if(style) {
	switchStylestyle(style);
	}

	function switchStylestyle(styleName)
	{

		$('link[@rel=*style][title]').each(function(i) 
		{
			this.disabled = true;
			if(this.getAttribute('title') == styleName) 
				this.disabled = false;
		});
		createCookie('style',styleName,60);
	}

	function createCookie(name,value,days)
	{
		if(days)
		{
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else 
			var expires = "";
		document.cookie = name + "=" + value + expires + "; path=/";
	}

	function readCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var index = 0; index < ca.length; index++)
		{
			var c = ca[index];
			while(c.charAt(0 )== ' ') 
				c = c.substring(1,c.length);
			if(c.indexOf(nameEQ) == 0) 
				return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}
	
	
	
	}
);
