jQuery.noConflict();

jQuery(document).ready(function() 
{
		
	// Slider Homepage
	if(jQuery('#slider').length)
	{
		jQuery('#slider').cycle({
			fx: 'fade',
			speed: 2000,
			timeout: 5000,
			pager: '#controls',
			slideExpr: '.panel'
		});
	}




	if(jQuery('li.home1').length)
	{
		jQuery("a[rel^='prettyPhoto']").prettyPhoto({

			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			//default_width: 500,
			default_width: 300,
			theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: true, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			//wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true /* Automatically start videos: True/False */
			//modal: false, /* If set to true, only the close button will close the window */
			//overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			//keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
		
		});
	}


	if(jQuery('a.videobutton').length)
	{
		jQuery("a[rel^='prettyPhoto']").prettyPhoto({

			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			//default_width: 500,
			default_height: 500,
			theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: true, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			//wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true /* Automatically start videos: True/False */
			//modal: false, /* If set to true, only the close button will close the window */
			//overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			//keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
		
		});
	}



	jQuery('div#video-popup').hide();

	jQuery('a#videolaunch').toggle(function()
	{
		jQuery("html, body").animate({scrollTop:"0px"}, 500, 'easeOutQuad', function(){ jQuery('div#video-popup').show(); });
		return false;
	}, function(){
	
		jQuery('div#video-popup').hide();
		
	});



	jQuery('div#video-popup div#closeoverlay a').click(function()
	{
		jQuery(this).parent().parent().hide();
	});
			





	// Product Image Zoom
	if(jQuery('img.jqzoom').length)
	{
		jQuery("img.jqzoom").jqueryzoom(
		{
			xzoom: 585, //zooming div default width(default width value is 200)
			yzoom: 385, //zooming div default width(default height value is 200)
			offset: -70  //zooming div default offset(default offset value is 10)
			//position: "right" //zooming div position(default position value is "right")
		});
	}



	// Category Description Expand
		
	if(jQuery('div.categoryexpand').length)
	{
		//if(jQuery("div.categoryexpand p + p").length)
		//{
			// get total height
			var fullheight = jQuery("div.categoryexpand").height();

			// get height of first p (plus a bit more)
			var pheight = jQuery("div.categoryexpand p:first").height() + 50;

			// hide all p's after the first
			jQuery("div.categoryexpand p + p").hide();

			// set height of div to that of first p
			jQuery("div.categoryexpand").css({"height":pheight});


			jQuery('span#readmore').toggle(function()
			{
				jQuery("div.categoryexpand").animate({"height":fullheight}, {queue:false, duration:500});
				jQuery("div.categoryexpand p + p").fadeIn();
			},
			function()
			{
				jQuery("div.categoryexpand").animate({'height':pheight}, {queue:false, duration: 500});
				jQuery("div.categoryexpand p + p").fadeOut();
			});
		//}
	}



	jQuery("#more-views ul li a").click(function()
	{
		
		var thethumbsrc = jQuery(this).attr('href');
		var thefullsrc	= jQuery(this).attr('rel');

		//alert(thehref);

		jQuery('#mainimage img#primary').attr('src', thethumbsrc);

		jQuery('#mainimage img#primary').attr('alt', thefullsrc);

		return false;

	});


	if(jQuery('div#idtabs').length)
	{
		jQuery("#idtabs ul").idTabs(); 
	}


	// On document ready hide all images first
    jQuery("#imageShowcase img").hide();
    jQuery("#productImgDefault").show();
    


	jQuery("#attribute80").live('change', function() 
	{
		//var theval = jQuery(this).val();

		var thevaltext = jQuery(':selected', this).text().toLowerCase().replace(' / ', ' ').split(' ').join('-');

		var newobj = jQuery("#productImg" + thevaltext);
		
		var newsrc = newobj.attr('src');

		var fullsrc	= newobj.attr('rel');



		//alert(newsrc);
		
		jQuery("#mainimage img#primary").attr('src', newsrc);
		jQuery('#mainimage img#primary').attr('alt', fullsrc);

	});





});
