var xmlhttp

function inlocuieste(data) { 
  var replace1 = new Array(/\n/g,/\t/g,/&/g,/</g,/>/g); 
  var by = new Array("[breack]","[tab]","[amp]","[lt]","[gt]","[plus]"); 
  //---->/[valoare]/g (g de la global)<----
  for (var i=0; i<replace1.length; i++) { 
     data = data.replace(replace1[i],by[i]); 
  } 
  return data; 
} 

function view(str,str1)
{
	
if(document.getElementById('checkbox').checked == true){
if (str.length == 0 && str1.length == 0 )
  {
  document.getElementById('preview').innerHTML="Preview is ON!";
  return;
  }
}else{
	document.getElementById('preview').innerHTML="Preview is OFF!";
  return;
}
	  
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
//----------------------------------------loading---------------------------------
//document.getElementById(div).innerHTML='<div class="loading"></div>';
//---------------------------------------------------------------------------------
str1 = inlocuieste(str1);

var url="http://www.instalgrup.ro/preview_data.php";
//url=url+"?q="+str;
//url=url+"&q1="+str1;
//url=url+"&sid="+Math.random();

var val = "q="+str+"&q1="+str1;

xmlhttp.open("POST",url,true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", val.length);
xmlhttp.setRequestHeader("Connection", "close");

xmlhttp.onreadystatechange=stateChanged;
xmlhttp.send(val);
}

function stateChanged()
{
if (xmlhttp.readyState == 4)
  {
  document.getElementById('preview').innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
//////////////////////////////////////////////////////////////

