/*
 *
 * jQuery initialization code for LIB-TECH.com
 *
 */


		
		var J = jQuery.noConflict();
	
		J(document).ready(function(){
			
// MEGA MENU INIT

//On Hover Over
function megaHoverOver(){
    J(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
	J(this).addClass('active'); // apply active style to parent menu
}
//On Hover Out
function megaHoverOut(){
  J(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      J(this).hide();  //after fading, hide it
  });
  J(this).removeClass('active'); // remove the active class
}

// CONFIG MEGA MENU

//Set custom configurations
var config = {
     sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)
     interval: 100, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 400, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};

J("#supernav ul li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
J("#supernav ul li").hoverIntent(config); //Trigger Hover intent with custom configurations			
			
J("#supernav ul li .sub ul:first-child").css({'background':'none', 'padding-left':'0'}); //Fade sub nav to 0 opacity on default


// CATEGORY TREE VIEW ON BLOG PAGES

J("li.widget ul:first").treeview({
								 
		persist: "location",
		collapsed: true,
		unique: false,
		animated: "fast"
	});
	

// HIDING LINKS ON SOME CATS	
	
	J("li.page-item-771 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for NPG
	J("li.page-item-819 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for SNOW rippers
	J("li.page-item-869 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for NAS rippers 
	J("li.page-item-2940 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for NAS tech
	J("li.page-item-837 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for artists 
	J("li.page-item-2294 a:first").attr( { href: 'javascript:void()' } );  //  Hiding the "main" link for ams 		
		

// Colorway Hovers

		var color0href = J('#colorway0 a').attr('href');
		var color1href = J('#colorway1 a').attr('href')
		var color2href = J('#colorway2 a').attr('href')
		var color3href = J('#colorway3 a').attr('href')
		var color4href = J('#colorway4 a').attr('href')

		  
		  J('#colorway0 a')
		  .bind('mouseenter',function() {
			J('#colorway0_img').removeClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway1_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4_img').addClass('hide');
		  })
		 .bind('mouseenter',function() {
			J('#colorway2 a').removeClass('active');
		  })
		 .bind('mouseenter',function() {
			J('#colorway3 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway1 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway0 a').addClass('active');
		  })
		  //.bind('mouseleave',function() {
		//	J('#prod_zoom_icon').attr('href', color0href);
		//  })
		  
		  
		
		  J('#colorway1 a')
		  .bind('mouseenter',function() {
			J('#colorway1_img').removeClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway0_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4_img').addClass('hide');
		  })
		 .bind('mouseenter',function() {
			J('#colorway2 a').removeClass('active');
		  })
		 .bind('mouseenter',function() {
			J('#colorway3 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway0 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway1 a').addClass('active');
		  })
		//  .bind('mouseleave',function() {
		//	J('#prod_zoom_icon').attr('href', color1href);
		//  })
		  
		  
		  
		  J('#colorway2 a')
		  .bind('mouseenter',function() {
			J('#colorway2_img').removeClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway0_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway1_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4_img').addClass('hide');
		  })
		 .bind('mouseenter',function() {
			J('#colorway0 a').removeClass('active');
		  })
		 .bind('mouseenter',function() {
			J('#colorway1 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway2 a').addClass('active');
		  })
		//  .bind('mouseleave',function() {
		//	J('#prod_zoom_icon').attr('href', color2href);
		//  })
		  
		  
		  
		  
		  J('#colorway3 a')
		  .bind('mouseenter',function() {
			J('#colorway3_img').removeClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway0_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway1_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway4_img').addClass('hide');
		  })
		 .bind('mouseenter',function() {
			J('#colorway0 a').removeClass('active');
		  })
		 .bind('mouseenter',function() {
			J('#colorway1 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway4 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway3 a').addClass('active');
		  })
		//  .bind('mouseleave',function() {
		//	J('#prod_zoom_icon').attr('href', color3href);
		//  })
		  
		  
		  
		   J('#colorway4 a')
		  .bind('mouseenter',function() {
			J('#colorway4_img').removeClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway0_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway1_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2_img').addClass('hide');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3_img').addClass('hide');
		  })
		 .bind('mouseenter',function() {
			J('#colorway0 a').removeClass('active');
		  })
		 .bind('mouseenter',function() {
			J('#colorway1 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway2 a').removeClass('active');
		  })
		  .bind('mouseenter',function() {
			J('#colorway3 a').removeClass('active');
		  })
		  .bind('mouseleave',function() {
			J('#colorway4 a').addClass('active');
		  })
		//  .bind('mouseleave',function() {
		//	J('#prod_zoom_icon').attr('href', color4href);
		//  })
		  
		  
		  

						 
		// FancyBox

		J.fn.getTitle = function() {
			var arr = J("a.fancybox");
			J.each(arr, function() {
				var title = J(this).children("img").attr("title");
				if (title =="") {title = J(this).next().children("p").html()}; // create title from PWA + PHP captions
				if (title == "") {title = J(this).attr("title")}; // if nothing else, set title to that of the page
				J(this).attr('title',title);
			})
		}

		// Supported file extensions
		var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

	
		J(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

		//J(thumbnails).addClass("fancybox").attr("rel","fancybox");

			J("a.fancybox").fancybox({
			'autoScale': false,
			'padding': 10,
			'zoomOpacity': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'zoomSpeedChange': 300,
			'overlayShow': true,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'frameWidth':  560,
			'frameHeight':  340,
			'callbackOnStart': null,
			'callbackOnShow': null,
			'callbackOnClose': null,
			'centerOnScroll': false,
			'title'			: this.title,
			'titlePosition'	:	'over',
			'onComplete'	:	function() {
			J("#fancybox-wrap").hover(function() {
			J("#fancybox-title").show();
			}, function() {
			J("#fancybox-title").hide();
			});
		}

		});
			
			J("a.fancybox-notitle").fancybox({
			'autoScale': false,
			'padding': 10,
			'zoomOpacity': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'zoomSpeedChange': 300,
			'overlayShow': true,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'frameWidth':  560,
			'frameHeight':  340,
			'callbackOnStart': null,
			'callbackOnShow': null,
			'callbackOnClose': null
	
			
		});
			
		J("a.more_info").fancybox({						   
				'hideOnContentClick': false,
				'autoDimensions' : true,
				'padding': 20
		});
		
		J("a.iframe").fancybox({
		'hideOnContentClick': false,
		'width'				: 660,
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
		
			
		J("a.get_specs").fancybox({
		'hideOnContentClick': false,
		'width'				: 980,
		'height'			: 500,
        'autoScale'     	: false,
		'overlayColor': "#333333",
		'overlayOpacity': 0.5,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'padding'			: 0
	});
		
		J("a.tooltip").fancybox({
		'hideOnContentClick': false,
		'width'				: 400,
		'height'			: 260,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'ajax',
		'padding'			: 0
	});
	
		J("a.tooltip-vid").fancybox({
		'hideOnContentClick': false,
		'width'				: 720,
		'height'			: 480,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'padding'			: 0
	});


		J("a.open-vid").fancybox({
		'hideOnContentClick': false,
		'width'				: 720,
		'height'			: 410,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titleShow'			: false,
		'padding'			: 0
	});

		J("a.bio-vid").fancybox({
		'hideOnContentClick': false,
		'width'				: 720,
		'height'			: 410,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titleShow'			: false,
		'padding'			: 0
	});
		
		J("a.shop_online").fancybox({
		'hideOnContentClick': false,
		'width'				: 400,
		'height'			: 260,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'padding'			: 0
	});
		
		J("a.acc_shop_online").fancybox({
		'hideOnContentClick': false,
		'width'				: 400,
		'height'			: 260,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titleShow'				: false,
		'padding'			: 0
	});
		
	});
	
	function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
