var objMessageBox = new DHL.UTIL.MESSAGEBOX(document);
var objStatusHttpRequest = new DHL.NET.HTTPREQUEST();
var objModelListHttpRequest = new DHL.NET.HTTPREQUEST();
var objThemeHttpRequest = new DHL.NET.HTTPREQUEST();
var blnIgnoreResponse = false;
var blnHaveThemeShow = false;
var objLastNiche = null;
var arrNiche = null;
var arrNicheOrder = null;
var arrSubNiche = null;
var blnHdModels = false;

var blnCustomSearchOptions = false;
var oItemList = new Object();
oItemList.iVideoQuality = 0;
oItemList['niches'] = new Object();
oItemList.nbNiches = 0;

var arrDisplayedModel = new Array();
var arrOverImage = new Array();

var strModellistClassName = "largeModelList";
var blnLoadingModelList = false;
objMessageBox.addListener(DHL.UTIL.MESSAGEBOX.EVENT_HIDE, function(){
	blnIgnoreResponse = true;
});

var MODELLIST_SEARCHOPTION_AGE = new Object();
MODELLIST_SEARCHOPTION_AGE[1] = 20;
MODELLIST_SEARCHOPTION_AGE[3] = 30;
var MODELLIST_SEARCHOPTION_AGE_YOUNG = 1;
var MODELLIST_SEARCHOPTION_AGE_MIDDLE = 2;
var MODELLIST_SEARCHOPTION_AGE_MILF = 3;


function getModellistClassName() {
/**
 *
 * Define The modelllist Class Name
 */
	if (window.innerWidth) {
		var WIDTH = window.innerWidth;
	}
	else {
		var WIDTH = document.body.clientWidth;
	}
	
	strModellistClassName = "largeModelList";
}

/**
 *
 */
if (document.layers) {
	// Netscape
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
} else if (document.all) {
	// Internet Explorer
	document.onmousemove = captureMousePosition;
} else if (document.getElementById) {
	// Netcsape 6
	document.onmousemove = captureMousePosition;
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function dhlBuy(){
	objMessageBox.alert('You need to add funds to your account to access this feature');
}

function captureMousePosition(e) {
	 if (document.layers) {
		  xMousePos = e.pageX;
		  yMousePos = e.pageY;
		  xMousePosMax = window.innerWidth+window.pageXOffset;
		  yMousePosMax = window.innerHeight+window.pageYOffset;
	 }
	 else if (document.all)
	 {
		  xMousePos = window.event.x+document.body.scrollLeft;
		  yMousePos = window.event.y+document.body.scrollTop;
		  xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		  yMousePosMax = document.body.clientHeight+document.body.scrollTop;
	 }
	 else if (document.getElementById)
	 {
		  xMousePos = e.pageX;
		  yMousePos = e.pageY;
		  xMousePosMax = window.innerWidth+window.pageXOffset;
		  yMousePosMax = window.innerHeight+window.pageYOffset;
	 }
}

function dhlShowDiv1(objImage, attstrContent) {
	ol_width=160;
	ol_height=120;
	
	var imgPosX = findPosX(objImage);
	var imgPosY = findPosY(objImage);
	
	var posX = Math.round(imgPosX / 142);
	ol_fixx = (posX * 142)+75;
	ol_fixy = imgPosY-75;
	dcs(attstrContent,'Info');
}

function dhlHideDiv1() {
	nd();
	return true;
}

function dhlShowDiv(objImage, attintModelId, strLabel) {
	var strOutput = '<img src="' + dhlGetModelImagePath(attintModelId) + '" width="160" height="120" border="0">' + (strLabel?'<span class="floatingLabel">' + strLabel + '</span>':'');
	dhlShowDiv1(objImage, strOutput);
}

function dhlHideDiv() {
	dhlHideDiv1();
}

function dhlRegister() {
	objMessageBox.alert('Login or Signup to access the group nude chat.');
	objMessageBox.addListener(DHL.UTIL.MESSAGEBOX.EVENT_RESPONSE, function(objMessageBox){
		if(objMessageBox.getClientResponse()) {
			redirectToRegistration();
		}
	});
}
function dhlBuy(){
	objMessageBox.alert('You need to add funds to your account to access the group nude chat.');
	objMessageBox.addListener(DHL.UTIL.MESSAGEBOX.EVENT_RESPONSE, function(objMessageBox){
		if(objMessageBox.getClientResponse()) {
			redirectToBuy();
		}
	});
}

function redirectToRegistration() {
	objRelocateUrl = new DHL.NET.URL(strRegisterUrl);
	document.location = objRelocateUrl.toString();
}

function redirectToBuy() {
	document.location = strBuyUrl;
}

function nicheExists(lstNicheId, intNicheId) {
	blnFound = false;
	if(intNicheId == 0) {
		blnFound = true;
	} else {
		var arrNiche = lstNicheId.split(",");
		//alert(arrNiche);
		for(var intI = 0; intI <= arrNiche.length && !blnFound; intI++) {
			if(
				arrNiche[intI] == intNicheId
			) {
				blnFound = true;
			}
		} 
	}
	return blnFound;
}

function hideShowBlockFromNiche(intNicheId, objRs, blnForceHide) {
	objRs.seek(0);
	
	while(arrRow = objRs.fetch()) {
		var objNode = document.getElementById(arrRow["modelId"]);
		if(objNode) {
			if(
				!blnForceHide && 
				(
					intNicheId == 0 ||
					nicheExists(arrRow['nicheList'], intNicheId) ||
					(intNicheId == 'hd' && arrRow['isHD'] == 1)
				)
			){
				objNode.parentNode.parentNode.nbElement++;
				objNode.style.display = "block";
			}
		}
	}	
}

function hideShowBlockFromSubNiche(intSubNicheId, objRs) {
	objRs.seek(0);
	
	while(arrRow = objRs.fetch()) {
		if(arrRow['siteSubNicheId'] != 0) {
			var objNode = document.getElementById(arrRow["modelId"]);
			if(objNode) {
				if(arrRow['siteSubNicheId'] == intSubNicheId){
					objNode.parentNode.parentNode.nbElement++;
					objNode.style.display = "block";
				}
			}
		}
	}
}

function changeSubNiche(objSelectedNiche, intSubNicheId) {
	if(!blnLoadingModelList) {
		if(document.getElementById("subniche-" + intSelectedSubNicheId)) {
			document.getElementById("subniche-" + intSelectedSubNicheId).className ="unselectedNiche";
		}
		if(document.getElementById("niche-" + intSelectedNicheId)) {
			document.getElementById("niche-" + intSelectedNicheId).className ="unselectedNiche";
		}

		//reset the number of displayed model
		document.getElementById("fpsContainer").nbElement = 0;
		document.getElementById("featureContainer").nbElement = 0;

		//hide all model
		for(intModelId in arrDisplayedModel) {
			var objNode = document.getElementById(intModelId);
			if(objNode && parseInt(intModelId) > 0) {
				objNode.style.display = "none";
			}
		}

		intSelectedSubNicheId = intSubNicheId;
		intSelectedNicheId = 0;
		
		if(objSubNicheRs != null) {
			hideShowBlockFromSubNiche(intSubNicheId, objSubNicheRs);
		}
		objSelectedNiche.className ="selectedNiche";
	}
	
	var objFpsContainer = document.getElementById("fpsContainer");
	var objFeatureContainer = document.getElementById("featureContainer");
	
	objFpsContainer.style.display = (objFpsContainer.nbElement >= 1? "block": "none"); 
	objFeatureContainer.style.display = (objFeatureContainer.nbElement >= 1? "block": "none");
	if(blnHaveThemeShow) {
		hideThemeShow();
	}
}

function changeNiche(objSelectedNiche, intNicheId) {
	if(!blnLoadingModelList) {
		if(document.getElementById("subniche-" + intSelectedSubNicheId)) {
			document.getElementById("subniche-" + intSelectedSubNicheId).className ="unselectedNiche";
		}
		
		if(document.getElementById("niche-" + intSelectedNicheId)) {
			document.getElementById("niche-" + intSelectedNicheId).className ="unselectedNiche";
		}
		
		//reset the number of displayed model
		document.getElementById("fpsContainer").nbElement = 0;
		document.getElementById("featureContainer").nbElement = 0;
		
		//hide all model
		for(intModelId in arrDisplayedModel) {
			var objNode = document.getElementById(intModelId);
			if(objNode && parseInt(intModelId) > 0) {
				objNode.style.display = "none";
			}
		}
		
		intSelectedNicheId = intNicheId;
		intSelectedSubNicheId = 0;
		if(objModelRs != null) {
			hideShowBlockFromNiche(intNicheId, objModelRs, false);
		}
		
		objSelectedNiche.className ="selectedNiche";
	}
	
	if(parseInt(document.getElementById("fpsContainer").nbElement) >= 1) {
		document.getElementById("fpsContainer").style.display = "block";
	}
	else {
		document.getElementById("fpsContainer").style.display = "none";
	}
	
	if(document.getElementById("featureContainer").nbElement >= 1) {
		document.getElementById("featureContainer").style.display = "block";
	}
	else {
		document.getElementById("featureContainer").style.display = "none";
	}
	
	var objFpsContainer = document.getElementById("fpsContainer");
	var objFeatureContainer = document.getElementById("featureContainer");
		
	objFpsContainer.style.display = (objFpsContainer.nbElement >= 1? "block": "none"); 
	objFeatureContainer.style.display = (objFeatureContainer.nbElement >= 1? "block": "none");
	if(blnHaveThemeShow) {
		showThemeShow();
	}
}

function requestStatusUpdate() {
	var objUrl = objCurrentUrl;
	objUrl.setPath('/shared/template/remotecall/modellist.htm');
	var strAttributes = "action=breakprivate";
	objStatusHttpRequest.open('POST', objUrl, true);
	objStatusHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	objStatusHttpRequest.setRequestHeader('Content-length', strAttributes.length);
	objStatusHttpRequest.setRequestHeader('Connection', 'close');
	objStatusHttpRequest.onreadystatechange(function(){
		receiveStatusUpdate();
	});

	objStatusHttpRequest.send(strAttributes);
		
}

function changeModelLabel(objRs) {
	if(objRs) {
		while(arrRow = objRs.fetch()) {
			var strStatus = "";
			if(arrRow['isOnShow'] == 1) {
				strStatus = "PRIVATE";
			} 
			if(arrRow['isOnBreak'] == 1) {
				strStatus = "BREAK";
			}
	
			if(objModelBlock = document.getElementById(arrRow["modelId"])) {
				arrModelBlock = dom_getElementsByTagName(objModelBlock, '*');
				arrModelBlock["modellistLabel"].innerHTML = strStatus;
			}
		}
	}
}

function receiveStatusUpdate() {
	if(
		objStatusHttpRequest.getReadyState() == 4 &&
		objStatusHttpRequest.getStatus() == 200
	) {
		eval("var arrRs = " + objStatusHttpRequest.getResponseText());
		var objRsFps = arrRs['objRs'];
		var objSubNicheFpsRs = arrRs['objSubNicheRs'];
		changeModelLabel(objRsFps);
		changeModelLabel(objSubNicheFpsRs);
	}
}

function askModellistReferesh() {
	var objUrl = objCurrentUrl;
	objUrl.setPath('/shared/template/remotecall/modellist.htm');
	
	var strAttributes = "action=refreshall";
	objModelListHttpRequest.open('POST', objUrl, true);
	objModelListHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	objModelListHttpRequest.setRequestHeader('Content-length', strAttributes.length);
	objModelListHttpRequest.setRequestHeader('Connection', 'close');
	objModelListHttpRequest.onreadystatechange(function(){
		receiveModelListUpdate();
	});

	objModelListHttpRequest.send(strAttributes);
}

function receiveModelListUpdate() {
	if(
		objModelListHttpRequest.getReadyState() == 4 &&
		objModelListHttpRequest.getStatus() == 200
	) {
		blnLoadingModelList = true;
		eval("var arrRs = " + objModelListHttpRequest.getResponseText());
		objModelRs = arrRs['objRs'];
		objSubNicheRs = arrRs['objRsSubNiche'];
		arrNiche = arrRs['arrNiche'];
		arrNicheOrder = arrRs['arrNicheOrder'];
		arrSubNiche = arrRs['arrSubNiche'];
		arrNicheTopModel = arrRs['arrTopModelsNiche'];
		arrSubNicheTopModel = arrRs['arrTopModelsSubNiche'];

		objFpsContainer = document.getElementById("fpsModelListContainer");
		objFeatureContainer = document.getElementById("featureModelListContainer");

		var arrTempNicheModel = redrawModel(objModelRs, objFpsContainer, objFeatureContainer, arrNicheTopModel);
		var arrTempSubNicheModel = redrawModel(objSubNicheRs, objFpsContainer, objFeatureContainer, arrSubNicheTopModel);
		
		//concatenate the 2 table
		var arrTempTotal = arrTempNicheModel;
		for(intModelId in arrTempSubNicheModel) {
			arrTempTotal[intModelId] =1;
		}
		if(arrDisplayedModel.length > 0) {
			removeOfflineModel(arrTempTotal);
		}
		arrDisplayedModel = arrTempTotal;
		redrawNiche();
		redrawCustomNiche();
		blnLoadingModelList = false;

		if (blnCustomSearchOptions) {
			displayCustom();
			reposition(100);
			var objContainer = document.getElementById('soptNiches');
			if (oItemList['ssNid'] && oItemList['ssNid'] > 0) {
				setSelected(oItemList['ssNid'],objContainer, 'subniche');
			} else {
				setSelected(oItemList['niches'],objContainer, 'niche');
			}
		} else {
			//if a niche is selected..
			if (	(intSelectedNicheId)  && 
					(document.getElementById('niche-'+intSelectedNicheId))
				)	changeNiche(document.getElementById('niche-'+intSelectedNicheId),intSelectedNicheId, false);
			else changeNiche(document.getElementById('niche-0'),0, false);
		}
	}
}

function redrawNiche() {
	var objNiche = document.getElementById("nicheContainer");
	var objSepTemplate = document.getElementById("imgNicheSep");
	while(objNiche.firstChild) {
		objNiche.removeChild(objNiche.firstChild);
	}
	
	if(
		intDefaultNicheId != 0 &&
		arrNiche[intDefaultNicheId]
	) {
		var arrData = arrNiche[intDefaultNicheId];
		var objSep = objSepTemplate.cloneNode(true);
		var objA = document.createElement('a');

		objA.className = "stdtitle";
		objA.style.marginLeft = "3px";
		objA.style.marginRight = "3px";
		objNiche.appendChild(objA);
		objNiche.appendChild(objSep);
		
		objA.innerHTML = arrData["displayText"];
		objA.href="#";
		objA.id="niche-" + intDefaultNicheId;
		objA.nicheId = intDefaultNicheId;
		objA.onclick = function() {
			changeNiche(this, this.nicheId, false);
			return false;
		}

		if(
			intSelectedNicheId == intDefaultNicheId &&
			intSelectedSubNicheId == 0
		) {
			objA.className = "selectedNiche";
		}
		else {
			objA.className = "unselectedNiche";
		}
		
	}
	
	var objA = document.createElement('a');
	objNiche.appendChild(objA);
	objA.id= "niche-0";
	objA.innerHTML = 'All';
	objA.href="#";
	objA.style.marginLeft = "3px";
	objA.style.marginRight = "3px";
	objA.className = "stdtitle";
	objA.onclick = function() {
		changeNiche(this, 0, false);
		return false;
	}
	
	if(
		intSelectedNicheId == 0 &&
		intSelectedSubNicheId == 0
	) {
		objA.className = "selectedNiche";
	}
	else {
		objA.className = "unselectedNiche";
	}

	var objA = document.createElement('a');
	if (blnHdModels) {
		objNiche.appendChild(objA);
	}
	objA.id= "niche-hd";
	objA.innerHTML = 'HD';
	objA.href="#";
	objA.style.marginLeft = "3px";
	objA.style.marginRight = "3px";
	objA.className = "stdtitle";
	objA.onclick = function() {
		changeNiche(this, 'hd', false);
		return false;
	}
	
	if(
		intSelectedNicheId == 'hd' &&
		intSelectedSubNicheId == 0
	) {
		objA.className = "selectedNiche";
	}
	else {
		objA.className = "unselectedNiche";
	}
	
	for(intNicheId in arrNiche) {
		if(intNicheId != intDefaultNicheId) {
			var objSep = objSepTemplate.cloneNode(true);
			var objA = document.createElement('a');
	
			objA.className = "stdtitle";
			objA.style.marginLeft = "3px";
			objA.style.marginRight = "3px";
			objNiche.appendChild(objSep);
			objNiche.appendChild(objA);
			
			objA.innerHTML = arrNiche[intNicheId]["displayText"];
			objA.href="#";
			objA.id="niche-" + intNicheId;
			objA.nicheId = intNicheId;
			objA.onclick = function() {
				changeNiche(this, this.nicheId, false);
				return false;
			}
			
			if(
				intSelectedNicheId == intNicheId &&
				intSelectedSubNicheId == 0
			) {
				objA.className = "selectedNiche";
			}
			else {
				objA.className = "unselectedNiche";
			}
		}
	}

	for(intNicheId in arrSubNiche) {
		var objSep = objSepTemplate.cloneNode(true);
		var objA = document.createElement('a');
		
		objA.className = "stdtitle";
		objA.style.marginLeft = "3px";
		objA.style.marginRight = "3px";
		objNiche.appendChild(objSep);
		objNiche.appendChild(objA);
		
		objA.innerHTML = arrSubNiche[intNicheId]["displayText"];
		objA.href="#";
		objA.id = "subniche-" + intNicheId;
		objA.nicheId = intNicheId;
		objA.onclick = function() {
			changeSubNiche(this, this.nicheId, false);
			return false;
		}
		
		if(
			intSelectedNicheId == 0 &&
			intSelectedSubNicheId == intNicheId
		) {
			objA.className = "selectedNiche";
		}
		else {
			objA.className = "unselectedNiche";
		}
	}
	var objSep = objSepTemplate.cloneNode(true);
	var objA = document.createElement('a');
	objA.href="#";
	objA.onclick = function() {
		switchSearchOptions();
		return false;
	}
	objA.id = 'custLink';
	objA.innerHTML = "More Search Options";
	objA.style.marginLeft = "3px";
	objA.style.marginRight = "3px";
	objNiche.appendChild(objSep);
	objNiche.appendChild(objA);
}

function redrawCustomNiche() {
	var objNiche = document.getElementById("customNicheContainer");
	while(objNiche.firstChild) {
		objNiche.removeChild(objNiche.firstChild);
	}
	
	var iCnt = 0;
	var iNbTotal = 0;
	for(intNicheId in arrNicheOrder) {
		iNbTotal++;
	}
	for(intNicheId in arrSubNiche) {
		iNbTotal++;
	}
	var intNbByCol = Math.ceil(Number(iNbTotal) / 3 );
	
	var objUl = document.createElement('ul');
	objUl.className = 'nicheList';
	objNiche.appendChild(objUl);
	
	for(intNicheId in arrNicheOrder) {
		var objLi = document.createElement('li');
		var objA = document.createElement('a');
		objLi.appendChild(objA);
		objUl.appendChild(objLi);
		
		objA.innerHTML = arrNicheOrder[intNicheId]["displayText"];
		objA.href="#";
		objA.id="niche-" + intNicheId;
		objA.className = "stdAll";
		objA.nicheId = intNicheId;
		objA.onclick = function() {
			addNicheToFilter(this,this.nicheId);
			return false;
		}
		iCnt++;
		if (iCnt % intNbByCol == 0 && iNbTotal > 4 ) {
			var objUl = document.createElement('ul');
			objUl.className = 'nicheList';
			objNiche.appendChild(objUl);
		}
	}
	
	for(intNicheId in arrSubNiche) {
		var objLi = document.createElement('li');
		var objA = document.createElement('a');
		objLi.appendChild(objA);
		objUl.appendChild(objLi);
		
		objA.innerHTML = arrSubNiche[intNicheId]["displayText"] ;
		objA.href="#";
		objA.id = "niche-0-" + intNicheId;
		objA.className = "stdAll";
		objA.nicheId = intNicheId;
		objA.onclick = function() {
			addNicheToFilter(this,0,this.nicheId);
			return false;
		}
		iCnt++;
	}
	
}

function removeOfflineModel(arrNewArray) {
	for(intModelId in arrDisplayedModel) {
		if(!arrNewArray[intModelId]) {
			var objModelBlock = document.getElementById(intModelId);
			if(objModelBlock && objModelBlock.parentNode) {
				//if we are hidding a themed show, move the niche to the top
				if(intModelId == 'themeShowContainer') {
					hideThemeShow();
				}
			
				if(objModelBlock.parentNode.parentNode.nbElement >= 1) {
					objModelBlock.parentNode.parentNode.nbElement--;
				}
				if(objModelBlock.parentNode.parentNode.nbElement <= 0) {
					//hide the container with the header
					objModelBlock.parentNode.parentNode.style.display = "none";
				}
				objModelBlock.parentNode.removeChild(objModelBlock);
			}
		}
	}
}

function redrawModel(objRs, fpsContainer, featureContainer, arrTopModel) {
	var objModelTemplate = document.getElementById("modelBlock");
	//change modellist class if we changed browser size
	document.getElementById("modellistContainer").className = strModellistClassName;
	
	objRs.seek(0);
	var arrTempModel = new Array();
	
	while(arrRow = objRs.fetch()) {
		//Fill a table with the list of the current displayed model
		var objContainer = null;
		if(arrRow['fmsSessionId'] == 1) { //FPS
			var objContainer = fpsContainer;
			arrTempModel[arrRow["modelId"]] = 1;
		} else if(arrRow['fmsSessionId'] == 2) { //FEATURED
			var objContainer = featureContainer;
			arrTempModel[arrRow["modelId"]] = 1;
		}
		else if(arrRow['fmsSessionId'] == 3) { //THEMED
			//we have a themed model, request themed model information to display
			askThemedRefresh();
			arrTempModel["themeShowContainer"] = 1;
		}
		var objModelBlock = document.getElementById(arrRow["modelId"]);
		//Check if we already have the model, but not in the good section (ex: Switched from FPS to Nude Chat)
		if(objContainer != null) {
			if(
				objModelBlock &&
				objModelBlock.parentNode.id != objContainer.id
			) {
				if(objModelBlock.parentNode.parentNode.nbElement >= 1) {
					objModelBlock.parentNode.parentNode.nbElement--;
				}
				if(objModelBlock.parentNode.parentNode.nbElement <= 0) {
					//hide the container with the header
					objModelBlock.parentNode.parentNode.style.display = "none";
				}
				objModelBlock.parentNode.removeChild(objModelBlock);
				objModelBlock = null;
				
			}
			if(
				objModelBlock == null || 
				!objModelBlock
			) {
				//if the header is hidden, display it since we are going to add a model
				if(objContainer.parentNode.style.display = "none") {
					objContainer.parentNode.style.display = "block";
				}
				
				var objModelBlock = objModelTemplate.cloneNode(true);
				if(arrDisplayedModel.length <= 0) {
					objContainer.appendChild(objModelBlock);
				}
				else {
					objContainer.insertBefore(objModelBlock, objContainer.firstChild);
				}
				var arrData = dom_getElementsByTagName(objModelBlock, '*');
				
				var strClassName = "tdmodellist";
				if(arrRow['isTopModel'] == 1) {
					strClassName += "-top";
				}
				else if(arrTopModel['i' + arrRow['modelId']]) {
					strClassName += "-high";
				}
				
				objModelBlock.className = strClassName;
				//Fill Block Value
				objModelBlock.id = arrRow['modelId'];
				arrData['modelNicknameText'].innerHTML = arrRow['nickName'];
				if(arrRow['image']) {
					if(arrRow["image68"] != null){
						var intImage = arrRow["image68"];
						var intPath = 68;
					}else{
						var intImage = arrRow["image"];
						var intPath = 16;
					}
					arrData['largeImage'].src = "/shared/modelImage/"+ intPath +"/" + arrRow['modelId'] + "/" + intImage;
				}
				else {
					if(arrRow['siteSubNicheId'] == 0) {
						arrData['largeImage'].src = strDefaultLargeImage;
						blnIsMale = arrRow['nicheList'].split(',');
						for(val in blnIsMale){
							if(blnIsMale[val] == 20){
								arrData['largeImage'].src = strDefaultMaleLargeImage;
							}
						}
					}
					else {
						arrData['largeImage'].src = strDefaultMaleLargeImage;
					}
				}
				//define overlay image for small design
				arrOverImage[arrRow['modelId']] = strDefaultLargeImage;
				
				if(arrRow['age']) {
					arrData['age'].innerHTML = arrRow['age'] + " yo,&nbsp;";
				}
				
				if(arrRow['nicheTitle']) {
					arrData['nicheName'].innerHTML =  arrRow['nicheTitle'];
				}
				else {
					arrData['nicheName'].innerHTML = "New";
				}

				if (arrRow['billingProfile'] && arrData['model-price']) {
					//arrData['model-price'].src = 'http://www.privatefeeds.com/shared/images/prices/price-' + arrRow['billingProfile'] + '.gif';
					arrData['model-price'].className = 'model-price-icon-' + arrRow['billingProfile'];
					arrData['model-price'].style.display = "";
				}
				
				/* 
				if (arrData['modelperf']) {
					//arrData['model-price'].src = 'http://www.privatefeeds.com/shared/images/prices/price-' + arrRow['billingProfile'] + '.gif';
					arrData['modelperf'].className = 'perf-hal-rank' + normalizeRank((arrRow['modelPerformancePerct']?arrRow['modelPerformancePerct']:0.1));
					arrData['modelperf'].style.display = "";
					objModelBlock.className = objModelBlock.className + " perf";
				*/
				
				if(arrRow['nationality']) {
					if(arrRow['nationality'].length >= 12) {
						arrRow['nationality'] = arrRow['nationality'].substr(0,10) + '...';
					} 
					//arrData['nationality'].innerHTML = "<b class=\"\">&;</b><span class=\"nicheTitleText\">" + arrRow['nationality'] + "</span>";
				}
							
				//Check if we want to display the HD image
				if(arrRow['isHD'] == 1) {
					arrData['hd'].style.display = "";
					if (arrRow['billingProfile']) {
						//arrData['hd'].className = 'hd-log';
					}
				}
				else {
					arrData['hd'].style.display = "none";
				}
				
				objContainer.parentNode.nbElement++;
			}

			//This code apply to both already drawn block and new one
			var arrData = dom_getElementsByTagName(objModelBlock, '*');
			var strLabel = "";
			if (arrRow['isOnBreak'] == 1) {
				strLabel = 'Break';
			}
			if (arrRow['isOnShow'] == 1) {
				strLabel = 'Private';
			}
			//if we are in feature force  to display no label
			if(arrRow['fmsSessionId'] == 2) {
				strLabel = '';
			}
			arrData["modellistLabel"].innerHTML = strLabel;
			if(strLabel != "") {
				arrData["modellistLabel"].style.display = "block";
			}
			else {
				arrData["modellistLabel"].style.display = "none";
			}
			
			//Set the block url
			var objUrl = objCurrentUrl;
			objUrl.setPath("/" + strMainDirectory + "/feed.html");
			objUrl.setAttribute('modelId', arrRow['modelId']);
			if(arrRow['showType'] == 'DHL_FMS_SHOW::PRIVATE') {
				if(arrData['imageContainer']) {
					arrData['imageContainer'].id = "imageContainer";
					arrData['imageContainer'].href = objUrl.toString();
					arrData['imageContainer'].target = "freechat";
					arrData['modelNicknameText'].href = objUrl.toString();
					arrData['modelNicknameText'].target = "freechat";
				}
			}
			else {
				if(arrData['imageContainer']) {
					arrData['imageContainer'].id = "imageContainer";
					arrData['imageContainer'].modelId = arrRow['modelId'];
					arrData['imageContainer'].href = "javascript:goPrivate('DHL_FMS_SHOW::FEATURED',"+ arrRow['modelId'] +")";
					arrData['modelNicknameText'].href = "javascript:goPrivate('DHL_FMS_SHOW::FEATURED',"+ arrRow['modelId'] +")";
				}
			}
			
			//Decide if we display the block
			if (!blnCustomSearchOptions) { 
				if(
					( //selected and Is a subniche
						intSelectedSubNicheId != 0 && 
						arrRow['siteSubNicheId'] != 0 &&
						intSelectedSubNicheId == arrRow['siteSubNicheId']
					) ||
					( //selected nothing
						intSelectedSubNicheId == 0 &&
						intSelectedNicheId == 0 &&
						arrRow['siteSubNicheId'] == 0
					) ||
					( // selected a specific niche
						intSelectedNicheId != 0 &&
						arrRow['siteSubNicheId'] == 0 &&
						nicheExists(arrRow['nicheList'], intSelectedNicheId) 
					) ||
					( // selected a specific niche
						intSelectedNicheId == 'hd' &&
						arrRow['siteSubNicheId'] == intSelectedSubNicheId &&
						arrRow['isHD'] == 1 
					)
				) {
					if (arrRow['isHD'] == 1) {
						blnHdModels = true;
					}
					objModelBlock.style.display = "block";
				}
				else {
					objModelBlock.style.display = "none";
				}
			}
			
		}
	}
	
	var objDiv = document.createElement("div");
	fpsContainer.appendChild(objDiv);
	objDiv.style.clear = "both";
	
	var objDiv = document.createElement("div");
	featureContainer.appendChild(objDiv);
	objDiv.style.clear = "both";
	
	return arrTempModel;
}

function askThemedRefresh() {
	var objContainer = document.getElementById("themeShowContainer");

	//only do request if the container is not already displayed.
	if(!objContainer) {
		var objContainer = document.getElementById("themedTemplate").cloneNode(true);
		document.getElementById("modellistContainer").insertBefore(
			objContainer, document.getElementById("modellistContainer").firstChild
		);
		objContainer.id = "themeShowContainer";
		objContainer.style.display = "none";

		objThemeHttpRequest
		var objUrl = objCurrentUrl;
		objUrl.setPath('/shared/template/remotecall/modellist.htm');
		var strAttributes = "action=themed";
		objThemeHttpRequest.open('POST', objUrl, true);
		objThemeHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		objThemeHttpRequest.setRequestHeader('Content-length', strAttributes.length);
		objThemeHttpRequest.setRequestHeader('Connection', 'close');
		objThemeHttpRequest.onreadystatechange(function(){
			displayThemeModel();
		});
		
		objThemeHttpRequest.send(strAttributes);
	}
}

function normalizeRank(fltPerct) {
	
	var iRank = 0;
	if (fltPerct > .8) {
		iRank = 5;
	} else if (fltPerct > .6) {
		iRank = 4;
	} else if (fltPerct > .4) {
		iRank = 3;
	} else if (fltPerct > .2) {
		iRank = 2;
	} else if (fltPerct != '' && fltPerct) {
		iRank = 1;
	}
	
	var oD = new Date();
	if (oD.getDate() < 18 && iRank >= 4) {
		iRank = 2;
	} else if (oD.getDate() < 22 && iRank >= 4) {
		iRank = 3;
	} else if (oD.getDate() < 24 && iRank >= 5) {
		iRank = 4;
	}
	
	return iRank;
}

function showTimeLeft(strObjectName, intNbSecond) {
	//timerText
	obj = document.getElementById(strObjectName);
	var arrData = dom_getElementsByTagName(obj, '*');
	if(intNbSecond > 0 && obj) {
		var intNbHours = Math.floor(intNbSecond / 60 / 60);
		var intNbMinute = Math.floor((intNbSecond - intNbHours * 60 * 60) / 60);
		var intSeconde = intNbSecond - 
			(intNbHours > 0? intNbHours * 3600: 0) -
			(intNbMinute > 0? intNbMinute * 60: 0);
			
		DOM_innerHTML(arrData["timerText"], 
			(intNbHours.toString().length < 2? "0" + intNbHours: intNbHours)  + ": " +
			(intNbMinute.toString().length < 2? "0" + intNbMinute: intNbMinute) + ": "  +
			(intSeconde.toString().length < 2 ? "0" + intSeconde: intSeconde) 
		);
		window.setTimeout("showTimeLeft('" + strObjectName + "'," + (intNbSecond-1) + ")", 1000);
	}
	else if(intNbSecond == 0) {
		if(arrData["themedEnterLive"]) {
			arrData["themedEnterLive"].style.display = "block";
		}
		if(arrData["timerContainer"]) {
			arrData["timerContainer"].style.display = "none";
		}
	}
}

function hideThemeShow() {
	var objContainer = document.getElementById("themeShowContainer");
	var arrData = dom_getElementsByTagName(objContainer, '*');
	if(document.getElementById("nicheContainer")) {
		document.getElementById("nicheContainer").style.top = "5px";
	}
	
	if(arrData["themeSeparator"]) {
		arrData["themeSeparator"].style.display = "none";
	}
	objContainer.style.display = "none";
}

function showThemeShow() {
	var objContainer = document.getElementById("themeShowContainer");
	var arrData = dom_getElementsByTagName(objContainer, '*');
	if(document.getElementById("nicheContainer")) {
		document.getElementById("nicheContainer").style.top = "130px";
	}
	if(
		arrData["themeSeparator"] &&
		arrData["themeSeparator"].style.display == "none"
	) {
		arrData["themeSeparator"].style.display = "block";
	}
	objContainer.style.display = "block"
}

function displayThemeModel(arrThemeShow) {
	if(
		objThemeHttpRequest.getReadyState() == 4 &&
		objThemeHttpRequest.getStatus() == 200 
	) {
		
		var objContainer = document.getElementById("themeShowContainer");
		//if we dont find the themed container, then create one and insert it at the start of the modellist
		var arrData = dom_getElementsByTagName(objContainer, '*');
		var blnHide = false;
		
		if(objThemeHttpRequest.getResponseText() != "") {
			eval("var arrThemeShow = " + objThemeHttpRequest.getResponseText());
			arrData["themeTitle"].innerHTML = arrThemeShow["title"];
			arrData["themeDescription"].innerHTML = arrThemeShow["description"]

			arrData["lnkImage"].href = arrThemeShow["strUrl"];
			arrData["lnkImage"].target = "freechat";
			arrData["lnkPreview"].href = arrThemeShow["strUrl"];
			arrData["lnkPreview"].target = "freechat";
			arrData["lnkImageEnter"].href = arrThemeShow["strUrl"];
			arrData["lnkImageEnter"].target = "freechat";
			arrData["lnkSexShow"].href = arrThemeShow["strUrl"];
			arrData["lnkSexShow"].target = "freechat";
			arrData["lnkFeatured"].href = arrThemeShow["strUrl"];
			arrData["lnkFeatured"].target = "freechat";
			
			arrData["block"].feedUrl = arrThemeShow["strUrl"];
			arrData["block"].onclick = function() {
				freechat.document.location = this.feedUrl;
			}
			arrData["block"].style.cursor = "pointer";
	

			arrData["themeImage"].src = arrThemeShow["strImage"];
			if(arrThemeShow["freeTimeLeft"] > 0) {
				arrData["timerContainer"].style.display = "block";
				if(arrData["themedEnterLive"]) {
					arrData["themedEnterLive"].style.display = "none";
				}
			}
			else {
				arrData["timerContainer"].style.display = "none";
				if(arrData["themedEnterLive"]) {
					arrData["themedEnterLive"].style.display = "block";
				}
			}
			showTimeLeft(objContainer.id, arrThemeShow["freeTimeLeft"]);

			
			blnHaveThemeShow = true;
			
			//if we are in a sub-niche, hide it
			if(
				(
					parseInt(arrThemeShow['siteSubNicheId']) == 0 &&
					intSelectedSubNicheId == 0
				) ||
				parseInt(arrThemeShow['siteSubNicheId']) == intSelectedSubNicheId
			) {
				blnHide = false;
				showThemeShow();
			}
			else {
				blnHide = true;
			}
		}
		else if(	objContainer.style.display="block") {
			blnHide = true;
			blnHaveThemeShow = false;
		}
		
		if(blnHide) {
			hideThemeShow();
		}
	}
}

function reloadModelList() {
	var objFpsContainer = document.getElementById("fpsModelListContainer");
	var objFeatureContainer = document.getElementById("featureModelListContainer");
	var objthemeShowContainer = document.getElementById("themeShowContainer");
	
	if(objFpsContainer) {
		while(objFpsContainer.firstChild) {
			objFpsContainer.removeChild(objFpsContainer.firstChild);
		}
	}
	
	if(objFeatureContainer) {
		while(objFeatureContainer.firstChild) {
			objFeatureContainer.removeChild(objFeatureContainer.firstChild);
		}
	}
	
	if(objthemeShowContainer) {
		objthemeShowContainer.parentNode.removeChild(objthemeShowContainer);
	}
	
	arrDisplayedModel = new Array();
	askModellistReferesh();
}

function switchSearchOptions() {
	var objNicheSelector = document.getElementById('nicheContainer');
	var objSoptContainer = document.getElementById('searchBoxContainer');
	document.getElementById('fpsModelListContainer').style.marginTop = "0px";
	document.getElementById('featureModelListContainer').style.marginTop = "0px";
	
	var objFpsContainer = document.getElementById("fpsContainer");
	if (objFpsContainer.nbElement >= 1) {
		var objContainer = document.getElementById('fpsModelListContainer');
	} else {
		var objContainer = document.getElementById('featureModelListContainer');
	}

	blnCustomSearchOptions = (!blnCustomSearchOptions);
	
	if (blnCustomSearchOptions) {
		objNicheSelector.style.display = "none";
		objSoptContainer.style.display = "block";
		reposition(100);
	} else {
		objNicheSelector.style.display = "block";
		objSoptContainer.style.display = "none";
		objContainer.style.marginTop = "0px";
		intSelectedNicheId = 0;
		intSelectedSubNicheId = 0;
		//reloadModelList();
	}
}

function resetSearch() {
	var objContainer = document.getElementById('searchBoxContainer');
	cleanObject(objContainer);
	oItemList = new Object();
	oItemList.iVideoQuality = 0;
	setSelected(oItemList,objContainer);
	displayCustom();
	reposition(100);
}

function cleanObject(objContainer){
	var arrTag = objContainer.getElementsByTagName('a');
	for(var i=0; i < arrTag.length; i++) {
		arrTag[i].className = '';
	}
}

function setSelected (objSelectedObject, objContainer, strKeyName) {
	var arrTag = objContainer.getElementsByTagName('a');
	var blnAll = true;
	
	if (strKeyName) {
		for(var i=0; i < arrTag.length; i++) {
			var strId = arrTag[i].id;
			switch(strKeyName) {
				case 'niche':
					strId = strId.replace(/niche-/,'');
					if (objSelectedObject[strId]) {
						blnAll = false;
						arrTag[i].className = 'highlight';
					} else {
						arrTag[i].className = '';
					}
	
				break;
				case 'subniche':
					if (arrTag[i].id == ('niche-0-' + objSelectedObject)) {
						blnAll = false;
						arrTag[i].className = 'highlight';
					} else {
						arrTag[i].className = '';
					}
				break;
				case 'age':
					strId = strId.replace(/ages-/,'');
					if (objSelectedObject[strId]) {
						blnAll = false;
						arrTag[i].className = 'highlight';
					} else {
						arrTag[i].className = '';
					}
				break;
				case 'vid':
					if (arrTag[i].id == ('vidQ-' + objSelectedObject)) {
						blnAll = false;
						arrTag[i].className = 'highlight';
					} else {
						arrTag[i].className = '';
					}
				break;
				case 'lang':
					strId = strId.replace(/lang-/,'');
					if (objSelectedObject[strId]) {
						blnAll = false;
						arrTag[i].className = 'highlight';
					} else {
						arrTag[i].className = '';
					}
				break;
			}
		}
	}
	

	if (blnAll) {
		for(var i=0; i < arrTag.length; i++) {
			if (arrTag[i].id.length <= 8) {
				arrTag[i].className = 'stdAll';
			} else {
				arrTag[i].className = '';
			}
		}
	}
	//arrTag[i].className = '';
	
}

function addNicheToFilter(objLink, vNicheId, vSubNicheId) {
	if (!oItemList['niches']) {
		oItemList['niches'] = new Object();
	}
	if ((!vSubNicheId || vSubNicheId == 0) && oItemList['ssNid'] > 0) {
		var oContainer = document.getElementById('soptNiches');
		cleanObject(oContainer);
	}
	if (vNicheId == 0 && (!vSubNicheId || vSubNicheId == 0)) {
		oItemList['niches'] = new Object();
		oItemList.nbNiches = 0;
	} else if (vNicheId == 0 && vSubNicheId) {
		oItemList.nbNiches = 0;
	} else {
		if (oItemList['niches'][vNicheId]) {
			//objLink.className = '';
			oItemList['niches'][vNicheId] = false;
			oItemList.nbNiches -= 1;
		} else {
			oItemList['niches'][vNicheId] = true;
			//objLink.className = 'highlight';
			if(oItemList.nbNiches) {
				oItemList.nbNiches += 1;
			} else {
				oItemList.nbNiches = 1;
			}
		}
	}
	
	if (vSubNicheId > 0 && oItemList['ssNid'] && oItemList['ssNid'] == vSubNicheId) {
		oItemList['ssNid'] = 0;
		//objLink.className = '';
	} else if (vSubNicheId > 0) {
		var oContainer = document.getElementById('soptNiches');
		cleanObject(oContainer);
		oItemList['niches'] = new Object();
		oItemList.nbNiches = 0;
		//objLink.className = 'highlight';
		oItemList['ssNid'] = vSubNicheId;
	} else {
		oItemList['ssNid'] = 0;
	}
	
	var objContainer = document.getElementById('soptNiches');

	if ((!vSubNicheId || vSubNicheId == 0)) {
		setSelected(oItemList['niches'],objContainer, 'niche');
	} else {
		setSelected(oItemList['ssNid'],objContainer, 'subniche');
	}
	
	displayCustom();
	reposition(100);
}


function reposition(intHeight) {
	
	var objSearchContainer = document.getElementById("searchBoxContainer");
	var objSearchContainerTable = document.getElementById("searchTable");
	var objSearchContainerTd = document.getElementById("soptNiches");
	var objSearchContainerLink = document.getElementById("resetLink");
	
	var iNbTotal = 0;
	for(intNicheId in arrNiche) {
		iNbTotal++;
	}
	for(intNicheId in arrSubNiche) {
		iNbTotal++;
	}
	// Add a visual row to the table if necessary 
	if (iNbTotal > 15 && iNbTotal <= 18) {
		objSearchContainer.style.height = "122px";
		objSearchContainerTable.style.height = "122px";
		objSearchContainerTd.height = "120";
		objSearchContainerLink.style.marginTop = "122px";
	} else {
		objSearchContainer.style.height = "110px";
		objSearchContainerTable.style.height = "110px";
		objSearchContainerTd.height = "108";
		objSearchContainerLink.style.marginTop = "110px";
	}
}

function addAge(objLink, iAgeGroup) {
	if(!oItemList['ageGroup']) {
		oItemList['ageGroup'] = new Object();
		oItemList.nbAge = 0;
	}
	
	if (oItemList['ageGroup'][iAgeGroup]) {
		oItemList['ageGroup'][iAgeGroup] = false;
		//objLink.className = '';
		oItemList.nbAge -= 1;
	} else {
		oItemList['ageGroup'][iAgeGroup] = true;
		//objLink.className = 'highlight';
		oItemList.nbAge += 1;
	}
	var objContainer = document.getElementById('soptAges');
	setSelected(oItemList['ageGroup'],objContainer, 'age');
	displayCustom();
	reposition(100);
}
function setVideo(isHd) {
	
	if (oItemList.iVideoQuality == isHd) {
		oItemList.iVideoQuality = 0;
	} else if (oItemList.iVideoQuality != isHd && oItemList.iVideoQuality > 0) {
		oItemList.iVideoQuality = 0;
	} else {
		oItemList.iVideoQuality = isHd;
	}
	var objContainer = document.getElementById('soptVid');
	setSelected(oItemList.iVideoQuality,objContainer, 'vid');
	displayCustom();
	reposition(100);
}

function filterByNick(strNick) {
	oItemList['nick'] = strNick;
	displayCustom();
	reposition(100);
}

function addLang(objLink, iLangId) {
	if(!oItemList['lang']) {
		oItemList['lang'] = new Object();
		oItemList.nbLang = 0;
	}
	
	if (oItemList['lang'][iLangId]) {
		oItemList['lang'][iLangId] = false;
		//objLink.className = '';
		oItemList.nbLang -= 1;
	} else {
		oItemList['lang'][iLangId] = true;
		//objLink.className = 'highlight';
		oItemList.nbLang += 1;
	}
	var objContainer = document.getElementById('soptLang');
	setSelected(oItemList['lang'],objContainer, 'lang');
	displayCustom();
	reposition(100);
}

function hideShowBlockFromFilters(objRs, blnForceHide) {
	objRs.seek(0);

	while(arrRow = objRs.fetch()) {
		var objNode = document.getElementById(arrRow["modelId"]);
		if(	
			objNode && 
			getVideoQualityFilter(arrRow['isHD']) &&
			(oItemList['lang']?getMultiLangFilter(arrRow['modelTextProfileLstLanguageId']):true)
		) {
			if(
				!blnForceHide && 
				(
					getMultiNicheFilter(arrRow['nicheList'])
					&&
					(!oItemList['ssNid']?(arrRow['siteSubNicheId'] > 0?false:true):(arrRow['siteSubNicheId'] == oItemList['ssNid']))
				)
				&&
				getAgeFilter(arrRow['age'])
				&& 
				getNickFilter(arrRow['nickName'])
			){
				objNode.parentNode.parentNode.nbElement++;
				objNode.style.display = "block";
			}
		}
	}
}
function getNickFilter(strNick) {
	blnFound = false;
	if (!oItemList['nick'] ||oItemList['nick'] == '') {
		blnFound = true;
	} else {
		if (eval('strNick.search(/' + oItemList['nick'] + '/i)') == 0) {
			blnFound = true;
		}
	}
	return blnFound;
}
function getAgeFilter(iAge) {
	blnFound = false;
	if(oItemList.nbAge == 0 || !oItemList.nbAge) {
		blnFound = true;
	} else {
		var arrAges = iAge.split(",");
		for(var i = 0; i< arrAges.length && !blnFound; i++) {
			if (Number(arrAges[i]) <= MODELLIST_SEARCHOPTION_AGE[1] && oItemList['ageGroup'] && oItemList['ageGroup'][MODELLIST_SEARCHOPTION_AGE_YOUNG]) {
				blnFound = true;
			} else if (Number(arrAges[i]) > MODELLIST_SEARCHOPTION_AGE[3] && oItemList['ageGroup'] && oItemList['ageGroup'][MODELLIST_SEARCHOPTION_AGE_MILF]) {
				blnFound = true;
			} else if ( 
					oItemList['ageGroup'] &&
					oItemList['ageGroup'][MODELLIST_SEARCHOPTION_AGE_MIDDLE] && 
				(
					Number(arrAges[i]) > MODELLIST_SEARCHOPTION_AGE[1] &&
					Number(arrAges[i]) < MODELLIST_SEARCHOPTION_AGE[3]
				)
			) {
				blnFound = true;
			}
		}
	}
	return blnFound;
}
function getMultiNicheFilter(lstNicheId) {
	blnFound = false;
	if(!oItemList['niches'] || oItemList.nbNiches == 0) {
		blnFound = true;
	} else {
		var arrNiche = lstNicheId.split(",");
		//alert(arrNiche);
		for(var intI = 0; intI <= arrNiche.length && !blnFound; intI++) {
			if(
					oItemList['niches'][arrNiche[intI]] == true
			) {
				blnFound = true;
			}
		} 
	}
	return blnFound;
}
function getVideoQualityFilter(isHd) {
	blnFound = false;
	if (!oItemList.iVideoQuality || oItemList.iVideoQuality == 0) {
		blnFound = true;
	}
	if (!blnFound && oItemList.iVideoQuality && oItemList.iVideoQuality == 2 && isHd == 0 ) {
		blnFound = true;
	}
	if (!blnFound && oItemList.iVideoQuality && oItemList.iVideoQuality == 1 && isHd == 1 ) {
		blnFound = true;
	}
	return blnFound;
}
function getMultiLangFilter(lstLangId) {
	blnFound = false;
	if(!oItemList['lang'] || oItemList.nbLang == 0) {
		blnFound = true;
	} else {
		if (lstLangId) {
			var arrLangs = lstLangId.split(",");
			for(var intI = 0; intI <= arrLangs.length && !blnFound; intI++) {
				if(
						oItemList['lang'][arrLangs[intI]] == true
				) {
					blnFound = true;
				}
			}
		}
	}
	return blnFound;
}
function displayCustom() {
	if(!blnLoadingModelList) {
		//reset the number of displayed model
		document.getElementById("fpsContainer").nbElement = 0;
		document.getElementById("featureContainer").nbElement = 0;
		//hide all model
		for(intModelId in arrDisplayedModel) {
			var objNode = document.getElementById(intModelId);
			if(objNode && parseInt(intModelId) > 0) {
				objNode.style.display = "none";
			}
		}
		if(objModelRs != null) {
			hideShowBlockFromFilters(objModelRs, false);
		}
		if(objSubNicheRs  != null) {
			hideShowBlockFromFilters(objSubNicheRs , false);
		}
	}
	
	if(parseInt(document.getElementById("fpsContainer").nbElement) >= 1) {
		document.getElementById("fpsContainer").style.display = "block";
	} else {
		document.getElementById("fpsContainer").style.display = "none";
	}
	
	if(document.getElementById("featureContainer").nbElement >= 1) {
		document.getElementById("featureContainer").style.display = "block";
	} else {
		document.getElementById("featureContainer").style.display = "none";
	}

	var objContainerEmpty = document.getElementById('emptyContainer');
	if (parseInt(document.getElementById("fpsContainer").nbElement + document.getElementById("featureContainer").nbElement) > 0 ) {
		var objFpsContainer = document.getElementById("fpsContainer");
		var objFeatureContainer = document.getElementById("featureContainer");
		objContainerEmpty.style.display = "none";
			
		objFpsContainer.style.display = (objFpsContainer.nbElement >= 1? "block": "none"); 
		objFeatureContainer.style.display = (objFeatureContainer.nbElement >= 1? "block": "none");
		if(blnHaveThemeShow) {
			showThemeShow();
		}
	} else {
		objContainerEmpty.style.display = "block";
	}
}