//var sDomain	= 'http://www.thinco.nl/';

function initialize() {
	var myLatlng = new google.maps.LatLng(51.86942,4.855589);
	var myOptions = {
	  zoom: 12,
	  center: myLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,	  
	  mapTypeControl: false
	}
	var map = new google.maps.Map(document.getElementById('map'), myOptions);
	
	var image = new google.maps.MarkerImage('images/google.png',
		new google.maps.Size(225, 121),
		// The origin for this image is 0,0.
		new google.maps.Point(0,0),
		// The anchor for this image is the base of the flagpole at 0,32.
		new google.maps.Point(100, 75)
	);

	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		icon: image
	}); 
	

	
}


function slideCycle(){
	$('#items')
	.after('<div id="nav">')
	.cycle({
		fx:     'fade',
		timeout: 7000,
		speed:	 600,
		random: 1,
		pager: '#nav'
	});
}

function contactform () {
	$('#send_message').click(function(e){
		
		//stop the form from being submitted
		e.preventDefault();
		
		/* declare the variables, var error is the variable that we use on the end
		to determine if there was an error or not */
		var error = false;
		var destiny = $('#destiny').val();
		var email = $('#email').val();
		var firstname = $('#firstname').val();
		var lastname = $('#lastname').val()
		var phone = $('#phone').val();
		var message = $('#message').val();
		
		if(destiny == '0'){
		var error = true;
			$('#destiny_error').fadeIn(500);
		}else{
			$('#destiny_error').fadeOut(500);
		}

		if(firstname.length == 0 || firstname == 'voornaam'){
		var error = true;
			$('#firstname_error').fadeIn(500);
		}else{
			$('#firstname_error').fadeOut(500);
		}

		if(lastname.length == 0|| lastname == 'achternaam'){
		var error = true;
			$('#lastname_error').fadeIn(500);
		}else{
			$('#lastname_error').fadeOut(500);
		}
					
		if(email.length == 0 || email.indexOf('@') == '-1'){
			var error = true;
			$('#email_error').fadeIn(500);
		}else{
			$('#email_error').fadeOut(500);
		}

		
/*
		if(phone.length == 0 || phone == 'telefoon'){
			var error = true;
			$('#phone_error').fadeIn(500);
		}else{
			$('#phone_error').fadeOut(500);
		}
*/
		if(message.length < 15 || message == 'bericht'){
			var error = true;
			$('#message_error').fadeIn(500);
		}else{
			$('#message_error').fadeOut(500);
		}
		
		//now when the validation is done we check if the error variable is false (no errors)
		if(error == false){

		
			//disable the submit button to avoid spamming
			//and change the button text to Sending...
			$('#send_message').attr({'disabled' : 'true', 'value' : '' });
			
			/* using the jquery's post(ajax) function and a lifesaver
			function serialize() which gets all the data from the form
			we submit it to send_email.php */

			
			$.post("send_email.php", $("#contact_form").serialize(),function(result){
				//and after the ajax request ends we check the text returned
				if(result == 'sent'){
					
					//if the mail is sent remove the submit paragraph
					 $('#cf_submit_p').remove();
					//and show the mail success div with fadeIn
					$('#mail_success').fadeIn(500);
				}else{
					//show the mail failed div
					$('#mail_fail').fadeIn(500);
					//reenable the submit button by removing attribute disabled and change the text back to Send The Message
					$('#send_message').removeAttr('disabled').attr('value', '');
				}
			});
		}
	});    			
}

$(".fancy").fancybox({
				'titleShow'		: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});






