var xmlhttp

function yorumEkleLink(haberId) {
	document.getElementById('HaberSayfaYorumGetter').style.display='block';
	//getirUrl='/jx/cmd.php?yorumEkleForm,'+haberId
	getirUrl='/jx/cmd.php?yorumEkleForm,'+haberId;
	loadXMLDoc(getirUrl)
}

function yorumEklePost(yazanAd,yazanEposta,yorumMetin,haberId) {
	//document.getElementById('HaberSayfaYorumGetter').style.display='block'
	/*yazanAd=document.getElementById('YorumYazanAd').value
	yazanEposta=document.getElementById('YorumEPosta').value
	yorumMetin=escape(document.getElementById('YorumYazi').value)
	haberId=document.getElementById('yFHaberId').value*/
	yazanAd = yazanAd.replace('%20', '&nbsp;');
	yazanAd = yazanAd.replace(/ /g, '&nbsp;');
	
	yorumMetin = yorumMetin.replace('%20', '&nbsp;');
	yorumMetin = yorumMetin.replace(/ /g, '&nbsp;');
	//yorumMetin = yorumMetin.replace(',', '&sbquo;');
	yorumMetin = yorumMetin.replace(',', '‚');
	
	document.getElementById('HaberSayfaYorumPad2').style.display='none'
	getirUrl='/jx/cmd.php?yorumEkle,'+yazanAd+','+yazanEposta+','+yorumMetin+','+haberId
	loadXMLDoc(getirUrl)
}


function loadXMLDoc(url)
//url='fetcher?a='+url;


{
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change
  //xmlhttp.open("GET",url,true)
  xmlhttp.open("POST",url,true)
  xmlhttp.send(null)
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
		xmlhttp.onreadystatechange=state_Change
		//xmlhttp.open("GET",url,true)
		xmlhttp.open("POST",url,true)
		xmlhttp.send()
    }
  }
}

function state_Change()
{


// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {
 	 document.getElementById('HaberSayfaYorumGetter').innerHTML=xmlhttp.responseText
  }
  else
  {
 	 alert("Sayfa derlenemiyor:" + xmlhttp.statusText)
  }
  }
}



/* yorum ekleme formu, karakter sınırlaması */
function yorumEkleKntrl(textarea,uzunluk) {
   if(window.event.keyCode==44) {
   		textarea.value = textarea.value.replace(',', '‚');
   }
   if(window.event.keyCode==13 || textarea.value.length>=uzunluk ) {
      window.event.keyCode = 0 ;
   }

   yorumCharStat.innerText = uzunluk - textarea.value.length+'/'+uzunluk;
}


function setClipboard(setValue) {
	if (document.all) {
		document.copytoclipboard.clipboard.value = setValue;
		document.copytoclipboard.clipboard.focus();
		document.copytoclipboard.clipboard.select();	
		clipboardValue = document.copytoclipboard.clipboard.createTextRange();
		clipboardValue.execCommand("Copy");
	}

}

// Example:

// value1 = 3; value2 = 4;

// messageBox("text message %s and %s", value1, value2);

// this message box will display the text "text message 3 and 4"

function messageBox()

{

  var i, msg = "", argNum = 0, startPos;

  var args = messageBox.arguments;

  var numArgs = args.length;

  if(numArgs)

  {

    theStr = args[argNum++];

    startPos = 0;  endPos = theStr.indexOf("%s",startPos);

    if(endPos == -1) endPos = theStr.length;

    while(startPos < theStr.length)

    {

      msg += theStr.substring(startPos,endPos);

      if (argNum < numArgs) msg += args[argNum++];

      startPos = endPos+2;  endPos = theStr.indexOf("%s",startPos);

      if (endPos == -1) endPos = theStr.length;

    }

    if (!msg) msg = args[0];

  }

  alert(msg);

}



function messageWindow(title, msg)

{

  var width="300", height="125";

  var left = (screen.width/2) - width/2;

  var top = (screen.height/2) - height/2;

  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;

  var msgWindow = window.open("","msgWindow", styleStr);

  var head = '<head><title>'+title+'</title></head>';

  var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';

  msgWindow.document.write(head + body);

}


function kbToMb(KB) { return KB / 1024; }


function mbToKb(MB) { return MB * 1024; }

function redirect(URLStr) { location = URLStr; }


