$(document).ready
(
	function() 
	{
		// activate fancy zoom
		/*$('.video_link').fancyZoom({width:500, height:375});
		
		var strNoFlashHTML = $('#video1').innerHTML;
		
		//save the url to the swf and video
		// use hash to video1 panel for fancy zoom to work
		$('.video_link').each
		(
			function(i)
			{
				$(this).data('url', $(this).attr('href'));
				$(this).attr('href', '#video1');
			}
		);
		
		// create swf object on video link click
		$('.video_link').click
		(
			function()
			{	
				var pnlVideo1 = $('#video1');
				pnlVideo1.html("");
				doVideoSwfObject(strNoFlashHTML, $(this).data('url'));
				var strHtml = pnlVideo1.html().toLowerCase();
				
				// log flv in google analytics, only if flash is installed
				if(strHtml.indexOf('embed') > -1 || strHtml.indexOf('object') > -1)
				{
					// get the xml file's path
					var strXmlPath = "";
					var aryMatch = /xmlfile=.+\.xml/.exec($(this).data('url'));
					
					if(aryMatch)
					{
						var aryNameVal = aryMatch[0].split("=");
						strXmlPath = aryNameVal[1];
					}
					
					// track the flv 
					$.ajax
					(
						{
							type: "GET",
							url: strXmlPath,
							dataType: "xml",
							success: function(xml) 
								    {
									var strDir = "";
									
									$(xml).find('album').each
									(
										function()
										{
											strDir = $(this).attr('lgPath');
										}
									);
									
									var strVidUrl = "";
									
									$(xml).find('img').each
									(
										function()
										{
											strVidSrc = $(this).attr("src");
										}
									);
									
									trackPageView(strDir + strVidSrc);
								     }
						}
					);
				}
			}
		);
		
		// remove swf object html when closing
		$('#zoom_close').click
		(
			function()
			{
				var pnlVideo = $('#video1');
				
				if(pnlVideo.html().indexOf('embed') > -1 || pnlVideo.html().indexOf('object') > -1)
					pnlVideo.html("");
			}
		);*/
		$('.product_info_link').fancyZoom({width:650, height:650});
	
		// do sifr
		var sifrObj = new SifrObject("span.hp_avenir", "/swf/sifr_avenir_black_2.swf", "#F9F9F9", "#8BC554", "#8BC554", "transparent");
		sifrObj.replaceElement();
		
		// deallocate sifr object
		delete sifrObj;
		sifrObj = null;
		
		// setup callout targets
		setTargetEvents();
		
		// do blur on slide clicks
		$('#slides div a').click
		(
			function()
			{
				$(this).blur();
			}
		);
		
		if(window.location.hash == "#video")
			displayHomeVideo();
			
		
	}
);

function displayHomeVideo()
{
	$('#linkBar_WatchDemo a.video_link').simulate('click');
}

/*function doVideoSwfObject(strNoFlashHTML, strSwfUrl)
{
	var so = new SWFObject(strSwfUrl, "so", "500", "375", "9");
	so.addParam("quality", "best");
	so.addParam("wmode", "opaque");
	so.write("video1");        
			
	var pnlVideo = $('#video1'); 

	if(pnlVideo.html().indexOf('embed') < 0 || pnlVideo.html().indexOf('object') < 0)
		pnlVideo.html(strNoFlashHTML);
}*/

function setTargetEvents()
{
	var bIsAnimating = false;
	
	$('a.target').hover
	(
		function()
		{
			var strPnlCalloutId = "#" + $(this).attr('id').replace('target', 'callout');
			var pnlCallout = $(strPnlCalloutId);
			
			if(pnlCallout && !bIsAnimating)
			{
				bIsAnimating = true;
				
				pnlCallout.fadeIn
				(
					1000,
					function()
					{
						bIsAnimating = false;
					}
				);
			}
		},
		function()
		{
			var strPnlCalloutId = "#" + $(this).attr('id').replace('target', 'callout');
			var pnlCallout = $(strPnlCalloutId );
			
			if(pnlCallout)
			{
				pnlCallout.fadeOut(1000);
			}
		}
		
	);
	
	$('a.target').click
	(
		function()
		{
			$(this).blur();
		}
	);
}

function startSlideShow()
{
	var iTimeOut = 12000;
	
	if(arguments.length > 0 && !isNaN(parseInt(arguments[0])))
		iTimeOut = parseInt(arguments[0]);
		
	$('#previous_slide').after('<div id="nav">');
	
	$('#slides').cycle
	(
		{ 
		    fx:  'scrollLeft', 
		    timeout: iTimeOut,
		    sync: 0,
		    pause: 1,
		    pager: '#nav',
		    prev: '#previous_slide',
		    next: '#next_slide'
		}
	);
	
	$('#nav a').html("&nbsp;");
	
	$('#previous_slide').click
	(
		function()
		{
			$(this).blur();
		}
	);
	
	$('#next_slide').click
	(
		function()
		{
			$(this).blur();
		}
	);
	
	$('#nav a').click
	(
		function()
		{
			$(this).blur();
		}
	);
	
	// ie6 fixes
	if(navigator.userAgent.toLowerCase().indexOf('msie 6') > -1)
	{
		// remove the background color set in ie6 by the cycler plugin
		$('#slides div').each
		(
			function(i)
			{
				$(this).css("background-color", "transparent");
			}
		);
	}
}