//Online Ofline Bulma CanlÄ± Destek
/*function cevirimici(){
    var sc;
    
    var MID = document.getElementById('musteri_no').value;
	sc = "durum=1";
    sc += '&musteri_no='+MID;
	JXP(0,"online","/canlidestek/online.php",sc);
    setTimeout("cevirimici()",5000);
}
*/
//Canlı Destek Başlangıç
function canlidestek(){
	var yazi = document.getElementById('yazi').value;
        var kisi_ID = document.getElementById('kisi_ID').value;
        var konusma_ID = document.getElementById('konusma_ID').value;

	var post = 'yazi='+yazi;
	post += '&kisi_ID='+kisi_ID;
	post += '&konusma_ID='+konusma_ID;
   // alert(konusma_ID);
	JXP(1,"karalama","/canlidestek/sorguekle.php",post);
	document.getElementById('yazi').value='';
}

/*function yenile(){
    var sc;
    var kisi_ID = document.getElementById('kisi_ID').value;
    var konusma_ID = document.getElementById('konusma_ID').value;
//	var sc="session_ID="+session_ID;
	sc = "asd";
    sc += '&kisi_ID='+kisi_ID;
    sc += '&konusma_ID='+konusma_ID;

	JXP(0,"yazitahtasi","/canlidestek/sorgulistele.php",sc);
    setTimeout("yenile()",1000);
}*/

function eminmisin(){
	if(confirm('DİKKAT bu geri alınamayacak bir işlemdir.\nSeçili olan öğeler ve varsa alt öğeler silinecek!\nSilmek İstediğinizden Emin misiniz?')){
		return true; 
	}else{
		return false;
	}
}

function FirmaYonet() {
      var gelen = document.getElementById('firma_yonet');
            if (gelen.value.length > 0) {
            var sc = "musteri="+gelen.value;
            JXP(1, 'firmayonet', '/sorgular/yonet.php', sc);
     }
}

function BayiFirmaYonet(MID) {
      var gelen = document.getElementById('firma_yonet');
            if (gelen.value.length > 0) {
            var sc = "musteri="+gelen.value;
            sc += "&MID="+MID;
            JXP(1, 'firmayonet', '/sorgular/bayiyonet.php', sc);
     }
}

function firmAra(){
    var gelen = document.getElementById('musteri');
	if (gelen.value.length > 0) {
	var sc = "musteri="+gelen.value;
	JXP(1, 'firmaekle', '/sorgular/musteri.php', sc);
    }
}

function addOnLoad(func) {
	if (window.onload) {
		var temp = window.onload;
		window.onload = function () {
		temp();
		func();
		}
	} else {
	window.onload = func;
	}
}
var menu;

function ozellikler(){
	var genislik, yukseklik;
	var ozellik = new Array("genislik","yukseklik");
	if (self.innerHeight) {	// all except Explorer
		ozellik['genislik'] = self.innerWidth;
		ozellik['yukseklik'] = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		ozellik['genislik'] = document.documentElement.clientWidth;
		ozellik['yukseklik'] = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		ozellik['genislik'] = document.body.clientWidth;
		ozellik['yukseklik'] = document.body.clientHeight;
	}	
	return ozellik;	
}
			
		
function Yazdir(header, alan) { 
	if(document.getElementById('yazilmayacak')){
		document.getElementById('yazilmayacak').style.display='none';
	}
	if (document.getElementById('olustur_buton')){
		document.getElementById('olustur_buton').style.display='none';	
	}
	var hd = '<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><title>Rapor</title></head>'+document.getElementById(header).innerHTML+'';
	var txt = document.getElementById(alan).innerHTML;
	txt = hd+txt+'</html>';
	document.open(); 
	document.write(txt); 
	window.print();
	document.close();  
}



function navbar(string){
	bar_yukselik = parseInt(20);
	bar_genislik = parseInt(970);
	
	var genislik, yukseklik, ust, marg_sol, txt, ozellik;
	ozellik = ozellikler();
	genislik = ozellik['genislik'];
	yukseklik = ozellik['yukseklik'];
	//alert(genislik+' '+yukseklik);
	
	ust = (yukseklik-bar_yukselik)-4;
	marg_sol =(genislik- bar_genislik)/2 ;
	txt = '<span style="height:'+bar_yukselik+'px;"></span><br /><br /><div id="nav_bar" style="position:fixed; '; 
	txt += 'background-color:#E5E5E5; ';
	txt += 'top:'+ust+'px; height:'+bar_yukselik+'px; width:'+bar_genislik+'px; ';
	txt += 'margin-left: '+marg_sol+'px; border:2px groove #FFFFFF;">'+string+'</div>';
	document.write(txt);
}

function showhide(idx){
	if (document.getElementById){
		obj = document.getElementById(idx);
		if (obj.style.display == "none"){
			obj.style.display = "";
		}
		else if (obj.style.display == ""){
			obj.style.display = "none";
		}
	}
} 

function dikey_ortala(param){
	var obje,ozellik;
	ozellik = ozellikler();
	obje = document.getElementById(param);
	obje.style.position = "absolute";
	obje.style.top = "20px";
}

function id2(param){
	var val=document.getElementById(param);
	return val;
}

function coklu_secim_selected(param){
		var a,b;
		a = document.getElementById(param);
		b = new Array();
		
		for(i=0; i<a.length; i++){	
			if(a[i].selected == true){
				 b.push(a[i].value);
			}
		}
		return b;
}

function coklu_secim_checked(idOfElement){
      var arr = new Array();
      var allCheckBoxes = document.getElementsByTagName('input');
      for( i = 0; i < allCheckBoxes.length; i++) {
            var checkbox = allCheckBoxes[i];
            if(checkbox.type == 'checkbox' && checkbox.id == idOfElement && checkbox.checked){
                  arr[arr.length] = checkbox.value;
            }
      }
      if(arr.length > 0) return arr;
      return 0;
}

function showhide(idx){
	if (document.getElementById){
		obj = document.getElementById(idx);
		if (obj.style.display == "none"){
			obj.style.display = "";
		}
		else if (obj.style.display == ""){
			obj.style.display = "none";
		}
	}
}

// AJAX
function AJAX() {
   var ajax = false;
   
   // Internet Explorer (5.0+)
   try {
     ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
   } catch(e) {
	   
      try {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        ajax = false;
      }
   }

   // Mozilla veya Safari
   if ( !ajax && typeof XMLHttpRequest != 'undefined' ) {
	   
     try{
        ajax = new XMLHttpRequest();
     }catch(e) {    
        ajax = false;
     }

   }

   // Diger (IceBrowser)
   if ( !ajax && window.createRequest ) {
     
	 try{
        ajax = window.createRequest();
     }catch(e) {  
        ajax = false;
     }

   }

	return ajax;
}


// POST işlemleri
function JXP(yukleniyor, yer, dosya, sc) {
	ajax = new AJAX();
	
	if (ajax) {
		ajax.onreadystatechange = function () {}
		ajax.abort()
	}

    ajax.onreadystatechange = function () {	Loading(yukleniyor, yer) }
	
	ajax.open('POST', dosya, true)
	ajax.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
    ajax.setRequestHeader("Content-length", sc.length)
    ajax.setRequestHeader("Connection", "close")
	ajax.send(sc)		
}


// GET işlemleri
function JXG(yukleniyor, yer, dosya, sc) {
	ajax = new AJAX();
	
	if ( ajax ) {
		ajax.onreadystatechange = function () {};
		ajax.abort();
	}

	// son hazırlık
	if(sc) {
		dosya = dosya +'?'+ sc;
	}

    ajax.onreadystatechange = function () {	Loading(yukleniyor, yer); }
	
	ajax.open('GET', dosya, true);
	ajax.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	ajax.setRequestHeader("Connection", "close");
	ajax.send(null);	
}


// Ajax Yükleme işlemleri
function Loading(yukleniyor, yer) {
	if( yukleniyor == 1 && yer != 'no_id' ) {
		if( ajax.readyState == 1 || ajax.readyState == 2 || ajax.readyState == 3 ) {
			var loading = '<img src="images/loading.gif" width="16" height="16" alt="Yükleniyor ..." border="0"/>Bekleyiniz...'
			document.getElementById(yer).innerHTML = loading;
		}
	}

	if( ajax.readyState == 4 && yer != 'no_id' ) {
		if (ajax.status == 200) {
            document.getElementById(yer).innerHTML = ajax.responseText;
        } else {
            document.getElementById(yer).innerHTML = '<strong>HATA:</strong> ' + ajax.statusText;
        }
		function AJAX() {};
    }
}


// Özel karakterleri zararsız hale dönüştür
// ( Fix Character )
function fixChar(text) {
	var temp;
	temp = encodeURIComponent(text);	
	return temp;
}

// yanıp sönme efekti
function doBlink() {
  var blink = document.all.tags("blink")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)setInterval("doBlink()",800)
}
addOnLoad(startBlink);

/***********************************************
* Balon mesaj
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove=positiontip

// seçimi sınırlandırma fonksiyonu
function checkSelect(sel,smax)
{
	scount=0;
	if(sel.options[0].selected==true)
	{
		for(i=0;i<sel.length;i++)
		{
			sel.options[i].selected=false;
		}
	}
	for(i=0;i<sel.length;i++)
	{
		if (sel.options[i].selected) scount++;
		if (scount>smax) sel.options[i].selected=false;
	}
	if (scount>smax)
	{
		alert (smax+' adetden fazla seçim yapamazsınız...');
	}
	return (scount);
}
function SelectCount(select,maxSelected)
{
	if (!select.storeSelections){
		select.storeSelections = new Array(select.options.length);
		select.selectedOptions = 0;
	}
	for (var i = 0; i < select.options.length; i++){
		if (select.options[i].selected && !select.storeSelections[i]){
			if (select.selectedOptions < maxSelected){
				select.storeSelections[i] = true;
				select.selectedOptions++;
			}
			else{
				alert('Maksimum '+maxSelected+' Tane Seçim Yapabilirsiniz!');
				select.options[i].selected = false;
			}
		}
		else if (!select.options[i].selected && select.storeSelections[i]){
			select.storeSelections[i] = false;
			select.selectedOptions--;
		}
	}
}



//Yazdırma Scripti
function Yazdir(alan) {
	if(document.getElementById('yazilmayacak')){
		document.getElementById('yazilmayacak').style.display='none';
	}
	var txt = document.getElementById(alan).innerHTML;
	//window.open(null,'');
	document.write(txt);
	window.print();
	document.close();
}

