$(function(){

	Cufon.replace('#slider p.primary', {
		fontFamily: 'Helvetica Neue LT Std',
		fontWeight: 275
	});
	Cufon.replace('#slider p.secondary', {
		fontFamily: 'Helvetica Neue LT Std',
		fontWeight: 300
	});

	$('body.contact #content form div.input:odd').addClass('odd');
	$('body.contact #content form div.input:even').addClass('even');

	$('.block.secondary article:first, #page > footer .top > ul > li:first').addClass('first');
	$('.block.secondary article:last, #page > footer .top > ul > li:last').addClass('last');

	$('#page > footer .top > ul > li').equalHeights();

	$('#slider').anythingFader({
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 5000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 500,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: false,         // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true              // If true, and autoPlay is enabled, the show will pause on hover
	});
	/*
	if ($('.gallery').size() > 0) {
		$('.gallery').nivoSlider({
			animSpeed: 100,
			effect: 'fade',
			slices: 1,
			directionNav: false,
			controlNav: true,
			controlNavThumbs: true,
			controlNavThumbsSearch: '.jpg',
			controlNavThumbsReplace: '_thumb.jpg',
			manualAdvance: true
		});
	}
	*/
	
	/*$('.form').submit(function(){
		$(this).find('.message').hide();
		name = $(this).find('input[id="contact-form-name"]').val();
		email = $(this).find('input[id="contact-form-email"]').val();
        country = $(this).find('input[id="contact-form-country"]').val();

		$(this).find('input[id="contact-form-name"], input[id="contact-form-email"], input[id="contact-form-country"]').removeClass('error');

		error = new Array();
		if (jQuery.trim(name) == '') {
			error.push($(this).find('input[id="contact-form-name"]'));
		}
        //if (jQuery.trim(country) == '') {
        //    error.push($(this).find('input[id="contact-form-country"]'));
        //}
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
			error.push($(this).find('input[id="contact-form-email"]'));
		}
		if ($(error).size() > 0) {
			$(error).each(function(){
				$(this).addClass('error');
			});
			$(this).find('.message').text('Please complete the fields marked in red').fadeIn();
			return false;
		}

	});*/
	
	
	
	/*$('.form.footer').submit(function(){
		$(this).find('.message').hide();
		name = $(this).find('input[id="contact-form-name-footer"]').val();
		email = $(this).find('input[id="contact-form-email-footer"]').val();

		$(this).find('input[id="contact-form-name-footer"], input[id="contact-form-email-footer"]').removeClass('error');

		error = new Array();
		if (jQuery.trim(name) == '') {
			error.push($(this).find('input[id="contact-form-name-footer"]'));
		}
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
			error.push($(this).find('input[id="contact-form-email-footer"]'));
		}
		if ($(error).size() > 0) {
			$(error).each(function(){
				$(this).addClass('error');
			});
			$(this).find('.message').text('Please complete the fields marked in red').fadeIn();
			return false;
		}
		else
		{
			$(this).find('.message').text('Message Sent').fadeIn();
			return false;
		}

	});*/
	
	
	

	/*if ($('#map').length > 0) {
		initialize();
	}*/
	$('#search').submit(function(){
		var search = $(this).find('input[id="search-term"]').val();
		if (jQuery.trim(search) == '') {
			return false;
		}
		return true;

	})
});

function initialize() {
	var latlng = new google.maps.LatLng(51.47847, 5.651779);
	var myOptions = {
		zoom: 14,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	/*
	var image = $('#map-icon').attr('src');
	var icon = new google.maps.Marker({
	      position: latlng,
	      map: map,
	      icon: image,
	      title: 'Parabeam'
	});
	*/
}

$(document).ready(function(){

	$('#gallery-container a').colorbox({slideshow:false,maxHidth:'100%', maxHeight:'100%'});

	$("#gallery-container a").live('click', function(event){
		event.preventDefault();
	});


	$("#gallery-thumbs a").click(function(e) {
		e.preventDefault();
		var imageIndex = $(this).index();
		
		$("#gallery-container a.active").fadeOut(function(){
			$(this).removeClass('active');
			$("#gallery-container a:eq(" + imageIndex + ")").fadeIn('fast').addClass('active');
		});
		$('#gallery-container a').colorbox({slideshow:false,maxHidth:'100%', maxHeight:'100%'});


	});
	
	//codigo thumbs video
	$('#video-thumbs a').click(function(){
    segundos = $(this).attr('id');
	segundos = segundos.replace("seg-desde-", "")
    //alert (segundos);
	
    flowplayer().seek(segundos);
	});
	
	
});
