//BACK TO TOP

	$(document).ready(function(){
		$('a[href*=#top]').click(function() {
		if (location.pathname.replace(/^\//,") == this.pathname.replace(/^\//,")
		&& location.hostname == this.hostname) {
		var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
			var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
				}
			}
		});
	});

//GOOGLE MAPS CODE
	
	function initialize() {     
		var latlng = new google.maps.LatLng(53.22310,6.56363);  
		var markerPos = new google.maps.LatLng(53.22270,6.56360);
		
		var myOptions = {       
			zoom: 16,       
			center: latlng,       
			mapTypeId: google.maps.MapTypeId.ROADMAP  
		};  
		   
		var map = new google.maps.Map(document.getElementById("map_canvas"),         
			myOptions);   
		
		var marker = new google.maps.Marker({
			position: markerPos, 
			map: map, 
			title:"Grasgroen Media",
			icon: '/cfsystem/layout/images/point.png',
			clickable: false
		});

	}



//SKYPE REMOVE PLUGIN MARKUP CODE

	$(document).ready(function() {
		
		$("a").filter(function() {

        	return this.hostname && this.hostname.replace("www.", "") != location.hostname.replace("www.", "");

    	}).click(function() {

        	window.open($(this).attr("href"));

        	return false;

    	});
	
		$.geekSkypeRemover(10000000);
	});



//NIEUWSBRIEF CODE

	$(document).ready(function() {
		
		$(".loadingTweets").show();		
		
		$("#tweetStreamContent").tweet({
            username: "grasgroenmedia",
            join_text: "auto",
            avatar_size: 32,
            count: 3,
            auto_join_text_default: "",
            auto_join_text_ed: "",
            auto_join_text_ing: "",
            auto_join_text_reply: "",
            auto_join_text_url: "",
            loading_text: "",
			//query: "#grasgroenmedia"
        });	
						   
		var validate = $("#myForm2").validate({
			errorClass: "error2",					
			rules: {
				emailnieuwsbrief: {
					required: true,
					email: true
				}
			},
			messages: {
				emailnieuwsbrief: {
					required: "Vul uw email adres in.",
					minlength: "Gebruik een geldig email."
				}                
			}, 
			submitHandler: function() {
				$(".loadingSubscription").show();
				$("#myForm2").ajaxSubmit({
					success: function() { 
						var email = document.getElementById("emailnieuwsbrief").value;
						$("#edituser_feedback").load("/index.php", { 	
							'loadRequestFront'	: 'loadRequestFront', 
							'object'			: 'loadRequestFront', 
							'function'			: 'addMailToDb',
							'emailnieuwsbrief'				: email
						}, function(data){					
								$(".loadingSubscription").hide();				
						});
					} 
				});
			}
		});
	});	
	

//TOOLTIP CODE

	this.tooltip = function(){	
		/* CONFIG */		
			xOffset = 10;
			yOffset = 20;		
			// these 2 variable determine popup's distance from the cursor
			// you might want to adjust to get the right result		
		/* END CONFIG */		
		$("a.tooltip").hover(function(e){											  
			this.t = this.title;
			//this.title = "";									  
			$("body").append("<p id='tooltip'>"+ this.t +"</p>");
			$.geekSkypeRemover(10000000);
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");		
		},
		function(){
			this.title = this.t;		
			$("#tooltip").remove();
		});	
		$("a.tooltip").mousemove(function(e){
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});			
	};
	
	$(document).ready(function(){
		tooltip();
	});
	
	
	
//FANCYBOX CODE

	$(document).ready(function() {

		$("a[rel=portfolio]").fancybox({
			'titlePosition' : 'over',
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">' + title.replace("Klik voor een vergroting van het project: ", ""); + '</span>';
			}
		});
	});	
	
	
	
//LAVALAMP CODE

	$(function() {
	
		$(".1").lavaLamp({
			fx: "backout",
			speed: 800,
			click: function(event, menuItem) {
				return true;
			}
		});
		
	});
	
	
	
//FORM VALIDATIE CODE

	$(document).ready(function() {
		 
		var validate = $("#myForm").validate({
			rules: {
				naam: {
					required: true
				},
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				naam: {
					required: "Vul uw naam in."
				},
				email: {
					required: "Vul uw email adres in.",
					minlength: "Gebruik een geldig email."
				}
			
			},
			submitHandler: function() {
				$("#myForm").ajaxSubmit({
					success: function() { 
						$("#contact_form").html("Bedankt voor uw reactie. Wij zullen zo spoedig mogelijk reageren.");
						setTimeout(function() { 
							$('#contact_route_wrapper').stop().animate( {marginTop: "-280px"}, 500, function() {
								$("#contact_push").html('Contact <img src="/cfsystem/layout/images/show_contact.png" />');
							});
							setTimeout(function() { 
								location.reload();
							}, 600);
						}, 2000);
					} 
				});
			}
		});
		
	});
	
	
	
//REST JQUERY CODE

	$(function() {

		$("#contact_push").toggle(function() {
			$('#contact_route_wrapper').stop().animate( {marginTop: "0px"}, 500, function() {
				$("#contact_push").html('Contact <img src="/cfsystem/layout/images/hide_contact.png" />');
			});
		}, function(){
			$('#contact_route_wrapper').stop().animate( {marginTop: "-280px"}, 500, function() {
				$("#contact_push").html('Contact <img src="/cfsystem/layout/images/show_contact.png" />');
			});
		});
	
	});	
	
	$(document).ready(function(){	
	
		$("#slider").easySlider({
			auto: true,
			continuous: true,
			controlsShow: true,
			pause: 10000,
			speed: 1500
		});
		
	});
	
	Cufon.replace('h1');
	
	function toggleNews(){
		$("#nieuwsbrief").toggle("slide");	
	}
	
	$(".portfolio_frontpage_content").mouseover(function() {
		var theID	= $(this).attr('id');
		$("#" + theID + " .portfolio_frontpage_content_title").stop().animate( {top: "121px"}, 400);
	});
	
	$(".portfolio_frontpage_content").mouseout(function() {
		var theID	= $(this).attr('id');
		$("#" + theID + " .portfolio_frontpage_content_title").stop().animate( {top: "159px"}, 400);
	});
