// JavaScript Document

function getLink(lnk){
	window.location.href = lnk
	}

function wOp(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 == ""){form.elements[i].parentNode.bgColor=clr;form.elements[i].focus();return false;var sendForm = false;}else{form.elements[i].parentNode.bgColor='#FFFFFF';var sendForm = true;}
		}
	}
	if (checkEmail(form.email)=='0'){form.email.parentNode.bgColor=clr;form.email.focus();var sendForm = false;}else{form.email.parentNode.bgColor='#FFFFFF';var sendForm = true;}
	if (sendForm == true){form.submit();}
	}

function checkEmail(field){
var email = field.value
if (email.indexOf("@") == "-1"){return "0"}else{
	if (email.lastIndexOf(".") == "-1"){return "0"}
	}
	}

function chgCls(fld,cls){
	fld.className = cls;
	}

function selectOpt(fld,val){
  for (i=0;i<fld.options.length;i++){
	  if (fld.options[i].value == val){fld.options[i].selected=true;}
  }
}

function resizeWindow(wid,heg,mt,rs) {
	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 (mt){window.moveTo(leftAlign, topAlign);}
	if (rs){window.resizeTo(width=wid, height=heg);}
}

function chgClsx(fld,cls1,cls2){
	if (fld.className==cls1){fld.className=cls2}else{fld.className=cls1}
	}

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 checkAll(chk,field){
var table = document.getElementById(field);var cells = table.getElementsByTagName("INPUT");if (chk.value == "unchecked"){chk.value = "checked";chk.checked = true;for (var i = 0; i < cells.length; i++) {cells[i].checked = true;}}else{chk.value = "unchecked";chk.checked = false;for (var i = 0; i < cells.length; i++) {cells[i].checked = false;}}}

var where = ""; // which link
function checkwhere(e) {//Koordinatları yakalatma
	if (document.all){return  event.clientX+","+event.clientY;}}

function showInputTip(fld){
if(document.captureEvents) {document.captureEvents(Event.MOUSEMOVE);}//Sonraki işlem için koordinat atama. Bu bölüm şart
coorSplVar = checkwhere();//Gelen Koordinat değerlerini sabitleme.
coorSpl = coorSplVar.split(",")//Değerleri x ve y değişkenlerine bölme

placer = document.getElementById(fld)
		placer.style.left = Number(coorSpl[0])+10 //Özel istek için x koordinatını nesnenin sol değerine atama
		placer.style.top = Number(coorSpl[1])+20 //Özel istek için y koordinatını nesnenin üst değerine atama
		
}

function validateNumber(field,validate) {
nesne = field
nesne.parentNode.bgColor='#FFFFFF';
var valid = validate
var ok = "yes";
var temp;
if (field.value!=''){
for (var i=0; i<nesne.value.length; i++) {
temp = "" + nesne.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1"){nesne.value=nesne.value.substring(0, i);}
}
field.focus();
return false;
}
}
function enterAction(code,url){
	if (window.event.keyCode == Number(code)){
		openLink(url);
		}
	}

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;
    }

	}
	
function checkLogin(){
redPl();
}
function redPl(){
loginPanel.bgColor = "#FFFF33"
setTimeout("recoverPl()",50)
}

function recoverPl(){
loginPanel.bgColor = "#FFFFFF"
setTimeout("reredPl()",20)
clearTimeout("redPl()")
}

function reredPl(){
loginPanel.bgColor = "#FFFF33"
clearTimeout("redPl()")
setTimeout("rerecoverPl()",20)
}

function rerecoverPl(){
loginPanel.bgColor = "#FFFFFF"
clearTimeout("redPl()")
clearTimeout("redPl()")
clearTimeout("rerecoverPl()")
}

function fWImg(fitField,absWid,absHeg){
var fld = document.getElementById(fitField);
fld.width = absWid;
fld.height = absHeg;
	}