function ajItemRatings(idx,lib,shop)
{
	document.getElementById('itRate'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itRate'+idx;
	obj.dataSet = 'itRate'+idx;
	obj.formField = 'itRate'+idx;
	obj.actionType='RATESTART';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajItemsList(ddx,idx,lib,shop)
{
	curPage = document.getElementById('cItemPage').value;
	
	curPage = curPage-1;
	
	if(curPage <= 0 || curPage == 999998)
		curPage = 1;
	document.getElementById('itLIST'+shop).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itLIST'+shop;
	obj.dataSet = 'itLIST'+shop;
	obj.formField = 'itLIST'+shop;
	obj.actionType='ITEMLIST';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&dlid='+ddx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	
}
function ajItemP(ddx,idx,lib,shop,stp)
{
	curPage = stp;
	
	//curPage = curPage-1;
	
	if(curPage <= 0)
		curPage = 1;
	document.getElementById('itLIST'+shop).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
	obj.shop = shop;
	obj.item = idx;
	obj.sBar='itLIST'+shop;
	obj.dataSet = 'itLIST'+shop;
	obj.formField = 'itLIST'+shop;
	obj.actionType='ITEMLIST';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&dlid='+ddx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.useAddictFields = new Array('cItemPage','cTotalPage');
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	return false;
}
function ajItemBrand(idx,lib,shop)
{
	document.getElementById('itmBrand'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmBrand'+idx;
	obj.dataSet = 'itmBrand'+idx;
	obj.formField = 'itmBrand'+idx;
	obj.actionType='ITEMBRAND';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajRecomendedItem(lib,shop)
{
	document.getElementById('recomendID').innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = '';
	obj.sBar='recomendID';
	obj.dataSet = 'recomendID';
	obj.formField = 'recomendID';
	obj.actionType='ITEMRECOMENDATION';
	obj.objectParams = '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajItemPath(idx,lib,shop)
{
	document.getElementById('itmPath'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmPath'+idx;
	obj.dataSet = 'itmPath'+idx;
	obj.formField = 'itmPath'+idx;
	obj.actionType='ITEMPATH';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajBrandPath(brandID,classID,lib,shop)
{
	document.getElementById('brdPath'+brandID).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = '';
	obj.sBar='brdPath'+brandID;
	obj.dataSet = 'brdPath'+brandID;
	obj.formField = 'brdPath'+brandID;
	obj.actionType='BRANDPATH';
	obj.objectParams = '&brand='+brandID;
	obj.objectParams = '&class='+classID;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajItemRating(idx,lib,shop)
{
	document.getElementById('itmRating'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmRating'+idx;
	obj.dataSet = 'itmRating'+idx;
	obj.formField = 'itmRating'+idx;
	obj.actionType='ITEMRATING';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajItemCommentP(idx,lib,shop,stp)
{
	curPage = stp;
	
	//curPage = curPage-1;
	
	if(curPage <= 0)
		curPage = 1;
	document.getElementById('itmComment'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmComment'+idx;
	obj.dataSet = 'itmComment'+idx;
	obj.formField = 'itmComment'+idx;
	obj.actionType='ITEMCOMMENT';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.useAddictFields = new Array('cItemPage','cTotalPage');
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	return false;
}

function ajItemComment(idx,lib,shop)
{
	curPage = document.getElementById('cItemPage').value;
	
	curPage = curPage-1;
	
	if(curPage <= 0)
		curPage = 1;
	document.getElementById('itmComment'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmComment'+idx;
	obj.dataSet = 'itmComment'+idx;
	obj.formField = 'itmComment'+idx;
	obj.actionType='ITEMCOMMENT';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.useAddictFields = new Array('cItemPage','cTotalPage');
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	
}
function ajBrandComment(bid,bbid,lib,shop)
{
	curPage = document.getElementById('cItemPage').value;
	
	curPage = curPage-1;
	
	if(curPage <= 0)
		curPage = 1;
	document.getElementById('brdComment'+bbid).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = bbid;
	obj.sBar='brdComment'+bbid;
	obj.dataSet = 'brdComment'+bbid;
	obj.formField = 'brdComment'+bbid;
	obj.actionType='BRANDCOMMENT';
	obj.objectParams = '&brand='+bid;
	obj.objectParams += '&brandid='+bbid;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.useAddictFields = new Array('cItemPage','cTotalPage');
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	
}
function ajBrandCommentP(bid,bbid,lib,shop,stp)
{
	curPage = stp;
	
	//curPage = curPage-1;
	
	if(curPage <= 0)
		curPage = 1;
	document.getElementById('brdComment'+bbid).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = bbid;
	obj.sBar='brdComment'+bbid;
	obj.dataSet = 'brdComment'+bbid;
	obj.formField = 'brdComment'+bbid;
	obj.actionType='BRANDCOMMENT';
	obj.objectParams = '&brand='+bid;
	obj.objectParams += '&brandid='+bbid;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&sval='+curPage;
	obj.useAddictFields = new Array('cItemPage','cTotalPage');
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequestPageable(obj);
	return false;
}
function ajItemCommentCount(idx,lib,shop)
{
	document.getElementById('itmCommentCount'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itmCommentCount'+idx;
	obj.dataSet = 'itmCommentCount'+idx;
	obj.formField = 'itmCommentCount'+idx;
	obj.actionType='COMMENTCOUNT';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	
}
function ajBrandsRatings(idx,lib,shop)
{
	document.getElementById('itBrand'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itBrand'+idx;
	obj.dataSet = 'itBrand'+idx;
	obj.formField = 'itBrand'+idx;
	obj.actionType='RATEBRAND';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','OK','error');
	ajCatalogRequest(obj);
	
}
function ajPopularBrands(idx,lib,shop)
{
	document.getElementById('itPopular'+idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
		obj.shop = shop;
	obj.item = idx;
	obj.sBar='itPopular'+idx;
	obj.dataSet = 'itPopular'+idx;
	obj.formField = 'itPopular'+idx;
	obj.actionType='POPBRANDS';
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.StatusText = new Array('loading...','OK','error');
	ajCatalogRequest(obj);
	
}
function ajStatistic(idx)
{
	document.getElementById(idx).innerHTML = '<img src="/lib/images/tiny_red.gif" border="0">';
	var obj = new Object();
	obj.libraryRoot = 'lib';
	obj.response='';
		obj.shop = '';
	obj.item = '';
	obj.sBar=idx;
	obj.dataSet = idx;
	obj.actionType='DICTSTAT';
	
	obj.StatusText = new Array('loading...','ok','error');
	ajStatRequest(obj);
	
}
function ajCatalogRequest(obj)
{
	if(obj.response == '')
	{
	
	 var req = new xmlHttp(obj.dataSet,'','');
	 urel = '/'+obj.libraryRoot+'/xml/catRequest.xml.php?action='+URLEncode(obj.actionType)+obj.objectParams;
 
	    req.configure(urel,obj.sBar,obj.StatusText[0],obj.StatusText[1],obj.StatusText[2]);
	    req.setAddictField('actionType',obj.actionType);
	    req.setAddictField('libraryRoot',obj.libraryRoot);
	    req.setAddictField('shop',obj.shop);
	    req.setAddictField('callscript',urel);
	    req.setAddictField('item',obj.item);
	    
	    req.callAsync = true; 
	    req.load(urel);
	    return req;
	}
	else
	{
		
		obj.formField.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'+obj.dataText+'</table>';
		if(obj.actionType == 'ITEMFEEDBACK')
		{
			ajItemCommentCount(obj.item,obj.libraryRoot,obj.shop);
			ajItemComment(obj.item,obj.libraryRoot,obj.shop);
			ajItemBrand(obj.item,obj.libraryRoot,obj.shop);
			
		}
	}
}
function ajCatalogRequestSync(obj)
{
	if(obj.response == '')
	{
	
	 var req = new xmlHttp(obj.dataSet,'','');
	 urel = '/'+obj.libraryRoot+'/xml/catRequest.xml.php?action='+URLEncode(obj.actionType)+obj.objectParams;
 
	    req.configure(urel,obj.sBar,obj.StatusText[0],obj.StatusText[1],obj.StatusText[2]);
	    req.callAsync = false; 
	    req.load(urel);
	    return req;
	}
	else
	{
		obj.formField.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'+obj.dataText+'</table>';
	}
}
function ajCatalogRequestPageable(obj)
{
	if(obj.response == '')
	{
	
	 var req = new xmlHttp(obj.dataSet,'','');
	 urel = '/'+obj.libraryRoot+'/xml/catRequest.xml.php?action='+URLEncode(obj.actionType)+obj.objectParams;

	    req.configure(urel,obj.sBar,obj.StatusText[0],obj.StatusText[1],obj.StatusText[2]);
	    
	    if(obj.useAddictFields != null)
	    {
	    	
	    	req.setAddictField('afields',obj.useAddictFields);
	    	for( i = 0; i < obj.useAddictFields.length; i++)
	    	{
	    		req.setAddictField(obj.useAddictFields[i],document.getElementById(obj.useAddictFields[i]));
	    	}
	    }
	   
	    req.callAsync = true; 
	    req.load(urel);
	    return req;
	}
	else
	{
	
		if(obj.afields != null)
		{
			var avr = explode(",",obj.afields);
			
			for(i =0; i < avr.length; i++)
			{
				document.getElementById(avr[i]).value = response.getElementsByTagName(avr[i])[0].firstChild.data;
			}
		}
		
		obj.formField.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'+obj.dataText+'</table>';
	}
}
function ajStatRequest(obj)
{
	if(obj.response == '')
	{
	
	 var req = new xmlHttp(obj.dataSet,'','');
	 urel = '/'+obj.libraryRoot+'/xml/statRequest.xml.php?action='+URLEncode(obj.actionType);

	    req.configure(urel,obj.sBar,obj.StatusText[0],obj.StatusText[1],obj.StatusText[2]);
	    req.callAsync = true; 
	    req.load(urel);
	    return req;
	}
	else
	{
		obj.formField.innerHTML = '<table width="100%" cellpadding="2" cellspacing="1" border="0">'+obj.dataText+'</table>';
	}
}
function ajSendFeedback(idx,shop,lib,txtid,rateid,usrid)
{
	var rid = document.getElementsByName(rateid);
	var tid = document.getElementById(txtid);

	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
	obj.sBar='cmess'+idx;
	obj.dataSet = 'cmess'+idx;
	obj.formField = 'cmess'+idx;
	obj.actionType='ITEMFEEDBACK';
	obj.shop = shop;
	obj.item = idx;
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&usr='+usrid;
	obj.objectParams += '&rate='+URLEncode(getCheckedValue(rid));
	obj.objectParams += '&msg='+URLEncode(tid.value);
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	closeCodeBlock('cblock'+idx);
	tid.value = '';
	document.getElementById('bterrID').style.display='none';
	document.getElementById('btcmtID').style.display='none';
}

function ajSendError(idx,shop,lib,txtid,usrid)
{
	var tid = document.getElementById(txtid);

	var obj = new Object();
	obj.libraryRoot = lib;
	obj.response='';
	obj.sBar='cerrs'+idx;
	obj.dataSet = 'cerrs'+idx;
	obj.formField = 'cerrs'+idx;
	obj.actionType='ITEMERROR';
	obj.shop = shop;
	obj.item = idx;
	obj.objectParams = '&clid='+idx;
	obj.objectParams += '&shopid='+shop;
	obj.objectParams += '&usr='+usrid;
	obj.objectParams += '&msg='+URLEncode(tid.value);
	obj.StatusText = new Array('loading...','ok','error');
	ajCatalogRequest(obj);
	closeCodeBlock('cerrblc'+idx);
	tid.value = '';
	
}