// JavaScript Document
// JavaScript Document
/******************* AJAX *****************************/
var xmlHttp
/**********************************************************************/
function GetSubCat(CatId)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="Include/Itenary.php?catid="+CatId+"&sw=xcat"
	
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=subcat
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function subcat() 
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		var Response = xmlHttp.responseText
		
		var SubCats = Response
	
		if(SubCats == '0'){
			/*document.frm_flower.isSubCat.value = false*/
			NoElement(document.frm_flower.subcat)
			
		}
		else{
			CreateDropDown(document.frm_flower.subcat, SubCats)
			/*document.frm_flower.isSubCat.value = true*/
		}
		EndWait()
	}
	else
		StartWait()
}
/**** END **** Send Mail ****************************************/
/****************** Get Subcategories AND Products *************************/
/* Following Functions are used to get Products (Flowers) on a Category + Its Sub Category + Products (Flowres) of Subcategories */
/* GetAllProducts(CatId) This Function is Used to Get All Products (Flowrs) of Catgegory + SubCategory */

/************************************************/
// JavaScript Document
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
/**************************************************************************/
/************************ Create Drop Down *******************************/
function CreateDropDown(DropDown, Options)
{
	Opts = Options.split('|')						// Splits Texts and Values
	MakeEmptyDropDown(DropDown)						// Clears all Existing Options
	if(Opts.length > 1)								// If There is no any Option
	{
		var Option = CreatOption("Select Sub Category", document.frm_flower.cat.value, true)
		DropDown.options.add(Option)
		DropDown.disabled = false;
		for(var i=0; i < (Opts.length-1); i++)
		{
			SubCat = Opts[i].split("`");
			Option = CreatOption(SubCat[0], SubCat[1], false)
	 		DropDown.options.add(Option)
		}
	}
	else
	{
		NoElement(DropDown)
	}
}
/*** END **************** Create Drop Down *******************************/
function MakeEmptyDropDown(DropDown)
{
	var i
	for(i=DropDown.options.length-1;i>=0;i--)
	{
		DropDown.remove(i);
	}
}
function NoElement(DropDown)
{
	var Option = CreatOption("No Sub Category", "", true)
	DropDown.options.add(Option)
	DropDown.disabled = true;
}
function CreatOption(Text, Value, Flag)
{
	var option = document.createElement("option");	// First Element
	option.text = Text
	option.value = Value
	if(Flag) 
		option.selected = "selected"
	return option;
}
/****************************************************************************************/
function GoTo(URL)
{
	
	window.location.href = URL;
}
function ShowMe(ID)
{
	document.getElementById("BigImage").className = "Show";
}
function HideMe()
{
	document.getElementById("BigImage").className = "Hide";
}
/*** END *********** AJAX *****************************/
function StartWait()
{
/*	/*var Working = document.createElement("div");
	Working.innerHTML = "Please wait. Working on request ...";
	Working.className = 'working';
	Working.setAttribute('id', 'working')
	document.body.appendChild(Working);*/
	/*document.getElementById("working").className = 'working show';*/
	
}
function EndWait()
{
	/*document.getElementById("working").className = 'hide';*/
}