function expandFirst() {
			document.getElementById(expandFirst.arguments[0]).style.display = "block";
			for (var i=1; i<expandFirst.arguments.length; i++) {
				document.getElementById(expandFirst.arguments[i]).style.display = "none";
			}
		}
function expandCollapse() {
	var str_control_name;
	for (var i=0; i<expandCollapse.arguments.length; i++) {
		var element = document.getElementById(expandCollapse.arguments[i]);
		str_control_name = element.id;
		element.style.display = (element.style.display == "none") ? "block" : "none";
	}
	//alert(str_control_name);
	//Advertisement Categories
	if (str_control_name == "id1"){ 
		 /*
		 	Getting the categories list through AJAX
		 */
	 	//getDetails('available',0,'parent');
	     
	}
	
}





function maketree(param1,param2,param3){
	var element1 = document.getElementById(param1);
	var element2 = document.getElementById(param2);
	element1.style.display = "block";
	element2.style.display = "none";
	getDetails('available',param3,'child');
}

function getDetails(categorytype,categoryid,hierarchy){
//alert(custid);
	  
// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
		if (hierarchy == 'child')
			xmlhttp.onreadystatechange=state_Change_child;
		else
			xmlhttp.onreadystatechange=state_Change_parent;
		xmlhttp.open("GET",'getcategorydetails.php?type=' + categorytype+'&id='+categoryid,true);
		xmlhttp.send(null);

	}
// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttp){
			if (hierarchy == 'child')
				xmlhttp.onreadystatechange=state_Change_child;
			else
				xmlhttp.onreadystatechange=state_Change_parent;
			xmlhttp.open("GET",'getcategorydetails.php?type=' + categorytype+'&id='+categoryid,true);
			xmlhttp.send();
		}
	}
}
function state_Change_parent(){
	var listVal = document.getElementById('advertisement_list');
	listVal.innerHTML = ''; 
	if (xmlhttp.readyState==4){
		// if "OK"
		if (xmlhttp.status==200){
			result = xmlhttp.responseText;
			//alert(result);
			result_arr = result.split(":");
			ids = result_arr[0];
			category_name = result_arr[1];
			category_id = result_arr[2];
			category_count = result_arr[3];
			
			ids = ids.split("|");
			category_name = category_name.split("|");
			category_id = category_id.split("|");
			category_count = category_count.split("|");
			for(var i=0; i<category_id.length; i++) {
				listVal.innerHTML += "<li><a href=browse.php?tree=yes&category_type=available&categoryid="+ids[i]+"><img src=images/default.gif border=0 /></a><a href=browse.php?submenu=yes&category_type=available&category_id="+ids[i]+">"+category_name[i]+" ("+category_count[i]+")</a></li>";
			}
		}
	}	
}

function state_Change_child(){
	var listVal = document.getElementById('advertisement_list');
	listVal.innerHTML = ''; 
	if (xmlhttp.readyState==4){
		// if "OK"
		if (xmlhttp.status==200){
			result = xmlhttp.responseText;
			alert(result);
			result_arr = result.split(":");
			ids = result_arr[0];
			category_name = result_arr[1];
			category_id = result_arr[2];
			category_count = result_arr[3];
			
			ids = ids.split("|");
			category_name = category_name.split("|");
			category_id = category_id.split("|");
			category_count = category_count.split("|");
			listVal.innerHTML += "<ul>";
			for(var i=0; i<category_id.length; i++) {
				listVal.innerHTML += "<li><a href=browse.php?tree=yes&category_type=available&categoryid="+ids[i]+"><img src=images/default.gif border=0 /></a><a href=browse.php?submenu=yes&category_type=available&category_id="+ids[i]+">"+category_name[i]+" ("+category_count[i]+")</a></li>";
			}
			listVal.innerHTML += "</ul>";
		}
	}	
}
