$(document).ready(function() {
	$('.scroll-pane').jScrollPane({showArrows: true});
	$('#searchsubmit').attr("value","GO");
	$('#s').attr("value","Search");
	$("#s").focus(function(){
		if (this.value=="Search") this.value="";
        }
		);
    $("#s").blur(function(){
		if (this.value=="") this.value="Search";
        }
		);
	jQuery('#slider').nivoSlider({
		effect:'fade',
		animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:false, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
	});

	$('#videos a[href="#show_tab"]').click(function() { 
		var target=$(this).attr("rel");
		$('#videos div.video_tab').hide();
		$('#videos div#'+target).toggle();
		$('#videos li').removeClass("active");
		$(this).parent().addClass("active");

	});
	$('#videos div.video_tab').hide();
	$('#videos div#tab_product').show();
	$('.video_tabs li:first-child').addClass('active');

	$('.video_tab ul li a').click(function() { 
		$('.video_tab ul li').removeClass('active');
		$(this).parent().addClass("active");
		var video_url=$(this).attr("rel");
		var video_type=$(this).attr("href");
		if (video_url!='')
		{
			//alert(video_type+":  "+video_url);
			if (video_type=="#youtube")
			{
				show_youtube(video_url,1);
				return true;
			}
			if (video_type=="#video")
			{
				show_video(video_url,true);
				return true;
			}
		

		}
	});
	$('a.video_link').click(function() { 
		var video_url=$(this).attr("rel");
		var video_type=$(this).attr("href");
		if (video_url!='')
		{
			//alert(video_type+":  "+video_url);
			if (video_type=="#youtube")
			{
				show_youtube(video_url,1);
				return true;
			}
			if (video_type=="#video")
			{
				show_video(video_url,true);
				return true;
			}
		

		}
	});
	var video_url=$('.video_tab:first a').attr("rel");
	var video_type=$('.video_tab:first a').attr("href");
		if (video_url!='')
			{
			//alert(video_type+":  "+video_url);
			if (video_type=="#youtube")
			{
				show_youtube(video_url,0);
			}
			if (video_type=="#video")
			{
				show_video(video_url,false);
			}
		

		}

	$('#video_spot2 a.video_link').ready(function() { 
	var	work_on=$('#video_spot2 a.video_link');
	var video_url=$(work_on).attr("rel");
	var video_type=$(work_on).attr("href");
		if (video_url!='')
			{
			if (video_type=="#youtube")
				{
					$(work_on).parent().html('<object width="440" height="300"><param name="movie" value="'+video_url+'?version=3&amp;hl=en_US&amp;wmode=transparent"></param><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+video_url+'?version=3&amp;hl=en_US&amp;wmode=transparent" wmode="transparent" type="application/x-shockwave-flash" width="425" height="349" allowscriptaccess="always" allowfullscreen="true"></embed></object>');
				}
			if (video_type=="#video")
				{
					var video_spot=document.getElementById('video_spot2');
					video_spot.innerHTML='<div class="video_frame"><div id="mediaplayer">2</div></div>';

					jwplayer("mediaplayer").setup({
							flashplayer: "http://pacificid.curvine.com/videos/player.swf",
							file: "/"+video_url,
							image: 'http://pacificid.curvine.com/videos/vid_th.png',
							autostart:false
						});

				}
			}
	});


});
function show_youtube(v_url,auto_play) {
	//video_spot.innerHTML='<iframe width="440" height="300" src="'+v_url+'?autoplay='+auto_play+'&amp;wmode=transparent" frameborder="0" allowfullscreen></iframe>';
	$('#video_spot').html('<object width="440" height="300"><param name="movie" value="'+v_url+'?version=3&amp;hl=en_US&amp;wmode=transparent"></param><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+v_url+'?version=3&amp;hl=en_US&amp;wmode=transparent" wmode="transparent" type="application/x-shockwave-flash" width="425" height="349" allowscriptaccess="always" allowfullscreen="true"></embed></object>');
}
function show_video(v_url,auto_play) {
	var video_spot=document.getElementById('video_spot');
	video_spot.innerHTML='<div class="video_frame"><div id="mediaplayer">2</div></div>';

	jwplayer("mediaplayer").setup({
			flashplayer: "http://pacificid.curvine.com/videos/player.swf?"+ (Math.round(1000 * Math.random())),
			file: "/"+v_url+"?"+ (Math.round(1000 * Math.random())),
			image: 'http://pacificid.curvine.com/videos/vid_th.png',
			autostart:auto_play
		});


}
