/* Tab Menu JS */
// JavaScript Document

function tabSwitch(new_tab, new_content) {
	
	document.getElementById('content_1').style.display = 'none';
	document.getElementById('content_2').style.display = 'none';
	document.getElementById('content_3').style.display = 'none';		
	document.getElementById(new_content).style.display = 'block';	
	

	document.getElementById('tab_1').className = '';
	document.getElementById('tab_2').className = '';
	document.getElementById('tab_3').className = '';		
	document.getElementById(new_tab).className = 'active';		

}


// Ties a set of tabs and content id's together, and switches between them
// <div id='tab_1'> and <div id="content_1"> for example
// Usage: tabswitch(1, 4, 'tab', 'panel') would switch on tab_1 and panel_1

function tabSwitch_2(active, number, tab_prefix, content_prefix) {
	
	for (var i=1; i < number+1; i++) {
	  document.getElementById(content_prefix+i).style.display = 'none';
	  document.getElementById(tab_prefix+i).className = '';
	}
	document.getElementById(content_prefix+active).style.display = 'block';
	document.getElementById(tab_prefix+active).className = 'active';	
	
}
// il getir
//Ana grup listesinden secim yapildiginda , alt grup kutusunu doldurur.
function IlceGetir(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('nereden_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler_sube.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}

function createAnaGrup()
{
	var obj = document.getElementById('nereden_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function IlceGetir2(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('nereye_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup2;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}
function createAnaGrup2()
{
	var obj = document.getElementById('nereye_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function IlceGetir3(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('organizasyon_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup3;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}

function createAnaGrup3()
{
	var obj = document.getElementById('organizasyon_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}
function IlceGetir4(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('otel_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup4;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}

function createAnaGrup4()
{
	var obj = document.getElementById('otel_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function IlceGetir5(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('restorant_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup5;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}

function createAnaGrup5()
{
	var obj = document.getElementById('restorant_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}
function IlceGetir6(sel)
{

	var anagrup_id = sel.options[sel.selectedIndex].value;

	document.getElementById('arac_ilce').options.length = 0;	// Empty city select box
	
	if(anagrup_id.length>0)
	{
	ajax.requestFile = 'ilceler.php?id='+anagrup_id;	// Specifying which file to get
	ajax.onCompletion = createAnaGrup6;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function
	}
}

function createAnaGrup6()
{
	var obj = document.getElementById('arac_ilce');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

// otobus seferi ara form kontrol
function otobusfrmSubmit() {
	var frm = document.otobus;
	Error = "";
	validateNotEmpty(frm.nereden_il, 'Lutfen gideceginiz ili secin...!');
	if (Error=='')
	validateNotEmpty(frm.nereden_ilce, 'Lutfen gideceginiz ilceyi secin...!');
	if (Error=='')
	validateNotEmpty(frm.nereye_il, 'Lutfen gideceginiz ili secin...!');
	if (Error=='')
	validateNotEmpty(frm.nereye_ilce, 'Lutfen gideceginiz ilceyi secin...!');
	if (Error=='')
	validateNotEmpty(frm.gun, 'Lutfen gideceginiz tarihi duzgun giriniz...!');
	if (Error=='')
	validateNotEmpty(frm.ay, 'Lutfen gideceginiz tarihi duzgun giriniz...!');
	if (Error=='')
	validateNotEmpty(frm.yil, 'Lutfen gideceginiz tarihi duzgun giriniz...!');
	if (Error=='') {

		if(frm.nereden_ilce.value==frm.nereye_ilce.value) { Error = 'Ayni ilceden ayni ilceye gidemezsiniz'; }
	}
	
	if (Error=='')
		return true;
	else 
		alert(Error);
	return false;
}
function validateNotEmpty(str, msg) { var strTemp = str.value;  if(strTemp.length <= 0) { str.focus(); Error = msg;return;}}
function otobusFormSubmit() {if (otobusfrmSubmit() ) { document.otobus.submit(); } else {return false;}}
//function etkinlikFormSubmit() {if (otobusfrmSubmit() ) { document.otobus.submit(); } else {return false;}}