// JavaScript Document
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

var baseHeight;

function BulGel() {
var ara=document.getElementById('q').value;
arama = ara.replace(/ /g, "+");
arama = ara.replace(/%20/g, "+");
var nd=document.getElementById('neredesin').value;
if (nd==1) {
window.location='http://www.neyebenzer.com/ne/'+arama;
} else if (nd==2) {
document.getElementById('ariyor').style.display='inline';
document.getElementById('arananlar').style.display='inline';
islemL('http://www.neyebenzer.com/benzet/'+arama,'arananlar');
//window.location='http://localhost/neyebenzer/senbenzet/'+arama;
} else if (nd==3) {
window.open('http://www.google.com.tr/search?hl=tr&q='+arama);
} else {
window.location='http://www.neyebenzer.com/ne/'+arama;
}
}

function AraGel() {
var ara=document.getElementById('q').value;
arama = ara.replace(/ /g, "+");
arama = ara.replace(/%20/g, "+");
document.getElementById('ariyor').style.display='inline';
document.getElementById('arananlar').style.display='inline';
islemL('http://www.neyebenzer.com/benzet/'+arama,'arananlar');
}


function nesneyarat() {
    var nesne;
    var tarayici = navigator.appName;
    if(tarayici == "Microsoft Internet Explorer"){
        nesne = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        nesne = new XMLHttpRequest();
        if (nesne.overrideMimeType) {
            nesne.overrideMimeType('text/xml');
        }
    }
    return nesne;
}



function islemlink(deger,burasi) {
	
	var http = nesneyarat();
	
	function cevapFonksiyonu() {

    if(http.readyState == 4){

        if(http.status == 200)
		{
		document.getElementById("yorumok").innerHTML = http.responseText;
		document.getElementById('yazigonder').innerHTML='<div style="margin-bottom:20px; margin-bottom:20px;"><b>Yazınız Gönderildi...</b></div>';
		}
		else
		{
		document.getElementById("yorumok").innerHTML = "Bu iste bu hata var";
		}

        }

}

    document.getElementById(burasi).innerHTML=""
    
    var topic = document.entryform.topic.value;
    var entry = document.entryform.entry.value;
    var sc ='topic='+encodeURIComponent(topic)+'&entry='+encodeURIComponent(entry);

    http.open('POST', deger, true);
    http.onreadystatechange = cevapFonksiyonu;
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    var tarayici = navigator.appName;
    if(tarayici != "Microsoft Internet Explorer"){
    http.overrideMimeType('text/html');
    }
    http.send(sc);
    

}



function islemL(deger,burasi) {
	
	var http = nesneyarat();
	
	function cevapFonksiyonu() {

    if(http.readyState == 4){

        document.getElementById(burasi).innerHTML = decodeURIComponent(http.responseText);

        }

}

	document.getElementById(burasi).innerHTML="<div class='onbir' align='center' style='color:#FF9900; padding:2px; margin-top:10px; background:#f7f7f7;'><img src='img/loadinc.gif' alt='yukleniyor' /><br />BEKLEYİNİZ</div>"
    http.open('get', deger);
    http.onreadystatechange = cevapFonksiyonu;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    var tarayici = navigator.appName;
    if(tarayici != "Microsoft Internet Explorer"){
    http.overrideMimeType('text/html');
    }
    http.send(null);

}

function isLE(deger,burasi) {
	var http = nesneyarat();
	function cevapFonksiyonu() {
    if(http.readyState == 4){
        document.getElementById(burasi).innerHTML = decodeURIComponent(http.responseText);
        }
}
	document.getElementById(burasi).innerHTML="bekleyiniz..."
    http.open('get', deger);
    http.onreadystatechange = cevapFonksiyonu;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    var tarayici = navigator.appName;
    if(tarayici != "Microsoft Internet Explorer"){
    http.overrideMimeType('text/html');
    }
    http.send(null);
}

function BBAralik(Bgiris,Bcikis) {

	var txtarea = document.entryform.entry;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
	
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, Bgiris, Bcikis);
		return;
	}

	ToAdd = Bgiris+Bcikis;

	PostWrite(ToAdd);
}

function PostWrite(text) {
	var txtarea = document.entryform.entry;
	var oldPos = txtarea.scrollTop;
	txtarea.focus();
	if (txtarea.createTextRange && txtarea.caretPos) {
		if (baseHeight != txtarea.caretPos.boundingHeight) {
			txtarea.focus();
			storeCaret(txtarea);
		}
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
	} else
	if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0)) { 
		mozWrap(txtarea, text, "");
	} else {
		txtarea.value += text;
	}
	txtarea.scrollTop = oldPos;
	txtarea.focus();
}

function mozWrap(txtarea, open, close)
{
	if (txtarea.selectionEnd > txtarea.value.length) { txtarea.selectionEnd = txtarea.value.length; }

	var oldPos = txtarea.scrollTop;
	var oldHght = txtarea.scrollHeight;

	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd+open.length;

	txtarea.value = txtarea.value.slice(0,selStart)+open+txtarea.value.slice(selStart); 
	txtarea.value = txtarea.value.slice(0,selEnd)+close+txtarea.value.slice(selEnd);

	txtarea.selectionStart = selStart+open.length;
	txtarea.selectionEnd = selEnd;

	var newHght = txtarea.scrollHeight - oldHght;
	txtarea.scrollTop = oldPos + newHght;

	txtarea.focus();
}

function si(url, w, h){
	w+= 40;
	h+= 40;
	sw = screen.width;
	sh = screen.height;
	sbars = 'no';
	if( w > sw ){
		w = sw;
		sbars = 'yes';
	}
	if( h > sh ){
		h = sh;
		sbars = 'yes';
	}
	l = (sw/2)-(w/2);
	t = (sh/2)-(h/2);
	window.open(url, '_blank', 'scrollbars='+sbars+',location=no,menubar=no,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t);
	return false;
}

function basBol(bolad) {
document.getElementById(document.getElementById('nerdeyiz').value).style.fontWeight='normal'; 
document.getElementById('nerdeyiz').value=bolad; 
document.getElementById(bolad).style.fontWeight='bold';	
}
function blogBol(bolad) {
document.getElementById(document.getElementById('nerdeyizb').value).style.fontWeight='normal'; 
document.getElementById('nerdeyizb').value=bolad; 
document.getElementById(bolad).style.fontWeight='bold';	
}
function uyeBol(bolad) {
document.getElementById(document.getElementById('nerdeyizbu').value).style.fontWeight='normal'; 
document.getElementById('nerdeyizbu').value=bolad; 
document.getElementById(bolad).style.fontWeight='bold';	
}
function basOver(bid) {
document.getElementById(bid).style.display='inline';
}
function basOut(bid) {
document.getElementById(bid).style.display='none';	
}

var min=11;
var max=17;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}