var are_img = 0;

jQuery(document).ready(function() {
	
	jQuery.ajax({
		   url: "/update.php"
	});
	
	jQuery('.art_thumb').click(function() {
		  
		  my_class = jQuery(this).attr('class');  
		
		  new_src = jQuery(this).attr('src');
		  par1 = jQuery(this).parent();
		  jack = jQuery(par1).find('.art_main');
		  mack = jQuery(par1).find('.first'); 
		  old_src = jQuery(jack).attr('src');
		  
		  jQuery(jack).attr('src',new_src);
		  
		  if(my_class.search(/no_href/i)==-1)
			  jQuery(mack).attr('href',new_src.replace('_thumb','_main'));
		  
		  jQuery(this).attr('src',old_src);
		  
		  		  
	});
	jQuery("#nom_text").charCounter(650,{
		format: "%1 tekens."
	});
	 
	
	jQuery('input[title!=""]').hint();
	
	jQuery('.flash_popup').click(function(){
		window.open (jQuery(this).attr("href"),"my_pop","menubar=0,resizable=0,width=1000,height=600");
		return false;
	});
	
	jQuery("a.article").fancybox(
			{
				'easingIn'				: 'easeOutBack',
				'easingOut'				: 'easeInBack',
				'hideOnContentClick'	: false

			}
	);
	
	jQuery(function() {
		jQuery("#tree").treeview({
			collapsed: true,
			animated: "medium",
			control:"#sidetreecontrol"			
		});
	});
	
	jQuery('.read_more').click(function() {
		  jQuery('.read_more').show();
		  jQuery('div.news_cont_detail').slideUp();
		  par1 =jQuery(this).parent();
		  par2 = jQuery(par1).parent();
		  jack = jQuery(par2).find('div.news_cont_detail');
		  jQuery(this).hide();
		  if(jQuery(jack).css('display')=='none')
			  jQuery(jack).slideDown();
		  else
			  jQuery(jack).slideUp();
		  
		  return false;
	});
	jQuery('.custom_map_title').click(function() {
		  jQuery('.custom_map_options').slideToggle();
	});
	jQuery('.custom_map_options input').click(function() {
		  showFacilities();
	});
	
	
	if(are_img){
		// We only want these styles applied when javascript is enabled
		jQuery('div.navigation').css({'width' : '364px', 'float' : 'right'});
		jQuery('div.content_gal').css('display', 'block');

		// Initially set opacity on thumbs and add
		// additional styling for hover effect on thumbs
		var onMouseOutOpacity = 0.67;
		jQuery('#thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		
		// Initialize Advanced Galleriffic Gallery
		var gallery = jQuery('#thumbs').galleriffic({
			delay:                     2500,
			numThumbs:                 8,
			preloadAhead:              10,
			enableTopPager:            false,
			enableBottomPager:         true,
			maxPagesToShow:            7,
			imageContainerSel:         '#slideshow',
			controlsContainerSel:      '#controls',
			captionContainerSel:       '#caption',
			loadingContainerSel:       '#loading',
			renderSSControls:          true,
			renderNavControls:         true,
			playLinkText:              '<img src="/images/play.png" alt="play"/>',
			pauseLinkText:             '<img src="/images/pauze.png" alt="pause"/>',
			prevLinkText:              '&lsaquo; vorige foto',
			nextLinkText:              'volgende foto &rsaquo;',
			nextPageLinkText:          'volgende &rsaquo;',
			prevPageLinkText:          '&lsaquo; vorige',
			enableHistory:             false,
			autoStart:                 false,
			syncTransitions:           true,
			defaultTransitionDuration: 900,
			onSlideChange:             function(prevIndex, nextIndex) {
				// 'this' refers to the gallery, which is an extension of $('#thumbs')
				this.find('ul.thumbs').children()
					.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
					.eq(nextIndex).fadeTo('fast', 1.0);
			},
			onPageTransitionOut:       function(callback) {
				this.fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:        function() {
				this.fadeTo('fast', 1.0);
			}
		});
		}

});
jQuery(document).ready(function() { 
	jQuery('#image_rotate').innerfade({ 
		speed: 'slow', 
		timeout: 10000, 
		type: 'sequence', 
		containerheight: '122px'
	});
	
	jQuery('.prj_listing select').change(function() {
		  jQuery('.prj_listing form').submit();
	});
});

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}
		
function showFacilities(){
	var allmarkers = [];
	mgr.clearMarkers();
	var bounds = new GLatLngBounds();
	jQuery(".facility_checker:checked").each(function(){
		for (var i in markers_dan[jQuery(this).val()]) {
			var fac = markers_dan[jQuery(this).val()][i];
			if (fac.title!=''){
				jack = jQuery(this).val();
				
								
				var point = new GLatLng(fac.geo_lon, fac.geo_lat);
				var marker = createMarker(point,fac.title,fac.description, fac.id, ''); 
				allmarkers.push(marker);
				bounds.extend(point);
			}
		}
	});
	mgr.addMarkers(allmarkers,0, 17);
	mgr.refresh();
}
	

