$(document).ready(function() {

		$("#[id^=lightbox]").each(function() { 
			$('a',this).lightBox({
				overlayBgColor: '#000',
				overlayOpacity: 0.6,
				imageLoading: '/images/loading.gif',
				imageBtnClose: '/images/lightbox-btn-close.gif',
				imageBtnPrev: '/images/lightbox-btn-prev.gif',
				imageBtnNext: '/images/lightbox-btn-next.gif',
				containerResizeSpeed: 300
			})
		});

		$('a.lightbox').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.6,
			imageLoading: '/images/loading.gif',
			imageBtnClose: '/images/lightbox-btn-close.gif',
			imageBtnPrev: '/images/lightbox-btn-prev.gif',
			imageBtnNext: '/images/lightbox-btn-next.gif',
			containerResizeSpeed: 300
	   });

		$('#banner').cycle({
			fx: 'fade',
			speed: 2500, 
			timeout: 2500
		});

		$("a[rel*='external']").each(function() { 
			this.target = '_blank';
		});

		$("a[rel*='popup']").each(function() { 
			this.onclick = function() {
				window.open(this.href, 'Popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=500');	
				return false;
			}
		});

		$('.accordion').accordion({ 
			autoheight: false,
			header: 'a.head'
		});

		$("#products").click(
		  function () {
			$("#product_sub").slideDown('fast');
			$("#technical_sub").slideUp('slow');
		  }
		);

		$("#technical").click(
		  function () {
			$("#technical_sub").slideDown('fast');
			$("#product_sub").slideUp('slow');
		  }
		);


		$("ul").hover(
		  function () {
		  },
		  function () {
			$("#product_sub").slideUp('slow');
			$("#technical_sub").slideUp('slow');
		  }
		);

		$("p.prod-title").click(
			function () {
				$(this).next().slideDown('fast');
			}
		);

		$(".tooltip").click(
			function () {
				$(this).slideUp('fast');
			}
		);
		
		$("#content .anc-product").click(
			function () {
				$(this).parent().children(".tooltip").slideDown('fast');
	
			}
		);

		$(".tooltip").click(
			function () {
				$(this).slideUp('fast');
			}
		);

		$('input').keypress(function(e){
			if(e.which == 13){
				e.preventDefault();
			}
		});

});

function checkvariationselected(product_id) {
	// if var_id isn't set
	//if( $('var_id').val() == '' ) { 
	if( typeof $("#form_"+product_id+" input[@name='var_id']:checked").val() == "undefined" ) {
		alert('You must select a size first');
		return false;
	} else {
		return true;
	}
}

