var JQ = jQuery.noConflict();

JQ(document).ready(function(){
	on_page_load();
	
	JQ('#nav ul.menu li:last-child').hide();
	
	JQ("img[src='/templates/caliopeDefault/img/bekijkPresentatie.png']").addClass('bekijkPresentatie');
	JQ("img[src='/templates/caliopeDefault/img/de-bekijkPresentatie.png']").addClass('de-bekijkPresentatie');
	JQ("img[src='/templates/caliopeDefault/img/en-bekijkPresentatie.png']").addClass('en-bekijkPresentatie');
	
	JQ("img.bekijkPresentatie").hover(function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/bekijkPresentatie_hover.png');
	},
	function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/bekijkPresentatie.png');
	});
	
	JQ("img.de-bekijkPresentatie").hover(function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/de-bekijkPresentatie_hover.png');
	},
	function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/de-bekijkPresentatie.png');
	});
	
	JQ("img.en-bekijkPresentatie").hover(function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/en-bekijkPresentatie_hover.png');
	},
	function(){
		JQ(this).attr('src','/templates/caliopeDefault/img/en-bekijkPresentatie.png');
	});
	
	
});

function on_page_load(){
	var loc = window.location;
	var pathName = loc.pathname.substring(loc.pathname.lastIndexOf('/'));
	if(pathName!='/radiosoftware' && pathName!='/televisie' && pathName!='/fernsehen' && pathName!='/television'){
		JQ('.article-content table:first-child').addClass('first-child');
		var article_content_slider = setInterval('article_content_slider()',6000);
		JQ('.article-content table:first-child td:first').addClass('show').delay(200).find('img').animate({opacity:'1'},1500);
	}
}

function popUp(url) {
    window.open(url,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=400,left=400,top=150');
  }
  

function article_content_slider(){
	var snelheid = 1500;
	var slides = JQ('.article-content table.first-child tbody tr td').size();
	var loc = window.location;
	var pathName = loc.pathname.substring(loc.pathname.lastIndexOf('/'));
	if(pathName=='/radiosoftware' || pathName=='/televisie' || pathName=='/fernsehen' || pathName=='/television'){
		// do nothing
	}
	else{
		if(slides == 1){
			// do nothing 
		}
		else{
			if(JQ('.article-content table:first-child td:nth-child(' + slides + ')').hasClass("show")){ 
				JQ(".article-content table:first-child td.show").removeClass("show").find('img').animate({opacity:'0'},snelheid,function(){
					JQ(".article-content table:first-child td:first").addClass('show').find('img').animate({opacity:'1'},snelheid);
				});
			} 
				 
			else{
				JQ(".article-content table:first-child td.show").find('img').animate({opacity:'0'},snelheid,function(){
					JQ(".article-content table:first-child td.show").removeClass("show").next().addClass('show').find('img').animate({opacity:'1'},snelheid);
				});
			} 	
		}
	}
}
