function nav_menu_open(id){
	el = document.getElementById('navmenu_'+id);
	if(el.style.visibility=="hidden"){
		el.style.height="auto";
		el.style.visibility="visible";
		document.getElementById('navarrow_'+id).className="arrow_down";
	}else{
		if (el.offsetHeight>10){//open
			el.style.height="0px";
			el.style.visibility="hidden";
			document.getElementById('navarrow_'+id).className="arrow_right";
		}else{
			var myAjax = new Ajax.Updater('navmenu_'+id,current_file,
					{method: 'get', parameters:'action=update_leftcatmenu&supercatid='+id,
					onComplete:function(){
						document.getElementById('navarrow_'+id).className="arrow_down";
						resize_topban();
					}
				} );	
		}
	}
}

function filter_menu_open(id,cat_id){
	catSel=cat_id;
	catid=cat_id;
	el = document.getElementById('filtermenu_'+id);
	filters=document.getElementById('filterhistory').innerHTML;
	
	if(el.style.visibility=="hidden"){
		el.style.height="auto";
		el.style.visibility="visible";
		document.getElementById('filterarrow_'+id).className="arrow_down";
	}else{
		if (el.offsetHeight>10){//open
			el.style.height="0px";
			el.style.visibility="hidden";
			document.getElementById('filterarrow_'+id).className="arrow_right";
		}else{
			var myAjax = new Ajax.Updater('filtermenu_'+id,current_file,
					{method: 'get', parameters:'action=update_leftfiltermenu&filtertypeid='+id+'&filters='+filters,
					onComplete:function(){
						document.getElementById('filterarrow_'+id).className="arrow_down";
						resize_topban();	
					}
				} );	
		}
	}
}

function history_menu_open(id){
	el = document.getElementById('historymenu_'+id);
	if (el.offsetHeight>10){//open
		el.style.height="0px";
		el.style.visibility="hidden";
		document.getElementById('historyarrow_'+id).className="arrow_right";
	}else{
		var myAjax = new Ajax.Updater('historymenu_'+id,current_file,
				{method: 'get', parameters:'action=update_lefthistorymenu&menu='+id,
				onComplete:function(){
					el.style.height="auto";
					el.style.visibility="visible";
					document.getElementById('historyarrow_'+id).className="arrow_down";
					resize_topban();
				}
			} );	
	}	
}

function nav_menu_click(id, name, num , total, cat_id){
	if(current_file=="/index.php"){
		document.getElementById('hidebox').style.visibility="visible";
		document.getElementById('WaitMessage').style.visibility="visible";
		document.getElementById('filterhistory').innerHTML="";
		catid='new';
		if(total!=0){
			slider4.setValue(num/(total-1));
			slidepos = Math.round((num/(total-1))/slider4.maximum*(document.getElementById('scrollable').scrollWidth-document.getElementById('scrollable').offsetWidth));		
		}
		if(curSel=="0"){
			catid='new';	
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			document.getElementById('search_input_id').value="";
			curSel = id;
		} else if(curSel==id){
			document.getElementById('search_input_id').value="";
		} else {
			catid='new';
			if(curSel!="0"){changeSel(curSel)};
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			document.getElementById('search_input_id').value="";
			curSel = id;
		}
		pgnumber=1;
		catid=cat_id;
		name_adj=name.replace(/&/g,'-AND-',name);
		var myAjax = new Ajax.Updater('ProductListing','index.php', 
					{method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&catname='+name_adj+'&show='+showy, 
					onComplete:function(){
											catSel=cat_id;
											dhtmlHistory.add("scatid="+curSel+":"+"catid="+cat_id, cat_id+"_"+cat_id+"_"+name);
											resize_topban();
											}
				
			});
		var myAjax = new Ajax.Updater('CategoryList',current_file,
				{method: 'get', parameters:'action=draw_leftcatmenu&supercatid='+curSel+'&catid='+catid
				} );
	}else{
		window.location.href="/index.php/#scatid="+id+":catid="+cat_id;
	}
}

function nav_menu_product_click(id, name, num , total, cat_id, productid){
	if(current_file=="/index.php"){
		document.getElementById('hidebox').style.visibility="visible";
		document.getElementById('WaitMessage').style.visibility="visible";
		document.getElementById('filterhistory').innerHTML="";
		catid='new';
		if(total!=0){
			slider4.setValue(num/(total-1));
			slidepos = Math.round((num/(total-1))/slider4.maximum*(document.getElementById('scrollable').scrollWidth-document.getElementById('scrollable').offsetWidth));		
		}
		if(curSel=="0"){
			catid='new';	
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			document.getElementById('search_input_id').value="";
			curSel = id;
		} else if(curSel==id){
			document.getElementById('search_input_id').value="";
		} else {
			catid='new';
			if(curSel!="0"){changeSel(curSel)};
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			document.getElementById('search_input_id').value="";
			curSel = id;
		}
		pgnumber=1;
		catid=cat_id;
		name_adj=name.replace(/&/g,'-AND-',name);
		var myAjax = new Ajax.Updater('ProductListing','index.php', {method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&catname='+name_adj+'&show='+showy+'&productid='+productid,
									  onComplete:function(){
										resize_topban();
									  }
						} );
		
		var myAjax = new Ajax.Updater('CategoryList',current_file,
				{method: 'get', parameters:'action=draw_leftcatmenu&supercatid='+curSel+'&catid='+catid
				} );
	}else{
		window.location.href="/index.php/#scatid="+id+":catid="+cat_id+":prodid="+productid;
	}
}

function addfilter(filterid){
	document.getElementById('hidebox').style.visibility="visible";
	document.getElementById('WaitMessage').style.visibility="visible";
	var catid=catSel;
	document.getElementById('filterhistory').innerHTML = document.getElementById('filterhistory').innerHTML + filterid+'_';
	filters=document.getElementById('filterhistory').innerHTML;
	dhtmlHistory.add("scatid="+curSel+":catid="+catSel+":filters="+filters);
	
		var myAjax = new Ajax.Updater('ProductListing','index.php', {method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy+'&filters='+filters,
								onComplete : function(){
									resize_topban();	
								}	} );
		
		var myAjax = new Ajax.Updater('CategoryList',current_file,
				{method: 'get', parameters:'action=draw_leftcatmenu&supercatid='+curSel+'&catid='+catid+'&filters='+filters
							} );
}

function removefilter(filterid){
	document.getElementById('hidebox').style.visibility="visible";
	document.getElementById('WaitMessage').style.visibility="visible";
	var catid=catSel;
	filters=document.getElementById('filterhistory').innerHTML;
	document.getElementById('filterhistory').innerHTML="";
	ar_filter=filters.split("_");
	
	for(x=0; x < ar_filter.length; x++){
		if (ar_filter[x]==filterid){
			removed = ar_filter.splice(x,1);
		}
	}
	
	for(x=0; x < ar_filter.length; x++){
		if (x==0){
			document.getElementById('filterhistory').innerHTML=ar_filter[x];
		}else{
			document.getElementById('filterhistory').innerHTML=document.getElementById('filterhistory').innerHTML+'_'+ar_filter[x];
		}
	}
	
	filters=document.getElementById('filterhistory').innerHTML;
	ar_filter=filters.split("_");
	if(ar_filter.length>1){
		dhtmlHistory.add("scatid="+curSel+":catid="+catSel+":filters="+filters, filters);
	}else{
		dhtmlHistory.add("scatid="+curSel+":catid="+catSel, filters);
	}
	
	var myAjax = new Ajax.Updater('ProductListing','index.php', {method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy+'&filters='+filters,
					onComplete : function(){
						resize_topban();							
					}	} );
	
	var myAjax = new Ajax.Updater('CategoryList',current_file,
				{method: 'get', parameters:'action=draw_leftcatmenu&supercatid='+curSel+'&catid='+catid+'&filters='+filters
				} );
}