// *************************************************
// STANDARDS
// *********************************************** //

//emulate popup function...
var popWindow = function(u,w,h,popEl){
	if(!popEl){
		e = u.substring(u.lastIndexOf('.')+1).toLowerCase();
		if(e == 'png' || e == 'gif' || e == 'jpg')
			popEl = $("<div class=\"popWindowDiv\" style=\"display:block;\"><img src=\""+ u +"\" width=\"" + w + "\" height=\"" + h + "\" border=\"0\" /></div>",{overlay:20});
		else
			popEl = $("<div class=\"popWindowDiv\" style=\"display:block;\"><iframe src=\""+ u +"\"  width=\"" + w + "\" height=\"" + h + "\" border=\"0\" frameborder=\"0\"></iframe></div>",{overlay:20});
	}
	popEl.modal({
			onOpen: function (dialog) {
						dialog.data.addClass('alert');
						dialog.container.css('height','auto');
						dialog.overlay.fadeIn('normal', function () {
							dialog.container.show('normal', function () {
								dialog.data.fadeIn('normal'); // See Other Notes below regarding
														   // data display property and
														   // iframe details
							});
						});
					},
			onClose: function (dialog) {
						dialog.data.fadeOut('normal', function () {
						  dialog.container.hide('normal', function () {
							dialog.overlay.fadeOut('normal', function () {
							  $.modal.close(); // must call this to have SimpleModal
											   // re-insert the data correctly and
											   // clean up the dialog elements
							});
						  });
						});
					}
	});
	$("#modalContainer").css('width',w).css('margin-left',(w / 2) * -1).css('height',h).css('margin-top',(h / 2) * -1); 
}

// *************************************************
// DOCUMENT READY
// *********************************************** //

$(document).ready(function(){

	$('.button-translate a.translate').click(function(e){
		e.preventDefault();
		GoogleTranslate.Translate.initLanguageDialog();
	});

	//change layout for with_line articles and click function
	$('.article.with_line').each(function(){
		$(this).children('.content').find('img:eq(0)').wrap('<div class="image"></div>');
		$(this).hover(
		  function() {
			$(this).css('background','#dedede');
		  },
		  function() {
			$(this).css('background','#ffffff');
		  }
		).click(function(){
			var u = '';
			$(this).find('a').each(function(){
				a = $(this).text().match(/lees (meer|verder).*/i);
				if(a && a.length){
					self.location.href = $(this).attr('href');
				}
			});
		});
		//self.location.href = $(this).children('.content').find('a').attr('href');
		//$(this).children('.content').find('a[href]:first').remove();
	});

	$('.article').not('with_line').each(function(){
		//give images some margin
		$("img[align='left']").css('margin-right','15px');
		$("img[align='right']").css('margin-left','15px');
	});

});
