//global variables
var pbDid = 875146; //product browse dattributeid
var asDid = 885083; //attribute search dattributeid

function getAmpsPath() {
	return ((window.location.pathname.match(/\//g).length >= 1) ? '../../' : '../');
}//function getAmpsPath()

function getRelPath() {
	var count = window.location.pathname.match(/\//g);
	var host = window.location.host;
	if (host == 'webq1.insidehli.com' || host == 'dev.insidehli.com') {//dev box
		if (count.length <= 2) {//less than 2 "/" in path, we are on index page
			return '';
		} else { //one level down
			return '../';
		}//if (count.length <= 2)
	} else {//vhosted
		if (count.length <= 1) {//on index page
			return '';
		} else {
			return '../';
		}//if (count.length <= 1)
	}//if (host == 'webq1.insidehli.com' || host == 'dev.insidehli.com')
	return ret;
}//function getRelPath()

function getAbsPath(site) {
	var host = window.location.host;
	
	if (host == "webq1.insidehli.com" || host == "dev.insidehli.com") {
		//now we have to check to see if we're on the dev or test site (dev is our default db connection)
		if (window.location.pathname.match(/_test/g)) {
			//we're on testing site	
			return 'http://' + host + '/' + site + '_test/';						
		} else {
			//we're on dev (or we're defaulting to dev)
			return 'http://' + host + '/' + site + '_dev/';								
		}//if (window.location.pathname.match(/_test/g))		
	} else if (host == "qa.aleralighting.com") {
		//we're on qa site
		return 'http://qa.aleralighting.com/';
	} else if (host == "foobar") {
		//temporary for foobar
		return 'http://foobar/dev/' + site + '_dev/';
	} else {
		//we're on production site
		return 'http://www.aleralighting.com/';
	} //if (host == "webq1.insidehli.com" || host == "dev.insidehli.com") 	
}//function getAbsPath()

//main attSearch function, occurs on first click of attsearch
//build first drop-down
function attSearch() {
	var relPath = getRelPath();
	var ampsPath = getAmpsPath();	
	accessCSS('right-pane-browse').display = 'none';
	accessCSS('right-pane').display = 'block';
			   
	var ulstring = ' <ul>' +
				   '  <li class="selected" id="att-search-bttn"><a href="javascript: void(0);" onclick="attSearch();">&nbsp;</a></li>' +
	               '  <li id="prod-browse-bttn"><a href="javascript: void(0);" onclick="productBrowse();">&nbsp;</a></li>' +				   
				   ' </ul>';				  		   
	
	$('pbrowse').innerHTML = ulstring;

	$('right-pane-browse').innerHTML = '';
	$('attSearch1').innerHTML = ''; //clear existing att search
	
	accessCSS('prodBrowse').display = 'none';
	accessCSS('attSearch1').display = 'block';
	$("prodBrowse").innerHTML = ''; //clear any existing product list

	if (arguments.length == 1) {
		writeAttSearchDD(asDid, 'attSearch1', relPath, ampsPath, arguments[0], arguments[0]);
	} else {
		writeAttSearchDD(asDid, 'attSearch1', relPath, ampsPath, ''); //write DD starting at top of attribute search array		
	}//if (arguments.length == 1)
}//function attSearch()

//main product browse function, occurs on first click of product browse
function productBrowse() {
	var relPath = getRelPath();
	var ampsPath = getAmpsPath();
	accessCSS('right-pane-browse').display = 'none';
	accessCSS('right-pane').display = 'block';
					   
	var ulstring = ' <ul>' +
				   '  <li id="att-search-bttn"><a href="javascript: void(0);" onclick="attSearch();">&nbsp;</a></li>' +
	               '  <li class="selected" id="prod-browse-bttn"><a href="javascript: void(0);" onclick="productBrowse();">&nbsp;</a></li>' +				   
				   ' </ul>';
		
	$('pbrowse').innerHTML = ulstring;

	$('right-pane-browse').innerHTML = '';
	$('bottomDiv').innerHTML = '';
	$('attSearch1').innerHTML = ''; 
	$('prodBrowse').innerHTML = '';
	accessCSS('attSearch1').display = 'none';
	
	if (arguments.length == 1) {
		writeProdBrowseDD(pbDid, 'prodBrowse', relPath, ampsPath, arguments[0]); //write DD starting at top of product browse array
	} else {
		writeProdBrowseDD(pbDid, 'prodBrowse', relPath, ampsPath, '');
	}//if (arguments.length == 1)
	
	accessCSS('prodBrowse').visibility = 'hidden';
	accessCSS('prodBrowse').display = 'block';
	accessCSS('prodBrowse').visibility = 'visible';
}//function productBrowse()

//to write out a single DD for Attribute Search
function writeAttSearchDD (did, divid, relPath, ampsPath, ashist, aspath) {
	if (!isUndefined(aspath)) {
		if (aspath.indexOf('_') != -1) {//there is more than one selection 
			var nextid = aspath.substring(0, aspath.indexOf('_')); //grab the first selection in aspath
			aspath = aspath.substring(aspath.indexOf('_')+1); //remove first selection from aspath
		} else {//only one selection
			var nextid = aspath;
			aspath = '';
		}//if (aspath.indexOf('_') != -1)
	}//if (!isUndefined(aspath))
	
	if (did == '') {
		return false;
	}//if (did == '')
	
	var matched = ASindex[did][2];
	var nextdiv = nextDiv('attSearch', divid);
	var category = listChildren(did, 'as');

	//check if product returned		
	if (ASindex[category[0]][0] == 'Product Name') {//product level
		$('numProd').innerHTML = 'Found Matches: ' + matched;
		if (arguments.length != 6) {
			ajax('includes/ajax.php','getProductsByCategory',did,'','as', ashist);				
		}//if (arguments.length != 6)
		$(divid).innerHTML = '';
	} else {//category level 
		if (did == asDid) {
			$('right-pane-browse').innerHTML = '';
			accessCSS('right-pane-browse').display = 'none';
			accessCSS('right-pane').display = 'block';
		} else {
			if (arguments.length != 6) {
				ajax('includes/ajax.php','getProductsByCategory',did,'','as', ashist);				
			}//if (arguments.length != 6)
		}//if (did == asDid)

		var dd = '<h3><span>' + ASindex[category[0]][1] + '</span></h3>' +		
				 '<select name="' + did + '" onChange="searchChoice(this, \'' + nextdiv + '\', \'as\',\'' + relPath + '\',\'' + ampsPath + '\',\'' + ashist + '\');">\n' +
				 ' <option value="' + did + '">-- All --</option>\n';
				 
		var choices = listChildren(category[0], 'as');
		
		for (i=0; i < choices.length; i++) {
			if (choices[i] == nextid) {
				dd += ' <option value="' + choices[i] + '" selected>' + ASindex[choices[i]][1] + '</option>\n';
			} else {
				dd += ' <option value="' + choices[i] + '">' + ASindex[choices[i]][1] + '</option>\n';
			}//if (choices[i] == nextid)
		}//for (i=0; i < choices.length; i++)
		
		dd += '</select>\n' +
		      '<div id="' + nextdiv + '"></div>\n';
		
		//write out bottom divs
		//num matching prods and reset button into bottomDiv
		if ($(divid)) {
			$(divid).innerHTML = dd;
		}//if ($(divid))
		
		$('bottomDiv').innerHTML = '';
	}//if (ASindex[category[0]][0] == 'Product Name')

	//only show reset and found matches after first selection
	if (did != asDid) {
		var bottomDivs = '<div id="numProd">Found Matches: ' + matched + '</div>\n' +
						 '<div id="reset">' +
						 ' <input type="button" onClick="attSearch();" value="Reset" />\n' +
						 '</div><div class="clear">&nbsp;</div>\n';
						 
		$('bottomDiv').innerHTML = bottomDivs;
	}//if (did != asDid)

	if (!isUndefined(aspath)) {//have more path to display
		writeAttSearchDD(nextid, nextdiv, relPath, ampsPath, ashist, aspath)
	}//if (!isUndefined(aspath))
}//function writeAttSearchDD (did, divid, relPath, ampsPath, ashist, aspath)

function writeProdBrowseDD(did, divid, relPath, ampsPath) { //arguments[4] (the fifth one) is optional and is the passed in did of the category from url
	var nextdiv = nextDiv('prodBrowse', divid);
	var dd = '<h3><span>Browse Product Type</span></h3>' +
			 '<select id="pbrowse" name="pbrowse" onChange="searchChoice(this, \'' + nextdiv + '\', \'pb\',\'' + relPath + '\',\'' + ampsPath + '\');" />\n' +
			 ' <option value="' + did + '">-- All --</option>\n';
			 
	var choices = listChildren(did, 'pb');
		
	for (i=0; i < choices.length; i++) {
		if (arguments.length == 5 && choices[i] == arguments[4]) {
			dd += ' <option value="' + choices[i] + '" selected>' + PBindex[choices[i]][1] + '</option>\n';
		} else {
			dd += ' <option value="' + choices[i] + '">' + PBindex[choices[i]][1] + '</option>\n';
		}//if (arguments.length == 5 && choices[i] == arguments[4])
	}//for (i=0; i < choices.length; i++)
	
	dd += '</select>\n' +
	      '<div id="' + nextdiv + '" style="width: 170px;"></div>\n';
		  
	$(divid).innerHTML = dd;
		
	if (arguments.length == 5 && arguments[4]) {
		//here we need to get our product list for this category
		ajax('includes/ajax.php','getProductsByCategory',arguments[4],nextdiv,'pb','');				
	}//if (arguments.length == 5 && arguments[4])
}//function writeProdBrowseDD(did, divid, relPath, ampsPath)

function writeProdBrowseList(did, divid, relPath, ampsPath, data) {
	//PBindex: 
	//  0 - product vs category
	//  1 - Left Side Product Name
	//  2 - Real Product Name
	//  3 - product page file name
	//  4 - product image
	//  5 - dimensions
	//  6 - distribution (comma delimitted list)
	//  7 - number of lamps
	//  8 - mounting type
	//  9 - lamp types
	// 10 - product id
	// 11 - product description
	// 12 - model
	// 13 - express
	
	relPath = getAbsPath('alera'); //get our absolute path (necessary because of url rewriting)
	var filenameArray = window.location.pathname.split('/');	
	var filename = filenameArray[filenameArray.length-2];		

	var prodList = '<div id="browse-list">' +
	               ' <ul>';
	var children = listChildren(did, 'pb');
	
	if (data == "") {
		alert("No data available for the selected category. Please try your request again.");
		productBrowse();
		return;
	}//if (data == "")
	
	//parse our json string
	var prodData = JSON.parse(data);	
	
	for (var j = 0; j < prodData.products.length; j++) {				
		if (filename == prodData.products[j].filename) {//on this product page, don't link and no mouseover event
			prodList += '<li><span>' + prodData.products[j].productName + '</span></li>\n';;
		} else {//not on product page, include mouseover and link
		//hideProduct();
			prodList += '<li onMouseOver=\"showProduct(' + prodData.products[j].did + ',\'' + relPath + '\',\'' + ampsPath + '\',\'' + escape(JSON.stringify(prodData.products[j])) + '\');\" onMouseOut=\"this.className=\'\';hideProduct(); \"><a href=\"' + relPath + 'products/' + prodData.products[j].filename + '/?pbid=' + did + '\">' + prodData.products[j].productName + '</a></li>\n';							
		}//if (filename == prodData.products[j].filename)				
	}//for (var j = 0; j < prodData.products.length; j++)
	
	prodList += ' </ul>' +
	            '</div>\n';
				
	$(divid).innerHTML = prodList;	
}//function writeProdBrowseList(did, divid, relPath, ampsPath, data)

//show a product browse product on rollover
function showProduct(did, relPath, ampsPath, prodData) {

	if (prodData == "") {
		alert("No data available for the selected product. Please try your request again.");
		productBrowse();
		return;
	}//if (prodData == "")
	
	//set our prodData (parsing our JSON string)
	var prodData = JSON.parse(unescape(prodData));

	//check if relPath is empty, if so its coming from xml, build relpath here
	if (relPath == '') {var relPath = getAbsPath('alera');}//if (relPath == '')
		
	//-- prodData object definition --//
	//-- did                
	//-- category           
	//-- productName        
	//-- realProductName    
	//-- filename           
	//-- productImage       
	//-- dimensions         
	//-- distribution       
	//-- numberOfLamps      
	//-- mountingType       
	//-- lampTypes          
	//-- productID          
	//-- productDescription 
	//-- model              
	//-- express            

	var prod = '<div id="toolbar-contain">' + 
	           ' <h3 class="top"><span>Product Browse</span></h3>' +
			   '  <ul id="toolbar" style="display:none;"></ul>' + 
			   '</div>';
			   
	//product name
	prod += '<div class="bottom-border-contain">' +
			' <h4>' + prodData.realProductName + '</h4>' +
			' <div id="size">' + prodData.dimensions + '</div>' +
			' <div class="clear"></div>'+
			'</div>';
			
	prod += '<div id="product-rollover-container">' +
	        ' <div id="left-image">';

	if (prodData.productImage != '' && prodData.productImage != null) {
		prod += '  <img src="' + relPath + 'products/images/product/' + prodData.productImage + '" alt="product image" width="352"  />';		
	}//if (prodData.productImage != '' && prodData.productImage != null)
		
	prod +=	' </div>' +
		    ' <div id="right-info">' +
			'  <table width="100%" border="0" cellspacing="0" cellpadding="0">' +
			'	<tr>' +
			'	<td colspan="2" class="height">';
			
	if (prodData.productDescription != '' && prodData.productDescription != null) {
		prod += prodData.productDescription;
	}//if (prodData.productDescription != '' && prodData.productDescription != null)

	prod += '	</td>' +
			'	</tr>' +
			'   <tr>' +
    		'    <td colspan="2" class="tbl-head"><h4>Lamp and Distribution</h4></td>' +
 			'   </tr>' +
			'   <tr>';
			
	if (prodData.mountingType != '' && prodData.mountingType != null) {
		prod += '    <td class="height">' + prodData.mountingType +'</td>';
	}//if (prodData.mountingType != '' && prodData.mountingType != null)
		
	prod += '    <td valign="top" style="text-align:right;" class="height">';

	
	if (prodData.distribution != '' && prodData.distribution != null) {
		var distImgs = explodeArray(prodData.distribution, ",");
	
		//iterate through our linked distribution images and add to our prodDiv html string
		for (d = 0; d < distImgs.length; d++) {	
			prod += '     <img src="' + relPath + 'products/images/keywords/' + distImgs[d].strip() + '" alt="product image" id="icon" />';		
		}//for (d = 0; d < distImgs.length; d++)			
	}//if (prodData.distribution != '' && prodData.distribution != null)	
	
	prod += '    </td>' +
	        '   </tr>' +
	        '   <tr>' +
	        '    <td colspan="2" class="height">'

	if (prodData.numberOfLamps != '' && prodData.numberOfLamps != null) {
		prod += prodData.numberOfLamps;
	}//if (prodData.numberOfLamps != '' && prodData.numberOfLamps != null)

	prod += '    </td>' +
            '   </tr>' +
	        '   <tr>' +
	        '    <td colspan="2" class="height">';
			
	if (prodData.lampTypes != '' && prodData.lampTypes != null) {			
		prod += prodData.lampTypes;
	}//if (prodData.lampTypes != '' && prodData.lampTypes != null)
	
	prod += '    </td>' +
	        '   </tr>' +
	        '  </table>' +	
			' </div>' +
	        ' <div class="clear"></div>' +
			'</div>';	
			
	$('right-pane-browse').innerHTML = prod;
	accessCSS('right-pane').display = 'none';
	accessCSS('right-pane-browse').display = 'block';
}//function showProduct(did, relPath, ampsPath, prodData)

//have list of prod ids below this did in ASindex
function showProducts(did, relPath, ampsPath, prodData, ashist) {
	//-- prodData object definition --//
	//-- did                
	//-- category           
	//-- productName        
	//-- realProductName    
	//-- filename           
	//-- productImage       
	//-- dimensions         
	//-- distribution       
	//-- numberOfLamps      
	//-- mountingType       
	//-- lampTypes          
	//-- productID          
	//-- productDescription 
	//-- model              
	//-- express  
	
	if (prodData == "") {
		alert("No data available for the selected category. Please try your request again.");
		attSearch();
		return;
	}//if (prodData == "")
	
	//set our prodData (parsing our JSON string)
	var prodData = JSON.parse(unescape(prodData));
	
	if (relPath == '') {var relPath = getAbsPath('alera');}//if (relPath == '')
	
	var prodCnt = prodData.products.length;			
	
	//begin our product listing
	var prodDiv = '<div id="toolbar-contain">' + 
	           	  ' <h3 class="top"><span>Feature Search</span></h3>' +
			      '  <ul id="toolbar" style="display:none;"></ul>' + 
			      '</div>' +
				  '<div id="content">';	

	for (var i = 0; i < prodCnt; i++) {
		//ensure this is a valid product
		if (!isUndefined(prodData.products[i])) {	   		
			prodDiv += ' <div';

			//ensure we have a filename
			if (prodData.products[i].filename != '') {
				prodDiv += ' style="cursor:pointer;" onClick="document.location.href = \'' + relPath + 'products/' + prodData.products[i].filename + '/' +
				           (!isUndefined(ashist) ? '?ashist=' + ashist + '\';">' : '\';">');										
			} else {
				prodDiv += '>';
			}//if (prodData.products[i].filename != '')

			//product name
			prodDiv += '  <div class="bottom-border-contain">' +
					   '   <h4>';
		   
		   	if (prodData.products[i].realProductName != '' && prodData.products[i].realProductName != 'null') {
				prodDiv += prodData.products[i].realProductName;
			}//if (prodData.products[i].realProductName != '' && prodData.products[i].realProductName != 'null')
							   
			prodDiv += '   </h4>' +
					   '   <div id="size">';			
					   
			if (prodData.products[i].dimensions != '') {
				prodDiv += prodData.products[i].dimensions;
			}//if (prodData.products[i].dimensions != '')

			prodDiv += '   </div>'+
					   '   <div class="clear">&nbsp;</div>'+
					   '  </div>';

			prodDiv += '  <div id="product-rollover-container">' +
					   '   <div id="left-image">';
			
			if (prodData.products[i].productImage != '') {	
				prodDiv += '    <img src="' + relPath + 'products/images/product/' + prodData.products[i].productImage + '" alt="product image" width="352" />';
			}//if (prodData.products[i].productImage != '')						 
			
			prodDiv +=	'   </div>' +
					    '   <div id="right-info">' +
						'    <table width="100%" border="0" cellspacing="0" cellpadding="0">' +
						' 	  <tr>'+
						'  	   <td colspan="2" class="height">';

			if (prodData.products[i].productDescription != 'template') {
				prodDiv += prodData.products[i].productDescription;
			}//if (prodData.products[i].productDescription != 'template')
						
			prodDiv += '      </td>'+
					   '	 </tr>'+			
					   '     <tr>' +
					   '      <td colspan="2" class="tbl-head"><h4>Lamp and Distribution</h4></td>' +
					   '     </tr>' +
					   '     <tr>' +
					   '      <td class="height">' + prodData.products[i].numberOfLamps + '</td>' +
					   '      <td valign="top" style=\"text-align:right;\" class="height">';
					
			if (prodData.products[i].distribution != '') {		
				var distImgs = explodeArray(prodData.products[i].distribution, ",");
			
				//iterate through our linked distribution images and add to our prodDiv html string
				for (d = 0; d < distImgs.length; d++) {	
					prodDiv += '       <img src="' + relPath + 'products/images/keywords/' + distImgs[d].strip() + '" alt="distribution" id="icon" />';		
				}//for (d = 0; d < distImgs.length; d++)	
			}//if (prodData.products[i].distribution != '')
			
			prodDiv += '      </td>' +
					   '     </tr>' +
					   '     <tr>' +
					   '      <td colspan="2" class="height">' + prodData.products[i].lampTypes + '</td>' +
					   '     </tr>' +
					   '     <tr>' +	
					   '      <td colspan="2" class="height">' + prodData.products[i].mountingType + '</td>' +
					   '     </tr>' +
					   '    </table>' +
					   '   </div>' +
					   '   <div class="clear"></div>' +
					   '  </div>' +
					   '  </div>';
		}//if (!isUndefined(Pindex[pdids[i]]))
	}//for (var i = 0; i < prodCnt; i++)

	prodDiv += '</div>'; //end content	

	if (document.getElementById('numProd')) {document.getElementById('numProd').innerHTML = 'Found Matches: ' + prodCnt;}	
	$('right-pane-browse').innerHTML = prodDiv;
	accessCSS('right-pane').display = 'none';
	accessCSS('right-pane-browse').display = 'block';
}//function showProducts(did, relPath, ampsPath, prodData, ashist)

function hideProduct() {
	accessCSS('right-pane-browse').display = 'none';
	accessCSS('right-pane').display = 'block';
	$('right-pane-browse').innerHTML = '';
}//function hideProduct()

function searchChoice(myselect, divid, type, relPath, ampsPath) {
	var selval = myselect.options[myselect.selectedIndex].value
	if (selval == myselect.name) { //know this is attsearch since select name is a did
		var lastdiv = lastDiv('attSearch', divid);
		//chose all option, must redraw dd to calculate matched products
		//must remove all ashist entries to the right of passed in did
		if (arguments.length == 6) {
			if (arguments[5] != '') {
				var ashist = arguments[5].substring(0, arguments[5].indexOf(selval)+selval.length);
				writeAttSearchDD(selval, lastdiv, relPath, ampsPath, ashist);
			} else {
				writeAttSearchDD(selval, lastdiv, relPath, ampsPath, '');
			}//if (arguments[5] != '')
		}//if (arguments.length == 6)
	} else if (type == 'as') {
		if (arguments.length == 6) {
			if (arguments[5] != '') {
				//need to check if this is a selection above the current ahist and trim it accordingly
				//can achieve this by counting the number of ids in ahist and comparing it to the div id
				//alert(arguments[5]);
				var splitAShist = explodeArray(arguments[5], "_");
				var numAShist = splitAShist.length;
				var currentDD = divid.substring(9) - 0 - 1;
				if (numAShist >= currentDD) {//user selected up the asearch tree, trim ashist 
					for (i = 0; i < currentDD - 1; i++) {
						if (i == 0) {
							var ashist = splitAShist[i];
						} else {
							ashist += '_' + splitAShist[i];
						}//if (i == 0)
					}//for (i = 0; i < currentDD - 1; i++)
					
					if (isUndefined(ashist)) {//need to make sure this isn't the top level and that the ashist will be undefined
						var ashist = selval;
					} else {
						ashist += '_' + selval;
					}//if (isUndefined(ashist))
				} else {
					var ashist = arguments[5] + '_' + selval; 
				}//if (numAShist >= currentDD)
			} else {
				var ashist = selval;
			}//if (arguments[5] != '')
			writeAttSearchDD(selval, divid, relPath, ampsPath, ashist);
		} else {
			writeAttSearchDD(selval, divid, relPath, ampsPath, '');
		}//if (arguments.length == 6)
	} else if (type == 'pb') {
		if (selval == pbDid) {
			$(divid).innerHTML = '';
		} else {
			//here we need to get our product list for this category
			ajax('includes/ajax.php','getProductsByCategory',selval,divid,'pb','');			
		}//if (selval == pbDid)
	}//if (selval == myselect.name)
}//function searchChoice(myselect, divid, type, relPath, ampsPath)

function nextDiv(prefix, divid) {
	return prefix + (divid.substring(prefix.length) - 0 + 1);
}//function nextDiv(prefix, divid)

function lastDiv(prefix, divid) {
	return prefix + (divid.substring(prefix.length) - 0 - 1);
}//function lastDiv(prefix, divid)

function listChildren(did, type) {
	return ((type == 'as') ? explodeArray(ASplist[did], ',') : explodeArray(PBplist[did], ','));
}//function listChildren(did, type)

function accessCSS(layerID) {     
	if(document.getElementById) {
		if(!window.document.getElementById(layerID)) {
			return false;
		} else {
			return document.getElementById(layerID).style;
		}//if(!window.document.getElementById(layerID))
	} else if(document.all) {
		return document.all[layerID].style;
	} else if(document.layers) {
		return document.layers[layerID];
	}//if(document.getElementById)
}//function accessCSS(layerID)

function isUndefined(a) {
    return typeof a == 'undefined';
}//function isUndefined(a)

function ajax(url,theFunction,theParams,divid,type,ashist) {
	if (type == 'pb') {
		$(divid).innerHTML = '';
	}//if (type == 'pb')
	
	var success = function(t) {if(t.responseText == ''){alert('No data available for the selected category. Please try your request again.');}}
	var failure = function(t) {alert('No data available for the selected category. Please try your request again.');}
		
	var completed = function(t) {
						if (type == 'pb') {
							writeProdBrowseList(theParams, divid, getAbsPath('alera'), getAmpsPath(),t.responseText);
						} else {
							showProducts(theParams, getAbsPath('alera'), getAmpsPath(), t.responseText, ashist);
						}//if (type == 'pb')						
						
						hideLoader('aspb-loader');						
					}
						
	url = getAbsPath('alera') + url;
	var pars = 'fnc=' + theFunction + '&params=' + escape('&did=' + theParams + '&site=' + aspb)
	var myAjax = new Ajax.Request(url, {
				  method: 'get', 
				  parameters: pars, 
				  onCreate: function() {showLoader('aspb-loader');}, 
				  onSuccess:success, 
				  onFailure:failure, 
				  onComplete:completed
				 });							
}