// JavaScript Document
function cntObjToDoc(obj,w,h){
	if(!obj){obj = document.getElementById(obj)}
	var lf = (document.body.clientWidth / 2)-(w/2);
	var rg = (document.body.clientHeight / 2)-(h/2);
	obj.style.left = lf+"px";
	obj.style.top = rg+"px";
	}

function cntObjToScr(w,h){
	var topAlign = (screen.height/2)-(h/2);	//Ortalama için üst boşluk
	var leftAlign = (screen.width/2)-(w/2);	//Ortalama için sol boşluk
	window.moveTo(leftAlign, topAlign);
	window.resizeTo(width=w, height=h);
	}

function wOp(lnk,pnm,w,h){
	var mywin = window.open(lnk,pnm,"width="+w+",height="+h+",scrollbars=no,resizable=no,location=no,status=yes")
	}

function doWe(obj,href,fid,h){
	if(h){wid="100%";heg=h;}else{wid="1";heg="1";}
obj.innerHTML = "<iframe id='"+fid+"' src='"+href+"' name='"+fid+"' width='"+wid+"' height='"+heg+"' frameborder=0 scrolling='no' class=\"gizle1\"></iframe>"
}

function oWin(obj,href,w,h,frID){
	chgCls(obj,"goster");
	cntObjToDoc(obj,w,h);
	obj.style.width=w+"px";
	obj.style.height=h+"px";
	doWe(obj,href,frID,h);
	}

var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function sendLoad(nesne, lnk){
	var nesne_ = document.getElementById(nesne)
	nesne_.innerHTML = "<span style='color:#CCCCCC'>İşlem yapılıyor...</span>";
	xmlhttp.open("GET", lnk ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4){
		var alinan = xmlhttp.responseText
		
		nesne_.innerHTML = alinan;
		return "1"
		}
	}
	xmlhttp.send(null);
} 

function checkChecked(obj){
	if(obj.checked==true){return "1"}else{return "0"}
	}

function getUrl(trg,lnk){
	trg.location.href = lnk
	}

function checkFormValues(form,clr){
	for (i=0;i<form.elements.length;i++){
		if (form.elements[i].id.indexOf("G_") != -1){
			if (form.elements[i].value == ""){
				chgCls(window.top.processWindow,'gizle');
				responseError("Bu alan gerekli!",form);
				form.elements[i].parentNode.bgColor=clr;
				form.elements[i].focus();return false;
				var sendForm = false;
				}else{
					responseError("",form);
					form.elements[i].parentNode.bgColor='';
					var sendForm = true;
					chgCls(window.top.processWindow,'goster');
					}
		}
	}
	if(form.email){
	if (checkEmail(form.email)=='0'){
		form.email.parentNode.bgColor=clr;
		chgCls(window.top.processWindow,'gizle');
		form.email.focus();
		responseError("Bu alan gerekli!",form);
		var sendForm = false;
		}else{
			form.email.parentNode.bgColor='';
			var sendForm = true;
			chgCls(window.top.processWindow,'goster');
			responseError("",form);
			}
		}
	if (sendForm == true){
		form.submit();
		}else{return "0";}
	}

function checkEmail(field){
var email = field.value
	if (email.indexOf("@") == "-1"){return "0"}else{
	if (email.lastIndexOf(".") == "-1"){return "0"}
	}
}
	
function coloredTR(tblID){
  x = 1
  var tbl = document.getElementById(tblID);
  var tr = tbl.getElementsByTagName("TR")
  for (i=1;i<tr.length;i++){
  var x = x + 1
  if (x==2){tr[i].bgColor='';var x=0}else{tr[i].bgColor='#EEEEEE'}
  }
}

function chkFileType(f){
	var fld = document.getElementById(f).value
	var fldSp = fld.split("\\")
	var file = fldSp[fldSp.length-1];
	var fileSp = file.split(".");
	var fileType = fileSp[fileSp.length-1].toUpperCase();
	return fileType;
}

function deleteRowByLink(lnk){
  var tableRow = lnk.parentNode.parentNode;
  tableRow.parentNode.deleteRow(tableRow.rowIndex);
}

function setTitle(txt){
	document.getElementById("pagetitle").innerHTML = txt
	}
	
function selectOpt(fld,val){
  for (i=0;i<fld.options.length;i++){
	  if (fld.options[i].value == val){fld.options[i].selected=true;}
  }
}
function chgCls(obj,cls){
	obj.className = cls;
	}

function chgClsx(field,cls1,cls2){
if (field.className == cls1){field.className = cls2}else{field.className = cls1}
	}

function RemoveItem(fld,optGrp){
var to = document.getElementById(optGrp); if (fld.value){ var fldText = fld.options[fld.selectedIndex].text;	var fldValue = fld.options[fld.selectedIndex].value; var fld_index = fld.options[fld.selectedIndex].index;	to.options[to.length] = new Option(fldText,fldValue);	fld.remove(fld.selectedIndex);	if (fld_index>0){fld.options[fld_index-1].selected=true;}else{if(fld.options.length>0){fld.options[0].selected=true;}}}
}
function selAll(fld){var fld = document.getElementById(fld); for (i=0;i<fld.options.length;i++){fld[i].selected=true;}}
function remAll(fld){var fld = document.getElementById(fld); for (i=0;i<fld.options.length;i++){fld.remove(i);}}
function remItem(fld,itm){
	var fld = document.getElementById(fld);
	for (i=0;i<fld.options.length;i++){
		if(fld.options[i].value==itm){
			fld.remove(i); break;
			}
		}
	}

function checkProdBrowser(blm){
	var sekt = yenikayitform.firmasektor.options[yenikayitform.firmasektor.selectedIndex].value;
	var urn = document.getElementById(blm).value;
		if(blm=="urunler"){
		if(yenikayitform.firmasektor.options[yenikayitform.firmasektor.selectedIndex].value!=""){
			yenikayitform.firmasektor.parentNode.bgColor="";
			wOp("_formoptions.asp?bolum="+blm+"&durum="+sekt+"&sayfa="+urn,"formoptions",400,277)
		}else{yenikayitform.firmasektor.parentNode.bgColor="#FFCCCC";}
		}else{wOp("_formoptions.asp?bolum="+blm+"&durum="+sekt+"&sayfa="+urn,"formoptions",400,277)}
	}

function tabIndexLt(frm,fld){
	for(ti=0;ti<frm.elements.length;ti++){
		if(frm.elements[ti].tagName!="FIELDSET"){
			if(frm.elements[ti].className!="hidTxt"){
				frm.elements[ti].tabIndex=ti+1;
				}
			}
		}
		fld.focus();
	}


