/**
* 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');
	});
}
$(document).ready(function(){
	$('#contact').validate();
	
	var sSectie = $('body').attr('id');
	$('.'+sSectie).addClass('actief');
		
	/**
	* Designstuff
	**/
	/*$('#tagCloud').load('/js/ajax.js.php?sAction=tagCloud');*/
	
	/*$('#header .btn:not(.actief)').hover(function() {
		$('img',this).animate({ marginTop : '20px'}, 100);                       
	}, function() {
		$('img',this).animate({ marginTop : '33px'}, 100);
	});*/	
	
	/**
	* Pupup stuff
	**/
	$('#closePopUp').live('click',function(){
		$('#popUp').fadeOut('fast',function(){
			$('#popUp').remove();
			$('#darkLayer').fadeOut('fast',function(){
				$('#darkLayer').remove();
			});
		})		
	});
	
	
	$('.btn').click(function(){
		var sUrl = $('a',this).attr('href');
		window.location = sUrl;
	});
	
	var navDuration = 100; //time in miliseconds
	var navJumpHeight = "0.45em";
	$('#submenu li').hover(function() {
		$(this).animate({ paddingRight : "-="+navJumpHeight }, navDuration);            
	}, function() {
		$(this).animate({ paddingRight : "10px" }, navDuration);
	});	

	
	/**
	* Folder in div plaatsen
	**/
	/*
	var sFolder = '<iframe border="0" style="" src="http://www.qmotion.nl/e-folder/index.php?id=58809" width="878" height="458"><p>Your browser does not support iframes.</p></iframe>';
	$('#winkel #menu .nav a').click(function(){
		if($(this).html()=='Folder'){
			showPopUp(sFolder, 920,500);
			return false;		
		}
	});
	*/
	$('#winkel #menu .nav a').click(function(){
		if($(this).html()=='Folder'){
			window.open('http://www.qmotion.nl/e-folder/index.php?id=58809', 'Folder', ''); 
			return false;		
		}
	});
	
	/**
	* Bestelling/reparatiestatus ophalen
	**/ 
	$('[name=cmdLookup]').click(function(){
		var id_lookup = $('[name=lu_id_lookup]').attr('value');
		var postcode = $('[name=lu_postcode]').attr('value');

		$.post("/js/ajax.js.php", {sAction:"cmdLookup", id_lookup:id_lookup, postcode: postcode}, function(data){
			if(data!='') {
				showPopUp(data,250,80);
			}
			else{
				alert('Helaas');
			}
		});		
		return false;
	});
	/**
	 * Lijst stylen
	 */
	if($('#subContent').html()==null){
		$('#content ul').css('margin','5px 0px 5px 40px');
		$('#content ul').css('list-style-image','url(/images/icon_li.png)');
	}
	else{
		$('#subContent ul').css('margin','5px 0px 5px 40px');
		$('#subContent ul').css('list-style-image','url(/images/icon_li.png)');
	}
	
	$('tr:even','#canvas #content table').addClass("even");
	$('tr:odd','#canvas #content table').addClass("odd");
	
	/**
	* Ticket toevoegen
	**/
	$('#stap1 input').change(function(){
		$('.extrainfo').hide();
		var iSelected = $('[name=id_categorie]:checked').attr('value');
		var sElement = $('#stap3 #extrainfo_'+iSelected).html();
		if(sElement!==null){
			$('#stap3').show('fast');
			$('#extrainfo_'+iSelected).show('fast');
		}
		else{
			$('#stap3').hide('fast');
		}
	})
	$('#stap1 input').click(function(){
		$('#stap2').fadeIn();
	});
	
	/**
	* Portfolio
	**/
	$('.portfolioWerk img').click(function(){
		var sContent = $(this).parent().html();
		showPopUp(sContent,600,500);
		/*$('#portfolioCanvas').html(sContent);*/
	});	
});
