/*  Start /_templates/roottemplate/scripts/roottemplate.js */

swfobject.addLoadEvent(function(){

	if($('right')) {
		iDocHeight = document.viewport.getHeight();
		iMainHeight = $('main_container').getHeight()+1;
		if(iDocHeight > iMainHeight) {
			iHeight = iDocHeight;
		
			if($('right').className=='right') {
				iMinHeight= 273; //ivm met padding is deze 2x14px groter
			}else{
				iMinHeight= 245;
			}
			iHeight = iHeight-iMinHeight;
			
		}else{
			iHeight = iMainHeight;
		}
			
		$('right').style.height = iHeight+'px';
	}
});

function showImg(element) {
	$(element).up(1).show();
}

/*function hidePageCount() {
	if($('pagecount_ov')) {
		iCount = $('counter').innerHTML;
		if(iCount == 0 || iCount == 1 ) {
			var productCountElements = $$('.pagecount_overall#product_count');
			productCountElements.each(function(item) {
			//alert(item+ 'test');
				item.hide();
			});			
			
			//$('product_count').hide();
		}
	}
	
	//
}
*/

function hidePageCount() {
	if($('pagecount_ov')) {
		iCount = $('counter').innerHTML;
				
		var productCountElements = $$('.pagecount_overall'); // div met pagecount en productcount
		productCountElements.each(function(item) {
			if(iCount == 0 || isNaN(iCount) ) {	// isNaN check voor als variabele niet vervangen wordt doordat core repeat niet uitgevoerd wordt ivm met geen resultaten uit query
				removeElementBySelector(item,'id','pagecount_ov');
				removeElementBySelector(item,'id','product_count');
			} else if(iCount == 1) {
				removeElementBySelector(item,'id','pagecount_ov');
			}
		});
	}
	
			
	//
}

function removeElementBySelector (parentitem,selector,value) {
			var Elements = parentitem.getElementsBySelector('['+selector+'="'+value+'"]');
				Elements.each(function(element) {
					element.hide();				
				});
}

function updatePage(sVal){
	$('search_page_count').value = sVal;
	document.main_search.submit();
}


document.observe("dom:loaded", function() {
	$('main_container').style.overflow = 'hidden';
	hidePageCount();  

});

function toLocation(location) {
	window.location=(PGX.Path + location);
}

/*  End /_templates/roottemplate/scripts/roottemplate.js */

