
/////////////////////////////////////////////////////////////////////
////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');
	});
	
	$("hr").wrap("<div class=\"hr\"></div>");

	
	$("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();
		}
	});

})

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();", 3000);
	});
}

$(window).bind('load', function () {
	var maxHeight = 0;
	$("div.loopImgs div.image img").each(function() {
		maxHeight = $(this).height();
	});
	
	$("div.loopImgs").height(maxHeight);
	$("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();
});

function checkoutFormSubmit() {
	document.getElementById('extra[kampanjkod]').value = document.getElementById('editcustomer_[kampanjkod]').value;
	document.getElementById('extra[egetordernr]').value = document.getElementById('editcustomer_[egetordernr]').value;
	document.getElementById('extra[godsmarke]').value = document.getElementById('editcustomer_[godsmarke]').value;
	document.getElementById('extra[ovrigt]').value = document.getElementById('editcustomer_[ovrigt]').value;
	document.getElementById('checkoutForm').submit();
}
