
/////////////////////////////////////////////////////////////////////
////ONLY/////////////////////////////////////////////////////////////
////////SIFR/////////////////////////////////////////////////////////
////////////ABOVE////////////////////////////////////////////////////
/////////////////THIS////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////


/*function toggleStep(area, current) {
	alert(area);
	alert(current);
	var currentObj = $(current);
	
	var areaObj = $("#"+area);
		alert('togglar');
		
	//alert(area.attr('id'));
	//alert(current.attr('id'));
	areaObj.css('border', '1px solid red');
	
	$(".consumer button").removeClass("buttonhover");
	currentObj.addClass("buttonhover");
	
	if(visible(areaObj)) {
		
		$(".accordion:visible").slideUp("fast", function() {});
		areaObj.slideDown();
	} else {
		areaObj.slideUp("fast");
	}
}
function visible(e) {
	if(e.css("display") != "none") {
		return false;	
	} else {
		return true;
	}
}
$(document).ready(function() {
	$("p:last-child").addClass("last");
	$("ul.tabs li:last-child").addClass("last");
	$("#thumbnails_list li:odd").addClass("last");
	$("td:last-child").addClass("text_right");
	$("th:last-child").addClass("text_right");
	
	$('#productmenu ul.menu li:first-child').addClass("firstmenuitem");
	$('#productmenu ul.menu li:last-child').addClass("lastmenuitem");
	
	$('#no_reg').click(function() {
		$('div.consumer div.accordion').hide();
		$('div.consumer div#noRegister').toggle();
	});
	$('#already_customer').click(function() {
		$('div.consumer div.accordion').hide();
		$('div.consumer div#alreadyClient').toggle();
	});
	$('#new_customer').click(function() {
		$('div.consumer div.accordion').hide();
		$('div.consumer div#createUser').toggle();
	});
	
	
	$('.consumer button').hover(function() {
  		$(this).addClass('buttonhover');
	}, function() {
  		$(this).removeClass('buttonhover');
	}); 
})*/

function toggleStep(area, current) {
	var current = $(current);
	var area = $("#"+area);
	
		
	/*$(".consumer button").removeClass("buttonhover");
	current.addClass("buttonhover");*/
	
	if(visible(area)) {
		$(".accordion:visible").slideUp("fast", function() {});
		area.slideDown();
	} else {
		area.slideUp();
	}
}

function visible(e) {
	if($(e).css("display") != "none") {
		return false;	
	} else {
		return true;
	}
}

jQuery.fn.toggleClass = function(class1) {
    if (this.hasClass(class1)) {
        this.removeClass(class1);
    } else {
        this.addClass(class1);
    }
}; 

$(document).ready(function() {
	/*$("contentmenu ul li ul").mouseover(function() {
		$(this).getParent().addClass("hover");
	});*/
	
	$("#checkout input[type='text']").addClass('text');
	
	$('.productinfo h3.property').each(function () {
		$(this).click(function () {
			$(this).next('p.propertyvalue').toggle('normal');
			$(this).toggleClass('open');
		});
	});
	
	$('.menuImages .imagearea:nth-child(3n)').addClass('lastColumn');
	
	$('#productlist_1 .brand').next('div').addClass('first');
	
	var height = $('#slideshow .loopImgs').height();
	var width = $('#slideshow .loopImgs').width();
	$('#slideshow .loopImgs img').css('height', height);
	$('#slideshow .loopImgs img').css('width', width);

	$('.consumer button').hover(function() {
  		$(this).addClass('buttonhover');
	}, function() {
  		$(this).removeClass('buttonhover');
	}); 

	/*$('#already_customer').click(function() {
		$('div.consumer div.accordion').hide();
		$('div.consumer div#alreadyClient').toggle();
	});
	$('#new_customer').click(function() {
		$('div.consumer div.accordion').hide();
		$('div.consumer div#createUser').toggle();
	});*/
	
	$('#contentmenu ul li ul').each(function () {
		var ul = this;
		$(this).parent().mouseover(function () {
			/*$(this).children().each(function () {
				$(this).css('display', 'block');
			});*/
			$(ul).css('display', 'block');
		});

		$(this).parent().mouseout(function () {
			/*$(this).children().each(function () {
				alert(this.tagName);
				$(this).css('display', 'none');
			});*/
			$(ul).css('display', 'none');
		});
	});

	//e.mouseover = function () { alert(0); }
	/*$(".leafer").mouseout(function() {
	$(this).removeClass("hover");
	});*/
	
	/*$("div.loopImgs div.image").each(function() {
		loopImgsNum++;
	});*/
	/*var ps = new Array();
	ps[0] = 'hej';
	ps[1] = 'haj';
	ps[2] = 'wtf';*/
	/*$(ps).each(function () {
		alert(this);
	});*/

	$("div.loopImgs").children().each(function() {
		var oki = false;
		var tn = this.tagName.toLowerCase();
		if (tn == 'img') {
			oki = true;
		}
		if (tn == 'a') {
			$(this).children().each(function() {
				if (this.tagName.toLowerCase() == 'img') {
					oki = true;
				}
			});
		}
		if (oki == true) {
			$(this).wrap("<div class=\"image\"></div>");
			loopImgsNum++;
		} else {
			$(this).remove();
		}
	});
});


function doPopup (what) {
	if (what == 'blog') {
		window.open('/flash/dagbok.php','win','height=600,width=600,toolbar=no,scrollbars=yes');
	}
	if (what == 'fun') {
		window.open('/flash/bus.php','win','height=600,width=600,toolbar=no,scrollbars=yes');
	}
	if (what == 'recept') {
		window.open('/flash/recept.php','win','height=600,width=600,toolbar=no,scrollbars=yes');
	}
	if (what == 'books') {
		window.open('/flash/bok.php','win','height=600,width=600,toolbar=no,scrollbars=yes');
	}
	if (what == 'cds') {
		window.open('/flash/cd.php','win','height=600,width=600,toolbar=no,scrollbars=yes');
	}
}

var loopImgsIndex = -1;
var loopImgsNum = 0;
function loopImgsNext () {
	if (loopImgsIndex != null) {
		$("div.loopImgs div.image:eq(" + loopImgsIndex + ")").fadeOut("slow");
	}
	loopImgsIndex++;
	if (loopImgsIndex==loopImgsNum) { loopImgsIndex = 0; }

	$("div.loopImgs div.image:eq(" + loopImgsIndex + ")").fadeIn("slow", function () {
		setTimeout("loopImgsNext();", 2500);
	});
}

$(window).bind('load', function () {
	$("div.loopImgs div.image").fadeOut();
	//$("div.loopImgs div.image").css('display', 'block');
	/*$("div.loopImgs").height($("div.loopImgs div.image:eq(0)").height());
	$("div.loopImgs").width($("div.loopImgs div.image:eq(0)").width());*/
	loopImgsNext();
});
