// JavaScript Document
var tdId;
var mod_opt;
var GintId;
function expand(opt,slot)
{
//alert(opt);

   alert("test");
   alert(opt)
    alert(slot)
	
    if(opt=='3')
	{
		alert("fg");
		var strUrl = "packages_p.php?slot="+slot;
		alert("fg");
	}
	
	

	xmlhttpPost(strUrl);
}
function expand(intId, option, module_opt, current_cat)
{
	if(intId==0)
		{
			alert("Select a curriculum from list");
			return false;
		}
	mod_opt = module_opt;
	GintId = intId;
	//alert("test");
	if(module_opt==0)
	{
		tdId = "cat" + intId;
		var strUrl = "getsub.php?category_id="+intId+"&option="+option;
		xmlhttpPost(strUrl);
	}
	if((module_opt==1)|(module_opt==2))
	{
		var strUrl = "state_list.php?cur_id="+intId+"&option="+module_opt;
		xmlhttpPost(strUrl);
	}
	if(module_opt==3)
	{
		if(intId==0)
		{
			alert("Select a category from list");
			return false;
		}
		tdId = "div" + option;
		var strUrl = "getsub_p.php?cat="+intId+"&pos="+option+"&option="+module_opt+"&current_cat="+current_cat;
		alert(strUrl);
		xmlhttpPost(strUrl);
	}
	if(module_opt==4)
	{
		if(intId==0)
		{
			alert("Select a category from list");
			return false;
		}
		document.getElementById('category_id').value=intId;
		tdId = "div" + option;
		var strUrl = "getsub_c.php?cat="+intId+"&pos="+option+"&option="+module_opt;
		xmlhttpPost(strUrl);
	}
	if(module_opt==9)
	{
		var strUrl = "getsub_catname.php?cat="+intId+"&pos="+option+"&option="+module_opt;
		xmlhttpPost(strUrl);
	}
	
	if(module_opt==5)
	{
		tdId = "div0";
		var strUrl = "getsub_img.php?cat="+intId+"&pos=1";
		xmlhttpPost(strUrl);
	}
	if(module_opt==6)
	{
		tdId="but"+intId;
		var strUrl = "getsub_img.php?cat="+intId+"&pos=0";
		xmlhttpPost(strUrl);
	}
	if(module_opt==7)
	{
		tdId = "price_div0";
		var strUrl = "getsub_price.php?cat="+intId+"&pos=1";
		xmlhttpPost(strUrl);
	}
	if(module_opt==8)
	{
		tdId="price_but"+intId;
		var strUrl = "getsub_price.php?cat="+intId+"&pos=0";
		xmlhttpPost(strUrl);
	}
	if(module_opt==10)
	{
		tdId="div1";
		var strUrl = "init_category.php";
		xmlhttpPost(strUrl);
	}
	if(module_opt==11)
	{
		tdId="prname";
		var strUrl = "product_chk.php?product_name="+intId+"&pos=0";
		xmlhttpPost(strUrl);
	}
}
function expand1(intId,classId,subid,pacid,option, module1_opt)
{
	//alert("boon");
	//mod1_opt = module1_opt;
	
	//alert(intId);
	//alert(classId);
	
	if((module1_opt==1)|(module1_opt==2))
	{
		var strUrl = "packages_p.php?cur1_id="+intId+"&class_id="+classId+"&subid="+subid+"&pacid="+pacid+"&pos="+option+"&option="+module1_opt;
		xmlhttpPost(strUrl);
		
	}
	
}
function xmlhttpPost(strURL) 
{
	var xmlHttpReq = false;
	var self = this;
// Mozilla/Safari
    if (window.XMLHttpRequest) 
        self.xmlHttpReq = new XMLHttpRequest();
// IE
    else if (window.ActiveXObject) 
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

	strURL = strURL;
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.onreadystatechange = function() 
	{
	    if (self.xmlHttpReq.readyState == 4) 
            updatepage(self.xmlHttpReq.responseText);
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() 
{
   	var qstr="";
    return qstr;
}

function updatepage(str)
{
//	document.getElementById(tdId).innerHTML += str;
	if((mod_opt==0)|(mod_opt==3)|(mod_opt==4)|(mod_opt==6)|(mod_opt==8)|(mod_opt==10))
//Category List & Category Select
	{
		document.getElementById(tdId).innerHTML = str;
		if(mod_opt==4)
		{
			expand(GintId, 0, 9);	
		}
	}
	if(mod_opt==1)
	{
//Country Flag		
		document.getElementById("flag").innerHTML = str;
		expand(GintId, 0, 2);
	}
	if(mod_opt==2)
//State List
		document.getElementById("statelist").innerHTML = str;
	if(mod_opt==5)
	{
//Button Change		
		
		document.getElementById('div0').innerHTML += str;
//alert(GintId);
expand(GintId, 0, 6);
	}
	if(mod_opt==7)
	{
//Button Change		
		document.getElementById('price_div0').innerHTML += str;
		expand(GintId, 0, 8);
	}
	if(mod1_opt==1)
//Insert Category Name

		document.getElementById("test").innerHTML = str;
}
