// JavaScript Document

$(document).ready(function(){
	//uses bPopup to enlarge thumbs ID'd as popsmallN where N = integer and corresponds to large picture called poplargeN
	$("img.popcamera").bind('click', function(e){
		var popImageNumber = null;
		var targetId = e.target.getAttribute('id');
		if (targetId.indexOf('popsmall') != -1) {
			popImageNumber = targetId.substr(8);
		} else if (targetId.indexOf('popcamera') != -1) {
			popImageNumber = targetId.substr(9);
		}
		var largePopElement = "div#poplarge" + popImageNumber;
      $(largePopElement).openPopup({amsl:0, opacity:0.8});
   });
	
/*	$("img.popcamera").bind('click', function(e){
		var popImageNumber = e.target.getAttribute("id").substr(8);
		var largePopElement = "div#poplarge" + popImageNumber;
      $(largePopElement).openPopup({amsl:0, opacity:0.8});
   });*/	

/*	$("img.popcamera").bind('click', function(e){
		var popImageNumber = e.target.getAttribute("id").substr(9);
		var largePopElement = "div#poplarge" + popImageNumber;
      $(largePopElement).openPopup({amsl:0, opacity:0.8});
	  $(largePopElement + " input.bClose").css("float", "right");
   });*/
	
	//uses superfish plugin for drop down menu navigation
	$('.nav').superfish({
    delay: 800
	});
	/*$('.nav li:has(ul)').find('a:first').addClass('sub');
  	$('.nav ul li:has(ul)').find('a:first').removeClass('sub').addClass('subsub');*/
	
	//qtips
	$.fn.qtip.styles.nbstyle = { // Last part is the name of the style
	   width: {min: 100},
	   background: '#E5223F',
	   color: '#FFE1A6',
	   textAlign: 'center',
	   border: {
		  width: 1,
		  radius: 3,
		  color: '#821323'
	   },
	   tip: 'bottomLeft',
	   target: 'topRight',
	   name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
	
	$('img.popsmall, img.popcamera').qtip(
   {
      style: { name: 'nbstyle', tip: true },
	  content: 'Click to view image',
	  position: {
		  corner: {
					target: 'topMiddle',
					tooltip: 'bottomLeft'
		  },
		  adjust: { y: -10,
		  			screen: true,
		  			scroll: false}
	  }
   });
	
	$('div#header_NB_Icon').qtip(
	{
      style: { name: 'nbstyle', tip: true },
	  content: 'Click to visit Noteable Blends, our parent company, for some of the world\'s finest and rarest coffees.',
	  position: {
		  corner: {
					target: 'topMiddle',
					tooltip: 'bottomRight'
		  },
		  adjust: { y: -10,
		  			screen: true,
		  			scroll: false}
	  }
   });							 
	
	$('.emailHotspot').click(function(e) {
		var addressee = '';
		var mailtoHref = '';
		var contact = $(e.currentTarget).attr("id");
		switch (contact){
			case "contact_scott":
				addressee = 'scottdavis';
				break;
			case "contact_biz":
				addressee = 'biz';
				break;
			case "contact_webmaster":
				addressee = 'webmaster';
				break;
		}
		mailtoHref = 'mailto:' + addressee + '@daviscoffeeclub.com';
		window.location.href = mailtoHref;
		return false;
	});
});
