// JavaScript Document

var xmlHttp;

function createXMLHttpRequest()
{
   if(window.ActiveXObject)
   {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
   }

   else if(window.XMLHttpRequest)
   {
      xmlHttp = new XMLHttpRequest();
   }
}

function handleStateChange()
{	
	if(xmlHttp.readyState == 4)
	{	
		var response = xmlHttp.responseText;
		
		var update = new Array();
		
		if(response.indexOf('||' != -1))
		{	
			update = response.split('||');
			
			if(update[0] == 'comment')
			{
				if(update[1] == '1')
				{
					alert('Kommentaren har sparats.');
				}
			}
		}
	}
}

function saveComment(rowId, comment)
{
	if(rowId != '')
	{
		document.getElementById('img_submit_' + rowId).value = 'Sparar...';
		
		createXMLHttpRequest();

		xmlHttp.onreadystatechange = handleStateChange;
		
		ajaxUrl = "http://bildochtext.se/_ajax/comment.php?id="+escape(rowId)+"&comment="+escape(comment);
		
		xmlHttp.open("GET", ajaxUrl, true);
		
		xmlHttp.send(null);
		
		document.getElementById('img_submit_' + rowId).value = 'Spara';
	}
	else
	{
		alert('Ett fel uppstod! Kommentaren kunde inte sparas.');	
	}
}


<!-- Visa/dölj

function viewHide(id){

	if(document.getElementById(id).style.display == 'none'){
		
		document.getElementById(id).style.display = 'block';

	}else{

		document.getElementById(id).style.display = 'none';
	}
}

//-->



<!-- Popupfönster

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=1,resizable=1,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

//-->
