/**
 * sfSlider
 *
 * @version: 1.0
 *
 * Required settings:
 *  display 	- provide number of items displayed at once
 *
 * Other settings:
 *  time 		- transition time
 *  easing 		- easing for the transition
 *  width 		- width of the scrolled area (by default visible area + right margin on the last visible item)
 *  previous	- previous link text
 *  next		- next link text
 *  wrap		- wrap container selector
 *  slider		- items container selector
 *  items		- items selector
 */ 
eval(function($){jQuery.fn.sfSlider=function(options){var defaults={width:0,display:6,time:500,easing:'swing',previous:'Previous',next:'Next',wrap:'div.wrap',slider:'ul.items',items:'ul.items li'};var settings=$.extend({},defaults,options);return this.each(function(){var $root=$(this);var $wrap=$root.find(settings.wrap);var $slider=$root.find(settings.slider);var $items=$root.find(settings.items);var all=$items.size();var pages=Math.ceil(all/settings.display);if($items.size()<=settings.display)return false;var width=settings.width;if(settings.width===0)width=$wrap.width()+parseInt($items.css('margin-right'),10);var current=1;$root.append('<ul class="index"><li class="prev"><a href="#previous" class="off">'+settings.previous+'</a></li><li class="next"><a href="#next">'+settings.next+'</a></li></ul>');var $controls=$root.find('ul.index');var check=function(){if(current===1){$controls.find('li.prev a').addClass('off');}else{$controls.find('li.prev a').removeClass('off');}if(current===pages){$controls.find('li.next a').addClass('off');}else{$controls.find('li.next a').removeClass('off');}};$controls.find('a').click(function(){var direction=$(this).parent().attr('class');if($slider.is(':animated')||(current==1&&direction=='prev')||(current==pages&&direction=='next'))return false;if(direction=='next'){move='-='+width+'px';current++;}else{move='+='+width+'px';current--;}$slider.animate({'marginLeft':move},settings.time,settings.easing);check();return false;});});};})(jQuery);

/*
 * hrefID jQuery extention
 */
$.fn.extend({ hrefId: function() { return $(this).attr('href').substr($(this).attr('href').indexOf('#')); } });

/*
 * Scripts
 *
 */
jQuery(function($) {
 
	var Engine = {
		utils : {
			links : function(){
				$('a[rel*=external]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));						  
				});
			},
			mails : function(){
				$('a[href^=mailto:]').each(function(){
					var mail = $(this).attr('href').replace('mailto:','');
					var replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:'+replaced);
					if($(this).text() == mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		forms : {
			labels : function(){
				var $elements = $('form.newsletter-a p input, form#topform p input');
				$elements.each(function(){
					if($(this).val() !== '') $(this).prevAll('label:first').hide();
				}).focus(function(){
					$(this).prevAll('label:first').hide();
				}).blur(function(){
					if($(this).val() === '') $(this).prevAll('label:first').show();
				});
			}
		},
		fixes : {
			blog : function(){
				// no comments/trackbacks + alternative
				var $comments = $('div.comments-a');
				$comments.each(function(){
					if($(this).find('div.comment').length == 0){
						var fixed = $(this).html().replace(/<\/h2>/i,'</h2><p class="empty">') + '</p>';
						$(this).html(fixed);
					} else {
						$(this).find('div.comment:odd').addClass('alt');
					}
				});
				
				// show/hide comments/trackbacks
				var $links = $('div.post-a p.info a.comments, div.post-a p.info a.trackbacks');
				$links.click(function(){
					$($(this).hrefId()).toggle();
					if($(this).is('.comments')) $($(this).hrefId()).next('div.add-comment-a:first').toggle();
					return false;
				});
				
				// single post (show trackbacks and comments)
				if($('div.post-a').length == 1){
					$('div.comments-a, div.add-comment-a').show();
				}
			},
			separators : function(){
				$('ul[class*=cols]').each(function(){
					var matches = /cols([0-9]+)/i.exec($(this).attr('class'))
					var row = matches[1];
					$(this).find('li').each(function(i){
						if((i+1) % row == 0) $(this).after('<li class="separate"><a href="#top">Back to top</a></li>');
					});
				});
			}
		},
		slider : function(){
			$('#slider ul.items li:nth-child(6n+1)').addClass('start');
			$('#slider').sfSlider({display: 6});
		}
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.forms.labels();
	Engine.fixes.blog();
	Engine.fixes.separators();
	Engine.slider();
	
});

	jQuery(document).ready(function(){
    	jQuery("ul#nav_573062 li.selected ul:first").clone().appendTo("#sideNav");
            Cufon.replace('ul#nav_573062 li a', { fontFamily: 'Omnes', hover: true });
            
            //annivasary menu
            Cufon.replace('ul#nav_1205929 li a', { fontFamily: 'Omnes', hover: true });
            //Top Nav 
 			Cufon.replace('ul#nav_573064 li a', { fontFamily: 'Omnes', hover: true });
            
            
 			Cufon.replace('#sideNav a', { fontFamily: 'Omnes' , hover: true });
			Cufon.replace('#secureNav a', { fontFamily: 'Omnes' , hover: true });
			Cufon.replace('h1', { fontFamily: 'Omnes'});
			Cufon.replace('h2', { fontFamily: 'Omnes'});
			Cufon.replace('.eventTitle', { fontFamily: 'Omnes'});
			});
			

jQuery(document).ready(function () {

    jQuery(".slidePanelItem .slidePanelLink").click(function () {
        var slidePanelItem = jQuery(this).closest('.slidePanelItem');
        if (slidePanelItem.hasClass("open")) {
            slidePanelItem.animate({
                bottom: "-152px"
            }, 200).toggleClass("open").css('z-index' , 1);
            jQuery('#slidePanelWrapper').css('z-index' , 0);
        } else {
            slidePanelItem.animate({
                bottom: "0px"
            }, 200).toggleClass("open").css('z-index' , 500);
			jQuery('#slidePanelWrapper').css('z-index' , 50);

        }
    });
    
    jQuery("div.photoGallery").each(function(){
	var html = "";
	jQuery(this).append("<ul class='photogallery'></ul>");

		jQuery(this).find("td.photogalleryItem").each(function(){
			var theData = jQuery(this).html();
			html += "<li>"+theData+"</li>"
		 });
		
		jQuery(this).find("ul.photogallery").append(html);
		jQuery(this).append("<div style='clear:both;'></div>");
});

	
	
});


 
