    function getFlashMovieObject(movieName){
		  if (window.document[movieName]) 
		  {
			return window.document[movieName];
		  }
		  if (navigator.appName.indexOf("Microsoft Internet")==-1)
		  {
			if (document.embeds && document.embeds[movieName])
			  return document.embeds[movieName]; 
		  }
		  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		  {
			return document.getElementById(movieName);
		  }
      }
	  
function getSWF(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
    return window[movieName];
  }
  else {
        if(document[movieName].length != undefined){
             return document[movieName][1];
        }
    return document[movieName];
  }
}
       
		
	  function updateContentPath_index(path) {        
			//	  var movie=getFlashMovieObject("myFlashMovie");
				  var movie=getSWF("myFlashMovie");
				  if(movie){
					//  alert(movie.name);
				  movie.updateContentPath(path);
				  }else{
					//  alert('no movie');
				  }
			}
			
		function 	playToggle_index(play, path){
			  var movie=getSWF("myFlashMovie");
				  if(movie){
					  movie.playToggle(play, path);
				  }
		}
		var active; var sub_id_active; var img_id_active; var active_page; var vids; var paneImgs;
	    window.addEvent('domready', function(){
	//	   alert($('top_nav_wrap').getHeight());
		   var mouseCheck = true;
		   var url = window.location.href;
		   url =url.split('com/');
		   url = url[1].split('/');
						   
			var myMask = new Mask($('body'));
			
			$$('.sub_li a').each(function(el){
				if(el.hasClass('active_page')){
					el.addEvent('mouseenter', function(event){
						mouseCheck = false;
					});
					el.addEvent('mouseleave', function(event){
						mouseCheck = true;
					});
				}else{
					el.addEvent('mouseenter', function(event){
						 myMask.show();
					});
					el.addEvent('mouseleave', function(event){
						
					});
				}
			});
			
			  $('top_nav_wrap').addEvent('mouseenter', function(event){
				  if(mouseCheck){
				      myMask.show();
				  }
				  mouseCheck = true;
			  });
			
			$('top_nav_wrap').addEvent('mouseleave', function(event){
				myMask.hide(); 
				mouseCheck = true;
			});
			
			
			
			if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){//if on an inside page, find the active sub nav
				$$('.top_li').each(function(el){
					 if(el.hasClass('top_active')){
						 active = el.getProperty('id');
						if(active){
						  id = active.split('_');
						  id = id[1];
						  sub_id_active = 'sub_'+id;
						  img_id_active = 'arrow_'+id;
						
						  var links = $(sub_id_active).getChildren('li a');
						  links.each(function(a){
							  if(a.hasClass('active_page')){
								  active_page = a;
							  }
						  });
						}
						
					 }
				});
			}
			
			$$('.top_li').each(function(el){
				    var id_1 = el.getProperty('id');
					if(id_1){
					id = id_1.split('_');
					id = id[1];
					var sub_id = 'sub_'+id;
					var img_id = 'arrow_'+id;	
	//				if($(sub_id)){	
					   if(!el.hasClass('top_active')){
							el.addEvent('mouseenter', function(event){
								//	myMask.show();		
								     if(this.hasClass('top_first')||this.hasClass('top_last')){$('header').setStyle('height', '130px');}
								    this.addClass('top_active');	
									if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){$(sub_id_active).setStyle('display', 'none');}
									if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){$(active).removeClass('top_active');}		
									if($(sub_id)){					
										$(sub_id).setStyle('display', 'block');
										if(
										   (
										     !$(document.body).hasClass('home1') || $(document.body).hasClass('contact')
											 ) && id_1 != 'top_5'){
											$('header').setStyle('height', '220px');
											}
										$(img_id).setProperty('src', '/images/down-arrow-orange.png');
										if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){
											if(active){ 				
												$(img_id_active).setProperty('src', '/images/down-arrow.png');
											}
										}
									}
							});
							el.addEvent('mouseleave', function(event){
								//	myMask.hide(); 
								if($(document.body).hasClass('home1')){
								    if(this.hasClass('top_first')||this.hasClass('top_last')){$('header').setStyle('height', '220px');}
								}
								    this.removeClass('top_active');
									if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){$(sub_id_active).setStyle('display', 'block');}
									if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){$(active).addClass('top_active');}	
									if($(sub_id)){	
										$(sub_id).setStyle('display', 'none');
										if(!$(document.body).hasClass('home1') || $(document.body).hasClass('contact')){$('header').setStyle('height', '130px');}								
										$(img_id).setProperty('src', '/images/down-arrow.png');
										if($(document.body).hasClass('home1') && !$(document.body).hasClass('contact')){
										if(active){
											$(img_id_active).setProperty('src', '/images/down-arrow-orange.png');
									  }
									}
								}
							});
					   }else{
						   
						   if(url.length == 3){
							   $$('.sub_li').each(function(li){
								   li.addEvent('mouseenter', function(event){
									  active_page.removeClass('active_page');								  	
								   });
								   li.addEvent('mouseleave', function(event){
									//   active_page.addClass('active_page');								   
								   });
						    
						   });
						     $$('.top_nav_sub').each(function(ul){
								 ul.addEvent('mouseleave', function(event){
									 if(ul.getStyle('display') == 'block' && !active_page.hasClass('active_page')){
										 active_page.addClass('active_page');
									 }
								 });
							 });
							 
						   }
					   }
				//	}
				}
			  
			});
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		//video controls
		//video array is included in the row record
	if($('videos')){	
	     if(Browser.Plugins.Flash.version == 0){
			 $('videos').getParent('div.row').set('html', '<h4>This site contains flash based videos, which can only be viewed in a flash enabled browser. </h4>');
		 }else{
			   var li_controls = $('videos').getChildren('li');
			   var id =  Array();
			   var idNum = Array();
			   var vidPlay = false;
			   var activeVid;
			   
		  //	load first video and image
			  (function(){
				   updateContentPath_index(vids[0]);
				}
			  ).delay(1000);
			  
			  
			   li_controls.each(function(el, i){
				   id[i] = el.getProperty('id');
				   id[i] = id[i].split('_');
				   idNum[i] = id[i][1];
				  
				   el.addEvent('mouseenter', function(event){
					   if(!this.hasClass('active')){
						  if(!$('vidPlay_'+i).hasClass('active')){
							 $('vidPlay_'+i).setProperty('src', '/images/play_button_on.png');
							 
						  }
					   }
					   this.addClass('active');
				  
				  updateContentPath_index(vids[i]);
					   li_controls.each(function(other, j) {
						  if(i != j) {
							  var id_other = other.getProperty('id');
							 id_other = id_other.split('_');
							 idNum_other = id_other[1];
							  other.removeClass('active');
					  //		$('vidPlay_'+j).setStyle('right', '1%');
					  //		$('vidPlay_'+j).set('html','');
					  //		$('vidWrap_'+idNum_other).removeClass('active');
						  }  
					   });
				   });
				   
				   el.addEvent('mouseleave', function(event){
					  updateContentPath_index('close');
					  if(!$('vidPlay_'+i).hasClass('active')){
						$('vidPlay_'+i).setProperty('src', '/images/play_button.png');
					  //  $('vidPlay_'+i).setStyle('right', '1%');
					  }else{
					  //	$('vidPlay_'+i).setStyle('right', '1%');
					  }
				   });
				   
				   el.addEvent('click', function(event){		
					 vidPlay = true;
					  $('vidPlay_'+i).addClass('active');
					  activeVid =  $('vidPlay_'+i);
					  var button =  $('vidPlay_'+i).getProperty('src');
					   if(button.indexOf('play') != -1){
						   $('vidPlay_'+i).setProperty('src','/images/pause_button.png'); 
							  playToggle_index('play', vids[i]);
						  
					   }else if(button.indexOf('pause') != -1){
							$('vidPlay_'+i).setProperty('src', '/images/play_button_on.png');
						   playToggle_index('pause', vids[i]);
					   }
						li_controls.each(function(other, j) {
						  if(i != j) {
							  $('vidPlay_'+j).setProperty('src', '/images/play_button.png');
							   $('vidPlay_'+j).removeClass('active');
						  }
						});
				   });
				   
			   });
			   function flashCall() {
				   alert("This function was successfully triggered via the flash movie.");
				}
		  }	
	}
		 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		 		 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
			 		 
if($('prod_switch' )){				 
		 
		 var imgElements = []
	     var imgHolder = $('prod_switch');
		 var x= 1;
		 var preloadedPaneImgs = new Asset.images(paneImgs, {
			 onProgress: function() {  },
		    onComplete: function() {
				paneImgs.each(function(im) {
					//	imgElements.push(new Element('img',{ src:im, class:'slides', styles:{position:'absolute', top:0, left:0, opacity:0, visibility:'visible'} }).inject(imgHolder));
					imgElements.push(new Element('img',{ src:im,  styles:{position:'absolute', top:0, left:0, opacity:0, visibility:'visible'} }).inject(imgHolder));
								});
						imgElements[0].fade(1);
						if(url.length == 1){$('switch_title').set('html',panesHTML[0]);}
					}
			});
			
			imgElements.each(function(slide, i){
				slide.addClass('slides');
			})
			
			if(url.length == 3){
			   var tabs = $$(".tab");
			}else if(url.length == 1){
				var tabs = $$(".tabs");
			}
			
			var num_images = paneImgs.length;
			if(num_images > 1){
				
			 tabs.each(function(tab, i) {
	             tab.addEvent("mouseenter", function(event) {
				//	 $clear(imageRotateVar);
					 if(!this.hasClass('active')){
					this.addClass('active');
	
				//	imgElements[i].fade(1);
					imgElements[i].setStyle('opacity', 1);
					 if(url.length == 1){$('switch_title').set('html',panesHTML[i]);}
					tabs.each(function(other, j) {	
					   if(i != j) {
						  if(other.hasClass('active')){
						       other.removeClass('active');
							   imgElements[j].setStyle('opacity', 0);
						   }
					   }
					})
				 }
				})
				tab.addEvent("mouseout", function(event){
			       x = i;
			//	   $clear(imageRotateVar);
				//	imageRotateVar = imageRotate.periodical(5000, x);
				})
			 })
			   
			   imgHolder.addEvent("mouseenter", function(event){
				//    $clear(imageRotateVar);
			   });
			   
			    imgHolder.addEvent("mouseout", function(event){
				   $$('.slides').each(function(img, y){
				//	$$('prod_switch img').each(function(img, y){
						if(img.getStyle('opacity') == 1){
							x = y;
						}
					});
				//	$clear(imageRotateVar);
				//	imageRotateVar = imageRotate.periodical(5000, x);
			   });
			   
			
		//	var num_images = paneImgs.length;
			
			 var imageRotate = function(){
				//  alert(i);
				   if(x > 0){
				     imgElements[x - 1].setStyle('opacity', 0); 
					 tabs[x-1].removeClass('active');
				   }else{
					 imgElements[num_images - 1].setStyle('opacity', 0); 
					 tabs[num_images - 1].removeClass('active');
				   }
				    if(url.length == 1){$('switch_title').set('html',panesHTML[x]);}
					imgElements[x].fade(1);
					tabs[x].addClass('active');
					 if(x< (num_images -1)){ 
						  x++;  
						}	else if (x == (num_images -1)){
						   x = 0;
						}
			   }
		//	   var imageRotateVar = imageRotate.periodical(5000, x);
		   }
		}
		 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// if($('info')){
			if ( $$('.form')){
			 	  //a few settings
		  var labelColor = '#999', restingPosition = 5;
		  //for every form field
		  $$('.slider label').each(function(label){
			//set the label enhancements into place
			label.setStyles({
			//  color: labelColor,
			  position: 'absolute',
			  top: 1,
			  left: restingPosition,
			  display: 'inline',
			  'z-index': 99
			});
			//get input value
			var input = label.getNext('input');
			if(!input){
				var input = label.getNext('textarea');
			}
			//grab label width, add resting position value
			var width = label.getSize().x;
			var move = width + restingPosition;
			
			var textarea = $('message');
			//onload, check if a field is filled out, if so, move the label out of the way
			var ID = input.getProperty('id');
			if(textarea == 'message'){
				   if(textarea.value !== '') {
					label.tween('left',0 - move);
				  }
				  // if the input is empty on focus move the label to the left
				  // if it's empty on blur, move it back
				  input.addEvents({
					focus: function() {
					  if(textarea.value == '') {
						label.tween('left',0 - move);
					  }
					  else {
						label.setStyle('left',0 - move);
					  }
					},
					blur: function() {
					  if(textarea.value == ''){
						label.tween('left',restingPosition);
					  }
					}
				  });
			}else{
				
				  if(input.get('value') !== '') {
					label.tween('left',0 - move);
				  }
				  // if the input is empty on focus move the label to the left
				  // if it's empty on blur, move it back
				  input.addEvents({
					focus: function() {
					  if(input.get('value') == '') {
						label.tween('left',0 - move);
					  }
					  else {
						label.setStyle('left',0 - move);
					  }
					},
					blur: function() {
					  if(input.get('value') == ''){
						label.tween('left',restingPosition);
					  }
					}
				  });
			}
		  });
		 }
		 
		});
