/*	ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function M(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i);a.rel=a.rel||i.rel;a.href=a.href||i.href;a.title=a.title||i.title}function Z(b){i=b;a=c.extend({},c(i).data(q));Y();if(a.rel&&a.rel!=="nofollow"){g= c(".cboxElement").filter(function(){return(c(this).data(q).rel||this.rel)===a.rel});j=g.index(i);if(j<0){g=g.add(i);j=g.length-1}}else{g=c(i);j=0}if(!B){C=B=n;N=i;N.blur();c(document).bind("keydown.cbox_close",function(d){if(d.keyCode===27){d.preventDefault();e.close()}}).bind("keydown.cbox_arrows",function(d){if(g.length>1)if(d.keyCode===37){d.preventDefault();D.click()}else if(d.keyCode===39){d.preventDefault();E.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",e.close);c.event.trigger(aa); a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w=r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");e.position(0);O&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}P.add(D).add(E).add(t).add(Q).hide();R.html(a.close).show();e.slideshow();e.load()}var q="colorbox",F="hover",n=true,e,x=c.browser.msie&&!c.support.opacity,O=x&&c.browser.version<7,aa="cbox_open",H="cbox_load",S= "cbox_complete",T="resize.cbox_resize",s,k,u,p,U,V,W,X,g,m,l,I,J,K,Q,P,t,E,D,R,y,z,v,w,i,N,j,a,B,C,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n, slideshow:false,slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};e=c.fn.colorbox=function(b,d){var h=this;if(!h.length)if(h.selector===""){h=c("<a/>");b.open=n}else return this;h.each(function(){var f=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,f).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(h);return this};e.init=function(){function b(d){return c('<div id="cbox'+ d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s=b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),J=b("LoadingOverlay"),K=b("LoadingGraphic"),Q=b("Title"),P=b("Current"),t=b("Slideshow"),E=b("Next"),D=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"}); I=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");c("body").prepend(s,k.append(u,I));if(x){k.addClass("cboxIE");O&&s.css("position","absolute")}p.children().bind("mouseover mouseout",function(){c(this).toggleClass(F)}).addClass(F);y=U.height()+X.height()+p.outerHeight(n)-p.height();z=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":y,"padding-right":z}).hide();E.click(e.next);D.click(e.prev);R.click(e.close);p.children().removeClass(F); c(".cboxElement").live("click",function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};e.position=function(b,d){function h(A){U[0].style.width=X[0].style.width=p[0].style.width=A.style.width;K[0].style.height=J[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=A.style.height}var f=m.height();f=Math.max(f-a.h-v-y,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-z,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()=== a.h+v?0:b;u[0].style.width=u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:f,left:o},{duration:b,complete:function(){h(this);C=false;u[0].style.width=a.w+w+z+"px";u[0].style.height=a.h+v+y+"px";d&&d()},step:function(){h(this)}})};e.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function h(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function f(G){e.position(G,function(){if(B){if(x){A&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+a.href+"' "+(x?"allowtransparency='true'":"")+" />");l.show();Q.show().html(a.title);if(g.length>1){P.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,g.length)).show();E.html(a.next).show();D.html(a.previous).show();a.slideshow&&t.show()}J.hide();K.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(L,1,function(){x&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){e.position(0)})}})}if(B){var o,A,L=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(I).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});O&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(L,0,function(){f(0)})||f(L);if(a.preloading&&g.length>1){b=j>0?g[j-1]:g[g.length-1];o=j<g.length-1?g[j+1]:g[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;M(o)&&c("<img />").attr("src",o);M(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());e.position(L)},1)}};e.load=function(){var b,d,h,f=e.resize;C=n;i=g[j];a=c.extend({},c(i).data(q)); Y();c.event.trigger(H);a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-y:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-z:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-z;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-y;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href;J.show();K.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(H+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); f(c(b))}else if(a.iframe)f(" ");else if(a.html)f(a.html);else if(M(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){h=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;h()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;h()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";f(d);g.length>1&&c(d).css({cursor:"pointer"}).click(e.next); if(x)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(I).load(b,function(o,A){A==="success"?f(this):f(c("<p>Request unsuccessful.</p>"))})};e.next=function(){if(!C){j=j<g.length-1?j+1:0;e.load()}};e.prev=function(){if(!C){j=j>0?j-1:g.length-1;e.load()}};e.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){h=setTimeout(e.next,a.slideshowSpeed)}).bind(H,function(){clearTimeout(h)}).one("click",function(){d();c(this).removeClass(F)});k.removeClass(f+ "off").addClass(f+"on")}var d,h,f="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(h);k.removeClass(f+"off "+f+"on")});d=function(){clearTimeout(h);t.text(a.slideshowStart).unbind(S+" "+H).one("click",function(){b();h=setTimeout(e.next,a.slideshowSpeed);c(this).removeClass(F)});k.removeClass(f+"on").addClass(f+"off")};if(a.slideshow&&g.length>1)a.slideshowAuto?b():d()};e.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);B=false;c(document).unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){c("#colorbox iframe").attr("src","about:blank");l.remove();k.css({opacity:1});try{N.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};e.element=function(){return c(i)};e.settings=$;c(e.init)})(jQuery);
/* site js */
var $j = jQuery.noConflict();

$j(document).ready(function() {
	var customGoggles, customQty, defaultChoices, dvdSelect, goggleSelect, defaultDvd, phoneCondomQty, toTheTop, optionsToTheTop = '',
		 checksWidth = 14,
		 dvdMinuses = $j('.bundleOptions#dvdSelect .bOpt .controls .minus'), dvdMinusesDupe = $j('.bundleOptions#dvdSelect .bOpt .controlsDupe .minusDupe'),
		 dvdPluses = $j('.bundleOptions#dvdSelect .bOpt .controls .plus'),  dvdPlusesDupe = $j('.bundleOptions#dvdSelect .bOpt .controlsDupe .plusDupe'),
		 goggleMinuses = $j('.bundleOptions#goggleSelect .bOpt .controls .minus'),
		 gogglePluses = $j('.bundleOptions#goggleSelect .bOpt .controls .plus');
	
	if($j('.bundleWrap').length) {
		$j('.optionsHeader').addClass('s');
	}
	
	//configurator magic
	if((dvdSelect = $j('#dvdSelect')).length) {
		function updateDvds() {
			var dvds = $j('.bundleOptions#dvdSelect .bOpt'),
				 dvdSelects = $j('.dvdOptionsMove select'),
				 dvdsSelected = [],
				 dvdsSelectedCount = 0,
				 liText = '',
				 maxDvds = dvdSelects.length;
			
			$j('.bundleOptions#dvdSelect .bOpt').each(function(i, el) {
				var count = parseInt($j(el).find('.controls .checksWrap .checks').css('width')) / checksWidth;
				if(count) {
					$j(dvds[i]).addClass('a');
					for(x = 0; x < count; x++) {
						dvdsSelected[dvdsSelectedCount++] = $j(el).attr('rel');
						$j(dvdMinuses[i]).removeClass('mdis');
						//$j(dvdMinusesDupe[i]).removeClass('mdis');
					}
				} else {
					$j(dvds[i]).removeClass('a');
					$j(dvdMinuses[i]).addClass('mdis');
					//$j(dvdMinusesDupe[i]).addClass('mdis');
				}
			});
			if(maxDvds == dvdsSelected.length) {
				$j(dvds).each(function(i, el) {
					if(!$j(el).hasClass('a')) {
						$j(el).addClass('disabled').animate({ 'opacity': 0.3 }, 1000);
					} else {
						$j(el).removeClass('disabled').animate({ 'opacity': 1 }, 0);
					}
				});
				$j(dvdPluses).addClass('pdis');
				//$j(dvdPlusesDupe).addClass('pdis');
			} else {
				$j(dvds).removeClass('disabled').animate({ 'opacity': 1 }, 1000);
				$j(dvdPluses).removeClass('pdis');
				//$j(dvdPlusesDupe).removeClass('pdis');
			}
			
			$j(dvdSelects).each(function(i, el) {
				if(dvdsSelected[i]) {
					$j(el).find('option[rel=' + dvdsSelected[i] +']').attr('selected', true);
					liText = $j(el).find('option[rel=' + dvdsSelected[i] +']').html();
				} else {
					$j(el).find('option[value=]').attr('selected', true);
					liText = 'Select DVD Below';
				}
				$j($j(dvdSelect).find('ul li')[i]).html(liText);
			});
		}
		
		$j('.dvdOptionsMove').each(function(i, el) {
			//$j(el).appendTo($j(dvdSelect));
			if(defaultDvd = $j(el).find('select option:selected')) {
				var cur = $j('.bOpt#dvd' + $j(defaultDvd).attr('rel') + ' .controls .checksWrap .checks'),
					 newWidth = parseInt($j(cur).css('width')) + checksWidth;
				$j(cur).css('width', newWidth);
				//$j('.bOpt#dvd' + $j(defaultDvd).attr('rel') + ' .controlsDupe .checksWrapDupe .checksDupe').css('width', newWidth);
			}
			$j('<li>Select DVD Below</li>').appendTo($j(dvdSelect).find('ul'));
		});
		
		$j(dvdMinuses).each(function(i, el) {
			$j(el).click(function() {
				if(!$j(el).hasClass('mdis')) {
					var checks = $j(el).prev('.checksWrap').find('.checks'),
						 newWidth = parseInt($j(checks).css('width')) - checksWidth;
					$j(checks).css('width', newWidth);
					//$j(el).parent('.controls').next('.dvdHover').find('.checksDupe').css('width', newWidth);
					updateDvds();
				}
			});
		});
		
		/*
		$j(dvdMinusesDupe).each(function(i, el) {
			$j(el).click(function() {
				$j(dvdMinuses[i]).click();
			});
		});
		*/
		
		$j('.dvdImg').each(function(i, el) {
			$j(el).click(function() {
				$j(el).next('.dvdTitle').next('.controls').find('.plus').trigger('click');
			});
		});
		
		$j(dvdPluses).each(function(i, el) {
			$j(el).click(function() {
				if(!$j(el).hasClass('pdis')) {
					var checks = $j(el).prev('.minus').prev('.checksWrap').find('.checks'),
						 newWidth = parseInt($j(checks).css('width')) + checksWidth;
					$j(checks).css('width', newWidth);
					//$j(el).parent('.controls').next('.dvdHover').find('.checksDupe').css('width', newWidth);
					updateDvds();
				}
			});
		});
		
		/*
		$j(dvdPlusesDupe).each(function(i, el) {
			$j(el).click(function() {
				$j(dvdPluses[i]).click();
			});
		});
		*/
		
		$j('.bundleOptions#dvdSelect .bOpt .dvdImg.h, .bundleOptions#dvdSelect .bOpt .controls, .bundleOptions#dvdSelect .bOpt .dvdTitle').each(function(i, el) {
			var hover = $j(el).parent('.bOpt').find('.dvdHover');
			$j(el).mouseenter(function() {
				if(!$j(el).parent('.bOpt').hasClass('disabled')) {
					$j(hover).fadeIn(0);
				}
			});
			$j(el).mouseleave(function() {
				$j(hover).fadeOut(0);
			});
		});
		
		$j('.dvdSlide').slideUp(0);
		
		$j('.optionsHeader label').addClass('s');
		
		updateDvds();
	}
	
	if((goggleSelect = $j('#goggleSelect')).length) {
		function updateGoggles() {
			var goggles = $j('.bundleOptions#goggleSelect .bOpt'),
				 goggleSelects = $j('.goggleOptionsMove select'),
				 gogglesSelected = [],
				 gogglesSelectedCount = 0,
				 liText = '',
				 maxGoggles = goggleSelects.length;
			
			$j('.bundleOptions#goggleSelect .bOpt').each(function(i, el) {
				var count = parseInt($j(el).find('.controls .checksWrap .checks').css('width')) / checksWidth;
				if(count) {
					$j(goggles[i]).addClass('a');
					for(x = 0; x < count; x++) {
						gogglesSelected[gogglesSelectedCount++] = $j(el).attr('rel');
						$j(goggleMinuses[i]).removeClass('mdis');
					}
				} else {
					$j(goggles[i]).removeClass('a');
					$j(goggleMinuses[i]).addClass('mdis');
				}
			});
			if(maxGoggles == gogglesSelected.length) {
				$j(goggles).each(function(i, el) {
					if(!$j(el).hasClass('a')) {
						$j(el).addClass('disabled').animate({ 'opacity': 0.3 }, 1000);
					} else {
						$j(el).removeClass('disabled').animate({ 'opacity': 1 }, 0);
					}
				});
				$j(gogglePluses).addClass('pdis');
			} else {
				$j(goggles).removeClass('disabled').animate({ 'opacity': 1 }, 1000);
				$j(gogglePluses).removeClass('pdis');
			}
			
			$j(goggleSelects).each(function(i, el) {
				if(gogglesSelected[i]) {
					$j(el).find('option[rel=' + gogglesSelected[i] +']').attr('selected', true);
					liText = $j(el).find('option[rel=' + gogglesSelected[i] +']').html();
				} else {
					$j(el).find('option[value=]').attr('selected', true);
					liText = 'Select Goggle Below';
				}
				$j($j(goggleSelect).find('ul li')[i]).html(liText);
			});
			
			if($j('.tvlLenseSelectOptionsMove').length) {
				var lenseSelect = $j('.tvlLenseSelectOptionsMove select')[0],
					 goggleId = $j(goggleSelects[0]).val();
				
				if(goggleId) {
					var goggleLabel = $j($j('option[value=' + goggleId + ']')[0]).text().replace(/.*\s(.*)\sLabel.*/g, '$1');
					$j(".tvlLenseSelectOptionsMove option:contains('" + goggleLabel + "')").attr('selected', true);
				}
			}
		}
		
		$j('.goggleOptionsMove').each(function(i, el) {
			//$j(el).appendTo($j(goggleSelect));
			if(defaultGoggle = $j(el).find('select option:selected')) {
				var cur = $j('.bOpt#goggle' + $j(defaultGoggle).attr('rel') + ' .controls .checksWrap .checks'),
					 newWidth = parseInt($j(cur).css('width')) + checksWidth;
				$j(cur).css('width', newWidth);
			}
			$j('<li>Select Goggle Below</li>').appendTo($j(goggleSelect).find('ul'));
		});
		
		$j(goggleMinuses).each(function(i, el) {
			$j(el).click(function() {
				if(!$j(el).hasClass('mdis')) {
					var checks = $j(el).prev('.checksWrap').find('.checks'),
						 newWidth = parseInt($j(checks).css('width')) - checksWidth;
					$j(checks).css('width', newWidth);
					updateGoggles();
				}
			});
		});
		
		$j('.goggleImg').each(function(i, el) {
			$j(el).click(function() {
				$j(el).next('.goggleTitle').next('.controls').find('.plus').trigger('click');
			});
		});
		
		$j(gogglePluses).each(function(i, el) {
			$j(el).click(function() {
				if(!$j(el).hasClass('pdis')) {
					var checks = $j(el).prev('.minus').prev('.checksWrap').find('.checks'),
						 newWidth = parseInt($j(checks).css('width')) + checksWidth;
					$j(checks).css('width', newWidth);
					updateGoggles();
				}
			});
		});
		
		$j('.goggleSlide').slideUp(0);
		
		$j('.optionsHeader label').addClass('s');
		
		updateGoggles();
	}
	
	if(defaultChoices = $j('option.default')) {
		var goggle, dvd = '';
		$j('.optionsHeader label.standard').click(function() {
			$j('.controls .checksWrap .checks').css('width', '0px');
			$j(defaultChoices).each(function(i, el) {
				if(goggle = $j('#goggle' + $j(el).attr('rel'))[0]) {
					$j(goggle).find('.checks').css('width', parseInt($j(goggle).find('.checks').css('width')) + checksWidth);
				}
				if(dvd = $j('#dvd' + $j(el).attr('rel'))[0]) {
					$j(dvd).find('.checks').css('width', parseInt($j(dvd).find('.checks').css('width')) + checksWidth);
				}
			});
			if(goggleSelect.length) { updateGoggles(); }
			if(dvdSelect.length) { updateDvds(); }
			$j('.goggleSlide').slideUp(1000);
			$j('.dvdSlide').slideUp(1000);
			$j('.optionsHeader label').removeClass('a');
			$j(this).addClass('a');
			$j('.customize').removeClass('a');
		});
	}
	
	$j('.optionsHeader label.custom').click(function() {
		$j('.optionsHeader label').removeClass('a');
		$j(this).addClass('a');
		$j('.goggleSlide').slideDown(1000);
		$j('.dvdSlide').slideDown(1000);
		$j('.customize').addClass('a');
	});
	
	$j('.dvdCustomize').click(function() {
		if($j('.dvdSlide').css('display') == 'none') {
			$j(this).addClass('a');
			$j('.dvdSlide').slideDown(1000);
			$j('.optionsHeader label').removeClass('a');
			$j('.optionsHeader label.custom').addClass('a');
		} else {
			$j(this).removeClass('a');
			$j('.dvdSlide').slideUp(1000);
		}
	});
	
	$j('.goggleCustomize').click(function() {
		if($j('.goggleSlide').css('display') == 'none') {
			$j(this).addClass('a');
			$j('.goggleSlide').slideDown(1000);
			$j('.optionsHeader label').removeClass('a');
			$j('.optionsHeader label.custom').addClass('a');
		} else {
			$j(this).removeClass('a');
			$j('.goggleSlide').slideUp(1000);
		}
	});
	
	//phone condom javascript
	if($j('#phoneCondomSelect').length) {
		$j('#phoneCondomSelect select').change(function() {
			$j('#phoneCondomSelect select option').each(function(i, el) {
				if($j(el).attr('selected')) {
					$j($j('.phoneCondomOptionsMove option')[i]).attr('selected', true);
					$j($j('.phoneCondomOptionsMove option')[i]).trigger('change');
				}
			});
		});
	}
	
	//move DVDs and Goggles to top of the list
	if(toTheTop = $j('.bundleWrap.toTheTop')) {
		$j(toTheTop).each(function(i, el) { if($j(el).find('#phoneCondomSelect').length) { $j(el).prependTo($j($j('#product-options-wrapper dl')[0])); } });
		$j(toTheTop).each(function(i, el) { if($j(el).find('#tvlLenseSelect').length) { $j(el).prependTo($j($j('#product-options-wrapper dl')[0])); } });
		$j(toTheTop).each(function(i, el) { if($j(el).find('#dvdSelect').length) { $j(el).prependTo($j($j('#product-options-wrapper dl')[0])); } });
		$j(toTheTop).each(function(i, el) { if($j(el).find('#goggleSelect').length) { $j(el).prependTo($j($j('#product-options-wrapper dl')[0])); } });
	}
	
	if(optionsToTheTop = $j('.optionToTheTop')) {
		$j(optionsToTheTop).appendTo($j('.productInfo')[0]);
	}
	
	//custom goggles configurator
	if(customGoggles = $j('.customGogglesWrap .bundleWrap')) {
		$j(customGoggles).each(function(i, el) {
			$j($j(el).attr('rel').split(',')).each(function(ri, rel) {
				$j('.cGogglesOption[rel=' + rel + ']').appendTo($j(el).find('.bundleInfo'));
			});
			
			var displayQty = $j(el).find('.qtyInputDisplay');
			
			$j(displayQty).each(function(i, el) {
				var selectBox = $j('#bundle-option-' + $j(el).attr('rel'));
				var actualQty = $j('#bundle-option-' + $j(el).attr('rel') + '-qty-input');
				
				$j(el).keyup(function(e) {
					if(parseInt($j(el).val()) > 0) {
						$j($j(selectBox).find('option')[1]).attr('selected', true);
						$j($j(selectBox).find('option')[1]).trigger('change');
						$j(actualQty).val($j(el).val());
						$j(actualQty).trigger('blur');
					} else {
						$j($j(selectBox).find('option')[0]).attr('selected', true);
						$j($j(selectBox).find('option')[1]).trigger('change');
					}
					
					//update overall total
					var totalQty = 0;
					$j('.qtyInputDisplay').each(function(iT, elT) {
						totalQty+= Math.abs($j(elT).val());
					});
					$j($j('.customGoggleQty')[0]).val(totalQty);
					$j($j('.customGoggleQty')[0]).trigger('change');
					$j($j('.customGoggleQty')[0]).trigger('blur');
				});
			});
		});
		
		$j($j('.customGoggleQty')[0]).change(function() {
			var totalQty = $j(this).val(), gogglePrice = 0;
			if(totalQty < 5) {
				gogglePrice = 149;
			} else if(totalQty >= 5 && totalQty < 9) {
				gogglePrice = 129;
			} else if(totalQty >= 9) {
				gogglePrice = 116;
			}
			
			$j($j('.price-as-configured .price')[0]).text('$' + (totalQty * gogglePrice) + '.00');
		});
		
		if(customGoggles.length) {
			$j($j('.price-as-configured .price')[0]).text('$0.00');
		}
	}
	
	if(customQty = $j('.customQty')) {
		$j(customQty).each(function(i, el) {
			var displayQty = $j(el).find('.qtyInputDisplay');
			var selectBox = $j('#bundle-option-' + $j(displayQty).attr('rel'));
			var actualQty = $j('#bundle-option-' + $j(displayQty).attr('rel') + '-qty-input');
			
			$j(displayQty).keyup(function(e) {
				if(parseInt($j(displayQty).val()) > 0) {
					$j($j(selectBox).find('option')[1]).attr('selected', true);
					$j($j(selectBox).find('option')[1]).trigger('change');
					$j(actualQty).val($j(displayQty).val());
					$j(actualQty).trigger('blur');
				} else {
					$j($j(selectBox).find('option')[0]).attr('selected', true);
					$j($j(selectBox).find('option')[1]).trigger('change');
				}
			});
		});
	}
	
	$j('.hideMe').css({ 'position': 'absolute', 'top': '-5000px', 'left': '-5000px' });
	
	
	if($j('.inputReplace')) { $j('.inputReplace').each(function(i, el) { var orig = $j(el).val(); $j(el).focus(function() { $j(el).addClass('a'); if($j(el).val() == orig) { $j(el).val(''); } }); $j(el).blur(function() { $j(el).removeClass('a'); if(!$j(el).val()) { $j(el).val(orig); } }); }); }
	if($j('.homeSlider') && $j('.homeSlider #slides li').length > 1) { $j('.homeSlider').anythingSlider({ easing:"easeInOutExpo", autoPlay:true, delay:6000, startStopped:false, animationTime:600, hashTags:false, buildNavigation:true, pauseOnHover:true }); }
	
	if($j('.productInfoMedia')) {
		var mainImgs = $j('.productInfoMedia ul.mainImg li img'), thumbs = $j('.productInfoMedia ul.thumbs li a');
		$j(thumbs).each(function(i, el) {
			$j(el).click(function() {
				$j(mainImgs).each(function(ii, ele) {
					$j(ele).fadeTo(1000, ($j(el).attr('href') == $j(ele).attr('src') ? 1 : 0));
				});
				return false;
			});
		});
	}
	
	if($j('.productInfo .readMore').length) {
		var longDesc = $j('.productInfo .descWrap .longDesc'),
			 new_height = longDesc.height();
		
		$j(longDesc).fadeOut(0);
		
		$j('.productInfo .readMore').fadeOut(0);
		$j('.productInfo .readMore').parent().animate({ 'height': 0 }, 0);
		$j('.productInfo .descWrap').animate({ 'height': new_height }, 0);
		$j(longDesc).fadeIn(0);
		
		/*
		click = disabled
		$j('.productInfo .readMore').click(function() {
			$j(this).fadeOut(1000);
			$j(this).parent().animate({ 'height': 0 }, 1000);
			$j('.productInfo .descWrap').animate({ 'height': new_height }, 1000);
			$j(longDesc).fadeIn(1000);
		});
		*/
	}
	
	if($j('.bundleInfo .readMore')) {
		$j('.bundleInfo .readMore').each(function(i, el) {
			$j(el).click(function() {
				$j(el).next('h3').next('.descWrap').children('.longDesc').css('display', 'block');
			});
		});
	}
	
	if($j('#drincordion')) {
		$j('#drincordion').accordion({
			animated: 'easeInOutExpo',
			event: 'click'
		});
		
		$j('#drincordion').bind('accordionchange', function(event, ui) {
			$j('#drincordion li').each(function(i, el) {
				if(!$j(el).find('.ui-state-active')[0]) {
					$j(el).removeClass('a');
				}
			});
		});
		
		$j('#drincordion').bind('accordionchangestart', function(event, ui) {
			$j('#drincordion li').each(function(i, el) {
				if($j(el).find('.ui-state-active')[0]) {
					$j(el).addClass('a');
				}
			});
		});
	}
	
	if($j('.contentLeft .nav')) {
		var tran = 0;
		var tabs = $j('.contentLeft .nav li');
		var cont = $j('.contentLeft .cTabs li.c');
		$j(tabs).each(function(i, el) {
			if(!$j(el).hasClass('l')) {
				$j(el).click(function() {
					if(!tran) {
						window.location = window.location.toString().replace(/\#.*$/, '') + '#' + $j(el).attr('rel');
						
						tran = 1;
						$j(tabs).removeClass('a aa');
						$j(el).addClass('a');
						$j(tabs[i + 1]).addClass('aa');
						
						$j('.contentLeft .cTabs li.a').animate({ 'opacity': '0' }, 500, function() {
							$j(this).removeClass('a');
							$j(cont[i]).css('opacity', '0').addClass('a').animate({ 'opacity': '1' }, 500, function() { tran = 0; });
						});
					}
				});
			}
		});
	}
	
	var tabFocus = tabFocusEl = '';
	if(tabFocus = window.location.hash.replace('#', '')) {
		if($j('.contentLeft .nav li[rel=' + tabFocus + ']').length) {
			$j('.contentLeft .nav li[rel=' + tabFocus + ']').click();
		}
	}
	
	$j(window).hashchange(function() {
		tabFocus = window.location.hash.replace('#', '')
		if((tabFocusEl = $j('.contentLeft .nav li[rel=' + tabFocus + ']')).length) {
			if(!tabFocusEl.hasClass('a')) {
				$j(tabFocusEl).click();
			}
		}
	});
	
	if($j('.lightbox')) { $j('.lightbox').lightBox(); }
	
	if($j('#links form')) {
		$j('#links form').submit(function() {
			var loadUrl = '/interspire/email-subscription.php';
			var input = $j(this).find('input[name=email]')[0];
			if($j(input).val().search(/^[A-z0-9\._-]+@[A-z0-9][A-z0-9-]*(\.[A-z0-9_-]+)*\.([A-z]{2,6})$/) == 0) {
				$j(input).addClass('s');
				/* do ajax call here */
				$j(this).fadeOut(500, function() {
					$j('#successMsg').load(loadUrl, {email:$j(input).val()});
					$j('#successMsg').css({ 'opacity': '0', 'display': 'block' }).fadeTo(500, 1);
				});
			} else {
				alert('invalid email');
			}
			return false;
		});
	}
	//subnav animation
	
	
	//loading link
	$j('.showLoad').each(function(i, el) {
		var loader = $j('<div id="loader">Loading...</div>').appendTo($j('body'));
		
		$j(el).click(function() {
			$j(loader).text($j(el).attr('alt'));
			$j(loader).css('top', (Math.abs($j(window).height() - $j(loader).height()) / 2) + $j(window).scrollTop());
			$j(loader).css('left', (Math.abs($j(window).width() - $j(loader).width()) / 2) + $j(window).scrollLeft());
			$j(loader).css('display', 'block');
		});
	});
	
	$j('.btn-cart').each(function(i, el) {
		var loader = $j('<div id="loader">Adding product to cart...</div>').appendTo($j('body'));
		
		$j(el).click(function() {
			if(!$j(el).hasClass('noLoad')) {
				if($j(el).attr('alt')) {
					$j(loader).text($j(el).attr('alt'));
				}
				$j(loader).css('top', (Math.abs($j(window).height() - $j(loader).height()) / 2) + $j(window).scrollTop());
				$j(loader).css('left', (Math.abs($j(window).width() - $j(loader).width()) / 2) + $j(window).scrollLeft());
				$j(loader).css('display', 'block');
			}
		});
	});
	
	//preview video
	$j('.dvdPreview').each(function(i, dvdPreview) {
		if(dvdPreview) {
			var dvdPreviewAction = $j(dvdPreview).siblings('.dvdPreviewAction')[0],
				 closeDvdPreview = $j(dvdPreview).children('.closeDvdPreview')[0];
			
			console.log(dvdPreview);
			
			console.log(closeDvdPreview);
			
			$j(dvdPreviewAction).click(function() {
				$j(dvdPreview).css('top', (Math.abs($j(window).height() - $j(dvdPreview).height()) / 2) + $j(window).scrollTop());
				$j(dvdPreview).css('left', (Math.abs($j(window).width() - $j(dvdPreview).width()) / 2) + $j(window).scrollLeft());
				$j(dvdPreview).css('display', 'block');
				return false;
			});
			
			$j(closeDvdPreview).click(function() {
				$j(dvdPreview).css('display', 'none');
			});
		}
	});
	
	//cart ajax
	var cartAjax;
	if(cartAjax = $j('#cartAjax')[0]) {
		$j.ajax({
			url: "/cart-ajax.php",
			success: function(html) {
				$j(cartAjax).fadeOut(500, function() {
					$j(cartAjax).html(html).fadeIn(500);
				});
			}
		});
	}
	
	//fix multiple qty inputs
	$j('#product-options-wrapper .required, .product-options-bottom input[name=qty]').attr('disabled', 'disabled');
	
	if($j('.sp-methods dt').length) {
		var done = 0;
		$j('.sp-methods dt').each(function(i, el) {
			$j('.sp-methods dt').each(function(ii, ele) {
				if($j(el).text() == $j(ele).text() && ii != i && !done) {
					$j(el).css('display', 'none');
					$j($j('.sp-methods dd')[i]).find('ul li').prependTo($j($j('.sp-methods dd')[ii]).find('ul'));
					done = 1;
				}
			});
		});
	}
	
	//custom phone condom stuff...
	/*
	var phoneCondomWrap;
	if(phoneCondomWrap = $j('#phoneCondomSelect')[0]) {
		var phoneCondomChoices = $j('.phoneCondomChoice'),
			 pcDefault = '';
		
		$j(phoneCondomChoices).each(function(i, el) {
			if((pcDefault = $j(el).find('input')).length) {
				console.log(pcDefault);
			}
		});
	}
	*/
	
	$j('#video-playlist .playlist-item a').each(function(i, el) {
		$j(el).click(function() {
			$j('.youtube-player').attr('src', $j(el).attr('href'));
			return false;
		});
	});
	
	if($j('.product-phone-condom-phone-cell #qty').length) {
		var qty = $j('.product-phone-condom-phone-cell #qty')[0],
			 pricePer = oldPrice = 3.55,
			 discountedPrice = false;
		$j(qty).change(function() {
			var num = Math.abs($j(qty).val());
			
			if(num < 101) {
				pricePer = '3.55';
			} else if(num < 501) {
				pricePer = '3.50';
			} else if(num < 1001) {
				pricePer = '3.45';
			} else if(num < 5001) {
				pricePer = '3.40';
			} else if(num < 10000) {
				pricePer = '3.35';
			} else {
				pricePer = '3.30';
			}
         
			if(pricePer == oldPrice) {
				discountedPrice = false;
				if($j('.discountedPrice').length) {
					$j($j('.discountedPrice')[0]).remove();
				}
			} else {
				discountedPrice = true;
				if($j('.discountedPrice').length) {
					$j($j('.discountedPrice')[0]).text('New Price: $' + pricePer);
				} else {
					$j('<span class="discountedPrice">New Price: $' + pricePer + '</span>').appendTo($j($j('.regular-price')[0]));
				}
			}
			
			$j($j('.regular-price .price')[0]).css('text-decoration', (discountedPrice ? 'line-through' : 'none'));
			
		});
	}
	
	//phone condom bulk pricing
	if((phoneCondomQty = $j('.phoneCondomQty')).length) {
		var qty = $j('#qty')[0];
			 matureQty = $j('dl dd input')[0],
			 teenQty = $j('dl dd input')[1];
		
		$j('<span>Qty:</span>').prependTo($j('dl dd')[0]);
		$j('<span>Qty:</span>').prependTo($j('dl dd')[1]);
		
		$j('.product-options-bottom .add-to-cart').remove();
		
		$j('.product-options dl').appendTo($j(phoneCondomQty));
		
		$j([qty, matureQty, teenQty]).val('0');
		
		$j(qty).css({ 'cursor': 'default', 'font-size': '14px', 'font-weight': 'bold' });
		$j(qty).keypress(function() { return false; });
		$j(qty).click(function() { $j(qty).blur(); });
		
		$j('label[for=qty]').html('Total Qty:').css('color', '#332574');
		
		$j([matureQty, teenQty]).each(function(i, el) {
			$j(el).click(function() {
				$j(el).select();
			});
			$j(el).keyup(function() {
				if($j(el).val() == '') { $j(el).val('0'); }
				$j(qty).val(parseInt($j(matureQty).val()) + parseInt($j(teenQty).val()));
				$j(qty).trigger('change');
			});
		});
	}
	
});

function submitInfo(info) {
	alert('"' + info + '" will be passed to the server, returns true once finished');
	return true;
};
