var RAPOR_OK0006_TUR_1 = 1;
var RAPOR_OK0006_TUR_2 = 2;
var RAPOR_OK0006_TUR_3 = 3;

var RAPOR_GK0009_ADETSEL = 0;
var RAPOR_GK0009_PRIMSEL = 1;

var RAPOR_OK0010 = "10";
var RAPOR_OK0011 = "11";


var RAPOR_SIRALAMA_SIRKET_ADI = 1;
var RAPOR_SIRALAMA_POLICE_ADET = 2;	
var RAPOR_SIRALAMA_ADET_SIRALI = 3;
var RAPOR_SIRALAMA_PRIM_SIRALI = 4;	
var RAPOR_SIRALAMA_HATA_ORAN_SIRALI = 5;	


//----------------------------------------
// upload scrn usage
//----------------------------------------
function initDosyaDurumScrn()
{
	setFocus(document.sirketReportForm.basTarih);
}

function checkDosyaDurumScrn()
{
	with (document.sirketReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0001Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0001TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0001Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0001TarihGecersiz);
	}
	return true;
}

//----------------------------------------
// raporOK0001 scrn usage
//----------------------------------------
function initRaporOK0001Scrn()
{
	setFocus(document.acenteReportForm.basTarih);
}

function checkRaporOK0001Scrn()
{
	with (document.acenteReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0001Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0001TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0001Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0001TarihGecersiz);

		var d1 = new Date(basTarih.value.substring(6,10),basTarih.value.substring(3,5),basTarih.value.substring(0,2),0,0,0,0);
		var d2 = new Date(bitTarih.value.substring(6,10),bitTarih.value.substring(3,5),bitTarih.value.substring(0,2),0,0,0,0);
		
		if (userTip.value != USERTIP_TRAMER)
		{
			if (compareDateObjects(d1,HATA_RAPOR_KONTROL_TARIH) !=1)
				return reportError(basTarih,raporOK0001TarihKuralHatali);
	
			if (compareDateObjects(d2,HATA_RAPOR_KONTROL_TARIH) !=1)
				return reportError(bitTarih,raporOK0001TarihKuralHatali);
			
			if (dateDiff(d1,d2) > 7) return reportError(bitTarih,raporOK0001TarihKuralHatali);
		}
	}
	
	return true;
}

//----------------------------------------
// raporOK0001 scrn usage
//----------------------------------------
function initRaporOK0001DetayScrn()
{
	setFocus(document.acenteReportForm.basTarih);
}

function checkRaporOK0001DetayScrn()
{
	with (document.acenteReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0001Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0001TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0001Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0001TarihGecersiz);

		var d1 = new Date(basTarih.value.substring(6,10),basTarih.value.substring(3,5),basTarih.value.substring(0,2),0,0,0,0);
		var d2 = new Date(bitTarih.value.substring(6,10),bitTarih.value.substring(3,5),bitTarih.value.substring(0,2),0,0,0,0);
		
		if (userTip.value != USERTIP_TRAMER)
		{
			if (compareDateObjects(d1,HATA_RAPOR_KONTROL_TARIH) !=1)
				return reportError(basTarih,raporOK0001TarihKuralHatali);

			if (compareDateObjects(d2,HATA_RAPOR_KONTROL_TARIH) !=1)
				return reportError(bitTarih,raporOK0001TarihKuralHatali);

			if (dateDiff(d1,d2) > 7) return reportError(bitTarih,raporOK0001TarihKuralHatali);
		}
		
	    // 01/08/2007 den kucuk tarihler icin grup 3 verilmeyecek
		var kontrolTarih =  new Date(2007,7,1);	
		var basTar = new Date(basTarih.value.substring(6,10),(basTarih.value.substring(3,5)-1),basTarih.value.substring(0,2),0,0,0,0)
		
		if (compareDateObjects(kontrolTarih, basTar) == 1 && hataGrupKod.selectedIndex == 2) 
			return reportError(hataGrupKod,raporOK0001GrupSecimi);		
		
	}
	
	return true;
}

//----------------------------------------
// raporOK0002 scrn usage
//----------------------------------------
function initRaporOK0002Scrn()
{
	setFocus(document.acenteReportForm.basTarih);
}

function checkRaporOK0002Scrn()
{
	with (document.acenteReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0002Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0002TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0002Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0002TarihGecersiz);
	}
	return true;
}

//----------------------------------------
// raporOK0003 scrn usage
//----------------------------------------
function initRaporOK0003Scrn()
{
	setFocus(document.sirketReportForm.basTarih);
}

function checkRaporOK0003Scrn()
{
	with (document.sirketReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0003Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0003TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0003Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0003TarihGecersiz);
	}
	return true;
}

//----------------------------------------
// raporOK0004 scrn usage
//----------------------------------------
function initRaporOK0004Scrn()
{
	setFocus(document.acenteReportForm.basTarih);
}

function checkRaporOK0004Scrn()
{
	with (document.acenteReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0004Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0004TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0004Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0004TarihGecersiz);
	}
	return true;
}
//----------------------------------------
// raporOK0005 scrn usage
//----------------------------------------
var mesajArray = new Array();

function initRaporOK0005Scrn()
{
	with (document.sirketHataListTakipForm)
	{
		basDonem.selectedIndex = -1;
		sorguHataKod.checked = 0;
		siralamaType.selectedIndex = -1; 
		document.getElementById("mesajTD").style.display = "none";
		mesajArray[0] = " * Tüm hatalı poliçeler listelenmektedir.";
		mesajArray[1] = " * Öncelikli olarak düzeltilmesi gereken hatalara sahip olan poliçeler listelenmektedir.";
		mesajArray[2] = " * Yalnızca 61 hata kodunu (%5-%10 bant aralığı dışında kalan poliçeler) alan poliçeler listelenmektedir.";
		mesajArray[3] = " * Yalnızca 63 hata kodunu (%10-%20 bant aralığı dışında kalan poliçeler) alan poliçeler listelenmektedir.";
	}	
	raporOK0005HataKodChange(sirketHataListTakipForm);
	raporOK0005GizliGosterChange(sirketHataListTakipForm);
	
	return true;
}

function checkRaporOK0005Scrn()
{	
	with (document.sirketHataListTakipForm) {

		basDonem.value = basDonem.value.trim();
		if (basDonem.value.length == 0) return reportError(basDonem,raporOK0005Donem);
					
		var d1 = new Date(basDonem.value.substring(6,10),basDonem.value.substring(3,5)-1,basDonem.value.substring(0,2),0,0,0,0);

		if (sorguHataKod.checked == 1)
		{
			if (hataGrupKod.selectedIndex == -1) 
				return reportError(hataGrupKod,raporOK0005GrupHatali);
			else {
				// 01/08/2007 den kucuk tarihler icin grup 3 verilmeyecek
				var kontrolTarih =  new Date(2007,7,1);	
				var basTarih = new Date(basDonem.value.substring(6,10),(basDonem.value.substring(3,5)-1),basDonem.value.substring(0,2),0,0,0,0)
				
				if (basDonem.selectedIndex != 0 && compareDateObjects(kontrolTarih, basTarih) == 1 && hataGrupKod.selectedIndex == 2) 
					return reportError(hataGrupKod,raporOK0005GrupSecimi);		
			}
		}	
	}
	raporOK0005GizliGosterChange(document.sirketHataListTakipForm);
	return true;
}

function raporOK0005GizliGosterChange(form)
{
	if (form.sorguHataKod.checked == 0 || (form.sorguHataKod.checked == 1 && form.hataGrupKod.selectedIndex == 2) || (form.sorguHataKod.checked == 1 && form.hataGrupKod.selectedIndex == 3))
		raporOK0005ReportTypeChange(form);

	return true;
}

function raporOK0005HataKodChange(form)
{
	if (form.sorguHataKod.checked == 0)
	{
		form.hataGrupKod.disabled = true;
		form.hataGrupKod.selectedIndex = -1;
		form.siralamaType.disabled = false; 
		form.siralamaType.selectedIndex = 0;
	}
	else
	{
		form.hataGrupKod.disabled = false;
		form.siralamaType.disabled = true; 	
		form.siralamaType.selectedIndex = -1; 		
	}
	raporOK0005ReportTypeChange(form);
	return true;
}


function raporOK0005ReportTypeChange(form)
{
	var gizliGoster = -1;
	var siralamaType = -1;

	if (form.sorguHataKod.checked == 0)
	{
		document.getElementById("mesajTD").style.display = "none";
		if (form.gizliGoster.type == "hidden") gizliGoster = parseInt(form.gizliGoster.value); else gizliGoster = (form.gizliGoster.checked) ? 1 : 0;
		if (form.siralamaType.type == "hidden") siralamaType = parseInt(form.siralamaType.value); else siralamaType = parseInt(form.siralamaType.value);
				
		if (siralamaType == RAPOR_SIRALAMA_SIRKET_ADI)
		{
			if (gizliGoster == 1)
				form.reportName.value="raporOK0005a";
			else
				form.reportName.value="raporOK0005";
		}
		else if (siralamaType == RAPOR_SIRALAMA_HATA_ORAN_SIRALI)
		{
			if (gizliGoster == 1)
				form.reportName.value="raporOK0005HKSa";
			else
				form.reportName.value="raporOK0005HKS";
		}
		else
		{	
			if (gizliGoster == 1) 
				form.reportName.value="raporOK0005a";
			else
				form.reportName.value="raporOK0005";
		}	
	}
	else
	{
		
		if ((form.hataGrupKod.selectedIndex != 2) && (form.hataGrupKod.selectedIndex != 3)) {
			form.reportName.value="raporOK0005H";
		}else{
			/* tramer, birlik ve hazine kullanıı*/
			if (form.gizliGoster.type != "hidden") {
				if (form.gizliGoster.checked) {
					form.reportName.value="raporOK0005HGrup3Sirket";
				}
				else {
					form.reportName.value="raporOK0005HGrup3SirketAcik";	
				}
			}
			/*şrket kullanıı*/
			else {
				form.reportName.value="raporOK0005HGrup3";	
			}
		}
		if(form.hataGrupKod.selectedIndex >= 0){
			document.getElementById("mesajTD").innerText = mesajArray[form.hataGrupKod.selectedIndex];
			document.getElementById("mesaj").value = mesajArray[form.hataGrupKod.selectedIndex];
			document.getElementById("mesajTD").style.display = "";
		}
	}
	return true;
}


//----------------------------------------
// raporOK0006 scrn usage
//----------------------------------------
function initRaporOK0006Scrn()
{
	setFocus(document.acenteReportForm.basTarih);
}

function checkRaporOK0006Scrn()
{
	with (document.acenteReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporOK0006Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporOK0006TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporOK0006Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporOK0006TarihGecersiz);
		
		acenteNo.value = acenteNo.value.trim();
		if (acenteNo.value.length != 0 && reportType.value == RAPOR_OK0006_TUR_1)
			return reportError(reportType,raporOK0006ReportType);
	}
	return true;
}

function raporOK0006ReportTypeChange(form)
{
	if (form.reportType.selectedIndex == RAPOR_OK0006_TUR_1 -1)
		form.reportName.value="raporOK0006S";
	if (form.reportType.selectedIndex == RAPOR_OK0006_TUR_2 -1)
		form.reportName.value="raporOK0006A";
	if (form.reportType.selectedIndex == RAPOR_OK0006_TUR_3 -1)
		form.reportName.value="raporOK0006AD";
	return true;
}

//----------------------------------------
// raporOK0007 scrn usage
//----------------------------------------

function initRaporO0007Giris()
{
	with(document.sirketReportForm){	
		//default eksik bilgi tipi poli?e ba?lama ve hasar tarihi se?imi olacak.
		eksikBilgiTipi.selectedIndex = 4;
	}
}
function checkRaporO0007()
{
	with(document.sirketReportForm){
		//sigorta ?irket se?imi zorunludur.
		if(sigortaSirketKod.selectedIndex == -1) return reportError(sigortaSirketKod, sigortaSirketKodBos);
		
		//ba?lama tarihi giri?i zorunludur
		if(basTarih.value.length == 0) return reportError(basTarih, raporO0007TarihBas);
		if(!checkDate(basTarih.value)) return reportError(basTarih, raporO0007TarihGecersizBas);
		
		//biti? tarihi giri?i zorunludur
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporO0007TarihBit);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporO0007TarihGecersizBit);
	
		if(eksikBilgiTipi.selectedIndex == -1)	return reportError(eksikBilgiTipi, eksikBilgiTipiBos);
	}	
}
//----------------------------------------
// raporOK0010 - raporOK0011 
//----------------------------------------
function raporHasarHataTypeChange()
{
    with (document.sirketReportForm) {
		if (reportNum.value == RAPOR_OK0010 && hataGrupBazindaRapor.checked == true)
			reportName.value="raporOK0010";
	    if (reportNum.value == RAPOR_OK0010 && hataGrupBazindaRapor.checked == false)
			reportName.value="raporOK0010G";		
		if (reportNum.value == RAPOR_OK0011 && hataGrupBazindaRapor.checked == true)
			reportName.value="raporOK0011";	
	    if (reportNum.value == RAPOR_OK0011 && hataGrupBazindaRapor.checked == false)
	        reportName.value="raporOK0011G";
    }
	return true;
}
//----------------------------------------
// raporGK0001 scrn usage
//----------------------------------------
function initRaporGK0001Scrn()
{
	setFocus(document.sirketReportForm.basTarih);
}

function checkRaporGK0001Scrn()
{
	with (document.sirketReportForm) {
		basTarih.value = basTarih.value.trim();
		if (basTarih.value.length == 0) return reportError(basTarih,raporGK0001Tarih);
		if (!checkDate(basTarih.value)) return reportError(basTarih,raporGK0001TarihGecersiz);
		
		bitTarih.value = bitTarih.value.trim();
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporGK0001Tarih);
		if (!checkDate(bitTarih.value)) return reportError(bitTarih,raporGK0001TarihGecersiz);

		var d1 = new Date(basTarih.value.substring(6,10),basTarih.value.substring(3,5),basTarih.value.substring(0,2),0,0,0,0)
		var d2 = new Date(bitTarih.value.substring(6,10),bitTarih.value.substring(3,5),bitTarih.value.substring(0,2),0,0,0,0)
		if (d1.getFullYear() != d2.getFullYear()) return reportError(basTarih,raporGK0001YilFarkli);			
		
		//if (basTarih.getYear()  != bitTarih.getYear()) return reportError(basTarih,raporGK0001YilFarkli);
	}
	return true;
}

//----------------------------------------
// raporGK0002 scrn usage
//----------------------------------------
function initRaporGK0002Scrn()
{
	var myDate = new Date();
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
		document.getElementById("sirket").style.display = "";
		document.getElementById("arac").style.display = "none";
		document.getElementById("plaka").style.display = "none";	
		sigortaSirketKodlari.selectedIndex = 0;
	}
}

function checkRaporGK0002Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value) > parseInt(bitAy.value)) return reportError(basAy,raporGK0002BasAyGecersiz);	
	}
	return true;
}
//----------------------------------------
// raporGK0003 scrn usage
//----------------------------------------
function initRaporGK0003Scrn()
{
	var myDate = new Date();
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
		document.getElementById("sirket").style.display = "";
		document.getElementById("arac").style.display = "";
		document.getElementById("plaka").style.display = "none";	
		sigortaSirketKodlari.selectedIndex = 0;
		aracGrupKodlari.selectedIndex = 0;
	}
}

function checkRaporGK0003Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value)>parseInt(bitAy.value)) return reportError(basAy,raporGK0003BasAyGecersiz);	
	}
	return true;
}
//----------------------------------------
// raporGK0004 scrn usage
//----------------------------------------
function initRaporGK0004Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
		document.getElementById("sirket").style.display = "none";
		document.getElementById("arac").style.display = "";
		document.getElementById("plaka").style.display = "none";	
		
		aracGrupKodlari.selectedIndex = 0;		
	}
}

function checkRaporGK0004Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value)>parseInt(bitAy.value)) return reportError(basAy,raporGK0004BasAyGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporGK0007 scrn usage
//----------------------------------------
function initRaporGK0007Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
		document.getElementById("sirket").style.display = "";
		document.getElementById("arac").style.display = "";
		document.getElementById("plaka").style.display = "";	
		sigortaSirketKodlari.selectedIndex = 0;
		aracGrupKodlari.selectedIndex = 0;	
		ilPlakaKodlari.selectedIndex = 0;
	}
}

function checkRaporGK0007Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value)>parseInt(bitAy.value)) return reportError(basAy,raporGK0007BasAyGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporGK0009 scrn usage
//----------------------------------------
function initRaporGK0009Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
	}
}

function checkRaporGK0009Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value) > parseInt(bitAy.value)) return reportError(basAy,raporGK0009BasAyGecersiz);	
	}
	return true;
}

function raporGK0009ReportTypeChange(form)
{
	if (form.reportType.selectedIndex == RAPOR_GK0009_ADETSEL && parseInt(form.siralamaType.value) == RAPOR_SIRALAMA_SIRKET_ADI)
		form.reportName.value="raporGK0009";
	if (form.reportType.selectedIndex == RAPOR_GK0009_ADETSEL && parseInt(form.siralamaType.value) == RAPOR_SIRALAMA_POLICE_ADET)
		form.reportName.value="raporGK0009S";
	if (form.reportType.selectedIndex == RAPOR_GK0009_PRIMSEL && parseInt(form.siralamaType.value) == RAPOR_SIRALAMA_SIRKET_ADI)
		form.reportName.value="raporGK0009P";
	if (form.reportType.selectedIndex == RAPOR_GK0009_PRIMSEL && parseInt(form.siralamaType.value) == RAPOR_SIRALAMA_POLICE_ADET)
		form.reportName.value="raporGK0009PS";
	return true;
}

//----------------------------------------
// raporGK0010 scrn usage
//----------------------------------------
function initRaporGK0010Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}

function checkRaporGK0010Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(basYilBitAy.value)) return reportError(basAy,raporGK0010BasYilBasAyGecersiz);	
		if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0010BitYilBasAyGecersiz);	
	}
	return true;
}

function raporGK0010ReportTypeChange(form)
{
	if (form.siralamaType.selectedIndex == RAPOR_SIRALAMA_ADET_SIRALI-3)
		form.reportName.value="raporGK0010a";
	if (form.siralamaType.selectedIndex == RAPOR_SIRALAMA_PRIM_SIRALI-3)
		form.reportName.value="raporGK0010b";
	return true;
}

//----------------------------------------
// raporGK0011 scrn usage
//----------------------------------------
function initRaporGK0011Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}

function checkRaporGK0011Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(basYilBitAy.value)) return reportError(basAy,raporGK0011BasYilBasAyGecersiz);	
		if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0011BitYilBasAyGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporGK0012 scrn usage
//----------------------------------------
function initRaporGK0012Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}

function checkRaporGK0012Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(basYilBitAy.value)) return reportError(basAy,raporGK0012BasYilBasAyGecersiz);	
		if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0012BitYilBasAyGecersiz);	
	}
	return true;
}

function raporGK0012ReportTypeChange(form)
{
	if (form.siralamaType.selectedIndex == RAPOR_SIRALAMA_ADET_SIRALI-3)
		form.reportName.value="raporGK0012a";
	if (form.siralamaType.selectedIndex == RAPOR_SIRALAMA_PRIM_SIRALI-3)
		form.reportName.value="raporGK0012b";
	return true;
}

//----------------------------------------
// raporGK0013 scrn usage
//----------------------------------------
function initRaporGK0013Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}

function checkRaporGK0013Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(basYilBitAy.value)) return reportError(basAy,raporGK0013BasYilBasAyGecersiz);	
		if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0013BitYilBasAyGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporGK0014 scrn usage
//----------------------------------------
function initRaporGK0014Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
    //  ?r?n ba?lang??  tarihinde de?i?klik olmakta o y?zden jsp combosunun ilk eleman? setleniyo     
		yil.selectedIndex = 0;
	//	yil.value=2003;
		setFocus(yil);
		bitYil.value = myDate.getFullYear();
	}
}

function checkRaporGK0014Scrn()
{
	with (document.sirketAyReportForm) {
		if (yil.value > bitYil.value) return reportError(yil,tarihlerGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporOK0008 scrn usage
//----------------------------------------


function checkRaporO0008()
{
	with(document.mukerrerPoliceForm){
	
		//sigorta ?irket se?imi zorunludur.
		if(sigortaSirketKod.selectedIndex == -1) return reportError(sigortaSirketKod, sigortaSirketKodBos);
		
		//ba?lama tarihi giri?i zorunludur
		if(basTarih.value.length == 0) return reportError(basTarih, raporO0008TarihBas);
		if(!checkDate(basTarih.value)) return reportError(basTarih, raporO0008TarihGecersizBas);
		if(  basTarih.value.substring(6,10) < 2005 ||  (basTarih.value.substring(6,10) == 2005  && basTarih.value.substring(3,5)< 8 )     )return reportError(basTarih, raporO0008TarihGecersizBas2);
		//biti? tarihi giri?i zorunludur
		if (bitTarih.value.length == 0) return reportError(bitTarih,raporO0008TarihBit);
		if (!checkDate(bitTarih.value) ) return reportError(bitTarih,raporO0008TarihGecersizBit);

		
		if(basTarih.value.length != 0 && checkDate(bitTarih.value)){
			var baslangicTarih = new Date(basTarih.value.substring(6,10),basTarih.value.substring(3,5)-1,basTarih.value.substring(0,2),0,0,0,0);			
			var bitisTarih     = new Date(bitTarih.value.substring(6,10),bitTarih.value.substring(3,5)-1,bitTarih.value.substring(0,2),0,0,0,0);	
			// ba?lang??tarihi biti? tarihinden b?y?k olamaz..
			if (compareDateObjects(baslangicTarih, bitisTarih )==1) return reportError(bitTarih,raporO0008TarihGecersizBit);	
			// 7 g?n aral?ktan b?y?k olamaz..
			if( dateDiff(baslangicTarih, bitisTarih) > 7) return reportError(basTarih, raporO0008TarihUzunBit);
		}
	}	
	return true;
}

//----------------------------------------
// raporGK0018 scrn usage
//----------------------------------------
function initRaporGK0018Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		//bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}
function checkRaporGK0018Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basYilBasAy,raporGK0018BasYilBasAyGecersiz);	
		//if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0012BitYilBasAyGecersiz);	
	}
	return true;
}
//----------------------------------------
// raporGK0019 scrn usage
//----------------------------------------
function initRaporGK0019Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		basYil.value=myDate.getFullYear();
		//bitYil.value=myDate.getFullYear();
		setFocus(basYil);
	}
}
function checkRaporGK0019Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basYilBasAy,raporGK0019BasYilBasAyGecersiz);	
		//if (parseInt(bitYilBasAy.value) > parseInt(bitYilBitAy.value)) return reportError(basAy,raporGK0012BitYilBasAyGecersiz);	
	}
	return true;
}
//----------------------------------------
// raporGK0016 scrn usage
//----------------------------------------
function initRaporGK0016Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.value=myDate.getFullYear();
		setFocus(yil);
		//document.getElementById("sirket").style.display = "none";
		//document.getElementById("arac").style.display = "";
		//document.getElementById("plaka").style.display = "none";
		//aracGrupKodlari.selectedIndex = 0;	
		ilPlakaKodlari.selectedIndex = 0;	
	}
}

function checkRaporGK0016Scrn()
{
	with (document.sirketAyReportForm) {
		if (parseInt(basAy.value)>parseInt(bitAy.value)) return reportError(basAy,raporGK0016BasAyGecersiz);	
	}
	return true;
}

//----------------------------------------
// raporGK0015 scrn usage
//----------------------------------------
function initRaporGK0015Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.value=2003;
		setFocus(yil);
		bitYil.value = myDate.getFullYear();
		ilPlakaKodlari.selectedIndex = 0;
	}
}
function checkRaporGK0015Scrn()
{
	with (document.sirketAyReportForm) {
		if (yil.value > bitYil.value) return reportError(yil,tarihlerGecersiz);	
		
		var i = 0;
		for(j = 0; j< ilPlakaKodlari.length; j++){
			if(ilPlakaKodlari[j].value >0)
				if(ilPlakaKodlari[j].selected == true) i++;
		}
		if(userType.value.substring(0,2) != "TK" && userType.value.substring(0,2) != "HK" && i > 5 )return reportError(ilPlakaKodlari,fazlaSayidaIlSecili);	
	}
	return true;
}
//----------------------------------------
// raporOK0012 scrn usage
//----------------------------------------
function initRaporOK0012Scrn()
{
	var myDate = new Date();	
	with (document.sirketSorguTakipForm)
	{
		sigortaSirketKodlari.selectedIndex = 1;
		urunKodlari.selectedIndex = 0;	
	}
}

function checkRaporOK0012Scrn()
{
	with (document.sirketSorguTakipForm) {
		if(basTarih.value.length == 0 ) return reportError(basTarih, raporOK0012BasTarih);
	
		var baslangicTarih = new Date(basTarih.value.substring(6,10),basTarih.value.substring(3,5)-1,basTarih.value.substring(0,2),0,0,0,0);			
		var bitisTarih     = new Date(bitTarih.value.substring(6,10),bitTarih.value.substring(3,5)-1,bitTarih.value.substring(0,2),0,0,0,0);	
		// ba?lang??tarihi biti? tarihinden b?y?k olamaz..
		if (bitTarih.value.length >0 && compareDateObjects(baslangicTarih, bitisTarih )==1) return reportError(basTarih,raporOK0012BasTarihBuyuk);	
		
		//Ba?lang?? tarihi 01.01.2006 tarihinden k???k olamaz.
		var enKucukTarih =  new Date(2006,0,1,0,0,0,0);	
		if (compareDateObjects(enKucukTarih, baslangicTarih)== 1) 
			return reportError(basTarih,raporOK0012BasTarihGecersiz);	
	}
	return true;
}
//----------------------------------------
// raporGK0020 scrn usage
//----------------------------------------
function initRaporGK0020Scrn()
{
	var myDate = new Date();	
	with (document.sirketAyReportForm)
	{
		yil.selectedIndex = 0;
		setFocus(yil);
		bitYil.value = myDate.getFullYear();
	}
}

function checkRaporGK0020Scrn()
{
	with (document.sirketAyReportForm) {
		if (yil.value > bitYil.value) return reportError(yil,tarihlerGecersiz);	
		if(checkRaporGK0020AracGrupKodlari())return true;
		else return reportError(aracGrupKodlari,raporGK0020FazlaSayidaIlSecildi);
	}
	return true;
}
function checkRaporGK0020AracGrupKodlari()
{
	with (document.sirketAyReportForm) {
		if(ilPlakaKodlari[1].selected == true){
			if(aracGrupKodlari[1].selected == true)return false;
			var i = 0;
			for(j = 0; j< aracGrupKodlari.length; j++){
				if(aracGrupKodlari[j].selected == true) i++;
			}
			if(i>1) return false;
		}
	}
	return true;
}
function initRaporGK0021Scrn()
{
	var myDate = new Date();	
	with (document.birikimliHPDagilimiForm)
	{
		basYil.selectedIndex = 0;
		setFocus(basYil);
		bitYil.value = myDate.getFullYear();
		ilPlakaKodlari.selectedIndex = 0;
		sigortaSirketKod.selectedIndex = 0;
		ilKoduSecimiDegisti();
		siralamaMantigi.selectedIndex = 0;					
	}
	return true;
}

function checkRaporGK0021Scrn()
{                 
	with (document.birikimliHPDagilimiForm) {
		if (basYil.value > bitYil.value) return reportError(basYil,tarihlerGecersiz);	
	}
	return true;
}

function ilKoduSecimiDegisti()
{
	with (document.birikimliHPDagilimiForm) 
	{	
		
		for (var i=0; i<=(ilPlakaKodlari.options.length-1); i++) {
			var o = ilPlakaKodlari.options[i];	
		   
			if (o.selected && o.value == "0") {
				document.getElementById("siralama").style.display = "" ;
				break;
			}
			else if (o.selected && o.value != "0"){
				document.getElementById("siralama").style.display = "none";
                 break;    			
			}
		}
	}
}

function initRaporGK0022Scrn()
{
	var myDate = new Date();	
	
	with (document.birikimliHPDagilimiForm)
	{
		basYil.selectedIndex = 0;
		setFocus(basYil);
		bitYil.value = myDate.getFullYear();
		sigortaSirketKod.selectedIndex = 0;
		aracGrupKodlari.selectedIndex = 0;
	}
	return true;
}

function checkRaporGK0022Scrn()
{
	with (document.birikimliHPDagilimiForm) {
		if (basYil.value > bitYil.value) return reportError(basYil,tarihlerGecersiz);	
	}
	return true;
}

function initRaporGK0024Scrn()
{
	var myDate = new Date();	
	with (document.sigortasizlikOraniForm)
	{
		yil.selectedIndex = 0;
		setFocus(yil);
		ilPlakaKodlari.selectedIndex = 0;
		ilKoduSecimiChangedFor24();
		aracSayisiAraligi.selectedIndex = 0;
		aracGrupKodu.selectedIndex = 0;
		siralamaTipi.selectedIndex = 0;					
	}
	return true;
}

function checkRaporGK0024Scrn()
{
	return true;
}

function ilKoduSecimiChanged()
{
	with (document.sigortasizlikOraniForm) 
	{	
		for (var i=0; i<=(ilPlakaKodlari.options.length-1); i++) {
			var o = ilPlakaKodlari.options[i];	
						
			if (o.selected && o.value == "-1") {
				document.getElementById("siralama").style.display = "none";
				break;
			}
			else if (o.selected &&  o.value != "-1"){
				document.getElementById("siralama").style.display = "";
			}
		}
	}
}

function ilKoduSecimiChangedFor24()
{
	with (document.sigortasizlikOraniForm) 
	{	
		for (var i=0; i<=(ilPlakaKodlari.options.length-1); i++) {
			var o = ilPlakaKodlari.options[i];	
						
			if (o.selected && o.value == "-1") {
				document.getElementById("siralama").style.display = "none";
				document.getElementById("sayiAralik").style.display = "none";
				break;
			}
			else if (o.selected &&  o.value != "-1"){
				document.getElementById("siralama").style.display = "";
				document.getElementById("sayiAralik").style.display = "";
			}
		}
	}
}

function initRaporGK0027Scrn()
{
	with (document.ortalamaPrimForm)
	{
		yil.selectedIndex = 0;
		setFocus(yil);
		ilPlakaKodlari.selectedIndex = 0;
		sigortaSirketKod.selectedIndex = 0;
		siralamaMantigi.selectedIndex = 0;					
	}
	return true;
}


function checkRaporGK0027Scrn()
{
	with (document.ortalamaPrimForm) {
		if (basAy.value > bitAy.value) return reportError(basAy, raporGK0019BasYilBasAyGecersiz);	
	    
	    var kod=sigortaSirketKod.value;  
	   
	    for (var i=0; i<=(ilPlakaKodlari.options.length-1); i++) {
		      var o = ilPlakaKodlari.options[i];	
   		   	 
   		   	  if (o.selected && o.value == "0" && kod=='-1') {
   			      return reportError(ilPlakaKodlari, raporGK0027SektorIllerDetaySecildi);	
			      break;
			  }
		}
	    
	}
	return true;
}

//----------------------------------------
// raporGK0028 scrn usage
//----------------------------------------
function initRaporGK0028Scrn()
{
	var myDate = new Date();	
	with (document.ortalamaPrimForm)
	{
		yil.selectedIndex = 0;
		setFocus(yil);
	}
}

//----------------------------------------
// raporGK0009 scrn usage
//----------------------------------------
function initRaporGK0032Scrn()
{
	tarihKriteriSecimiChangedFor32()
	var myDate = new Date();	
	with (document.ykPrimUretimRaporForm)
	{
		yil.value=myDate.getFullYear();
		if(document.getElementById('yilRow').style.display != 'none') setFocus(yil);
	}
}

function checkRaporGK0032Scrn()
{
	with (document.ykPrimUretimRaporForm) {
		if (tarihKriteri.value=="1") {
			if (basTarih.value == "") return reportError(basTarih,raporGK0032BasTarihBos)
			if (bitTarih.value == "") return reportError(bitTarih,raporGK0032BitTarihBos)
			if (compareDates_ddMMYYYY(basTarih.value,bitTarih.value)) return reportError(basTarih, raporGK0032BasTarBitTarBuyuk);	
		}
	}
	return true;
}

/*str1:Start, str2:End*/
function compareDates_ddMMYYYY(str1, str2) {
	var dt1   = parseInt(str1.substring(0,2),10);
	var mon1  = parseInt(str1.substring(3,5),10);
	var yr1   = parseInt(str1.substring(6,10),10);
	var dt2   = parseInt(str2.substring(0,2),10);
	var mon2  = parseInt(str2.substring(3,5),10);
	var yr2   = parseInt(str2.substring(6,10),10);
	var date1 = new Date(yr1, mon1-1, dt1);
	var date2 = new Date(yr2, mon2-1, dt2);
	if(date2 < date1) {
		return true;
	} else {
		return false;
	}
} 

function tarihKriteriSecimiChangedFor32()
{
	with (document.ykPrimUretimRaporForm) 
	{	
		for (var i=0; i < tarihKriteri.options.length ; i++) {
			var o = tarihKriteri.options[i];	
			if (o.selected && o.value == "1") {
				document.getElementById("yilRow").style.display = "none";
				document.getElementById("basAy").style.display = "none";
				document.getElementById("bitAy").style.display = "none";
				document.getElementById("basTar").style.display = "";
				document.getElementById("bitTar").style.display = "";
				break;
			}
			else if (o.selected &&  o.value == "2"){
				document.getElementById("yilRow").style.display = "";
				document.getElementById("basAy").style.display = "";
				document.getElementById("bitAy").style.display = "";
				document.getElementById("basTar").style.display = "none";
				document.getElementById("bitTar").style.display = "none";
			}
		}
	}
}

