/************************************************************************************************************
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 getServiceBoxUpdate(sel,bid){
	var BusinessTypeCode=sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_service').innerHTML = null;	// Empty city select box
	if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(bid);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/getserviceboxesupdate2/'+BusinessTypeCode+'/'+bid;	// Specifying which file to get
		//alert(ajax[index].requestFile.);

		ajax[index].onCompletion = function(){ createServices(index) };	// Specify function that will be executed after file has been found
				
		ajax[index].runAJAX();		// Execute AJAX function
	}
	
	
}


function updatestats(businessID,operation){
	
//	alert(operation);
	var index = ajax.length;
	ajax[index] = new sack();
	ajax[index].requestFile = 'http://www.biocarepk.com/index.php/main/updateSearch/'+businessID+'/'+operation;	
	ajax[index].runAJAX();
}


function getServiceBoxes(sel)
{
	var BusinessTypeCode=sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_service').innerHTML = null;	// Empty city select box
	if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		
		ajax[index].requestFile = 'http://localhost/Kohana_v2.3.4/Kohana_v2.3.4/index.php/ajaxlist/getserviceboxes/'+BusinessTypeCode;	// Specifying which file to get
		//alert(ajax[index].requestFile);

		ajax[index].onCompletion = function(){ createServices(index) };	// Specify function that will be executed after file has been found
				
		ajax[index].runAJAX();		// Execute AJAX function
	}

}


function getserviceMulti(sel)
{
	var BusinessTypeCode=sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_service').innerHTML = null;	// Empty city select box
	if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(BusinessTypeCode);
		ajax[index].requestFile = 'http://localhost/Kohana_v2.3.4/Kohana_v2.3.4/index.php/ajaxlist/getserviceMultiList/'+BusinessTypeCode;	


		ajax[index].onCompletion = function(){ createServices(index) };	// Specify function that will be executed after file has been found
				
		ajax[index].runAJAX();		// Execute AJAX function
	}

}


function getBrandListMenu(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/getBrandsListMenu/'+BusinessTypeCode;	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createServices(index,BusinessTypeCode) };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}






function getBrandList(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML!='' ){
			document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='loading...';
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/getBrandsList/'+BusinessTypeCode;	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createServices(index,BusinessTypeCode) };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}

function editBrandList(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML!='' ){
			document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='loading...';
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/editBrandsList/'+BusinessTypeCode;	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createServices(index,BusinessTypeCode) };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}


function editptype(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML!='' ){
			document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='loading...';
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/editptype/'+BusinessTypeCode;	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createServices(index,BusinessTypeCode) };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}

function addptype(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML!='' ){
			document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('dhtmlgoodies_service['+BusinessTypeCode+']').innerHTML='loading...';
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/addptype';	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createServices(index,BusinessTypeCode) };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}

function addbrand()
{
	
	//var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('addbrand').innerHTML!='' ){
			document.getElementById('addbrand').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('addbrand').innerHTML='loading...';
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/addbrand';	// Specifying which file to get
		
		ajax[index].onCompletion = function(){ createreply(index,'addbrand') };	
		ajax[index].runAJAX();		// Execute AJAX function

}



function editBrand(sel)
{
	
	var BusinessTypeCode = sel;//sel.options[sel.selectedIndex].value;
	
	if(	document.getElementById('brand['+BusinessTypeCode+']').innerHTML!='' ){
			document.getElementById('brand['+BusinessTypeCode+']').innerHTML='';
			//alert('ddd');
			return;
	}
	
	document.getElementById('brand['+BusinessTypeCode+']').innerHTML='loading...';
	//document.getElementById('dhtmlgoodies_service').options.length = 0;	// Empty city select box
	//if(BusinessTypeCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
				//ajax[index].requestFile = "index.php/ajaxlist/getservicelist/"+BusinessTypeCode;	// Specifying which file to get		
		//alert(sel);
		ajax[index].requestFile = 'http://www.biocarepk.com/index.php/ajaxlist/editbrand/'+BusinessTypeCode;	// Specifying which file to get
		
		//alert(ajax[index].requestFile);
		//alert(sel);
		ajax[index].onCompletion = function(){ createreply(index,'brand['+BusinessTypeCode+']') };	// Specify function that will be executed after file has been found
				//alert(ajax[index].onCompletion);
		ajax[index].runAJAX();		// Execute AJAX function

	//}
}

function createreply(index,myobj)
{
	var obj = document.getElementById(myobj);
	//obj2=document.forms['form'].email.value;
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	
}



function createServices(index,ids)
{ 			  
	var obj = document.getElementById('dhtmlgoodies_service['+ids+']');
		document.getElementById('dhtmlgoodies_service['+ids+']').innerHTML='';
	 eval(ajax[index].response);	// Executing the response from Ajax as Javascript code		
}