var expandFirstItemAutomatically = false;	// Expand first menu item automatically ?
var initMenuIdToExpand = false;	// Id of menu item that should be initially expanded. the id is defined in the <li> tag.
var expandMenuItemByUrl = true;	// Menu will automatically expand by url - i.e. if the href of the menu item is in the current location, it will expand

var initialMenuItemAlwaysExpanded = true;

var dhtmlgoodies_slmenuObj;
var divToScroll = false;
var ulToScroll = false;	
var divCounter = 1;
var otherDivsToScroll = new Array();
var divToHide = false;
var parentDivToHide = new Array();
var ulToHide = false;
var offsetOpera = 0;
if(navigator.userAgent.indexOf('Opera')>=0)offsetOpera=1;	
var slideMenuHeightOfCurrentBox = 0;
var objectsToExpand = new Array();
var initExpandIndex = 0;
var alwaysExpanedItems = new Array();

//Ð´²Ëµ¥
function showmenu() {
document.write("<div id='side_menu'>");
document.write("<ul id='nav'>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Browse by top20 artists</b></font></a></li>");
document.write("<ul id='sub1'>");
document.write("<li><a target='notelist' href='showall.php?artist=Ande Worhol'>Ande Worhol</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Claude Monet'>Claude Monet</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Deigo Rivera'>Deigo Rivera</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Edgar Degas'>Edgar Degas</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Frida Kahlo'>Frida Kahlo</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Gustav Klimt'>Gustav Klimt</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Henri Matisse'>Henri Matisse</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Joan Miro'>Joan Miro</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Jackson Pollock'>Jackson Pollock</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Jan Vermeer Van Delft'>Jan Vermeer Van Delft</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Lord Frederick Leighton'>Lord Frederick Leighton</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Leonardo da Vinci'>Leonardo da Vinci</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Marc Chagall'>Marc Chagall</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Paul Gauguinr'>Paul Gauguinr</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Paul Klee'>Paul Klee</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Pablo Picasso'>Pablo Picasso</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Rene Magritte'>Rene Magritte</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Rembrandt Harmenszoon van Rijn'>Rembrandt</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Salvador Dali'>Salvador Dali</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Vincent Van Gogh'>Vincent Van Gogh</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=Wassily Kandinsky'>Wassily Kandinsky</a></li>");
document.write("</ul>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Browse by subject</b></font></a></li>");
document.write("<ul id='sub2'>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=diptych&diptych=buy_art_oil_painting_contemporary'>diptych</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=triptich&triptich=buy_art_oil_painting_contemporary'>triptich</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=split&split=buy_art_oil_painting_contemporary'>split</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=abstract&abstract=buy_art_oil_painting_contemporary'>abstract</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=animal&animal=buy_art_oil_painting_contemporary_cat_dog_horse_pet'>animal</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=architecture&architecture=buy_art_oil_painting_contemporary'>architecture</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=beach&beach_scene=buy_art_oil_painting_contemporary'>beach scene</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=figure&figure=buy_art_oil_painting_contemporary'>figure</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=flower&flower=buy_art_oil_painting_contemporary'>floral</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=garden&flower=buy_art_oil_painting_contemporary'>garden</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=med&mediterranean=buy_art_oil_painting_contemporary'>mediterranean</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=music&music=buy_art_oil_painting_contemporary'>music</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=nude&nude=buy_art_oil_painting_contemporaryy'>nude</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=poster&poster=buy_art_oil_painting_contemporary'>poster</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=sea&seascape=buy_art_oil_painting_contemporary'>seascape</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=scenic&scenic=buy_art_oil_painting_contemporary'>scenic</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=sports&sports=buy_art_oil_painting_contemporary'>sports</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=still&stilllife=buy_art_oil_painting_contemporary'>still life</a></li>");
document.write("<li><a target='notelist' href='showroompaintingstyle.php?style=transportation&transportation=buy_art_oil_painting_contemporary'>transportation</a></li>");
document.write("</ul>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Browse 2010 collection</b></font></a></li>");
document.write("<ul id='sub3'>");
document.write("<li><a target='notelist' href='showall.php?artist=2010 abstract&2010abstract=2010 abstract oil painting reproduction'>2010 abstract</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=2010 blackandwhite&2010blackandwhite=2010 black and white oil painting reproduction'>2010 black&white</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=2010 cartoon&2010cartoon=2010 cartoon oil painting reproduction'>2010 cartoon</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=2010 flower&2010blackandwhite=2010 flower oil painting reproduction'>2010 flower</a></li>");
document.write("</ul>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Browse 07-09 collection</b></font></a></li>");
document.write("<ul id='sub4'>");
document.write("<li><a target='notelist' href='showall.php?artist=09 abstract&09 abstract=reproduction_art_oil_painting_abstract'>09 abstract</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=09 animal&09 animal=reproduction_art_oil_painting_abstract'>09 animal</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=09 Asian&09 Asian=reproduction_art_oil_painting_Asian_bottle_wine'>09 asian</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=09 still&09 still=reproduction_art_oil_painting_still_life_bottle_wine'>09 still life</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=09 dancing&09 dancing=reproduction_art_oil_painting_dancing_ballet_figure'>09 dancing</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=09 portrait poster&09 portrait poster=reproduction_oil_painting_art_09 portrait posters'>09 portrait poster</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 abstract&08 abstract=buy_art_oil_painting_abstract_color'>08 abstract</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 animal&08 animal=buy_art_oil_painting_cat_dog_cow_horse'>08 animal</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 children&08 children=buy_art_oil_painting_children_baby'>08 children</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 digital&08 digital=buy_art_oil_painting_digital'>08 digital</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 flower&08 floral=buy_art_oil_painting_floral'>08 floral</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 scenic&08 scenic=buy_art_oil_painting_seasite_landscape'>08 scenic</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 sports&08 sports=buy_art_oil_painting_sports_games_football_basketball'>08 sports</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 still life&08 still life=buy_art_oil_painting_still life'>08 still life</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 transportation&08 transportation=buy_art_oil_painting_transportation_car_ship_plane'>08 transportation</a></li>");
document.write("<li><a target='notelist' href='searchweb.php?t1=08 weapon&08 weapon=buy_art_oil_painting_weapon_soldier_tank_plane'>08 weapon</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07abstract&07abstract=buy_art_oil_painting_contemporary'>07 abstract</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07animal&07animal=buy_art_oil_painting_contemporary'>07 animal</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07barcafe&07barcafe=buy_art_oil_painting_contemporary'>07 bar cafe</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07beach scenic&07beach=buy_art_oil_painting_contemporary'>07 beach scenic</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07cowboy&07cowboy=buy_art_oil_painting_america_cow_boy'>07 cowboy</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07flower&07flower=buy_art_oil_painting_contemporary'>07 floral</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07Palette Knife1&07palette=buy_art_oil_painting_contemporary'>07 garden landscape</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07idea&07idea=buy_art_oil_painting_contemporary'>07 idea</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07music&07music=buy_art_oil_painting_contemporary'>07 music</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07nude&07nude=buy_art_oil_painting_contemporary'>07 nude</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07sports&07sports=buy_art_oil_painting_contemporary'>07 sports</a></li>");
document.write("<li><a target='notelist' href='showall.php?artist=07still&07still=buy_art_oil_painting_contemporary'>07 still life</a></li>");
document.write("</ul>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Browse by our stock</b></font></a></li>");
document.write("<ul id='sub5'>");
document.write("<li><a target='_blank' href='onedaydelivery.php?stock=buy_stock_art_oil_painting_contemporary'>one day delivery art!</a></li>");
document.write("</ul>");
document.write("<li><a href='#'><font style='font-size: 8pt'><b>Contemporary art gallery</b></font></a></li>");
document.write("<ul id='sub6'>");
document.write("<li><a target='_blank' href='dlgallery101.htm'>D&amp;L gallery wrap</a></li>");
document.write("<li><a target='_blank' href='dlgallery8101.htm'>2008 gallery wrap<i><font face='Verdana' size='1' color='#FF0000'>(new!)</font></i></a></li>");
document.write("</ul>");
document.write("</ul>");
document.write("</div>");

initSlideDownMenu();

}
	
function popMenusToShow()
{
	var obj = divToScroll;
	var endArray = new Array();
	while(obj && obj.tagName!='BODY'){
		if(obj.tagName=='DIV' && obj.id.indexOf('slideDiv')>=0){
			var objFound = -1;
			for(var no=0;no<otherDivsToScroll.length;no++){
				if(otherDivsToScroll[no]==obj){
					objFound = no;		
				}					
			}	
			if(objFound>=0){
				otherDivsToScroll.splice(objFound,1);	
			}		
		}	
		obj = obj.parentNode;
	}	
}

function showSubMenu(e,inputObj)
{

	if(this && this.tagName)inputObj = this.parentNode;
	if(inputObj && inputObj.tagName=='LI'){
		divToScroll = inputObj.getElementsByTagName('DIV')[0];
		for(var no=0;no<otherDivsToScroll.length;no++){
			if(otherDivsToScroll[no]==divToScroll)return;
		}			
	}
	hidingInProcess = false;
	if(otherDivsToScroll.length>0){
		if(divToScroll){				
			if(otherDivsToScroll.length>0){
				popMenusToShow();
			}
			if(otherDivsToScroll.length>0){	
				autoHideMenus();
				hidingInProcess = true;
			}
		}	
	}		
	if(divToScroll && !hidingInProcess){
		divToScroll.style.display='';
		otherDivsToScroll.length = 0;
		otherDivToScroll = divToScroll.parentNode;
		otherDivsToScroll.push(divToScroll);	
		while(otherDivToScroll && otherDivToScroll.tagName!='BODY'){
			if(otherDivToScroll.tagName=='DIV' && otherDivToScroll.id.indexOf('slideDiv')>=0){
				otherDivsToScroll.push(otherDivToScroll);
									
			}
			otherDivToScroll = otherDivToScroll.parentNode;
		}			
		ulToScroll = divToScroll.getElementsByTagName('UL')[0];
		if(divToScroll.style.height.replace('px','')/1<=1)scrollDownSub();
	}	
	

}



function autoHideMenus()
{
	if(otherDivsToScroll.length>0){
		divToHide = otherDivsToScroll[otherDivsToScroll.length-1];
		parentDivToHide.length=0;
		var obj = divToHide.parentNode.parentNode.parentNode;
		while(obj && obj.tagName=='DIV'){			
			if(obj.id.indexOf('slideDiv')>=0)parentDivToHide.push(obj);
			obj = obj.parentNode.parentNode.parentNode;
		}
		var tmpHeight = (divToHide.style.height.replace('px','')/1 - slideMenuHeightOfCurrentBox);
		if(tmpHeight<0)tmpHeight=0;
		if(slideMenuHeightOfCurrentBox)divToHide.style.height = tmpHeight  + 'px';
		ulToHide = divToHide.getElementsByTagName('UL')[0];
		slideMenuHeightOfCurrentBox = ulToHide.offsetHeight;
		scrollUpMenu();		
	}else{
		slideMenuHeightOfCurrentBox = 0;
		showSubMenu();			
	}
}


function scrollUpMenu()
{

	var height = divToHide.offsetHeight;
	height-=15;
	if(height<0)height=0;
	divToHide.style.height = height + 'px';

	for(var no=0;no<parentDivToHide.length;no++){	
		parentDivToHide[no].style.height = parentDivToHide[no].getElementsByTagName('UL')[0].offsetHeight + 'px';
	}
	if(height>0){
		setTimeout('scrollUpMenu()',5);
	}else{
		divToHide.style.display='none';
		otherDivsToScroll.length = otherDivsToScroll.length-1;
		autoHideMenus();			
	}
}	

function scrollDownSub()
{
	if(divToScroll){			
		var height = divToScroll.offsetHeight/1;
		var offsetMove =Math.min(15,(ulToScroll.offsetHeight - height));
		height = height +offsetMove ;
		divToScroll.style.height = height + 'px';

		for(var no=1;no<otherDivsToScroll.length;no++){
			var tmpHeight = otherDivsToScroll[no].offsetHeight/1 + offsetMove;
			otherDivsToScroll[no].style.height = tmpHeight + 'px';
		}			
		if(height<ulToScroll.offsetHeight)setTimeout('scrollDownSub()',5); else {
			divToScroll = false;
			ulToScroll = false;
			if(objectsToExpand.length>0 && initExpandIndex<(objectsToExpand.length-1)){
				initExpandIndex++;
				
				showSubMenu(false,objectsToExpand[initExpandIndex]);
			}
		}
	}
}
	
function initSubItems(inputObj,currentDepth)
{		
	divCounter++;		
	var div = document.createElement('DIV');	// Creating new div		
	div.style.overflow = 'hidden';	
	div.style.position = 'relative';
	div.style.display='none';
	div.style.height = '1px';
	div.id = 'slideDiv' + divCounter;
	div.className = 'slideMenuDiv' + currentDepth;		
	inputObj.parentNode.appendChild(div);	// Appending DIV as child element of <LI> that is parent of input <UL>		
	div.appendChild(inputObj);	// Appending <UL> to the div
	var menuItem = inputObj.getElementsByTagName('LI')[0];
	while(menuItem){
		if(menuItem.tagName=='LI'){
			var aTag = menuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth'+currentDepth;	
			var subUl = menuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				initSubItems(subUl[0],currentDepth+1);					
			}
			aTag.onclick = showSubMenu;				
		}			
		menuItem = menuItem.nextSibling;						
	}		
}

function initSlideDownMenu()
{
	dhtmlgoodies_slmenuObj = document.getElementById('side_menu');
	dhtmlgoodies_slmenuObj.style.visibility='visible';
	var mainUl = dhtmlgoodies_slmenuObj.getElementsByTagName('UL')[0];		
	var mainMenuItem = mainUl.getElementsByTagName('LI')[0];
	mainItemCounter = 1;
	while(mainMenuItem){			
		if(mainMenuItem.tagName=='LI'){
			var aTag = mainMenuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth1';	
			var subUl = mainMenuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				mainMenuItem.id = 'mainMenuItem' + mainItemCounter;
				initSubItems(subUl[0],2);
				aTag.onclick = showSubMenu;
				aTag.href = 'javascript:void(null)';
				mainItemCounter++;
			}				
		}			
		mainMenuItem = mainMenuItem.nextSibling;	
	}		
	
	if(location.search.indexOf('mainMenuItemToSlide')>=0){
		var items = location.search.split('&');
		for(var no=0;no<items.length;no++){
			if(items[no].indexOf('mainMenuItemToSlide')>=0){
				values = items[no].split('=');
				showSubMenu(false,document.getElementById('mainMenuItem' + values[1]));	
				initMenuIdToExpand = false;				
			}
		}			
	}else if(expandFirstItemAutomatically>0){
		if(document.getElementById('mainMenuItem' + expandFirstItemAutomatically)){
			showSubMenu(false,document.getElementById('mainMenuItem' + expandFirstItemAutomatically));
			initMenuIdToExpand = false;
		}
	}

	if(expandMenuItemByUrl)
	{
		var aTags = dhtmlgoodies_slmenuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){
			var hrefToCheckOn = aTags[no].href;	
			if(location.href.indexOf(hrefToCheckOn)>=0 && hrefToCheckOn.indexOf('#')<hrefToCheckOn.length-1){
				initMenuIdToExpand = false;
				var obj = aTags[no].parentNode;
				while(obj && obj.id!='side_menu'){
					if(obj.tagName=='LI'){							
						var subUl = obj.getElementsByTagName('UL');
						if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
						if(subUl.length>0){								
							objectsToExpand.unshift(obj);
						}
					}
					obj = obj.parentNode;	
				}
				showSubMenu(false,objectsToExpand[0]);
				break;					
			}			
		}
	}
			
	if(initMenuIdToExpand)
	{
		objectsToExpand = new Array();
		var obj = document.getElementById(initMenuIdToExpand)
		while(obj && obj.id!='side_menu'){
			if(obj.tagName=='LI'){
				var subUl = obj.getElementsByTagName('UL');
				if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
				if(subUl.length>0){						
					objectsToExpand.unshift(obj);
				}
			}
			obj = obj.parentNode;	
		}
		
		showSubMenu(false,objectsToExpand[0]);

	}
		
}