<!--
var GalleriKommentarerSidnamn='galleri_kommentarer.php';



///////////////////////////////////////////////////////////////////////////////////////////
var KommentarFormular = true; 
function KommentarFormularVisa(GetVariablar)
{ 
	if (KommentarFormular == true)
	{
		//Visa 
		document.getElementById("opencloseimg").src = "bilder/kommentarer_knapp_stangform.gif";
		var serverPage= GalleriKommentarerSidnamn+"?gv=form&"+GetVariablar;
		KommentarFormular=false;
		var obj = document.getElementById("kommentarer_formular");
		xmlhttp.open("GET",serverPage);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
				obj.innerHTML = xmlhttp.responseText;
			}
			else
			{
				obj.innerHTML ='<img src="bilder/sym_java_vanta.gif" border="0" width="20" height="20">';	
			}
		}
		xmlhttp.send(null);
	} 
	else 
	{
		//Dölj 
		document.getElementById("opencloseimg").src = "bilder/kommentarer_knapp_visaform.gif";
		KommentarFormular = true;
		document.getElementById("kommentarer_formular_forhandsgranska").innerHTML = "";
		document.getElementById("kommentarer_formular").innerHTML = "";
		
	}
} 
////////////////////////////////////////////////////////////////////////////////////////////
function KommentarFormularVisaForhandsgranska(text)
{

	myRand= parseInt(Math.random()*99999999999999999);
	var serverPage= GalleriKommentarerSidnamn+"?gv=form_for&rand="+myRand;
	var obj = document.getElementById("kommentarer_formular_forhandsgranska");
	
	xmlhttp.onreadystatechange = alertContents;
	xmlhttp.open("POST",serverPage,true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Content-length", text.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			obj.innerHTML = xmlhttp.responseText ;
		}
		else
		{
			obj.innerHTML ='<img src="bilder/sym_java_vanta.gif" border="0" width="20" height="20">';	
		}
	}

	xmlhttp.send(text);
	
}
////////////////////////////////////////////////////////////////////////////////////////////
function getForhandsgranska(obj)
{
   
   var poststr = "Text=" + encodeURI( document.getElementById("Text").value ) ;  
   
   KommentarFormularVisaForhandsgranska(poststr);
}
////////////////////////////////////////////////////////////////////////////////////////////
function getSkicka(obj)
{
   	var poststr = "Text=" + encodeURI( document.getElementById("Text").value ) +
	"&GalleriId=" + encodeURI( document.getElementById("GalleriId").value ) +
	"&BilderId=" + encodeURI( document.getElementById("BilderId").value );
  	if ( document.getElementById("Text").value.length > 0 )
   	{
		KommentarFormularVisaSkicka(poststr,document.getElementById("SokvagKommentarer").value);		
   	}
	else
	{
		KommentarFormularVisaForhandsgranska(poststr);	
	}   
}
////////////////////////////////////////////////////////////////////////////////////////////
function KommentarFormularVisaSkicka(text,sokvagkommentarer)
{
	//confirm("visaskicka");
	//xmlhttp.setRequestHeader("Charset", "ISO-8859-1") 
	myRand= parseInt(Math.random()*99999999999999999);
	
	var serverPage= GalleriKommentarerSidnamn+"?gv=form_ski&rand="+myRand;
	var obj = document.getElementById("kommentarer_formular");
	//confirm(serverPage);
	xmlhttp.onreadystatechange = alertContents;
	xmlhttp.open("POST",serverPage,true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", text.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			obj.innerHTML = xmlhttp.responseText ;
			SidbrytningSidaAjax("galleri_kommentarer",sokvagkommentarer,"kommentarer");
		}
		else
		{
			obj.innerHTML ='<img src="bilder/sym_java_vanta.gif" border="0" width="20" height="20">';	
		}
	}
	xmlhttp.send(text);
	document.getElementById("kommentarer_formular_forhandsgranska").innerHTML = "";
	document.getElementById("opencloseimg").src = "bilder/kommentarer_knapp_visaform.gif";	
	

}
////////////////////////////////////////////////////////////////////////////////////////////
function KommentarMottagenStangFonster()
{
	KommentarFormular = true;
	document.getElementById("kommentarer_formular").innerHTML = "";
	document.getElementById("kommentarer_formular_forhandsgranska").innerHTML = "";	
}
////////////////////////////////////////////////////////////////////////////////////////////
function alertContents()
{
      if (xmlhttp.readyState == 4) {
         if (xmlhttp.status == 200) {
            //alert(http_request.responseText);
            result = xmlhttp.responseText;
            document.getElementById('kommentarer_formular_forhandsgranska').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
}
///////////////////////////////////////////////////////////////////////////////////////////
function KommentarerRapportera(obj,id)
{
	var poststr = "KommentarId=" + encodeURI( document.getElementById("KommentarId-"+id+"").value ) +
	"&SokvagKommentarer=" + encodeURI( document.getElementById("SokvagKommentarer").value );	
	
	if ( document.getElementById("KommentarId-"+id).value > 0 )
   	{
		if ( confirm("Vill du rapportera post "+ document.getElementById("KommentarText-"+id).value+" ? ") )
		{
			var serverPage= GalleriKommentarerSidnamn+"?gv=form_rap&rand="+myRand;
			var obj = document.getElementById("kommentarer_formular_svara-"+document.getElementById("KommentarId-"+id).value);
			xmlhttp.onreadystatechange = alertContents;
			xmlhttp.open("POST",serverPage,true);
			
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-length", poststr.length);
			xmlhttp.setRequestHeader("Connection", "close");			
		
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
				{
					obj.innerHTML = xmlhttp.responseText ;
				}
				else
				{
					obj.innerHTML ='<img src="bilder/sym_java_vanta.gif" border="0" width="20" height="20">';	
				}
			}
			xmlhttp.send(poststr);
		}	
	}
	else
	{
		alert("tekniskt fel vid rapportering");			
	}	
}
////////////////////////////////////////////////////////////////////////////////////////////
function KommentarerRapporteraStangFonster(id)
{
	KommentarFormular = true;
	document.getElementById("kommentarer_formular_svara-"+id).innerHTML = "";
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function KommentarerRadera(obj,id)
{
	var poststr = "KommentarId=" + encodeURI( document.getElementById("KommentarId-"+id+"").value ) +
	"&KommentarDel=" + encodeURI( document.getElementById("KommentarDel-"+id+"").value ) +
	"&KommentarAvsandare=" + encodeURI( document.getElementById("KommentarAvsandare-"+id+"").value ) +
	"&SokvagKommentarer=" + encodeURI( document.getElementById("SokvagKommentarer").value );	
	
	if ( document.getElementById("KommentarId-"+id).value > 0 )
   	{
		if ( confirm("Vill du radera post "+ document.getElementById("KommentarText-"+id).value+" ? ") )
		{
			var serverPage= GalleriKommentarerSidnamn+"?gv=form_rad&rand="+myRand;
			var obj = document.getElementById("kommentarer_formular");
			xmlhttp.onreadystatechange = alertContents;
			xmlhttp.open("POST",serverPage,true);
			
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-length", poststr.length);
			xmlhttp.setRequestHeader("Connection", "close");			
		
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
				{
					obj.innerHTML = xmlhttp.responseText ;
					SidbrytningSidaAjax("galleri_kommentarer",document.getElementById("SokvagKommentarer").value,"kommentarer");
				}
				else
				{
					obj.innerHTML ='<img src="bilder/sym_java_vanta.gif" border="0" width="20" height="20">';	
				}
			}
			xmlhttp.send(poststr);
		}	
	}
	else
	{
		alert("Tekniskt fel vid radera");			
	}
	
	
}
///////////////////////////////////////////////////////////////////////////////////////////////
function KommentarerRaderaStangFonster()
{
	KommentarFormular = true;
	document.getElementById("kommentarer_formular").innerHTML = "";
	document.getElementById("kommentarer_formular_forhandsgranska").innerHTML = "";	
}
//-->