$(document).ready(function(){
	$('a[rel="print"]').click( function() {
	 	TheNewWin = window.open($(this).attr('href'),'mypop','height=600,width=555,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	  return false;
	});
	
	$('input.send').hover(function(){
		$(this).attr('src', 'images/base/btn_skicka_hover.png');
	}, function(){
		$(this).attr('src', 'images/base/btn_skicka.png');
	});
	
	$("#newsTipSend").click(function(ev){
		ev.preventDefault();
		
		var data = new Object();
			data.action = 'sendNewsTip';
			if(typeof($("#newsTip_name").val()) !== 'undefined'){
				data.name = $("#newsTip_name").val();
			} else {
				data.name = 'Inte angivet';
			}
			
			if(typeof($("#newsTip_email").val()) !== 'undefined'){
				data.email = $("#newsTip_email").val();
			} else {
				data.email = 'Inte angivet';
			}
			
			if(typeof($("#newsTip_phone").val()) !== 'undefined'){
				data.telephone = $("#newsTip_phone").val();
			} else {
				data.telephone = 'Inte angivet';
			}
			
			if(typeof($("#newsTip_message").val()) !== 'undefined'){
				data.message = $("#newsTip_message").val();
			} else {
				data.message = 'Inte angivet';
			}
			
			var dataString = $.toJSON(data);
	  	
	  	$("#sendMessageWrapper").slideDown();
	  	
	  	$.post('ajax/contact.php', {data: dataString}, function(res){
	  		var obj = $.evalJSON(res);
			if(obj.success == 1){
				$("#sendMessage").text('Ditt meddelande har blivit skickat, tack!');
			}
		  });
	});
	
	$("p").each(function(){
		var previous = $(this).prev();
		if(previous.is('h3')){
			$(this).css({ 'margin-top' :  '5px'});
		}
	});
	
	if($.browser.msie){
		if($.browser.version.string() == "7.0"){
			$("hr.leafs").each(function(){
				$(this).replaceWith('<img src="images/base/hr.leafs.png" alt="Avdelning" />');
			});
		}
	}
});