var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";
function initToolTips()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }
}
function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "maroon";
    if(!bg) bg = "bisque";
    var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
    '"><td align="center"><font face="sans-serif" color="' + fg +
    '" size="-2">&nbsp\;' + msg +
    '&nbsp\;</font></td></table></td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
  }
}
function moveToMouseLoc(e)
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  return true;
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
function capitalizeWords(string)
{
var tmpStr, tmpChar, preString, postString, strlen;
tmpStr = string.toLowerCase();
stringLen = tmpStr.length;
if (stringLen > 0)
{
  for (i = 0; i < stringLen; i++)
  {
    if (i == 0)
	{
      tmpChar = tmpStr.substring(0,1).toUpperCase();
      postString = tmpStr.substring(1,stringLen);
      tmpStr = tmpChar + postString;
    }
    else
	{
      tmpChar = tmpStr.substring(i,i+1);
      if (tmpChar == " " && i < (stringLen-1))
	  {
      tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
      preString = tmpStr.substring(0,i+1);
      postString = tmpStr.substring(i+2,stringLen);
      tmpStr = preString + tmpChar + postString;
      }
    }
  }
}
return tmpStr;
}
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open('/'+URLStr, 'popUpWin', '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 popUpWin2=0;
function popUpWindow2(URLStr, left, top, width, height)
{
  if(popUpWin2)
  {
    if(!popUpWin2.closed) popUpWin2.close();
  }
  popUpWin2 = open(URLStr, 'popUpWin2', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function chkEBF() {
  for (i=0; i<document.forms[0].length; i++) {
    if (document.forms[0].elements[i].type == 'text') {
	  if (document.forms[0].elements[i].value == '') {
	    alert('Eksik bilgi girdiniz. Kutularda bilgi girmeyeceğiniz bölümleri boş bırakmayıp, tire (-) işareti koymalısınız!');
		document.forms[0].elements[i].focus();
		return false;
	  }
	}
  }
  return true;
}
function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}

function chkImages(im) {
  if (im == '') {
	alert('EBF numaras yok!');
	return false;
  }
  else {
	if (confirm('EBF numaras ' + im + ' olan kayt iin resim ilemi balyor. TAMAM yapp, ilem bitene kadar bekleyiniz.')) {
	}
	else {
	  alert('lem PTAL edildi!');
	  return false;
	}
  }
	var forim = document.forms[0];
	var ftxt = '';
	var stxt = '';
	var stxt2 = '';
	var len  = 0;
	var pos  = 0;
	var pos2 = 0;
	var pos3 = 0;
	var j = '';
	var ebf_no = '';
	var o_ebf_no = '';
	for (i=0; i<forim.length; i++) {
		if (i<10) { 
		  j = '0' ; }
		else { 
		  j = ''; 
		}
		if (forim.elements[i].type == 'file') {
	  	  ftxt = forim.elements[i].name;
		  stxt2 = forim.elements[i].value;
		  stxt = forim.elements[i].value;
		  if (stxt != '') {
			  pos  = stxt.lastIndexOf("_");
			  stxt = stxt.substring(pos);
			  pos = 1;
			  pos2  = stxt.lastIndexOf(".");
			  pos3  = stxt2.lastIndexOf("\\");
			  ebf_no= stxt2.substring(pos3+1);
			  ebf_no = ebf_no.substring(0,ebf_no.lastIndexOf("_"));
			  if (ebf_no != im) {
			    alert('Hata 03: Yanl bir EBF numarasna resim girii yapyorsunuz! EBF No: ' + im + ' olmaldr, siz ' + ebf_no + ' numarasna ait EBF kayd girmeyi deniyorsunuz!');
				forim.elements[i].focus();
				return false;
			  }
			  if (pos<0 || pos2<0) {
			    alert('Hata 01: Bu bolume eklenecek resmin kodu ' + im + '_' + j + ftxt.substring(4) + '.jpg olmalidir...Ltfen kontrol ediniz...');
				forim.elements[i].focus();
				return false;
			  }
			if (stxt.substring(pos,pos2) != (j + ftxt.substring(4)) ) {
			  alert('Hata 02: Bu bolume eklenecek resmin kodu ' + im + '_' + j + ftxt.substring(4) + '.jpg olmalidir...Ltfen kontrol ediniz...');
				forim.elements[i].focus();
			  return false;
			}
			len = 0;
			stxt = '';
		  }
		}
	}
  return true;
}
function fillMT(v) {
  var obj = findObj('MyMT1','');
  obj.location = 'getMT2.php?ac_id=' + v;
}
function showMap(x,y,z) {
  if (x>0 && y>0) {
    window.open('/showmap.php?x='+x+'&y='+y+'&n='+z,'showMap','fullscreen,scrollbars');
  }
}
function showOfficeMap(x,y,z) {
  if (x>0 && y>0) {
    window.open('/show_office_map.php?x='+x+'&y='+y+'&n='+z,'showMap','fullscreen,scrollbars');
  }
}

