// XHTML Strict External Links
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href")&&
       anchor.getAttribute("rel")=="external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

// Jquery Variables
$(document).ready(function(){	   
// PNG Fix for IE
$(document).pngFix();
	
// Flash Embedding
// Home Page Flash
	$('#flash-home').flash(
		{ 
		  src: 'home.swf',
		  width: 486,
		  height: 292,
		  wmode: 'transparent'
		},
		{ version: 9 }
	);

// Office Tour
	$('#flash-office-tour').flash(
		{ 
		  src: 'office-tour.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
		  	caption01: '',
			caption02: '',
			caption03: ''
		  }
		},
		{ version: 8 }
	);
	
// Oral Care Video
	$('#flash-oral-care-video').flash(
		{ 
		  src: 'oral-care-video.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + '2D7E3D'
		  }
		},
		{ version: 8 }
	);
	
// Emergency Care Video
	$('#flash-emergency-care-video').flash(
		{ 
		  src: 'emergency-care.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + '2D7E3D',
			pokingWire: 'true',
			bracket: 'true',
			looseWire: 'true',
			appliance: 'true',
			headgear: 'true',
			soreness: 'true'			
		  }
		},
		{ version: 8 }
	);
	
// Expander Video
	$('#flash-expander-video').flash(
		{ 
		  src: 'palatal-expander.swf',
		  width: 200,
		  height: 150,
		  wmode: 'transparent'
		},
		{ version: 8 }
	);

// Sample Patients Video
	$('#flash-sample-patients-video').flash(
		{ 
		  src: 'common-treatments.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + '2D7E3D',
			crowding: 'true',
			openbite: 'true',
			deepOverbite: 'true',
			missing: 'true',
			underbite: 'true',
			spacing: 'true',
			overbite: 'true',
			nonBraces: 'true',
			phaseI: 'true'			
		  }
		},
		{ version: 8 }
	);

// Brace Types Video
	$('#flash-brace-types-video').flash(
		{ 
		  src: 'types-of-braces.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + '2D7E3D',
			metal: 'true',
			gold: 'true',
			ceramic: 'true',
			invisible: 'true',
			lingual: 'true'
		  }
		},
		{ version: 8 }
	);

// Appliances Video
	$('#flash-appliances-video').flash(
		{ 
		  src: 'types-of-appliances.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + '2D7E3D',
			elastics: 'true',
			headgear: 'true',
			herbst: 'true',
			palatal: 'true',
			positioners: 'true',
			retainers: 'true',
			separators: 'true'
		  }
		},
		{ version: 8 }
	);

// Braces Diagram
	$('#flash-braces-diagram').flash(
		{ 
		  src: 'braces-diagram.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: {
			thisColor: '0x' + '2D7E3D'
		  }
		},
		{ version: 8 }
	);

// Wilckodontics
	$('#flash-wilckodontics').flash(
		{ 
		  src: 'wilckodontics.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
		  	caption01: '',
			caption02: '',
			caption03: ''
		  }
		},
		{ version: 8 }
	);
	
// Surgical Orthodontics
	$('#flash-surgical-orthodontics').flash(
		{ 
		  src: 'surgical-orthodontics.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
		  	caption01: 'Before                                     After',
			caption02: 'Before',
			caption03: 'After',
			caption04: 'Before (Above)                                     After (Below)',
			caption05: 'Before                           After'
		  }
		},
		{ version: 8 }
	);

// The Game Room
  $(function() {
    // define which games to activate
    var games = Array('asteroids', 'frogger', 'pong', 'simon', 'snake', 'space-invaders', 'tetris', 'tic-tac-toe');
  
    // set the click behavior for a game link
    var setGameClick = function(game){
      $("a." + game).click(function(){
        $('#sesame-game').flash(
          {
          src: 'games/' + game + '.swf',
          width: 400,
          height: 420,
          wmode: 'transparent'
          },
          { version: 8 }
        );
      });
    };
    
    // set the click behavior for each game
    for (var j=0; j<games.length; j++){
      setGameClick(games[j]);
    };
  });

// In-Ovation
	$('#flash-in-ovation').flash(
		{ 
		  src: 'flv-player.swf',
		  width: 320,
		  height: 285,
		  wmode: 'transparent',
		  flashvars: { 
			FLVPath: '/video/in-ovation.flv',
			SkinPath: 'http://www.millerbraces.com/video/SteelExternalAll.swf'
		  }
		},
		{ version: 8 }
	);
	
// iBraces Video 1
	$('#flash-ibraces-1').flash(
		{ 
		  src: 'flv-player.swf',
		  width: 320,
		  height: 285,
		  wmode: 'transparent',
		  flashvars: { 
			FLVPath: 'video/ibraces-1.flv',
			SkinPath: 'video/SteelExternalAll.swf'
		  }
		},
		{ version: 8 }
	);
	
// iBraces Video 2
	$('#flash-ibraces-2').flash(
		{ 
		  src: 'flv-player.swf',
		  width: 320,
		  height: 285,
		  wmode: 'transparent',
		  flashvars: { 
			FLVPath: 'video/ibraces-2.flv',
			SkinPath: 'video/SteelExternalAll.swf'
		  }
		},
		{ version: 8 }
	);

// iBraces Video 3
	$('#flash-ibraces-3').flash(
		{ 
		  src: 'flv-player.swf',
		  width: 320,
		  height: 285,
		  wmode: 'transparent',
		  flashvars: { 
			FLVPath: 'video/ibraces-3.flv',
			SkinPath: 'video/SteelExternalAll.swf'
		  }
		},
		{ version: 8 }
	);

// Brace Painter Flash
	$('#flash-brace-painter').flash(
		{ 
		  src: 'brace-painter.swf',
		  width: 500,
		  height: 430,
		  wmode: 'transparent'
		},
		{ version: 7 }
	);
	
	
	$('ul.slideshow').cycle({ pause: true, wmode: 'transparent' });  // Duplicate the following block of code to add extra office tours 
	$('#cycle-office-tour').before('<div class="office-tour-nav" id="office-1">') // Ditto for this ID 
		.cycle({ cleartype: true, // true if clearType corrections should be applied (for IE) 
			     cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 
				 speed: 500, // This controls speed of transition 
				 timeout: 0, // This controls autoplay/delay between slides. 
				 pager: '#office-1', 
				 before: function() { 
				 	$('#caption span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page 
				}, 
				after: function(curr, next, opts) { 
					var alt = $(next).find('img').attr('alt'); // This grabs the image alt text 
					$('#caption span').html(alt).fadeIn(); // This puts alt text into the caption span 
	} });
		
		$('ul.slideshow').cycle({ pause: true, wmode: 'transparent' });  // Duplicate the following block of code to add extra office tours 
	$('#cycle-office-tour-orange').before('<div class="office-tour-nav" id="office-orange">') // Ditto for this ID 
		.cycle({ cleartype: true, // true if clearType corrections should be applied (for IE) 
			     cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 
				 speed: 500, // This controls speed of transition 
				 timeout: 0, // This controls autoplay/delay between slides. 
				 pager: '#office-orange', 
				 before: function() { 
				 	$('#caption-orange span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page 
				}, 
				after: function(curr, next, opts) { 
					var alt = $(next).find('img').attr('alt'); // This grabs the image alt text 
					$('#caption-orange span').html(alt).fadeIn(); // This puts alt text into the caption span 
	} });
	
	
});//end document.ready
