function charCount(input,output,limit) {
	chars = parseInt(input.value.length);
	charsLeft = chars;
	
	output.value = charsLeft+' av max '+limit;
}

function toggleDisplay(val) {
	if (document.getElementById) {
		if (val==0) {
			document.getElementById('mainInformation').style.display = 'none';
			document.getElementById('deleteHide').value = 1;
		} 
		else {
			document.getElementById('mainInformation').style.display = 'block';
			document.getElementById('deleteHide').value = 0;
		}
	}
}

function ajaxTK(url,elementId) {
	var xmlHttp;
	
	try {
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Ett fel har uppstått."); //TITTA PÅ DEN HÄR!!!
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {	
			document.getElementById(elementId).innerHTML = xmlHttp.responseText;
			document.getElementById(elementId).style.display = 'block';
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	return false;
}

function openTip() {
	if (document.getElementById) { 
		document.getElementById('shareBox').style.display = 'none'; 
		document.getElementById('tipBox').style.display = 'block';
		document.getElementById('tipLink').href = 'javascript:closeTip();';
		document.getElementById('shareLink').href = 'javascript:openShare();';
		
		document.tipBox.recipient.focus();
	}
}

function closeTip() {
	if (document.getElementById) { 
		document.getElementById('tipBox').style.display = 'none';
		document.getElementById('tipLink').href = 'javascript:openTip();';
		document.getElementById('shareLink').href = 'javascript:openShare();';
	}
}

function openShare() {
	if (document.getElementById) { 
		document.getElementById('tipBox').style.display = 'none';
		document.getElementById('shareBox').style.display = 'block'; 
		document.getElementById('shareLink').href = 'javascript:closeShare();';
		document.getElementById('tipLink').href = 'javascript:openTip();';
	}
}

function closeShare() {
	if (document.getElementById) { 
		document.getElementById('shareBox').style.display = 'none'; 
		document.getElementById('shareLink').href = 'javascript:openShare();';
		document.getElementById('tipLink').href = 'javascript:openTip();';
	}
}

function openNewsletterName() {
	if (document.getElementById) {
		document.getElementById('newsletterName').style.display = 'block';
	}
}