/**
* Standaard functies/acties	
**/
function showPopUp(sContent, iWidth, iHeight){
	if($('#popUp').html()!==null){
		
	}
	iPadding = 20;
	iWidth = (iWidth-(2*iPadding));
	iHeight = (iHeight-(2*iPadding));
	sPosition = '-'+(iHeight/2)+'px 0px 0px -'+(iWidth/2)+'px';
	var sSluitknop = '<div id="closePopUp"></div>';
	var sDiv = '<div id="darkLayer"></div><div id="popUp" style="display: none;">'+sSluitknop+' <div id="popUpCanvas">'+sContent+'</div></div>';
	$('body').append(sDiv);
	$('#popUp').css('margin',sPosition);
	$('#popUp').css('padding',iPadding);
	$('#popUp').css('width',iWidth);
	$('#popUp').css('height',iHeight);
	$('#darkLayer').fadeTo('fast',0.8,function(){
		$('#popUp').show('fast');
	});
}
/**
* Standaard functies/acties	
**/
$(document).ready(function(){
		/**
	* Pupup stuff
	**/
	$('#closePopUp').live('click',function(){
		$('#popUp').fadeOut('fast',function(){
			$('#popUp').remove();
			$('#darkLayer').fadeOut('fast',function(){
				$('#darkLayer').remove();
			});
		})		
	});
	
	
	$('#contact').validate();
	$('input[type=\'submit\']').addClass('submitBtn');
	//Flashheader includen
	var sFlashEmbed = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="748" height="148" id="button" align="middle">';
	sFlashEmbed += '<param name="allowScriptAccess" value="sameDomain" />';
		sFlashEmbed += '<param name="movie" value="/images/button.swf" />';
		sFlashEmbed += '<param name="quality" value="best" />';
		sFlashEmbed += '<param name="wmode" value="transparent" />';
		sFlashEmbed += '<param name="bgcolor" value="#0000cc" />';
		sFlashEmbed += '<embed src="/images/button.swf" quality="best" bgcolor="#0000cc" width="748" height="148" name="button" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />';
	sFlashEmbed += '</object>';
	$('#divFlash').append(sFlashEmbed);
});


/**
* GALLERY functionaliteiten
**/
$(document).ready(function(){
	$("#thumbsHolder img").click(function(){
		var newImgSrc = $(this).attr("src");
		var newInfo = $(this).attr("id")+"info";
		var toAppend = $("#"+newInfo).html();
		$("#bigImg, #infoToAppend").fadeOut(150,function(){
			$("#infoToAppend").html(toAppend);
			$("#bigImg").attr("src",newImgSrc);
			$("#bigImg, #infoToAppend").fadeIn(100);			
		});
	});
});

/**
* WEBSHOPFUNCTIES
**/
$(document).ready(function(){
	/**
	* Forms valideren
	**/
	$('#form1').validate();
	$('#form2').validate();
	$('#form3').validate();
	
	/**
	* Via ajax een artikel verwijderen uit de winkelwagen
	**/
	$(".removeFromCart").click(
		function(){
			var id= $(this).parent().attr('id');
			var deleteRow = '#tr' + id;
			$.post('/shop/ajax_removeFromCart.php', { id: id },
				function(data){
					if(data.response == 1){
						$(deleteRow).fadeOut('fast');
						/*
						ALLEEN ALS JE BTW/SUBTOTAAL WILT WEERGEVEN IN DE WINKELWAGEN.
						$("#subtotaal").html(data.subtotaal);					
						$("#btw").html(data.btwbedrag);
						*/ 
						$("#totaal").html(data.totaal);
						if(data.aantal=='0'){
							$("#messageSpan").html("Er staan geen producten in uw winkelwagen.");
							$("#doorgaanKnop").fadeOut('fast');							
						}
					}else{
						alert("Er is een fout opgetreden.");
					}
				}, "json"
			);
		}
	);	
	
	/**
	* Loguitknop
	**/
	$('#loguitKnop').click(function() {
	  var url = $("#loguitKnop").attr('href');
	  window.location=url;
	  return false;
	})
	
	/**
	* Lightbox voor artikelfoto`s
	**/
	$('.imgDiv a').lightBox();
	
	/**
	* add review weergeven
	**/
	$('#addReview').hide(0);
	$('#addReviewBtn').click(function(){
		$('#addReviewBtn').hide(300);
		$('#addReview').show(300);
	});
	
	/**
	* Meer informatie knop. Klik op hele div, door naar de detailpagina
	**/
	$('.article img').click(function(){
		var sLinkDetail = $(this).parent().parent().find('.btnMoreInfo').attr('href');
		//alert(sElement);
		window.location.replace(sLinkDetail);
	});
	
	/**
	* Account pagina orderdetails weergeven wanneer er op de order wordt geklikt
	**/
	$('.order').click(function(){
		var orderTag = $(this).attr('id');
		var orderDetailTag = orderTag+'_details';
		var sDisplay = $('#'+orderDetailTag).css('display');
		if(sDisplay=='none'){
			$('#'+orderDetailTag).fadeIn(200);
		}
		else{
			$('#'+orderDetailTag).fadeOut(200);
		}
	});
	
	/**
	* Ticket toevoegen
	**/
	$('#stap1 input').click(function(){
		$('#stap2').fadeIn();
	});
	
});
