/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 
/*
function getCatO(){
//selVal=document.frm.city_name.options[document.frm.city_name.selectedIndex].value;

http.open('get', '1.php?cc=Others');


http.onreadystatechange = handleSC1; 
http.send(null);
}
*/


function catNameChange(val){
selVal=document.frm.cat1.options[document.frm.cat1.selectedIndex].value;
//selVal=document.frm.cat1.value;
//selVal=val.value;
//alert(selVal+"san");
http.open('get', 'subcatindex.php?id='+selVal);
http.onreadystatechange = handleGallery; 
http.send(null);
}

function handleGallery(){
	//alert(val);
	obj="cat2";
	load(obj);
	//alert(tob.name);
	//obj='subcat1';//object name
	if(http.readyState == 1){

		nosub(obj);//load(obj);
	}

	if(http.readyState == 4){ //Finished loading the response
	
		var response = http.responseText;
			if (response=="")
			{
				nosub(obj)
		
			}else{
			//	alert(response);
				pop(response,obj);
			}
	
	}
	
	
}


///////////////////////////////////////////////////////////////////////////////////////////

// No need to edit below this	

function pop(st1,obj)
{
		selNum=1;
		//alert(st1);
		var selbox = eval('document.frm.'+ obj);//eval('document.frm.s' + cnt);
		selbox.length=0;


	opt11 = "All"; // for assigning thedefault value


			var opt = new Option(opt11,""); // for assigning thedefault value
		selbox.options[0] = opt;
		optStr=st1.split("~");

                        for (i=0;i<optStr.length - 1; i++)
                        {
							optStrSplit=optStr[i].split(",");
                        var optText=optStrSplit[1]
                        var optVal=optStrSplit[0]
                        var opt = new Option(optText,optVal);
                        selbox.options[selNum] = opt;opt.selected;
                        selNum=selNum+1;						
                        }
selbox.disabled=0;
}



function load(obj)
{
		var selbox = eval('document.frm.'+ obj);
		selbox.length=0;
		var opt = new Option("No Value",""); // for assigning thedefault value
		selbox.options[0] = opt;		
		selbox.disabled=1;
}

function nosub(obj)
{
		var selbox = eval('document.frm.'+ obj);
		selbox.length=0;
		var opt = new Option("No Value",""); // for assigning thedefault value
		selbox.options[0] = opt;		
		selbox.disabled=1;
}