

function getXmlHttpRequestObject(){
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} 
	else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
	else {
		alert("Your browser does not support AJAX!");
	}
}

var searchReq = getXmlHttpRequestObject();
var searchReq2 = getXmlHttpRequestObject();


// returns  series for STEP2 MENU
function getSeries(functionName,series_name,shown_in_section) {
	
	//alert(functionName);
	searchReq.abort();
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=series&series='+series_name+'&shown_in_section='+shown_in_section+'&level='+dealerLevel, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
			//flash.populateManu(searchReq.responseText.split('|'));
			if(searchReq.responseText != "")
				eval("flash."+functionName+"(searchReq.responseText.split('|'))");
			
			}
		};
		searchReq.send(null);
		
	}
	
	
}


// returns  groups for STEP2 MENU
function getGroup(functionName,series_name,parent_group,shown_in_section) {
	//alert("group");
	//alert(parent_group);
	//alert(functionName);
	searchReq.abort();
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=group&series='+series_name+'&shown_in_section='+shown_in_section+'&parent_group='+parent_group+'&level='+dealerLevel, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
			//flash.populateManu(searchReq.responseText.split('|'));
			if(searchReq.responseText != "")
				eval("flash."+functionName+"(searchReq.responseText.split('|'))");
			
			}
		};
		searchReq.send(null);
		
	}
	
	
}


// returns  parent_groups for STEP2 MENU
function getParentGroup(functionName,series_name,shown_in_section) {
	searchReq.abort();
	//alert(functionName);
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=parentGroup&series='+series_name+'&shown_in_section='+shown_in_section+'&level='+dealerLevel, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
			//flash.populateManu(searchReq.responseText.split('|'));
			if(searchReq.responseText != "")
				eval("flash."+functionName+"(searchReq.responseText.split('|'))");
			
			}
		};
		searchReq.send(null);
		
	}
	
	
}

// returns  series/parent_group for STEP2 MENU
function getSeriesPgroup(functionName,group,series_name,shown_in_section) {
	
	searchReq.abort();
	//alert(functionName);
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=seriesPgroup&group='+group+'&series='+series_name+'&shown_in_section='+shown_in_section+'&level='+dealerLevel, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
			//flash.populateManu(searchReq.responseText.split('|'));
			if(searchReq.responseText != "")
				eval("flash."+functionName+"(searchReq.responseText.split('|'))");
			
			}
		};
		searchReq.send(null);
		
	}
	
	
}


// one way to retrieve data 
// working !!

// returns the list of all products/typicals to populate PARTS TRAY in STEP2
//////////////////////////////////////////////////////////////
function getProduct(functionName,series_name,parent_group,group,shown_in_section) {
	//alert(functionName+ " " +series_name+ " " +parent_group+ " " +group+ " " +shown_in_section);
	searchReq.abort();
	//alert(functionName);
	//alert(group);
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=product&parent_group='+parent_group+'&series='+series_name+'&group='+group+'&shown_in_section='+shown_in_section+'&level='+dealerLevel, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
				if(searchReq.responseText != ""){
				//if(searchReq.responseXML != ""){
					text = searchReq.responseText;
				
					try //Internet Explorer
					{
						//alert('ie');
						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
						//xmlDoc=new ActiveXObject("Msxml2.DOMDocument.3.0");
						xmlDoc.async="false";
						xmlDoc.loadXML(text);
					}
					catch(e)
					{
						try //Firefox, Mozilla, Opera, etc.
						{
							//alert('firefox');
							parser=new DOMParser();
							xmlDoc=parser.parseFromString(text,"text/xml");
						}
						catch(e)
						{
							alert(e.message);
							return;
						}
					}
					
					//var xmlDoc=searchReq.responseXML.documentElement;
					//// parsing xml
					///////////////////////
					var productArray = new Array();
					var typicalArray = new Array();
					
					
					
					products = xmlDoc.getElementsByTagName("product");
					typicals = xmlDoc.getElementsByTagName("typical");
					//alert(products.length);
					//alert(typicals.length);
					for(i=0 ; i<products.length; i++){
						//alert(products[i].getElementsByTagName("sku")[0].childNodes[0].nodeValue); 
						if(products[i].getElementsByTagName("name")[0].hasChildNodes())
							product_name = products[i].getElementsByTagName("name")[0].childNodes[0].nodeValue; 
						else 
							product_name = "";
							
						if(products[i].getElementsByTagName("group")[0].hasChildNodes())
							product_group = products[i].getElementsByTagName("group")[0].childNodes[0].nodeValue; 
						else 
							product_group = "";
							
						if(products[i].getElementsByTagName("prod_type")[0].hasChildNodes())
							product_prod_type = products[i].getElementsByTagName("prod_type")[0].childNodes[0].nodeValue; 
						else 
							product_prod_type = "";
							
						if(products[i].getElementsByTagName("shown_in_section")[0].hasChildNodes())
							product_shown_in_section = products[i].getElementsByTagName("shown_in_section")[0].childNodes[0].nodeValue; 
						else 
							product_shown_in_section = "";
							
						if(products[i].getElementsByTagName("series_name")[0].hasChildNodes())
							product_series_name = products[i].getElementsByTagName("series_name")[0].childNodes[0].nodeValue; 
						else 
							product_series_name = "";
							
						if(products[i].getElementsByTagName("parent_group")[0].hasChildNodes())
							product_parent_group = products[i].getElementsByTagName("parent_group")[0].childNodes[0].nodeValue; 
						else 
							product_parent_group = "";
						
						if(products[i].getElementsByTagName("sku")[0].hasChildNodes())
							product_sku = products[i].getElementsByTagName("sku")[0].childNodes[0].nodeValue; 
						else 
							product_sku = "";
						
						if(products[i].getElementsByTagName("component_2d")[0].hasChildNodes())
							product_component_2d = products[i].getElementsByTagName("component_2d")[0].childNodes[0].nodeValue; 
						else 
							product_component_2d = "";
						
						if(products[i].getElementsByTagName("component_3d")[0].hasChildNodes())
							product_component_3d = products[i].getElementsByTagName("component_3d")[0].childNodes[0].nodeValue; 
						else 
							product_component_3d = "";
						
						if(products[i].getElementsByTagName("threedExists")[0].hasChildNodes())
							product_threedExists = products[i].getElementsByTagName("threedExists")[0].childNodes[0].nodeValue; 
						else 
							product_threedExists = "";
						
						if(products[i].getElementsByTagName("ass_color_skus")[0].hasChildNodes())
							product_ass_color_skus = products[i].getElementsByTagName("ass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							product_ass_color_skus = "";
						
						if(products[i].getElementsByTagName("unass_color_skus")[0].hasChildNodes())
							product_unass_color_skus = products[i].getElementsByTagName("unass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							product_unass_color_skus = "";
						
						if(products[i].getElementsByTagName("ass_price")[0].hasChildNodes())
							product_ass_price = products[i].getElementsByTagName("ass_price")[0].childNodes[0].nodeValue; 
						else 
							product_ass_price = "";
						
						if(products[i].getElementsByTagName("unass_price")[0].hasChildNodes())
							product_unass_price = products[i].getElementsByTagName("unass_price")[0].childNodes[0].nodeValue; 
						else 
							product_unass_price = "";
						
						if(products[i].getElementsByTagName("price_3")[0].hasChildNodes())
							product_price_3 = products[i].getElementsByTagName("price_3")[0].childNodes[0].nodeValue; 
						else 
							product_price_3 = "";
						
						if(products[i].getElementsByTagName("width")[0].hasChildNodes())
							product_width = products[i].getElementsByTagName("width")[0].childNodes[0].nodeValue; 
						else 
							product_width = "";
						
						if(products[i].getElementsByTagName("height")[0].hasChildNodes())
							product_height = products[i].getElementsByTagName("height")[0].childNodes[0].nodeValue; 
						else 
							product_height = "";
						
						if(products[i].getElementsByTagName("depth")[0].hasChildNodes())
							product_depth = products[i].getElementsByTagName("depth")[0].childNodes[0].nodeValue; 
						else 
							product_depth = "";
							
						if(products[i].getElementsByTagName("description")[0].hasChildNodes())
							product_description = products[i].getElementsByTagName("description")[0].childNodes[0].nodeValue; 
						else 
							product_description = "";
							
						if(products[i].getElementsByTagName("info_details")[0].hasChildNodes())
							product_info_details = products[i].getElementsByTagName("info_details")[0].childNodes[0].nodeValue; 
						else 
							product_info_details = "";
						
						if(products[i].getElementsByTagName("acc_below")[0].hasChildNodes())
							product_acc_below = products[i].getElementsByTagName("acc_below")[0].childNodes[0].nodeValue; 
						else 
							product_acc_below = "";
						
						if(products[i].getElementsByTagName("acc_above")[0].hasChildNodes())
							product_acc_above = products[i].getElementsByTagName("acc_above")[0].childNodes[0].nodeValue; 
						else 
							product_acc_above = "";
							
						if(products[i].getElementsByTagName("colors")[0].hasChildNodes())
							product_colors = products[i].getElementsByTagName("colors")[0].childNodes[0].nodeValue; 
						else 
							product_colors = "";
						
						var addedObjectsArray = new Array();
						addedOjects = products[i].getElementsByTagName("addedObj");
						
						//alert(addedOjects.length);
						for(a=0 ; a<addedOjects.length; a++){
							addedObjectsArray.push({sku:addedOjects[a].getAttribute('sku'), ass_price: addedOjects[a].getAttribute('ass_price'), 
							unass_price: addedOjects[a].getAttribute('unass_price'), name: addedOjects[a].getAttribute('name')});
						}
							
						
						
						// pushing object into an Array
						productArray.push({name : product_name, parent_group : product_parent_group, group : product_group, sku : product_sku, colors : product_colors,
						ass_color_skus : product_ass_color_skus, unass_color_skus : product_unass_color_skus, width : product_width, depth : product_depth,
						height : product_height, series_name : product_series_name, ass_price : product_ass_price, unass_price : product_unass_price, price_3 : product_price_3,
						component_2d : product_component_2d, component_3d : product_component_3d, prod_type : product_prod_type, shown_in_section : product_shown_in_section,
						description : product_description, info_details : product_info_details, acc_below : product_acc_below, acc_above : product_acc_above,
						threedExists : product_threedExists, addedObjectsArray: addedObjectsArray});
						
						//alert(productArray[i].threedExists);
					}
					
					for(i=0 ; i<typicals.length; i++){
					
						if(typicals[i].getElementsByTagName("id")[0].hasChildNodes())
							typical_id = typicals[i].getElementsByTagName("id")[0].childNodes[0].nodeValue; 
						else 
							typical_id = "";
							
						if(typicals[i].getElementsByTagName("name")[0].hasChildNodes())
							typical_name = typicals[i].getElementsByTagName("name")[0].childNodes[0].nodeValue; 
						else 
							typical_name = "";
							
						if(typicals[i].getElementsByTagName("series_name")[0].hasChildNodes())
							typical_series_name = typicals[i].getElementsByTagName("series_name")[0].childNodes[0].nodeValue; 
						else 
							typical_series_name = "";
							
						if(typicals[i].getElementsByTagName("parent_group")[0].hasChildNodes())
							typical_parent_group = typicals[i].getElementsByTagName("parent_group")[0].childNodes[0].nodeValue; 
						else 
							typical_parent_group = "";
							
						if(typicals[i].getElementsByTagName("ggroup")[0].hasChildNodes())
							typical_ggroup = typicals[i].getElementsByTagName("ggroup")[0].childNodes[0].nodeValue; 
						else 
							typical_ggroup = "";
							
						if(typicals[i].getElementsByTagName("lockFlag")[0].hasChildNodes())
							typical_lockFlag = typicals[i].getElementsByTagName("lockFlag")[0].childNodes[0].nodeValue; 
						else 
							typical_lockFlag = "";
							
						if(typicals[i].getElementsByTagName("typImage")[0].hasChildNodes())
							typical_typImage = typicals[i].getElementsByTagName("typImage")[0].childNodes[0].nodeValue; 
						else 
							typical_typImage = "";
						
						//updated 070909
						// typical has its own depth, height, and width
						/////////////////////////////////////////////////////////////////
						if(typicals[i].getElementsByTagName("typWidth")[0].hasChildNodes())
							typical_typWidth = typicals[i].getElementsByTagName("typWidth")[0].childNodes[0].nodeValue; 
						else 
							typical_typWidth = "";
						
						if(typicals[i].getElementsByTagName("typHeight")[0].hasChildNodes())
							typical_typHeight = typicals[i].getElementsByTagName("typHeight")[0].childNodes[0].nodeValue; 
						else 
							typical_typHeight = "";
						
						if(typicals[i].getElementsByTagName("typDepth")[0].hasChildNodes())
							typical_typDepth = typicals[i].getElementsByTagName("typDepth")[0].childNodes[0].nodeValue; 
						else 
							typical_typDepth = "";
						/////////////////////////////////////////////////////////////////
						
						//data from product table 
						///////////////////
						if(typicals[i].getElementsByTagName("prodName")[0].hasChildNodes())
							typical_prodName = typicals[i].getElementsByTagName("prodName")[0].childNodes[0].nodeValue; 
						else 
							typical_prodName = "";
							
						if(typicals[i].getElementsByTagName("prod_type")[0].hasChildNodes())
							typical_prod_type = typicals[i].getElementsByTagName("prod_type")[0].childNodes[0].nodeValue; 
						else 
							typical_prod_type = "";
							
						if(typicals[i].getElementsByTagName("shown_in_section")[0].hasChildNodes())
							typical_shown_in_section = typicals[i].getElementsByTagName("shown_in_section")[0].childNodes[0].nodeValue; 
						else 
							typical_shown_in_section = "";
						
						if(typicals[i].getElementsByTagName("sku")[0].hasChildNodes())
							typical_sku = typicals[i].getElementsByTagName("sku")[0].childNodes[0].nodeValue; 
						else 
							typical_sku = "";
						
						if(typicals[i].getElementsByTagName("component_2d")[0].hasChildNodes())
							typical_component_2d = typicals[i].getElementsByTagName("component_2d")[0].childNodes[0].nodeValue; 
						else 
							typical_component_2d = "";
						
						if(typicals[i].getElementsByTagName("component_3d")[0].hasChildNodes())
							typical_component_3d = typicals[i].getElementsByTagName("component_3d")[0].childNodes[0].nodeValue; 
						else 
							typical_component_3d = "";
						
						if(typicals[i].getElementsByTagName("threedExists")[0].hasChildNodes())
							typical_threedExists = typicals[i].getElementsByTagName("threedExists")[0].childNodes[0].nodeValue; 
						else 
							typical_threedExists = "";
						
						if(typicals[i].getElementsByTagName("ass_color_skus")[0].hasChildNodes())
							typical_ass_color_skus = typicals[i].getElementsByTagName("ass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							typical_ass_color_skus = "";
						
						if(typicals[i].getElementsByTagName("unass_color_skus")[0].hasChildNodes())
							typical_unass_color_skus = typicals[i].getElementsByTagName("unass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							typical_unass_color_skus = "";
						
						if(typicals[i].getElementsByTagName("ass_price")[0].hasChildNodes())
							typical_ass_price = typicals[i].getElementsByTagName("ass_price")[0].childNodes[0].nodeValue; 
						else 
							typical_ass_price = "";
						
						if(typicals[i].getElementsByTagName("unass_price")[0].hasChildNodes())
							typical_unass_price = typicals[i].getElementsByTagName("unass_price")[0].childNodes[0].nodeValue; 
						else 
							typical_unass_price = "";
						
						if(typicals[i].getElementsByTagName("price_3")[0].hasChildNodes())
							typical_price_3 = typicals[i].getElementsByTagName("price_3")[0].childNodes[0].nodeValue; 
						else 
							typical_price_3 = "";
						
						if(typicals[i].getElementsByTagName("width")[0].hasChildNodes())
							typical_width = typicals[i].getElementsByTagName("width")[0].childNodes[0].nodeValue; 
						else 
							typical_width = "";
						
						if(typicals[i].getElementsByTagName("height")[0].hasChildNodes())
							typical_height = typicals[i].getElementsByTagName("height")[0].childNodes[0].nodeValue; 
						else 
							typical_height = "";
						
						if(typicals[i].getElementsByTagName("depth")[0].hasChildNodes())
							typical_depth = typicals[i].getElementsByTagName("depth")[0].childNodes[0].nodeValue; 
						else 
							typical_depth = "";
							
						if(typicals[i].getElementsByTagName("description")[0].hasChildNodes())
							typical_description = typicals[i].getElementsByTagName("description")[0].childNodes[0].nodeValue; 
						else 
							typical_description = "";
							
						if(typicals[i].getElementsByTagName("info_details")[0].hasChildNodes())
							typical_info_details = typicals[i].getElementsByTagName("info_details")[0].childNodes[0].nodeValue; 
						else 
							typical_info_details = "";
						
						if(typicals[i].getElementsByTagName("acc_below")[0].hasChildNodes())
							typical_acc_below = typicals[i].getElementsByTagName("acc_below")[0].childNodes[0].nodeValue; 
						else 
							typical_acc_below = "";
						
						if(typicals[i].getElementsByTagName("acc_above")[0].hasChildNodes())
							typical_acc_above = typicals[i].getElementsByTagName("acc_above")[0].childNodes[0].nodeValue; 
						else 
							typical_acc_above = "";
							
						if(typicals[i].getElementsByTagName("colors")[0].hasChildNodes())
							typical_colors = typicals[i].getElementsByTagName("colors")[0].childNodes[0].nodeValue; 
						else 
							typical_colors = "";
						///////////////////
						
						var objectsArr = new Array();
						
						for(f=0; f<typicals[i].getElementsByTagName("object_grouping")[0].getElementsByTagName("object").length; f++){
						
							object = typicals[i].getElementsByTagName("object_grouping")[0].getElementsByTagName("object")[f]; 
							object_sku = object.getAttribute('sku');
							object_objDepth = object.getAttribute('objectDepth');
							object_rotation = object.getAttribute('rotation');
							object_y = object.getAttribute('y');
							object_x = object.getAttribute('x');
							
							//data from product table 
							///////////////////
							object_name = object.getAttribute('name');
							object_group = object.getAttribute('group');
							object_prod_type = object.getAttribute('prod_type');
							object_shown_in_section = object.getAttribute('shown_in_section');
							object_series_name = object.getAttribute('series_name');
							object_parent_group = object.getAttribute('parent_group');
							object_component_2d = object.getAttribute('component_2d');
							object_component_3d = object.getAttribute('component_3d');
							object_threedExists = object.getAttribute('threedExists');
							object_ass_color_skus = object.getAttribute('ass_color_skus');
							object_unass_color_skus = object.getAttribute('unass_color_skus');
							object_height = object.getAttribute('height');
							object_depth = object.getAttribute('depth');
							object_width = object.getAttribute('width');
							object_ass_price = object.getAttribute('ass_price');
							object_unass_price = object.getAttribute('unass_price');
							object_price_3 = object.getAttribute('price_3');
							object_description = object.getAttribute('description');
							object_info_details = object.getAttribute('info_details');
							object_acc_below = object.getAttribute('acc_below');
							object_acc_above = object.getAttribute('acc_above');
							object_colors = object.getAttribute('colors');
							///////////////////
							
							var aboveArr = new Array();
							var belowArr = new Array();
							
							if(object.hasChildNodes()){
								
								for(g=0; g<object.getElementsByTagName("config_obj").length; g++){
									configObj = object.getElementsByTagName("config_obj")[g];
									if (configObj.getAttribute('sku') == "undefined") {
										continue;
									}
									configObj_sku = configObj.getAttribute('sku');
									configObj_yposft = configObj.getAttribute('yposft');
									configObj_xposft = configObj.getAttribute('xposft');
									configObj_y = configObj.getAttribute('y');
									configObj_x = configObj.getAttribute('x');
									
									//data from product table 
									///////////////////
									configObj_name = configObj.getAttribute('name');
									configObj_group = configObj.getAttribute('group');
									configObj_prod_type = configObj.getAttribute('prod_type');
									configObj_shown_in_section = configObj.getAttribute('shown_in_section');
									configObj_series_name = configObj.getAttribute('series_name');
									configObj_parent_group = configObj.getAttribute('parent_group');
									configObj_component_2d = configObj.getAttribute('component_2d');
									configObj_component_3d = configObj.getAttribute('component_3d');
									configObj_threedExists = configObj.getAttribute('threedExists');
									configObj_ass_color_skus = configObj.getAttribute('ass_color_skus');
									configObj_unass_color_skus = configObj.getAttribute('unass_color_skus');
									configObj_height = configObj.getAttribute('height');
									configObj_depth = configObj.getAttribute('depth');
									configObj_width = configObj.getAttribute('width');
									configObj_ass_price = configObj.getAttribute('ass_price');
									configObj_unass_price = configObj.getAttribute('unass_price');
									configObj_price_3 = configObj.getAttribute('price_3');
									configObj_description = configObj.getAttribute('description');
									configObj_info_details = configObj.getAttribute('info_details');
									configObj_acc_below = configObj.getAttribute('acc_below');
									configObj_acc_above = configObj.getAttribute('acc_above');
									configObj_colors = configObj.getAttribute('colors');
									///////////////////
									
									if (configObj.getAttribute('loc') == "below") {
										belowArr.push({sku:configObj_sku, x:configObj_x, y:configObj_y, xposft:configObj_xposft, yposft:configObj_yposft,
										name:configObj_name, group:configObj_group, prod_type:configObj_prod_type, shown_in_section: configObj_shown_in_section,
										series_name:configObj_series_name, parent_group: configObj_parent_group, component_2d:configObj_component_2d,
										component_3d:configObj_component_3d, threedExists:configObj_threedExists, ass_color_skus: configObj_ass_color_skus,
										unass_color_skus:configObj_unass_color_skus, height:configObj_height, depth:configObj_depth, width:configObj_width,
										ass_price: configObj_ass_price, unass_price: configObj_unass_price, price_3:configObj_price_3,description:configObj_description,
										info_details:configObj_info_details, acc_below:configObj_acc_below,acc_above: configObj_acc_above,colors:configObj_colors});
										
									} else if (configObj.getAttribute('loc') == "above") {
										aboveArr.push({sku:configObj_sku, x:configObj_x, y:configObj_y, xposft:configObj_xposft, yposft:configObj_yposft,
										name:configObj_name, group:configObj_group, prod_type:configObj_prod_type, shown_in_section: configObj_shown_in_section,
										series_name:configObj_series_name, parent_group: configObj_parent_group, component_2d:configObj_component_2d,
										component_3d:configObj_component_3d, threedExists:configObj_threedExists, ass_color_skus: configObj_ass_color_skus,
										unass_color_skus:configObj_unass_color_skus, height:configObj_height, depth:configObj_depth, width:configObj_width,
										ass_price: configObj_ass_price, unass_price: configObj_unass_price, price_3:configObj_price_3,description:configObj_description,
										info_details:configObj_info_details, acc_below:configObj_acc_below,acc_above: configObj_acc_above,colors:configObj_colors});
									}
								}
							}
							
							/////////////
							//getSkuResult(object_sku);
							/////////////
							objectsArr.push({sku:object_sku, rotation:object_rotation, x:object_x, y:object_y, objDepth:object_objDepth, above:aboveArr, below:belowArr,
							name:object_name, group:object_group, prod_type:object_prod_type, shown_in_section: object_shown_in_section,
							series_name:object_series_name, parent_group: object_parent_group, component_2d:object_component_2d,
							component_3d:object_component_3d, threedExists:object_threedExists, ass_color_skus: object_ass_color_skus,
							unass_color_skus:object_unass_color_skus, height:object_height, depth:object_depth, width:object_width,
							ass_price: object_ass_price, unass_price: object_unass_price, price_3:object_price_3,description:object_description,
							info_details:object_info_details, acc_below:object_acc_below,acc_above: object_acc_above,colors:object_colors});
						}
					
						typicalArray.push({id:typical_id, group:typical_ggroup, series_name:typical_series_name, parent_group:typical_parent_group, 
						name:typical_name, typImage:typical_typImage, lock:typical_lockFlag, objectData:objectsArr, prodSku:typical_sku,
						prodName:typical_prodName, prod_type:typical_prod_type, shown_in_section: typical_shown_in_section,
						component_2d:typical_component_2d, component_3d:typical_component_3d, threedExists:typical_threedExists, 
						ass_color_skus: typical_ass_color_skus, unass_color_skus:typical_unass_color_skus, height:typical_height, 
						depth:typical_depth, width:typical_width,ass_price: typical_ass_price, unass_price: typical_unass_price, 
						price_3:typical_price_3, description:typical_description, info_details:typical_info_details, acc_below:typical_acc_below,
						acc_above: typical_acc_above, colors:typical_colors, typWidth:typical_typWidth , typHeight:typical_typHeight, typDepth:typical_typDepth});
						
						//alert(typicalArray[i].objectData[0].sku);
						//alert(typicalArray[i].typDepth);
					}
					//alert(typicalArray.length);
					///////////////////////
					if(shown_in_section == 'planner')
						eval("flash."+functionName+"(productArray,typicalArray)");
					else //if (shown_in_section == 'accessory')
						eval("flash."+functionName+"(productArray)");
				}
			
			}
		};
		searchReq.send(null);
		
	}

}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// onother way to retrieve data  using for loop
// not working !!
//////////////////////////////////////////////////////////////
/*function getProduct(functionName,series_name,parent_group,group,shown_in_section) {
	//alert(shown_in_section);
	searchReq.abort();
	//alert(functionName);
	//alert(group);
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		//var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'sql/sql.php?generate=product&parent_group='+parent_group+'&series='+series_name+'&group='+group+'&shown_in_section='+shown_in_section, true);
		searchReq.onreadystatechange = function(){
			
			if (searchReq.readyState == 4) {
			//alert(searchReq.responseText);
				if(searchReq.responseText != ""){
				//if(searchReq.responseXML != ""){
					text = searchReq.responseText;
				
					try //Internet Explorer
					{
						//alert('ie');
						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
						xmlDoc.async="false";
						xmlDoc.loadXML(text);
					}
					catch(e)
					{
						try //Firefox, Mozilla, Opera, etc.
						{
							//alert('firefox');
							parser=new DOMParser();
							xmlDoc=parser.parseFromString(text,"text/xml");
						}
						catch(e)
						{
							alert(e.message);
							return;
						}
					}
					
					//var xmlDoc=searchReq.responseXML.documentElement;
					//// parsing xml
					///////////////////////
					var productArray = new Array();
					var typicalArray = new Array();
					
					
					
					products = xmlDoc.getElementsByTagName("product").style.whiteSpace="nowrap";
					typicals = xmlDoc.getElementsByTagName("typical");
					
					//alert(typicals.length);
					alert(products.length);
					for(i=0 ; i<products.length; i++){
					alert(products[i].childNodes.length);
						for(p=0; p<products[i].childNodes.length; p++){
							//if(products[i].childNodes[p].hasChildNodes()){
								alert(products[i].childNodes[p].tagName);
							//}
						}
						for(p=0; p<products[i].childNodes.length; p++){
							if(products[i].childNodes[p].hasChildNodes()){
								if(products[i].childNodes[p].childNodes[0].nodeValue != null){
									eval("product_"+products[i].childNodes[p].tagName + " = products[i].childNodes[p].childNodes[0].nodeValue");
								}
							}
							else{
									eval("product_"+products[i].childNodes[p].tagName + " = ''";
							}
						}
						
						
						// pushing object into an Array
						productArray.push({name : product_name, parent_group : product_parent_group, group : product_group, sku : product_sku, colors : product_colors,
						ass_color_skus : product_ass_color_skus, unass_color_skus : product_unass_color_skus, width : product_width, depth : product_depth,
						height : product_height, series_name : product_series_name, ass_price : product_ass_price, unass_price : product_unass_price, price_3 : product_price_3,
						component_2d : product_component_2d, component_3d : product_component_3d, prod_type : product_prod_type, shown_in_section : product_shown_in_section,
						description : product_description, info_details : product_info_details, acc_below : product_acc_below, acc_above : product_acc_above,
						threedExists : product_threedExists});
						
						//alert(productArray[i].prod_type);
					}
					
					for(i=0 ; i<typicals.length; i++){
					
						if(typicals[i].getElementsByTagName("id")[0].hasChildNodes())
							typical_id = typicals[i].getElementsByTagName("id")[0].childNodes[0].nodeValue; 
						else 
							typical_id = "";
							
						if(typicals[i].getElementsByTagName("name")[0].hasChildNodes())
							typical_name = typicals[i].getElementsByTagName("name")[0].childNodes[0].nodeValue; 
						else 
							typical_name = "";
							
						if(typicals[i].getElementsByTagName("series_name")[0].hasChildNodes())
							typical_series_name = typicals[i].getElementsByTagName("series_name")[0].childNodes[0].nodeValue; 
						else 
							typical_series_name = "";
							
						if(typicals[i].getElementsByTagName("parent_group")[0].hasChildNodes())
							typical_parent_group = typicals[i].getElementsByTagName("parent_group")[0].childNodes[0].nodeValue; 
						else 
							typical_parent_group = "";
							
						if(typicals[i].getElementsByTagName("ggroup")[0].hasChildNodes())
							typical_ggroup = typicals[i].getElementsByTagName("ggroup")[0].childNodes[0].nodeValue; 
						else 
							typical_ggroup = "";
							
						if(typicals[i].getElementsByTagName("lockFlag")[0].hasChildNodes())
							typical_lockFlag = typicals[i].getElementsByTagName("lockFlag")[0].childNodes[0].nodeValue; 
						else 
							typical_lockFlag = "";
							
						if(typicals[i].getElementsByTagName("typImage")[0].hasChildNodes())
							typical_typImage = typicals[i].getElementsByTagName("typImage")[0].childNodes[0].nodeValue; 
						else 
							typical_typImage = "";
							
						//data from product table 
						///////////////////
						if(typicals[i].getElementsByTagName("prodName")[0].hasChildNodes())
							typical_prodName = typicals[i].getElementsByTagName("prodName")[0].childNodes[0].nodeValue; 
						else 
							typical_prodName = "";
							
						if(typicals[i].getElementsByTagName("prod_type")[0].hasChildNodes())
							typical_prod_type = typicals[i].getElementsByTagName("prod_type")[0].childNodes[0].nodeValue; 
						else 
							typical_prod_type = "";
							
						if(typicals[i].getElementsByTagName("shown_in_section")[0].hasChildNodes())
							typical_shown_in_section = typicals[i].getElementsByTagName("shown_in_section")[0].childNodes[0].nodeValue; 
						else 
							typical_shown_in_section = "";
						
						if(typicals[i].getElementsByTagName("sku")[0].hasChildNodes())
							typical_sku = typicals[i].getElementsByTagName("sku")[0].childNodes[0].nodeValue; 
						else 
							typical_sku = "";
						
						if(typicals[i].getElementsByTagName("component_2d")[0].hasChildNodes())
							typical_component_2d = typicals[i].getElementsByTagName("component_2d")[0].childNodes[0].nodeValue; 
						else 
							typical_component_2d = "";
						
						if(typicals[i].getElementsByTagName("component_3d")[0].hasChildNodes())
							typical_component_3d = typicals[i].getElementsByTagName("component_3d")[0].childNodes[0].nodeValue; 
						else 
							typical_component_3d = "";
						
						if(typicals[i].getElementsByTagName("threedExists")[0].hasChildNodes())
							typical_threedExists = typicals[i].getElementsByTagName("threedExists")[0].childNodes[0].nodeValue; 
						else 
							typical_threedExists = "";
						
						if(typicals[i].getElementsByTagName("ass_color_skus")[0].hasChildNodes())
							typical_ass_color_skus = typicals[i].getElementsByTagName("ass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							typical_ass_color_skus = "";
						
						if(typicals[i].getElementsByTagName("unass_color_skus")[0].hasChildNodes())
							typical_unass_color_skus = typicals[i].getElementsByTagName("unass_color_skus")[0].childNodes[0].nodeValue; 
						else 
							typical_unass_color_skus = "";
						
						if(typicals[i].getElementsByTagName("ass_price")[0].hasChildNodes())
							typical_ass_price = typicals[i].getElementsByTagName("ass_price")[0].childNodes[0].nodeValue; 
						else 
							typical_ass_price = "";
						
						if(typicals[i].getElementsByTagName("unass_price")[0].hasChildNodes())
							typical_unass_price = typicals[i].getElementsByTagName("unass_price")[0].childNodes[0].nodeValue; 
						else 
							typical_unass_price = "";
						
						if(typicals[i].getElementsByTagName("price_3")[0].hasChildNodes())
							typical_price_3 = typicals[i].getElementsByTagName("price_3")[0].childNodes[0].nodeValue; 
						else 
							typical_price_3 = "";
						
						if(typicals[i].getElementsByTagName("width")[0].hasChildNodes())
							typical_width = typicals[i].getElementsByTagName("width")[0].childNodes[0].nodeValue; 
						else 
							typical_width = "";
						
						if(typicals[i].getElementsByTagName("height")[0].hasChildNodes())
							typical_height = typicals[i].getElementsByTagName("height")[0].childNodes[0].nodeValue; 
						else 
							typical_height = "";
						
						if(typicals[i].getElementsByTagName("depth")[0].hasChildNodes())
							typical_depth = typicals[i].getElementsByTagName("depth")[0].childNodes[0].nodeValue; 
						else 
							typical_depth = "";
							
						if(typicals[i].getElementsByTagName("description")[0].hasChildNodes())
							typical_description = typicals[i].getElementsByTagName("description")[0].childNodes[0].nodeValue; 
						else 
							typical_description = "";
							
						if(typicals[i].getElementsByTagName("info_details")[0].hasChildNodes())
							typical_info_details = typicals[i].getElementsByTagName("info_details")[0].childNodes[0].nodeValue; 
						else 
							typical_info_details = "";
						
						if(typicals[i].getElementsByTagName("acc_below")[0].hasChildNodes())
							typical_acc_below = typicals[i].getElementsByTagName("acc_below")[0].childNodes[0].nodeValue; 
						else 
							typical_acc_below = "";
						
						if(typicals[i].getElementsByTagName("acc_above")[0].hasChildNodes())
							typical_acc_above = typicals[i].getElementsByTagName("acc_above")[0].childNodes[0].nodeValue; 
						else 
							typical_acc_above = "";
							
						if(typicals[i].getElementsByTagName("colors")[0].hasChildNodes())
							typical_colors = typicals[i].getElementsByTagName("colors")[0].childNodes[0].nodeValue; 
						else 
							typical_colors = "";
						///////////////////
						
						var objectsArr = new Array();
						
						for(f=0; f<typicals[i].getElementsByTagName("object_grouping")[0].getElementsByTagName("object").length; f++){
						
							object = typicals[i].getElementsByTagName("object_grouping")[0].getElementsByTagName("object")[f]; 
							object_sku = object.getAttribute('sku');
							object_objDepth = object.getAttribute('objectDepth');
							object_rotation = object.getAttribute('rotation');
							object_y = object.getAttribute('y');
							object_x = object.getAttribute('x');
							
							//data from product table 
							///////////////////
							object_name = object.getAttribute('name');
							object_group = object.getAttribute('group');
							object_prod_type = object.getAttribute('prod_type');
							object_shown_in_section = object.getAttribute('shown_in_section');
							object_series_name = object.getAttribute('series_name');
							object_parent_group = object.getAttribute('parent_group');
							object_component_2d = object.getAttribute('component_2d');
							object_component_3d = object.getAttribute('component_3d');
							object_threedExists = object.getAttribute('threedExists');
							object_ass_color_skus = object.getAttribute('ass_color_skus');
							object_unass_color_skus = object.getAttribute('unass_color_skus');
							object_height = object.getAttribute('height');
							object_depth = object.getAttribute('depth');
							object_width = object.getAttribute('width');
							object_ass_price = object.getAttribute('ass_price');
							object_unass_price = object.getAttribute('unass_price');
							object_price_3 = object.getAttribute('price_3');
							object_description = object.getAttribute('description');
							object_info_details = object.getAttribute('info_details');
							object_acc_below = object.getAttribute('acc_below');
							object_acc_above = object.getAttribute('acc_above');
							object_colors = object.getAttribute('colors');
							///////////////////
							
							var aboveArr = new Array();
							var belowArr = new Array();
							
							if(object.hasChildNodes()){
								
								for(g=0; g<object.getElementsByTagName("config_obj").length; g++){
									configObj = object.getElementsByTagName("config_obj")[g];
									if (configObj.getAttribute('sku') == "undefined") {
										continue;
									}
									configObj_sku = configObj.getAttribute('sku');
									configObj_yposft = configObj.getAttribute('yposft');
									configObj_xposft = configObj.getAttribute('xposft');
									configObj_y = configObj.getAttribute('y');
									configObj_x = configObj.getAttribute('x');
									
									//data from product table 
									///////////////////
									configObj_name = configObj.getAttribute('name');
									configObj_group = configObj.getAttribute('group');
									configObj_prod_type = configObj.getAttribute('prod_type');
									configObj_shown_in_section = configObj.getAttribute('shown_in_section');
									configObj_series_name = configObj.getAttribute('series_name');
									configObj_parent_group = configObj.getAttribute('parent_group');
									configObj_component_2d = configObj.getAttribute('component_2d');
									configObj_component_3d = configObj.getAttribute('component_3d');
									configObj_threedExists = configObj.getAttribute('threedExists');
									configObj_ass_color_skus = configObj.getAttribute('ass_color_skus');
									configObj_unass_color_skus = configObj.getAttribute('unass_color_skus');
									configObj_height = configObj.getAttribute('height');
									configObj_depth = configObj.getAttribute('depth');
									configObj_width = configObj.getAttribute('width');
									configObj_ass_price = configObj.getAttribute('ass_price');
									configObj_unass_price = configObj.getAttribute('unass_price');
									configObj_price_3 = configObj.getAttribute('price_3');
									configObj_description = configObj.getAttribute('description');
									configObj_info_details = configObj.getAttribute('info_details');
									configObj_acc_below = configObj.getAttribute('acc_below');
									configObj_acc_above = configObj.getAttribute('acc_above');
									configObj_colors = configObj.getAttribute('colors');
									///////////////////
									
									if (configObj.getAttribute('loc') == "below") {
										belowArr.push({sku:configObj_sku, x:configObj_x, y:configObj_y, xposft:configObj_xposft, yposft:configObj_yposft,
										name:configObj_name, group:configObj_group, prod_type:configObj_prod_type, shown_in_section: configObj_shown_in_section,
										series_name:configObj_series_name, parent_group: configObj_parent_group, component_2d:configObj_component_2d,
										component_3d:configObj_component_3d, threedExists:configObj_threedExists, ass_color_skus: configObj_ass_color_skus,
										unass_color_skus:configObj_unass_color_skus, height:configObj_height, depth:configObj_depth, width:configObj_width,
										ass_price: configObj_ass_price, unass_price: configObj_unass_price, price_3:configObj_price_3,description:configObj_description,
										info_details:configObj_info_details, acc_below:configObj_acc_below,acc_above: configObj_acc_above,colors:configObj_colors});
										
									} else if (configObj.getAttribute('loc') == "above") {
										aboveArr.push({sku:configObj_sku, x:configObj_x, y:configObj_y, xposft:configObj_xposft, yposft:configObj_yposft,
										name:configObj_name, group:configObj_group, prod_type:configObj_prod_type, shown_in_section: configObj_shown_in_section,
										series_name:configObj_series_name, parent_group: configObj_parent_group, component_2d:configObj_component_2d,
										component_3d:configObj_component_3d, threedExists:configObj_threedExists, ass_color_skus: configObj_ass_color_skus,
										unass_color_skus:configObj_unass_color_skus, height:configObj_height, depth:configObj_depth, width:configObj_width,
										ass_price: configObj_ass_price, unass_price: configObj_unass_price, price_3:configObj_price_3,description:configObj_description,
										info_details:configObj_info_details, acc_below:configObj_acc_below,acc_above: configObj_acc_above,colors:configObj_colors});
									}
								}
							}
							
							/////////////
							//getSkuResult(object_sku);
							/////////////
							objectsArr.push({sku:object_sku, rotation:object_rotation, x:object_x, y:object_y, objDepth:object_objDepth, above:aboveArr, below:belowArr,
							name:object_name, group:object_group, prod_type:object_prod_type, shown_in_section: object_shown_in_section,
							series_name:object_series_name, parent_group: object_parent_group, component_2d:object_component_2d,
							component_3d:object_component_3d, threedExists:object_threedExists, ass_color_skus: object_ass_color_skus,
							unass_color_skus:object_unass_color_skus, height:object_height, depth:object_depth, width:object_width,
							ass_price: object_ass_price, unass_price: object_unass_price, price_3:object_price_3,description:object_description,
							info_details:object_info_details, acc_below:object_acc_below,acc_above: object_acc_above,colors:object_colors});
						}
					
						typicalArray.push({id:typical_id, group:typical_ggroup, series_name:typical_series_name, parent_group:typical_parent_group, 
						name:typical_name, typImage:typical_typImage, lock:typical_lockFlag, objectData:objectsArr, prodSku:typical_sku,
						prodName:typical_prodName, prod_type:typical_prod_type, shown_in_section: typical_shown_in_section,
						component_2d:typical_component_2d, component_3d:typical_component_3d, threedExists:typical_threedExists, 
						ass_color_skus: typical_ass_color_skus, unass_color_skus:typical_unass_color_skus, height:typical_height, 
						depth:typical_depth, width:typical_width,ass_price: typical_ass_price, unass_price: typical_unass_price, 
						price_3:typical_price_3, description:typical_description, info_details:typical_info_details, acc_below:typical_acc_below,
						acc_above: typical_acc_above, colors:typical_colors});
						
						//alert(typicalArray[i].objectData[0].sku);
					}
					//alert(typicalArray.length);
					///////////////////////
					if(shown_in_section == 'planner')
						eval("flash."+functionName+"(productArray,typicalArray)");
					else if (shown_in_section == 'accessory')
						eval("flash."+functionName+"(productArray)");
				}
			
			}
		};
		searchReq.send(null);
		
	}

}*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////


