// JavaScript Document
function chgCls(fld,cls){
	fld.className = cls;
	}

function openLink(lnk){
		window.location.href = lnk;
	}
	
function wOp(lnk,syf,w,h,r,s){
	var syf = window.open(lnk,syf,"width="+w+",height="+h+",resizable="+r+",status=yes,location=0,scrollbars="+s)
	}
	
function smallPreview(newImgSrc){
	var nesne = document.getElementById("smallPrev")
	nesne.src = newImgSrc;
	nesne.width = 51;
	nesne.height = 37;
}

function galeriPrevBuyut(){
	chgCls(smallPrevCont,'goster');
	var target = document.getElementById("smallPrev")
	var startwid = 50
	var endwid = 160
	var currwid = Number(target.width)
	var currheg = Number(target.height)
	if(currwid<endwid){
		target.width = currwid + 10
		target.height = (currwid * 40) / startwid
		setTimeout("galeriPrevBuyut()",1)
	}else{
		clearTimeout("galeriPrevBuyut()");
		target.style.cursor="pointer";
		target.onclick = kucultSayfaAc;
		setTimeout("galeriPrevKucult()",2500)
	}
}

function galeriPrevKucult(){
	clearTimeout("galeriPrevBuyut()")
	var target = document.getElementById("smallPrev")
	target.width = 50;
	target.height = 40;
	clearTimeout("galeriPrevKucult()");
	target.style.cursor="default";
	chgCls(smallPrevCont,'gizle');
}

function kucultSayfaAc(lnk){
	var target = document.getElementById("smallPrev")
	galeriPrevKucult();
	var prevWindow = window.open("bigFoto.asp?foto="+target.src,"bigFoto","width=600, height=480, scrollbars=no, resizable=yes, status=yes")
	var topAlign = (screen.height/2)-(600/2);	//Ortalama için üst boşluk
	var leftAlign = (screen.width/2)-(480/2);	//Ortalama için sol boşluk
		if (prevWindow){
			prevWindow.moveTo(leftAlign, topAlign);
			prevWindow.resizeTo(width=600,height=480);
		}
	
	}


function imageChecker(imgsrc){
    var myImage = new Image();	
        myImage.src = imgsrc;
    var clocktime = new Date();
    var utchours = clocktime.getUTCHours();
    var utcminutes = clocktime.getUTCMinutes();
    var utcseconds = clocktime.getUTCSeconds();
    var utcyear = clocktime.getUTCFullYear();
    var utcmonth = clocktime.getUTCMonth()+1;
    var utcday = clocktime.getUTCDate();
    var utctime = utcyear+''+utcmonth+''+utcday;
        utctime += utchours+''+utcminutes+''+utcseconds;
 
      isNew = myImage.src;
        if(!isNew.match('#')){
           document.images['mycount'].src = myImage.src+'?'+utctime;
        }
      else{document.images['mycount'].src = document.images['mycount'].src;
    }

	}

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 sendLoadOutput(lnk){
	xmlhttp.open("GET", lnk ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4){
		var alinan = xmlhttp.responseText
		return alinan
		}
	}
	xmlhttp.send(null);
} 

function mansetDetay(fld,altFld,frmFld,lnk,opt){
	if(opt==1){
		fld.className = "goster";altFld.className = "gizle";
		}else{
			fld.className = "gizle";altFld.className = "goster";
			}
	frmFld.location.href=lnk;
	mansetFoto(1);
	mansetArkadasimaGonder(1)
	}
	
function mansetFoto(opt){if(mansetFotolar.className == "gizle"){mansetFotolar.className = "goster";}else{mansetFotolar.className = "gizle";} if(opt==1){mansetFotolar.className = "gizle";}}
	
function mansetArkadasimaGonder(opt){
	if(mansetArkadasimaGonder11.className == "gizle"){
		mansetArkadasimaGonder11.className = "goster";
		mansetarkadasimagondercontent.className="goster";
		mansetarkadasimagonderresult.className="gizle";
		}else{
			mansetArkadasimaGonder11.className = "gizle";
			} if(opt==1){mansetArkadasimaGonder11.className = "gizle";}}

function haberYazdir(objID){
		var haberWin = window.open("_aListener.asp?sayfa=mansethaber&objID="+objID,"haberWin","width=800,height=600,scrolling=yes,status=yes,resizable=yes")
		if(haberWin){
				haberWin.print();
			}
	}

function haberYazdir2(objID){
		var haberWin = window.open("_aListener.asp?sayfa=mansethaber2&objID="+objID,"haberWin","width=800,height=600,scrolling=yes,status=yes,resizable=yes")
		if(haberWin){
				haberWin.print();
			}
	}

function resizeWindow(wid,heg,r,m) {
	var topAlign = (screen.height/2)-(heg/2);	//Ortalama için üst boşluk
	var leftAlign = (screen.width/2)-(wid/2);	//Ortalama için sol boşluk
if (r){
	window.moveTo(leftAlign, topAlign);
}
if (m){
	window.resizeTo(width=wid,height=heg);
}
}

function checkEmail(field){
var email = field.value
	if (email.indexOf("@") != "-1"){
		if (email.slice(email.indexOf("@")).indexOf(".") != "-1"){
				return "1"
			}else{
			return "0"
				}
		}
		else{return "0"}
}

function addNewMail(fld,mVal){
	if(checkEmail(mVal)=="1"){
	fld.options[fld.length] = new Option(mVal.value,mVal.value);
	mVal.value = "";
	}else{
		alert("Girdiğiniz emailin yazımı yanlış\nyada henüz birşey yazmadınız!");
		mVal.focus();
		}
	}

function remMail(fld){
		if(fld.selectedIndex>=0){
		fld.remove(fld.selectedIndex);
			}else{
				alert("Seçmeden email adresi silemezsiniz!\nLütfen listeden seçim yapınız.")
				}
	}

function remAllMail(fld){
	if(fld.options.length>0){
		fld.options.length = 0;
	}
	}

function checkFormValues(form){
	for (i=0;i<form.elements.length;i++){
		if (form.elements[i].id.indexOf("G_") != -1){
			if (form.elements[i].value == ""){
				alert("Bu alan gerekli!",form);
				form.elements[i].focus(); return false; var sendForm = false;
				}else{var sendForm = true;}}
		}
		
		if (sendForm == true){form.submit();}else{return "0";}
}

function sendToPol_Submit(){
	var theForm = document.sendtopal
	if(theForm.mailobj.options){
		if(theForm.mailobj.options.length>0){
			theForm.mailobj.multiple=true;
			for(i=0;i<theForm.mailobj.options.length;i++){theForm.mailobj.options[i].selected=true;}
			if(checkFormValues(theForm)=="0"){
				theForm.button2.disabled=false
				}else{
					theForm.button2.disabled=true
					}
			}
		}
	}
	
function CorrectDateStr(field){
	var tarih = field.value
	if (tarih != ""){
		tarihSpl = tarih.split("."); gun = Number(tarihSpl[0]); ay = Number(tarihSpl[1]); yil = Number(tarihSpl[2])
		if (gun < 10){gun = "0"+""+gun;}
		if (ay < 10){ay = "0"+""+ay;}
		field.value = gun+"."+ay+"."+yil
	}
}

function filterNews(){
	var t1 = document.getElementById("sDatei").value;var t2 = document.getElementById("eDatei").value;
	window.location.href=traceUrl()+'?baslangic='+t1+'&bitis='+t2;
	}

function filterFirms(obj){
	var t1 = document.getElementById("funvan").value;var t2 = document.getElementById("ffalan").value;
	if(window.event){if(window.event.keyCode=="13"){window.location.href='uyesorgulama.asp?funvan='+t1+'&ffalan='+t2;}else{
	if(obj){window.location.href='uyesorgulama.asp?funvan='+t1+'&ffalan='+t2;}}
	}
	}

function filterFirms2(obj){
	var t1 = document.getElementById("funvan").value;var url = "window.location.href='firmalar.asp?funvan='+t1+'&firmatur='+ftur"
	if(window.event){if(window.event.keyCode=="13"){eval(url)}else{
	if(obj){eval(url)}}
	}
	}

function maillist(opt){
	var email = document.getElementById("maillistemail");
		openLink("?sayfa=maillist&objID="+opt+"&maillistemail="+email.value);
	}
	
function autoPassword(){
	var img = document.getElementById("autopass")
	if(img.className=="passhided"){
			document.getElementById("body").style.cursor="wait";xmlhttp.open("GET", "pwgen.asp" ,true);
			xmlhttp.onreadystatechange=function() {
				if (xmlhttp.readyState==4){
				var alinan = xmlhttp.responseText

			img.className = "passshown";
			document.form1.kullanici_sifre.className="gizle";document.form1.kullanici_sifre_tekrar.className="gizle";
			document.form1.kullanici_sifre_gizli.className="textbox";document.form1.kullanici_sifre_gizli_tekrar.className="textbox";
			document.form1.kullanici_sifre_gizli.value = alinan;document.form1.kullanici_sifre_gizli_tekrar.value = alinan;
			document.form1.kullanici_sifre.value = alinan;document.form1.kullanici_sifre_tekrar.value = alinan;
			document.getElementById("body").style.cursor="default";
				}
			}
			xmlhttp.send(null);
		}else{
			img.className = "passhided";
			document.form1.kullanici_sifre.className="textbox";
			document.form1.kullanici_sifre_tekrar.className="textbox";
			document.form1.kullanici_sifre_gizli.className="gizle";
			document.form1.kullanici_sifre_gizli_tekrar.className="gizle";
			document.getElementById("body").style.cursor="default";
			}
	}
	
function transferPasses(){
	document.form1.kullanici_sifre_gizli_tekrar.value = document.form1.kullanici_sifre_gizli.value
	document.form1.kullanici_sifre.value = document.form1.kullanici_sifre_gizli.value
	document.form1.kullanici_sifre_tekrar.value = document.form1.kullanici_sifre_gizli.value
	}
	
function hideUserMarbles(){
	document.getElementById("yMarb").className = "passhide";
	document.getElementById("rMarb").className = "gizle";
	document.getElementById("gMarb").className = "gizle";
	}
	
function chkUserName(){
	var uName = document.getElementById("kullaniciadi").value;
	document.getElementById("body").style.cursor="wait";document.getElementById("userDenied").className = "gizle";
	document.getElementById("userAccept").className = "gizle";document.getElementById("chkLoader").className = "gizle"
	if(uName!=""){
		xmlhttp.open("GET", "_aListener.asp?sayfa=chkusername&uname="+uName ,true);
		xmlhttp.onreadystatechange=function() {
		document.getElementById("chkLoader").className = "goster";
		if (xmlhttp.readyState==4){
		document.getElementById("chkLoader").className = "gizle";
		var alinan = xmlhttp.responseText;document.getElementById("body").style.cursor="default";
			if(alinan.substring(alinan.length-1,alinan.length)=="1"){
					document.getElementById("userAccept").className = "goster";
				}else{
					document.getElementById("userDenied").className = "goster";document.getElementById("kullaniciadi").select();
					}
			}
		}
		xmlhttp.send(null);
	}
	document.getElementById("body").style.cursor="default";
	}
	
function upperCase(str){
	var smallCaps = new Array("ç","ö","i","ş","ü","ğ")
	var bigCaps = new Array("Ç","Ö","İ","Ş","Ü","Ğ")
	for(i=0;i<str.length;i++){
			for(s=0;s<smallCaps.length;s++){
					if(str.substring(i,i+1)==smallCaps[s]){
						str = str.replace(str.substring(i,i+1),bigCaps[s]);
						}
				}
		}
		return str.toUpperCase();
	}
	
function lowerCase(str){
	var smallCaps = new Array("ç","ö","i","ş","ü","ğ")
	var bigCaps = new Array("Ç","Ö","İ","Ş","Ü","Ğ")
	for(i=0;i<str.length;i++){
			for(s=0;s<smallCaps.length;s++){
					if(str.substring(i,i+1)==bigCaps[s]){
						str = str.replace(str.substring(i,i+1),smallCaps[s]);
						}
				}
		}
		return str.toLowerCase();
	}
	
function traceUrl(){
	var url = window.location.href.split("/");
	if(url[url.length-1].indexOf("?")>-1){qState = url[url.length-1].indexOf("?");}else{qState = url[url.length-1].length;}
	var tmp = url[url.length-1].substring(0,qState);
	return tmp;
}

function onlyNumbers() {
  if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
}