// JavaScript Document
$(document).ready(function(){
	$("ul.mainMenu li").hover(function(){
		$(this).find('ul').show();
	},
	function(){
		$(this).find('ul').hide();
	});
	$('.contactForm input[type="text"][name$="your-name"]').focus(function(){
		if (this.value=="Navn*") this.value="";
	});
	$('.contactForm input[type="text"][name$="your-phone"]').focus(function(){
		if (this.value=="Telefon") this.value="";
	});
	$('.contactForm input[type="text"][name$="your-email"]').focus(function(){
		if (this.value=="E-mail*") this.value="";
	});
	$('.contactForm textarea').focus(function(){
		if (this.value=="Besked*") this.value="";
	});
	
	$('.greenContactnew input[type="text"][name$="your-name"]').focus(function(){
		if (this.value=="Navn*") this.value="";
	});
	$('.greenContactnew input[type="text"][name$="your-email"]').focus(function(){
		if (this.value=="E-mail*") this.value="";
	});	
	$('.greenContactnew textarea').focus(function(){
		if (this.value=="Besked*") this.value="";
	});
	
	/*$(".greenContactnew").ready(function(){
		var visibleArea = window.innerHeight;
		topmargin = visibleArea/2 - $('.greenContactnew').height()/2;
		$('.greenContactnew').css('top', topmargin);
	});
	
	var options = { 
		target:     '.greenContactnew', 
		url:        'comment.php', 
		success:    function() { 
			alert('Thanks for your comment!'); 
		} 
	}; 
	$("#greenForm").validate({ 
		rules: { 
			name: "required",// simple rule, converted to {required:true} 
			email: {// compound rule 
				required: true, 
				email: true 
			},
	        message: { 
	          required: true 
	        } 
		}, 
		messages: { 
			message: "Please enter a message." 
		},
		submitHandler: function(form) {
			var opts = {
				target: '.greenContactnew',
			success: function(data) {
			alert("here");
			}
			};
			$(form).ajaxSubmit(opts);
		}
	});
	*/
	$(window).scroll(function(){
		if (window.pageYOffset > $('#greenBoxWrapper').position().top) {
			$('.greenContactnew').offset({top: window.pageYOffset+10});
		}
	});/*
	$(window).scroll(function(){ //alert("hi"); alert(document.documentElement.scrollTop);
		if (document.documentElement.scrollTop > $('#greenBoxWrapper').position().top) {
			$('.greenContactnew').offset({top: document.documentElement.scrollTop+10});
		}
	});*/
	
});
