var tmp_home = "http://www.muf.se";
function doClear(theText)
{ if(theText.value == theText.defaultValue || theText.value == "Sök på muf.se" || theText.value == "Artikelsök"){ theText.value = ""; theText.style.color = "#777"; } }

function doClearPost(theText)
{ if(theText.value == theText.defaultValue){ theText.value = ""; theText.style.color = "#000"; } }

function doSet(theText)
{
	if(theText.value ==''){ theText.style.color = "#bfbfbf"; theText.value="Epost"; } 
}

function doSetKontakt(theText)
{
	if(theText.value ==''){ theText.value="Hitta profil"; } 
}

function setMufSearch()
{
	document.getElementById('searchField').style.color = "#777"; document.getElementById('searchField').value="Sök på muf.se";
}

function setArticleSearch()
{
	document.getElementById('searchField').style.color = "#777"; document.getElementById('searchField').value="Artikelsök";
}

function doSetWriteTo(theText)
{
	if(theText.value ==''){ theText.value="Skriv till..."; } 
}

function doSetSkrivInlaggTo(theText)
{
	if(theText.value ==''){ theText.value="Skriv ett nytt inlägg"; } 
}

function getYoutubeBlock(id)
{	
	if(document.getElementById('youtube_block'+id+'').style.display=="block")
	{ document.getElementById('youtube_block'+id+'').style.display="none"; }
	else
	{ document.getElementById('youtube_block'+id+'').style.display="block"; }
}

function getImageBlock(id)
{	
	if(document.getElementById('image_block'+id+'').style.display=="block")
	{ document.getElementById('image_block'+id+'').style.display="none"; }
	else
	{ document.getElementById('image_block'+id+'').style.display="block"; }
}

function showForumVideo(id)
{

	document.getElementById('yt_video_'+id+'').style.display="block"
	document.getElementById('yt_image_'+id+'').style.display="none"
}

function checkPost(form, id)
{
	var ret = 0; var imgRights = "false"; var imgChk = 0; 
	for(i=0; i < form.elements.length; i++)
	{
		if(form.elements[i].type == "checkbox" && form.elements[i].name == "imageRights")
		{
			if(form.elements[i].checked == true){ imgRights = "true"; }
		}
	}
	
	if(imgRights == "false")
	{
		for(i=0; i < form.elements.length; i++)
		{
			if(form.elements[i].type == "file" && form.elements[i].name == "inlaggImage[]")
			{ 
				if(form.elements[i].value == ""){ imgChk++; }
				else{ ret = 1; }
			}
		}
	}
	
	if(imgChk == 4){ imgRights = "true"; }
	
	
	if(imgRights == "false")
	{ document.getElementById('imageRightsText'+id+'').style.color = "#ff0000"; }
	else{ document.getElementById('imageRightsText'+id+'').style.color = "#777777"; }

	var chkYT = document.getElementById('embed_video'+id+'').value.substring(0,7);

	if(chkYT!="<object")
	{
		if(chkYT == ""){ document.getElementById('error_yt'+id+'').style.display="none"; }
		else{ document.getElementById('error_yt'+id+'').style.display="block"; ret = 1; }
	}

	var post = document.getElementById('text'+id+'').value;

	if(post == "Skriv ett nytt inlägg" || post==""){ document.getElementById('text'+id+'').style.color="#ff0000"; ret=1; }
	else{ document.getElementById('text'+id+'').style.color="#000000"; }


	if(ret > 0){ return false; }
}

function getCommentField(id, s)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('commentField_'+id+'');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getComment = "getComment";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getCommentField.php?id="+id+"&s="+s+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getComment.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getComment);
}

function getCommentField2(id, s)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('commentField_'+id+'');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getComment = "getComment";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getCommentField2.php?id="+id+"&s="+s+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getComment.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getComment);
}

function getAllComments(id, map, page, k_page, org_id, d_id, f_id)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('comments_'+id+'');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getAllComments = "getAllComments";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getAllComments.php?id="+id+"&map="+map+"&page="+page+"&k_page="+k_page+"&org_id="+org_id+"&d_id="+d_id+"&f_id="+f_id+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getAllComments.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getAllComments);
}

function showAllComments(id, page)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('comments_'+id+'');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getAllComments = "getAllComments";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getAllComments.php?id="+id+"&page="+page+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getAllComments.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getAllComments);
}

function showAllComments2(id, page, org_id, d_id, f_id, d_chk)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('comments_'+id+'');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getAllComments = "getAllComments";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getAllComments2.php?id="+id+"&page="+page+"&o_id="+org_id+"&d_id="+d_id+"&f_id="+f_id+"&d_chk="+d_chk+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getAllComments.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getAllComments);
}


function liveSearch()
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('searchBox');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var txt = document.getElementById('search').value;
	
	var searchText = "searchText";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getLiveSearch.php?text="+txt+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", searchText.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(searchText);
}

function writeTo()
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('writeBox');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var txt = document.getElementById('write').value;
	
	var writeToText = "writeToText";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getWriteTo.php?text="+txt+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", writeToText.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(writeToText);
}


function showDistrikt(orgNr, d_id)
{
	if(orgNr == 3)
	{ 
		var ajaxDisplay = document.getElementById('distrikt');
		ajaxDisplay.innerHTML = ""; 
	}
	if(orgNr == 1 || orgNr == 2)
	{
		var ajaxDisplay = document.getElementById('distriktForening');
		ajaxDisplay.innerHTML = ""; 	
	}

		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}

		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				if(orgNr == 3 || orgNr == 4)
				{
					var ajaxDisplay = document.getElementById('distriktForening');
					ajaxDisplay.innerHTML = ajaxRequest.responseText;
				}
				else
				{
					var ajaxDisplay = document.getElementById('distrikt');
					ajaxDisplay.innerHTML = ajaxRequest.responseText;
				}
	
			}
		}
		var distriktForening = "distriktForening";
		if(orgNr == 3)
		{
			ajaxRequest.open("POST", ""+tmp_home+"/ajax/getForening.php?org_id="+orgNr+"", true);
		}
		else
		{
			ajaxRequest.open("POST", ""+tmp_home+"/ajax/getDistrikt.php?d_id="+d_id+"&o_id="+orgNr+"", true);
		}
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", distriktForening.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(distriktForening);
	
}

function showForening(distriktNr)
{
	if(distriktNr == 0)
	{ 
		var ajaxDisplay = document.getElementById('distriktForening');
		ajaxDisplay.innerHTML = ""; 
	}
	else
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				var ajaxDisplay = document.getElementById('distriktForening');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
	
			}
		}
		var distriktForening = "distriktForening";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/getForening.php?id="+distriktNr+"&org_id="+document.getElementById('org_id').value+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", distriktForening.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(distriktForening);
	}
}

function writeFlash(id, url, width, height)
{
    document.write( "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n" );
    document.write( "  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0\"\n" );
    document.write( "  id=\"Movie-"+id+"\" width=\""+width+"\" height=\""+height+"\">\n" );
    document.write( "  <param name=\"movie\" value=\""+url+"\">\n" );
    document.write( "  <param name=\"menu\" value=\"false\">\n" );
    document.write( "  <param name=\"quality\" value=\"best\">\n" );
    document.write( "  <param name=\"wmode\" value=\"transparent\">\n" );
    document.write( "  <param name=\"bgcolor\" value=\"#ffffff\">\n" );
    document.write( "    <embed name=\"Movie1\" src=\""+url+"\"\n" );
    document.write( "     menu=\"false\" quality=\"best\" wmode=\"transparent\" bgcolor=\"#ffffff\" swLiveConnect=\"true\"\n" );
    document.write( "     width=\""+width+"\" height=\""+height+"\"\n" );
    document.write( "     type=\"application/x-shockwave-flash\"\n" );
    document.write( "     pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>\n" );
    document.write( "</object>\n" );
}

function showReport(id){ document.getElementById("image_"+id).style.visibility="visible"; }
function hideReport(id){ document.getElementById("image_"+id).style.visibility="hidden"; }
function showReportComment(id){ document.getElementById("comment_"+id).style.visibility="visible"; }
function hideReportComment(id){ document.getElementById("comment_"+id).style.visibility="hidden"; }

function showReportCommentBambuser(id)
{document.getElementById("b_comment_"+id).style.visibility="visible"; }
function hideReportCommentBambuser(id)
{ document.getElementById("b_comment_"+id).style.visibility="hidden"; }

function report_inlagg(id)
{
	var agree = confirm("Vill du rapportera detta inlägg som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportInlagg = "reportInlagg";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportInlagg.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportInlagg.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportInlagg);
	}
}

function report_inlagg_debatt(id)
{
	var agree = confirm("Vill du rapportera detta inlägg som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportInlagg = "reportInlagg";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportInlaggDebatt.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportInlagg.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportInlagg);
	}
}

function report_comment(id)
{
	var agree = confirm("Vill du rapportera detta inlägg som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportComment.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function report_kommentar_debatt(id)
{
	var agree = confirm("Vill du rapportera detta inlägg som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentDebatt.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function printContent(id)
{
	var url = tmp_home+"/include/artiklar/print.php?id="+id+"";
	window.open(url,'','location=1,status=1, scrollbars=1,menubar=1, left=0,top=0,width=475,height=800')  
}

function tipsa(id)
{
	var url = tmp_home+"/include/artiklar/tipsa.php?id="+id+"";
	window.open(url,'','location=1,status=1, scrollbars=1,menubar=1,left=0,top=0,width=475,height=600')  
}

function tipsa_tubeit(id)
{
	var url = tmp_home+"/tubeit/tipsa.php?id="+id+"";
	window.open(url,'','location=1,status=1, scrollbars=1,menubar=1,left=0,top=0,width=475,height=600')  
}


function showAddress(address)
{
   var map = new GMap2(document.getElementById("map_canvas"));

   if(geocoder)
   {
        geocoder.getLatLng(address, function(point)
		{
            if (!point){ alert(address + " hittades inte"); }
			else
			{
				document.getElementById("lat").value = point.lat().toFixed(5);
				document.getElementById("long").value = point.lng().toFixed(5);
				map.clearOverlays()
				map.setCenter(point, 14);
   				map.setUIToDefault();
				
				GEvent.addListener(map,"click", function(overlay, point)
				{     
					if(point)
					{	
						document.getElementById('lat').value = point.lat();
						document.getElementById('long').value = point.lng();
						document.getElementById('zoom').value = map.getZoom();
					}
				}
				);
            }
          });
      }
}

function recalculateDate(place)
{
	
	if(place >= 0 && place <= 1)
	{
		if(place == 0)
		{
			var year = document.getElementById('sYear').value; 
			var mon = document.getElementById('sMonth').value;
			var day = document.getElementById('sDay').value;
		}
		else if(place == 1)
		{

			var year = document.getElementById('eYear').value; 
			var mon = document.getElementById('eMonth').value;
			var day = document.getElementById('eDay').value;
		}
		
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}

		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				if(place == 0){	var ajaxDisplay = document.getElementById('update_start_date'); }
				if(place == 1){ var ajaxDisplay = document.getElementById('update_end_date'); }
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
	
			}
		}
		var month = "month";
		ajaxRequest.open("POST", "/ajax/recalculate.php?y="+year+"&m="+mon+"&d="+day+"&p="+place+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", month.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(month);
	}
}

function check_sms_form(f, intyg)
{
	var ret = 0;
	var i; var validateLastFour = true; var validateMobilnr = true;
	
	if(f.fnamn.value==""){ document.getElementById('label_fnamn').innerHTML = '<b><font color="red">Namn *</font></b>'; ret++;}
	else{document.getElementById('label_fnamn').innerHTML = 'Namn *'; }
	
	if(f.enamn.value==""){ document.getElementById('label_enamn').innerHTML = '<b><font color="red">Efternamn *</font></b>'; ret++;}
  	else{document.getElementById('label_enamn').innerHTML = 'Efternamn *'; }
	
	for(i = 0; i < f.sistaFyraPnr.value.length; i++)
	{
		var c = f.sistaFyraPnr.value.charAt(i);
		if((c >="0") && (c <="9")){}
		else { validateLastFour = false; }
	}

	if(f.sistaFyraPnr.value=="" || f.sistaFyraPnr.value.length != 4 || validateLastFour == false){ document.getElementById('label_pnr').innerHTML = '<b><font color="red">Personnr. *</font></b>'; ret++;}
  	else{document.getElementById('label_pnr').innerHTML = 'Personnr. *'; }

	if(f.gata.value==""){ document.getElementById('label_gata').innerHTML = '<b><font color="red">Gata *</font></b>'; ret++;}
  	else{document.getElementById('label_gata').innerHTML = 'Gata *'; }

	if(f.postnr.value==""){ document.getElementById('label_postnr').innerHTML = '<b><font color="red">Postnr *</font></b>'; ret++;}
  	else{document.getElementById('label_postnr').innerHTML = 'Postnr *'; }
	
	if(f.postort.value==""){ document.getElementById('label_postort').innerHTML = '<b><font color="red">Postort *</font></b>'; ret++;}
  	else{document.getElementById('label_postort').innerHTML = 'Postort *'; }
	
	if(f.kod.value==""){ document.getElementById('label_kod').innerHTML = '<b><font color="red">Kod *</font></b>'; ret++;}
  	else{document.getElementById('label_kod').innerHTML = 'Kod *'; }
	
	for(i = 0; i < f.mobilnr.value.length; i++)
	{
		var c = f.mobilnr.value.charAt(i);
		if((c != "-")){}
		else { validateMobilnr = false; }
	}
	
	
	if(f.mobilnr.value=="" || validateMobilnr == false){ document.getElementById('label_mobilnr').innerHTML = '<b><font color="red">Mobilnr *</font></b>'; ret++;}
  	else{document.getElementById('label_mobilnr').innerHTML = 'Mobilnr *'; }
	
	if(intyg == "1")
	{
		if(document.f.intyg[1].checked)
		{ document.getElementById('label_intygar').style.color = '#000'; }
		else{ document.getElementById('label_intygar').style.color = '#f00'; ret++;}
	}
	
	if(ret>0){ return false; }
}

function check_sms_form_rm(f, intyg)
{
	var ret = 0;
	var i; var validateLastFour = true; var validateMobilnr = true;
	
	if(f.fnamn.value==""){ document.getElementById('label_fnamn').innerHTML = '<b><font color="red">Namn *</font></b>'; ret++;}
	else{document.getElementById('label_fnamn').innerHTML = 'Namn *'; }
	
	if(f.enamn.value==""){ document.getElementById('label_enamn').innerHTML = '<b><font color="red">Efternamn *</font></b>'; ret++;}
  	else{document.getElementById('label_enamn').innerHTML = 'Efternamn *'; }
	
	for(i = 0; i < f.sistaFyraPnr.value.length; i++)
	{
		var c = f.sistaFyraPnr.value.charAt(i);
		if((c >="0") && (c <="9")){}
		else { validateLastFour = false; }
	}

	if(f.sistaFyraPnr.value=="" || f.sistaFyraPnr.value.length != 4 || validateLastFour == false){ document.getElementById('label_pnr').innerHTML = '<b><font color="red">Personnr. *</font></b>'; ret++;}
  	else{document.getElementById('label_pnr').innerHTML = 'Personnr. *'; }

	if(f.kod.value==""){ document.getElementById('label_kod').innerHTML = '<b><font color="red">Kod *</font></b>'; ret++;}
  	else{document.getElementById('label_kod').innerHTML = 'Kod *'; }
	
	for(i = 0; i < f.mobilnr.value.length; i++)
	{
		var c = f.mobilnr.value.charAt(i);
		if((c != "-")){}
		else { validateMobilnr = false; }
	}
	
	
	if(f.mobilnr.value=="" || validateMobilnr == false){ document.getElementById('label_mobilnr').innerHTML = '<b><font color="red">Mobilnr *</font></b>'; ret++;}
  	else{document.getElementById('label_mobilnr').innerHTML = 'Mobilnr *'; }
	
	if(intyg == "1")
	{
		if(document.f.intyg[1].checked)
		{ document.getElementById('label_intygar').style.color = '#000'; }
		else{ document.getElementById('label_intygar').style.color = '#f00'; ret++;}
	}
	
	if(ret>0){ return false; }
}

function delete_follow(id, namn)
{
	var agree = confirm("Vill du sluta följa "+namn+"?");
	if (agree)
	{
		window.location=""+tmp_home+"/debatt/ta_bort/remove_follower.php?id="+id+"";
	}
}

function delete_kommentar_debatt(id, unik)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/debatt/ta_bort/remove_kommentar.php?id="+id+"&unik="+unik+"";
	}
}

function delete_inlagg_debatt(id)
{
	var agree = confirm("Vill du verkligen ta bort inlägget och dess kommentarer?");
	if (agree)
	{
		window.location=""+tmp_home+"/debatt/ta_bort/remove_inlagg.php?id="+id+"";
	}
}

function delete_inlagg(id, org_id, d_id, f_id, page, d_chk)
{
	var agree = confirm("Vill du verkligen ta bort inlägget och dess kommentarer?");
	if (agree)
	{
		window.location=""+tmp_home+"/medlemsinfo/kommunikation/ta_bort/remove_inlagg.php?id="+id+"&org_id="+org_id+"&d_id="+d_id+"&f_id="+f_id+"&page="+page+"&d_chk="+d_chk+"";
	}
}

function delete_comment(id, org_id, d_id, f_id, page, unik, d_chk)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/medlemsinfo/kommunikation/ta_bort/remove_kommentar.php?id="+id+"&org_id="+org_id+"&d_id="+d_id+"&f_id="+f_id+"&page="+page+"&unik="+unik+"&d_chk="+d_chk+"";
	}
}

function getMessageField(id, s)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('messageField');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getMessageField = "getMessageField";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getMessageField.php?id="+id+"&s="+s+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getMessageField.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getMessageField);
}

function getAktivitet(id, kpage, d_id)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('aktivitet_container');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var getAkt = "getAkt";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getAktivitet.php?k_id="+id+"&p="+kpage+"&d_id="+d_id+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getAkt.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getAkt);
}

function getAllAktivitet(page, d_id)
{
	var ajaxRequest;
		try	{ ajaxRequest = new XMLHttpRequest(); }
		catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
				catch (e){alert("Your browser broke!");	return false;	} }	}
	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{

			var ajaxDisplay = document.getElementById('aktivitet_container');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var getAllAkt = "getAllAkt";
	ajaxRequest.open("POST", ""+tmp_home+"/ajax/getAllAktivitet.php?p="+page+"&d_id="+d_id+"", true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", getAllAkt.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(getAllAkt);
}

function kalender(id)
{
	var url = tmp_home+"/_aktivitet.php?id="+id+"";
	window.open(url,'','location=1,status=1, scrollbars=1,menubar=0, left=0,top=0,width=425,height=400')  
}

function check_value(value)
{
	if(value==0){ return false }
	return true;
}

function skapaKontoChk(form)
{
	var password = 0;
	var number = false;
	
	if(document.getElementById('anvandarvilkor').checked == true)
	{ document.getElementById('vilkor_text').style.color = "#000"; }
	else { document.getElementById('vilkor_text').style.color = "#f00"; password++;}
	
	if(document.getElementById('pw').value.length >= "8")
	{
		len = document.getElementById('pw').value.length;
		for(i = 0; i < len; i++)
		{	
			var c = document.getElementById('pw').value.charAt(i);
			if((c >="0") && (c <="9")){ number = true; }	
		}
	}
	else{ document.getElementById('pw_text').style.color = "#f00"; password++;}
	
	if(password == 0 && number == true){ }
	else{ return false; }
}

function anvandarvilkor()
{
	var url = tmp_home+"/konto/anvandarvilkor.php";
	window.open(url,'','location=1,status=1, scrollbars=1,menubar=0, left=0,top=0,width=600,height=500')  
}

function glomtLosenChk(form)
{
	var password = "false";

	if(document.getElementById('pw').value.length >= "8")
	{
		len = document.getElementById('pw').value.length;
		for(i = 0; i < len; i++)
		{	
			var c = document.getElementById('pw').value.charAt(i);
			if((c >="0") && (c <="9")){ password = "true"; }	
		}
	}
	if(password == "true"){ return true; }
	document.getElementById('pw_text').style.color = "#f00";
	return false;
}

function nwShowComments()
{	
	
	if(document.getElementById('comments').style.display=="block")
	{
		document.getElementById('comments').style.display="none";
		document.getElementById('showAndHide').innerHTML = "Visa kommenter"
	}
	else
	{ 
		document.getElementById('comments').style.display="block";
		document.getElementById('showAndHide').innerHTML = "Dölj kommenter"
	}
	
}

function nwShowBambuser()
{	
	
	if(document.getElementById('b_comments').style.display=="block")
	{
		document.getElementById('b_comments').style.display="none";
		document.getElementById('showAndHideBambuser').innerHTML = "Visa kommenter"
	}
	else
	{ 
		document.getElementById('b_comments').style.display="block";
		document.getElementById('showAndHideBambuser').innerHTML = "Dölj kommenter"
	}
	
}



function nwShowBloggar()
{	
	
	if(document.getElementById('bloggar').style.display=="block")
	{
		document.getElementById('bloggar').style.display="none";
		document.getElementById('showAndHideBloggar').innerHTML = "Bloggar jag läser"
	}
	else
	{ 
		document.getElementById('bloggar').style.display="block";
		document.getElementById('showAndHideBloggar').innerHTML = "Dölj bloggar jag läser"
	}
	
}


function check_form(f)
{
	var ret = 0;
	var i; var validateLastFour = true; 
	
	if(f.namn.value==""){ document.getElementById('label_namn').innerHTML = '<b><font color="red">Namn</font></b>'; ret++;}
	else{document.getElementById('label_namn').innerHTML = 'Namn'; }
	
	for(i = 0; i < f.sistaFyraPnr.value.length; i++)
	{
		var c = f.sistaFyraPnr.value.charAt(i);
		if((c >="0") && (c <="9")){}
		else { validateLastFour = false; }
	}

	if(f.sistaFyraPnr.value=="" || f.sistaFyraPnr.value.length != 4 || validateLastFour == false){ document.getElementById('pnr').innerHTML = '<b><font color="red">Personnr</font></b>'; ret++;}
  	else{document.getElementById('pnr').innerHTML = 'Personnr'; }
	
	if(f.mob.value==""){ document.getElementById('label_mob').innerHTML = '<b><font color="red">Mobil</font></b>'; ret++;}
  	else{document.getElementById('label_mob').innerHTML = 'Mobil'; }
	
	if(f.epost.value==""){ document.getElementById('label_epost').innerHTML = '<b><font color="red">E-post</font></b>'; ret++;}
  	else{document.getElementById('label_epost').innerHTML = 'E-post'; }

	if(f.distrikt.value=="0"){ document.getElementById('label_distrikt').innerHTML = '<b><font color="red">Distrikt</font></b>'; ret++;}
  	else{document.getElementById('label_distrikt').innerHTML = 'Distrikt'; }


	if(ret>0){ return false; }
}

function delete_kommentar_nw(id)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/niklas/ta_bort/remove_kommentar.php?id="+id+"";
	}
}

function delete_kommentar_nw_bu(id)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/niklas/ta_bort/remove_kommentar_bu.php?id="+id+"";
	}
}

function delete_kommentar_almedalen(id)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/almedalen/ta_bort/remove_kommentar.php?id="+id+"";
	}
}

function delete_kommentar_almedalen_bu(id)
{
	var agree = confirm("Vill du verkligen ta bort kommentaren?");
	if (agree)
	{
		window.location=""+tmp_home+"/almedalen/ta_bort/remove_kommentar_bu.php?id="+id+"";
	}
}


function report_kommentar_nw(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentNw.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function report_kommentar_nw_bu(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentNwBu.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function report_kommentar_almedalen(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentAlmedalen.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function report_kommentar_almedalen_bu(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentAlmedalenBu.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}





function report_kommentar_tubeit(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportCommentTubeit.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function report_kommentar_artikel(id)
{
	var agree = confirm("Vill du rapportera denna kommentar som stötande?");
	if (agree)
	{
		var ajaxRequest;
			try	{ ajaxRequest = new XMLHttpRequest(); }
			catch (e) {	try	{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
					catch (e){alert("Your browser broke!");	return false;	} }	}
		
		var reportComment = "reportComment";
		ajaxRequest.open("POST", ""+tmp_home+"/ajax/setReportArticleComment.php?id="+id+"", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajaxRequest.setRequestHeader("Content-length", reportComment.length);
		ajaxRequest.setRequestHeader("Connection", "close");
		ajaxRequest.send(reportComment);
	}
}

function anmalningsform_chk(id)
{
	var ret = 0;
	if(id == 1)
	{
		if(document.getElementById('anv').checked == false)
		{
			document.getElementById('anv_c').style.color = "#f00";
			ret++; 
		}
	}
	
	if(ret > 0){ return false }
	
}

function check_order_form_nw(f)
{
	var ret = 0;
	var i; var validateLastFour = true; 
	
	if(f.fnamn.value==""){ document.getElementById('label_fnamn').innerHTML = '<b><font color="red">Namn</font></b>'; ret++;}
	else{document.getElementById('label_fnamn').innerHTML = 'Namn'; }
	
	if(f.enamn.value==""){ document.getElementById('label_enamn').innerHTML = '<b><font color="red">Efternamn</font></b>'; ret++;}
  	else{document.getElementById('label_enamn').innerHTML = 'Efternamn'; }
	
	if(f.gata.value==""){ document.getElementById('label_gata').innerHTML = '<b><font color="red">Gata</font></b>'; ret++;}
  	else{document.getElementById('label_gata').innerHTML = 'Gata'; }

	if(f.postnr.value==""){ document.getElementById('label_postnr').innerHTML = '<b><font color="red">Postnr</font></b>'; ret++;}
  	else{document.getElementById('label_postnr').innerHTML = 'Postnr'; }
	
	if(f.postort.value==""){ document.getElementById('label_postort').innerHTML = '<b><font color="red">Postort</font></b>'; ret++;}
  	else{document.getElementById('label_postort').innerHTML = 'Postort'; }
	
	if(f.tele.value==""){ document.getElementById('label_tele').innerHTML = '<b><font color="red">Telefon</font></b>'; ret++;}
  	else{document.getElementById('label_tele').innerHTML = 'Telefon'; }
	
	if(f.email.value==""){ document.getElementById('label_email').innerHTML = '<b><font color="red">Epost</font></b>'; ret++;}
  	else{document.getElementById('label_email').innerHTML = 'Epost'; }
	
	if(ret>0){ return false; }
}



