// JavaScript Document

var $j = jQuery.noConflict();



  $j(document).ready(function() {
	  
	  $j("a[rel^='prettyPhoto']").prettyPhoto();
	  
	  //Retail Survey Pod Functionality
	  $j('#survey').show();
	  $j('#thankyou').hide();
	  
	  $j('input#submit').click(function(){
		  
		  $j('#survey').hide();
		  $j('#thankyou').show();
		  
	  });
	  
	  $j('input[name="yes"]').attr('checked', false);
	  $j('input[name="no"]').attr('checked', false);
	  
	  $j('input[name="yes"]').click(function(){
		  
		  $j('input[name="yes"]').attr('checked', true);
		  $j('input[name="no"]').attr('checked', false);
		  
	  });
	  
	  $j('input[name="no"]').click(function(){
		  
		  $j('input[name="yes"]').attr('checked', false);
		  $j('input[name="no"]').attr('checked', true);
		  
	  });
	  
	  //Pop Up Functionality
	  var currentProdID = '';
	  
	  if($j.browser.msie){
	  
			//Pop Up Functionality in IE
			$j('#pop1').hide();
			$j('#pop2').hide();
			$j('#popProd').hide();
			$j('.popOpac').hide();
			
			
			//Homepage
			$j('img.rollOver1').mouseover(function(){
			
				$j('#pop1').show();
				$j('#pop1').css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px" } );
			
			});
			
			$j('img.rollOver1').mouseleave(function(){
				t = setTimeout(function(){
				  $j('#pop1').hide();
				}, 50);									  
			});
			
			$j('#pop1').mouseenter(function(){
				if($j(this).is(':hidden')){
					$j(this).stop().animate( { top:"-10000px"}, 100 );
				} else {
					clearTimeout(t);
					$j(this).show();
				}
			});
			$j('#pop1').mouseleave(function(){
				$j('#pop1').hide();							  
			});
			$j('#pop1 a.close').click(function(){
				$j('#pop1').hide();	
			});
			
			$j('img.rollOver2').mouseover(function(){
			
				$j('#pop2').show();
				$j('#pop2').css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px", "margin-left":"125px" } );
			
			});
			
			$j('img.rollOver2').mouseleave(function(){
				t = setTimeout(function(){
				  $j('#pop2').hide();
				}, 50);									  
			});
			
			$j('#pop2').mouseenter(function(){
				if($j(this).is(':hidden')){
					$j(this).stop().animate( { top:"-10000px"}, 100 );
				} else {
					clearTimeout(t);
					$j(this).show();
				}
			});
			$j('#pop2').mouseleave(function(){
				$j('#pop2').hide();							  
			});
			$j('#pop2 a.close').click(function(){
				$j('#pop2').hide();	
			});
			
			
			//Product Pages
			$j('img.prod').mouseover(function(){
				
				currentProdID = $j(this).attr('name');
				$j('#popProd-' + currentProdID).show();
				$j('#popProd-' + currentProdID).css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px" } );
				
			});
			$j('img.prod').mouseleave(function(){
				t = setTimeout(function(){
				  $j('#popProd-' + currentProdID).hide();
				}, 50);
			});
			$j('.popOpac').mouseenter(function(){
				if($j(this).is(':hidden')){
					$j(this).stop().animate( { top:"-10000px"}, 100 );
				} else {
					clearTimeout(t);
					$j(this).show();
				}
			});
			$j('.popOpac').mouseleave(function(){
				$j('#popProd-' + currentProdID).hide();					  
			});
			$j('.popOpac a.close').click(function(){
				$j('#popProd-' + currentProdID).show();
			});
	  
	  } else {
		  
		  
		  //Pop Up Functionality in Other / Better Browsers ;) ... IE Sucks.
		$j('#pop1').css('opacity',0);
		$j('#pop2').css('opacity',0);
		$j('#popProd').css('opacity',0);
		$j('.popOpac').css('opacity',0);
		
		
		//Homepage
		$j('img.rollOver1').mouseover(function(){
			
			$j('#pop1').stop().animate({ opacity: 1 }, { queue:false, duration:500 } );
			$j('#pop1').css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px", "margin-left":"125px", "margin-top":"50px" } );
			
		});
		
		$j('img.rollOver1').mouseleave(function(){
			$j('#pop1').stop().animate({ opacity: 0 }, { queue:false, duration:700 } );								  
		});
		
		$j('#pop1').mouseenter(function(){
			if($j('#pop1').css("opacity") == "0"){
				$j('#pop1').stop().animate( { top:"-10000px"}, 100 );
			} else {
				$j('#pop1').stop().animate({ opacity: 1 }, { queue:false, duration:200 } );
			}
		});
		$j('#pop1').mouseleave(function(){
			$j('#pop1').stop().animate({ opacity: 0 }, { queue:false, duration:500 } );							  
		});
		$j('#pop1 a.close').click(function(){
			$j("#pop1").stop().animate({ opacity: 0 }, { queue:false, duration:500 } );	
		});
		
		$j('img.rollOver2').mouseover(function(){
			
			$j('#pop2').stop().animate({ opacity: 1 }, { queue:false, duration:500 } );
			$j('#pop2').css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px", "margin-left":"125px", "margin-top":"50px" } );
			
		});
		
		$j('img.rollOver2').mouseleave(function(){
			$j('#pop2').stop().animate({ opacity: 0 }, { queue:false, duration:700 } );								  
		});
		
		$j('#pop2').mouseenter(function(){
			if($j('#pop2').css("opacity") == "0"){
				$j('#pop2').stop().animate( { top:"-10000px"}, 100 );
			} else {
				$j('#pop2').stop().animate({ opacity: 1 }, { queue:false, duration:200 } );
			}
		});
		$j('#pop2').mouseleave(function(){
			$j('#pop2').stop().animate({ opacity: 0 }, { queue:false, duration:500 } );							  
		});
		$j('#pop2 a.close').click(function(){
			$j('#pop2').stop().animate({ opacity: 0 }, { queue:false, duration:500 } );	
		});
		
		
		//Product Pages
		$j('img.prod').mouseover(function(){
			currentProdID = $j(this).attr('name');
			$j('#popProd-' + currentProdID).stop().animate({ opacity: 1 }, { queue:false, duration:500 } );
			$j('#popProd-' + currentProdID).css( { "left": (($j(this).offset()).left + ($j(this).width()).width) + "px", "top":($j(this).offset()).top + "px", "margin-left":"125px", "margin-top":"50px" } );
			
		});
		$j('img.prod').mouseleave(function(){
			$j('#popProd-' + currentProdID).stop().animate({ opacity: 0 }, { queue:false, duration:700 } );								  
		});
		$j('.popOpac').mouseenter(function(){
			if($j(this).css("opacity") == "0"){
				$j(this).stop().animate( { top:"-10000px"}, 100 );
			} else {
				$j(this).stop().animate({ opacity: 1 }, { queue:false, duration:200 } );
			}
		});
		$j('.popOpac').mouseleave(function(){
			$j('#popProd-' + currentProdID).stop().animate({ opacity: 0 }, { queue:false, duration:500 } );					  
		});
		$j('.popOpac a.close').click(function(){
			$j('#popProd-' + currentProdID).stop().animate({ opacity: 0 }, { queue:false, duration:500 } );
		});
		
		
		
			//YOUTUBE
			$j('[href^=http://www.youtube.com/watch]').each(function(index) {
    			var url = 'http://www.youtube.com/v/'+$(this).href.substring(31);
    			$(this).href = url;
  			});
   
			$j('[href^=http://www.youtube.com/v/]').fancybox({
				'width'				: 640,
				'height'			: 385,
				'autoScale'			: false,
				'type'				: 'swf'
			});

		
		  
	  }
  })
