window.addEvent('domready', function(){

	/* generic code to open all links with rel=_blank in new window, to pass validation in xhtml strict. */
	$$('a').each(function(link,i){
		if(link.get('rel')=='_blank') link.setProperty('target','_blank');
	});	
	/* end link code */

	/* Standard function to give mCCWrapper the remaining window height if avoidElements is defined */
	autosize_mCCWrapper();

	/* watermark search input field */
	$('query').addEvent('click', function(e){
		if(this.get('value') == this.get('alt'))
		{
			this.value = '';
		}	
	});

	$('query').addEvent('blur', function(e){
		if(this.get('value') == '')
		{
			this.value = this.get('alt');
		}	
	});
	/* end watermark*/	

	/* sjekker om den finner contact form og sjekker deretter om alle feleten er utfylt f¿r den sender */
	var cform = $$('.contactform');
	if(cform.get('id') == 'contactform'){
		cform.set('send',{
			onComplete : function(response){
				var result = JSON.decode(response);
				var msg = "";
				var error = 0;
				for(var i in result){
					error = error + 1;
					msg = msg + '\r\n' + result[i];
				}
				
				alert(msg);				
			}
		});
		
		$('btnsend').addEvent('click', function(e){
			e.stop();
			cform.send();		
		});
	}		
	/* form sjekk end */
});

window.addEvent('resize', function(){
	
	/* Standard function to give mCCWrapper the remaining window height if avoidElements is defined */
	autosize_mCCWrapper();
	
});

function submitform(frm){
	frm.s
}
