function fillCountryStateCity (){
	this.mainDiv = "success_registration";
	this.countryId = 0;
	this.stateId = 0;
	this.cityId = 0;

	this.page = SITEROOT + "countrystatecity.php";
	
	/****************************************/
	// send request for get ctates from db
	this.fillState = function(cId){
		var obj = document.getElementById("state");
		var selectede='';
		obj.options.length = 0;
		obj[0] = new Option('- - Select State - - - ', 0, '', '');

		if(document.getElementById(this.mainDiv) != null){
			document.getElementById(this.mainDiv).appendChild = MyIndicator();
		}
		ajax.sendrequest( "GET", this.page, { type:'state', countryId:cId }, 'csc.callBackState', '' );
		//var obj = document.getElementById("state");
		//obj.disabled = true;
		if(this.stateId){
				csc.fillCity(this.stateId);
		}
	}
	
	/****************************************/
	// callback function for fill state	
	this.callBackState = function (data) {
		var obj = document.getElementById("state");
		//obj.disabled = false;
		var j=1;
		var selected = '';
		obj.options.length = 1;

		if(data.success > 0) {
			for(i=0; i < data.row.length; i++) {
				selected = (this.stateId ==  data.row[i].id) ? "selected" : '';
				obj[j] = new Option(data.row[i].state_name, data.row[i].id, selected,selected);
				j+=1;
			}
		}
		var obj = document.getElementById("city");
		obj.options.length = 0;
		obj[0] = new Option('- - Select City - - - ', 0, '','');	
	}
	
	
	this.fillCity = function (sId){
		ajax.sendrequest( "GET", this.page, { type:'city', stateId:sId }, 'csc.callBackCity', '' );
	}
	
		/***************************************************************************/
	
	this.callBackCity = function (data) {
		var obj = document.getElementById("city");
		var j=1;
		var selectedd = "";
		
		if(data.success > 0) {
			for(i=0; i < data.row.length; i++) {
				selectedd = (this.cityId ==  data.row[i].id ? "selected" : "");
				obj[j] = new Option(data.row[i].name, data.row[i].id, selectedd, selectedd);
				j+=1;
			}
		}else{
		 	obj.options.length = 0;
			obj[0] = new Option('No City Found', 0, selectedd, selectedd);	
		}
	}
	
	
	this.autoFillfillSize = function(cid,ctype){
		this.category_id = cid;
		var t = setTimeout("csc.fillLocationSize('" + ctype + "');",1000);
	}
	
	this.autoFill = function(cId,sId,cityId) {
		this.countryId = cId;
		this.stateId = sId;
		this.cityId = cityId;
		
		if(cId > 0) {
			var t = setTimeout("csc.fillState(" + cId + ");",1000);
		}
		if(sId > 0) {
			var t = setTimeout("csc.fillCity(" + sId + ");",1500);
		}
	}

} // fillCountryStateCity

var csc = new fillCountryStateCity();