// This contains all base javascript (e.g. siFR, swfobject calls, etc)

//  base.js
//  
//  Created by Matt Dills on 2011-02-24.
//  Copyright 2010 Scully Group. All rights reserved.
// 

$(document).ready(function() {

  // /////////////////////////////////////////////////////////////// cufon
  Cufon.replace('#super-nav a', {hover:true, fontFamily: 'Media Gothic', fontSize: '14px'});
  Cufon.replace('#navigation a', {hover:true, fontFamily: 'Media Gothic', fontSize: '18px'});
  Cufon.replace('#features-top h1', {hover:true, fontFamily: 'Media Gothic', fontSize: '19.25px', letterSpacing: '15px'});
  // Cufon.replace('#content-interior h1', {hover:true, fontFamily: 'Media Gothic', fontSize: '32.27px'});
  Cufon.replace('#footer-content p.tagline', {hover:true, fontFamily: 'Media Gothic'});
  Cufon.replace('#footer-content p.tagline2', {hover:true, fontFamily: 'Media Gothic'});
  
  Cufon.replace('#slideshow-interior h1', {hover:true, fontFamily: 'Jenna Sue'});

  //////////////////////////////////////////////////////////////// add dividers to navigation elements
  $('#navigation ul.nav-left li:not(:first)').before('<li class="nav-dots">&#149;&#149;</li>');
  $('#navigation ul.nav-right li:not(:first)').before('<li class="nav-dots">&#149;&#149;</li>');
  
  
  ///////////////////////////////////////////////////////////////// add arrow to videoRight/videoLeft link
  $('.videoRight h3 a').after('<img class="vid-arrow" src="images/video-arrow.jpg" />');
  
  ///////////////////////////////////////////////////////////////// add "dots" to big elements, and give big paragraphs a class
  $('#content-interior big').each(function(){
    $(this).before('<span class="big-dots">&#149;&#149;</span>');
    $(this).parent().addClass('dots');
    $(this).after('<br />');
  });

  
  //////////////////////////////////////////////////////////////// feature image/subnav-video image frames
  $('.feat img').each(function() {
    $(this).wrap('<div class="feat-wrapper"></div>');
    $(this).before('<div></div>');
  });
  $('.home-video img').each(function() {
    $(this).before('<div><img src="/images/video-play.png" class="video-play" /></div>'); 
  });
  $('.home-video a').each(function(){
    $(this).addClass('youtube');
  });
    
  /// adds frame, button and class "youtube" (for modal box purposes) to the subnav video thumbnail  
  $('#subnav-video img').each(function() {
    $(this).wrap('<div class="feat-wrapper"></div>');
  });
  $('#subnav-video img').each(function() {
    $(this).before('<div><img src="/images/video-play.png" class="video-play" /></div>');
  });
  $('#subnav-video a').each(function(){
    $(this).addClass('youtube');
  });
  
  
  $('.imgVideo').each(function() {
    $(this).parent().wrap('<div class="content-video"></div>');
    $(this).wrap('<div class="feat-wrapper"></div>');
    $(this).before('<div><img src="/images/video-play.png" class="video-play" /></div>');
  });
  $('.content-video a').each(function(){
    $(this).addClass('youtube');
  });
  
  /////////////////////////////////////////////////////////////// fancybox for video
  $(".feat a.home-video").fancybox({
     'overlayOpacity': 0.5,
     'overlayColor' : '#000',
     'speedIn'   : 600, 
     'speedOut'    : 200, 
     'titleShow' : true,
     'titlePosition' : 'inside',
     'overlayShow' : true
  });
  
  $("#subnav-video a.video-link").fancybox({
     'overlayOpacity': 0.5,
     'overlayColor' : '#000',
     'speedIn'   : 600, 
     'speedOut'    : 200, 
     'titleShow' : true,
     'titlePosition' : 'inside',
     'overlayShow' : true
  });
  
  $(".fancy").fancybox({
     'overlayOpacity': 0.5,
     'overlayColor' : '#000',
     'speedIn'   : 600, 
     'speedOut'    : 200, 
     'titleShow' : true,
     'titlePosition' : 'inside',
     'overlayShow' : true
  });
  
  $(".photo-gallery-thumb").fancybox({
     helpers	: {
     			title	: {
     				type: 'inside'
     			},
     			overlay	: {
     				opacity : 0.8,
     				css : {
     					'background-color' : '#000'
     				}
     			},
     			thumbs	: {
     				width	: 50,
     				height	: 50
     			}
     		}
  });
  
  /////////////////////////////////////////////////////////////// fancybox youtube video
  $(".youtube").click(function() {
  	$.fancybox({
  			'padding'		: 0,
  			'autoScale'		: false,
  			'transitionIn'	: 'none',
  			'transitionOut'	: 'none',
  			'titleShow' : false,
  			'title'			: this.title,
  			'width'		  : 680,
  			'height'		: 410,
  			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + "&autoplay=1",
  			'type'			: 'swf',
  			'swf'			: {
  			  'wmode'		: 'transparent',
  				'allowfullscreen'	: 'true'
  			}
  		});

  	return false;
  });
  
  /////////////////////////////////////////////////////////////// procedures module video/fancybox area
  
  $('#content-interior .procedures-module a').each(function(){
    $(this).addClass('fancybox.iframe');
  });
  
  $("#content-interior .procedures-module a").fancybox({
    'width': 775,
    'height': 506,
    'scrolling': 'no'
  });
  
  $(".sub-procedure a").fancybox({
    'width': 775,
    'height': 506,
    'scrolling': 'no'
  });
  
    
}); //end document.ready
