/************************************************************************************************************
Ajax chained select
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var ajax = new Array();

function getCityList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('tip').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities/countryCode/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function getCityList1(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('oras').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities1/countryCode/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities1(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getCityList12(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('oras2').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities1/countryCode/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities12(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getSubcat(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('subcat').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getSubcat/categorie/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSubcat(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getCityList2(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('oras').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities2/countryCode/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities2(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getCityList5(sel)
{
	
	var countryCode = sel.options[sel.selectedIndex].value;
	
	document.getElementById('localitate').options.length = 0;	// Empty city select box
	
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities5/countryCode/'+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities5(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}
function getCityList3(sel,val)
{
	
	var countryCode = sel;
	//document.getElementById('oras').options.length = 0;	// Empty city select box
	
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities3/countryCode/'+countryCode+'/localitate/'+val;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities3(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}

function getCityList7(sel,val)
{
	
	var countryCode = sel;
	//document.getElementById('oras').options.length = 0;	// Empty city select box
	
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getCities7/countryCode/'+countryCode+'/localitate/'+val;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities7(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}
function getSubcat1(sel,val)
{
	
	var countryCode = sel;
	//document.getElementById('oras').options.length = 0;	// Empty city select box
	
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/page/getSubcat1/categorie/'+countryCode+'/subcat/'+val;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSubcat1(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}

function createCities(index)
{
	var obj = document.getElementById('tip');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createCities1(index)
{
	var obj = document.getElementById('oras');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createCities12(index)
{
	var obj = document.getElementById('oras2');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createSubcat(index)
{
	var obj = document.getElementById('subcat');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createSubcat1(index)
{
	var obj = document.getElementById('subcat');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function createCities2(index)
{
	var obj = document.getElementById('oras');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createCities5(index)
{
	var obj = document.getElementById('localitate');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createCities3(index)
{
	var obj = document.getElementById('oras');
	
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function createCities7(index)
{
	var obj = document.getElementById('oras');
	
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


function getSubCategoryList(sel)
{
	var category = sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_subcategory').options.length = 0;	// Empty city select box
	if(category.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'getSubCategories.php?category='+category;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSubCategories(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createSubCategories(index)
{
	var obj = document.getElementById('dhtmlgoodies_subcategory');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}		

