
function nameCounter() {

maxlimit = 40;
  
if (navigator.appName == "Microsoft Internet Explorer") {

	if (commentForm.name.value.length > maxlimit) 
    		commentForm.name.value = commentForm.name.value.substring(0, maxlimit);
	}
else {
	if (document.getElementById("commentForm").name.value.length > maxlimit) 
    		document.getElementById("commentForm").name.value = document.getElementById("commentForm").name.value.substring(0, maxlimit);
	}
}






function captCounter() {

maxlimit = 4;
  
if (navigator.appName == "Microsoft Internet Explorer") {

	if (commentForm.captcha.value.length > maxlimit) 
    		commentForm.captcha.value = commentForm.captcha.value.substring(0, maxlimit);
	}
else {
	if (document.getElementById("commentForm").captcha.value.length > maxlimit) 
    		document.getElementById("commentForm").captcha.value = document.getElementById("commentForm").captcha.value.substring(0, maxlimit);
	}
}





function messCounter() {

maxlimit = 400;
  
if (navigator.appName == "Microsoft Internet Explorer") {

	if (commentForm.mess.value.length > maxlimit) 
    		commentForm.mess.value = commentForm.mess.value.substring(0, maxlimit);
	else 
		charactersLeft.innerText = commentForm.mess.value.length;
}
else {

	if (document.getElementById("commentForm").mess.value.length > maxlimit) 
    		document.getElementById("commentForm").mess.value = document.getElementById("commentForm").mess.value.substring(0, maxlimit);
	else 
		document.getElementById("charactersLeft").textContent = document.getElementById("commentForm").mess.value.length;
}



/*
if (document.getElementById) {

// this is the way the standards work
document.getElementById('charactersLeft').textContent = maxlimit - field.value.length;

}

else if (document.all) {

// this is the way old msie versions work
document.all['charactersLeft'].textContent = maxlimit - field.value.length;

}

else if (document.layers) {

// this is the way nn4 works
document.layers['charactersLeft'].textContent = maxlimit - field.value.length;

}

*/

}






function oppna(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
//style2.display = style2.display? "":"block";
style2.display = "block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = "block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = "block";
}
}






function stang(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style3 = document.getElementById(whichLayer).style;
style3.display = "none";
}
else if (document.all)
{
// this is the way old msie versions work
var style3 = document.all[whichLayer].style;
style3.display = "none";
}
else if (document.layers)
{
// this is the way nn4 works
var style3 = document.layers[whichLayer].style;
style3.display = "none";
}
}






function expand(whichLayer) {

	if (document.getElementById) {

		var style4 = document.getElementById(whichLayer).style;

	}
	else if (document.all) {

		var style4 = document.all[whichLayer].style;

	}
	else if (document.layers) {

		var style4 = document.layers[whichLayer].style;

	}
	if (style4.display == "none") {

		oppna(whichLayer);
	}
	else { 
		stang(whichLayer);
	}
}











			function getReturnData( data , statusCode , statusMessage) {
			 	//AJFORM failed. Submit form normally.
			 	if( statusCode != AJForm.STATUS['SUCCESS'] ) {
			 	 alert( statusMessage );
				 return true;
			 	}
			 	//AJFORM succeeded.
			 	else {
					data = unescape(data);   // för att fixa till å, ä och ö från "lang"
					
					//ratethis.innerHTML = 'Rated! ' + data;

					if (navigator.appName == "Microsoft Internet Explorer") {
						ratethis.innerText = data;
					}
					else {
						document.getElementById("ratethis").textContent = data;
					}

			 	}
			}





			
			function preProcess( thisForm ) {

				if (navigator.appName == "Microsoft Internet Explorer") {
					voteForm.vote[0].disabled = true;
					voteForm.vote[1].disabled = true;
					voteForm.vote[2].disabled = true;
					voteForm.vote[3].disabled = true;
					voteForm.vote[4].disabled = true;
					voteForm.vote[5].disabled = true;
					voteForm.vote[6].disabled = true;
					voteForm.vote[7].disabled = true;
					voteForm.vote[8].disabled = true;
					voteForm.vote[9].disabled = true;
					voteForm.vote[10].disabled = true;
				
					//rategif.innerHTML = '<img src="http://www.kavalkad.se/ev/pics/rate/wait.gif" width="92" height="92" alt="Wait..." />';
					ratethis.innerText = '...';

				}
				else {
					document.getElementById("voteForm").vote[0].disabled = true;
					document.getElementById("voteForm").vote[1].disabled = true;
					document.getElementById("voteForm").vote[2].disabled = true;
					document.getElementById("voteForm").vote[3].disabled = true;
					document.getElementById("voteForm").vote[4].disabled = true;
					document.getElementById("voteForm").vote[5].disabled = true;
					document.getElementById("voteForm").vote[6].disabled = true;
					document.getElementById("voteForm").vote[7].disabled = true;
					document.getElementById("voteForm").vote[8].disabled = true;
					document.getElementById("voteForm").vote[9].disabled = true;
					document.getElementById("voteForm").vote[10].disabled = true;
					
					document.getElementById("ratethis").textContent = '...';
				}

			}
















			function getCommentsReturnData( data , statusCode , statusMessage) {
			 	//AJFORM failed. Submit form normally.
			 	if( statusCode != AJForm.STATUS['SUCCESS'] ) {
			 	 alert( statusMessage );
				 return true;
			 	}
			 	//AJFORM succeeded.
			 	else {
					data = unescape(data);   // för att fixa till å, ä och ö från "lang"
					arra = data.split("<i>");
					
					if (data.substring(0,3) == "#1#") {

						stang('addcomment');

						if (navigator.appName == "Microsoft Internet Explorer") {
							conr.innerText      = "#" + arra[1];
							coname.innerText    = arra[2];
							cotime.innerText    = arra[3];
							cocomment.innerText = arra[4];
							nroc.innerText      = arra[5];

							commentForm.name.innerText = '';
							commentForm.captcha.innerText = '';
							commentForm.mess.innerText = '';
						}
						else {
							document.getElementById("conr").textContent      = "#" + arra[1];
							document.getElementById("coname").textContent    = arra[2];
							document.getElementById("cotime").textContent    = arra[3];
							document.getElementById("cocomment").textContent = arra[4];
							document.getElementById("nroc").textContent      = arra[5];

							document.getElementById("commentForm").name.textContent = '';
							document.getElementById("commentForm").captcha.textContent = '';
							document.getElementById("commentForm").mess.textContent = '';
						}
					}
					else {
						alert(data.substring(3,data.length));

						if (navigator.appName == "Microsoft Internet Explorer") {
							commentForm.send.disabled = false;
						}
						else {
							document.getElementById("commentForm").send.disabled = false;
						}
					}						
			 	}
			}





			
			function preProcessComments( thisForm ) {


		

				if (navigator.appName == "Microsoft Internet Explorer") {

					commentForm.send.disabled = true;
					//commentForm.name.innerText = '';
					//commentForm.captcha.innerText = '';
					//commentForm.mess.innerText = '';

					//commentForm.name.disabled = true;
					//commentForm.captcha.disabled = true;
					//commentForm.mess.disabled = true;
					
					//ratethis.innerText = '...';

				}
				else {
					document.getElementById("commentForm").send.disabled = true;
					//document.getElementById("commentForm").name.textContent = '';
					//document.getElementById("commentForm").captcha.textContent = '';
					//document.getElementById("commentForm").mess.textContent = '';
					
					//document.getElementById("commentForm").name.disabled = true;
					//document.getElementById("commentForm").captcha.disabled = true;
					//document.getElementById("commentForm").mess.disabled = true;

					//document.getElementById("ratethis").textContent = '...';
				}
			
				//stang('addcomment');
				
			}















			function getReportReturnData( data , statusCode , statusMessage) {
			 	//AJFORM failed. Submit form normally.
			 	if( statusCode != AJForm.STATUS['SUCCESS'] ) {
			 	 alert( statusMessage );
				 return true;
			 	}
			 	//AJFORM succeeded.
			 	else {
					data = unescape(data);   // för att fixa till å, ä och ö från "lang"
					

					if (navigator.appName == "Microsoft Internet Explorer") {
						rep.innerText = data;
					}
					else {
						document.getElementById("rep").textContent = data;
					}

			 	}
			}







			
			function preProcessReport( thisForm ) {

				if (navigator.appName == "Microsoft Internet Explorer") {

					reportForm.send.disabled = true;

					//rep.innerText = '...';

				}
				else {
					document.getElementById("reportForm").send.disabled = true;
					
					//document.getElementById("rep").textContent = '...';
				}

			}







			function goForm(whichForm) {


			 thisForm = document.getElementById( whichForm );
			 // thisForm.submit() will not work using AJFORM. Instead, you need to use the following:
			 thisForm.ajform_submit();
			}