// JavaScript Document

function slideSwitch(t,speed) {
	var $active=$(t+' .slide.active');
	if ($active.length==0) $active=$(t+' .slide:last');
	var $next=$active.next().length ? $active.next() : $(t+' .slide:first');
	$active.addClass('last-active');
	$next.addClass('active')
		.hide()
		.fadeIn(speed, function() {
			$active.removeClass('active last-active');
		});
}
function slidePrev(t,speed) {
	var $active=$(t+' .slide.active');
	if ($active.length==0) $active=$(t+' .slide:last');
	var $next=$active.prev().length ? $active.prev() : $(t+' .slide:first');
	$active.addClass('last-active');
	$next.addClass('active')
		.hide()
		.fadeIn(speed, function() {
			$active.removeClass('active last-active');
		});
}

$(document).ready(function() {
	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
	$('#loginForm').hide();
	$('#loginShow').click(function(){
		//$('#loginForm').show();
		//$('#login').hide();
		//$('#loginForm #username').focus();
		document.location='/login/';
	});
	$('.focus:first').focus();
	$('.zoomimage').jqzoom({
	    zoomWidth: 390,
	    zoomHeight: 536,
			lens: false,
			xOffset: 20,
      yOffset: -146,
      position: "left" //and MORE OPTIONS
	});
	$('.zoomimage2').jqzoom({
	    zoomWidth: 482,
	    zoomHeight: 461,
			lens: false,
			xOffset: 20,
      yOffset: 0,
      position: "right" //and MORE OPTIONS
	});
	setInterval("slideSwitch('#randomProducts',1000)",3000);
});

function deleteCart(id) {
	if (confirm('Remove this item from shopping cart?')) {
		document.location='/webshop/?deletecart='+escape(id);
	}
}
function addCart(id) {
	var size=$('#size1_'+id).html();
	if (size==null) {
		t=document.getElementById('size_'+id);
		if (t) {
			size=t.options[t.selectedIndex].value;
			if (size=='') { alert('Please select a size'); size=false;}
		} else
			size=' ';
	}
	var color=$('#color1_'+id).html();
	if (color==null) {
		t=document.getElementById('color_'+id);
		if (t) {
			color=t.options[t.selectedIndex].value;
			if (color=='') { alert('Please select a color'); color=false;}
		} else
			color=' ';
	}
	if (size && color) {
		alert('Product added to cart');
		document.location='/webshop/?addcart='+id+'&opt='+escape(size)+' '+escape(color);
	}
}

function formSubmit(t) {
	t.action="";
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22733239-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

