// shw_siteSettings.js (c)2008 SugarHill Works LLC - http://www.sugarhillworks.com
var d = document;
var rootPath = "";
function getRootPath() {
	for(var i = 2; i < rootPathNum; i++) {
		rootPath += "../";
	}
	return rootPath;
}
var menuItems = new Array();

//// ********************************************************************************************************** //

//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      DO NOT EDIT ABOVE THIS LINE       ********************************* //
//// *********************************                                        ********************************* //
//// *********************************         SET SITE OPTIONS BELOW         ********************************* //
//// *********************************                                        ********************************* //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
////
//
//// THE FOLLOWING LINES AFFECT THE TITLE THAT APPEARS IN THE BROWSER WINDOW'S TITLEBAR
//// [any legal HTML text is allowed]
var defaultTitle = "Designs by Katrin Reifeiss";
var titleSeparator = " : ";
//var contactTitle = "contact";
//var bioTitle = "bio";

//// THE FOLLOWING LINES ARE USED TO BUILD THE SITE-WIDE HEADER MENU
// Each menuItem has several attributes:
// id (required) - the text that will appear as the link, the name of the file to be linked to, the name of the image(gif) if an image is to be used
//			that is, 'about' will appear in the menu or about.png will show,  and link to about.html
// image (required) - set to 1 if images are to be used - set to 0 for a text link
// submenuItems (optional) - set to a comma separated list of quote-enclosed submenu items. images not allowed.
//			or leave blank empty brakets for no submenu items , i.e. []
// 
// NOTE: menuItems link to an index.html file in the 'id' folder - i.e /about/index.hmtl
// NOTE: submenuItems link to 'item_name'.html file in the main menuitem 'id' folder' - i.e. /about/katrin.html, /about/shibori.html or use a '/' at the end to signify a directory, i.e. '2008/'
// NOTE: images are in the /mLnk/ folder of the site root and images should be named 'id'.png and 'id'_on.png - both files required - the _on.png file is for the mouse rollover event
//		See the example below and follow the pattern:
//
//		menuItems[0] = {
//			id: 'about', // should match desired link text or image name
//			image: true, // set to true if images are to be used - set to false for a text link
//			submenuItems: ['katrin', 'something'] // note: submenuItems are text-only
//		};
//
//		
menuItems[0] = {
	id: 'about', 
	image: true, 
	imageWidth: 45,
	imageHeight: 15,
	submenuItems: ['katrin', 'shibori']
};
menuItems[1] = {
	id: 'collections', 
	image: true, 
	imageWidth: 75,
	imageHeight: 15,
	submenuItems: ['2010&nbsp;collection/','custom&nbsp;designs/','color&nbsp;palette&nbsp;2010','previous&nbsp;collections/','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2009/','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;holiday&nbsp;2008/','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008/', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2007/', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2006/']
	//submenuItems: ['2010&nbsp;collection/','2009&nbsp;clothing&nbsp;+&nbsp;accessories/','custom/','past&nbsp;collections/','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;holiday&nbsp;2008/','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008/', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2007/', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2006/']
};
menuItems[2] = {
	id: 'news_events', 
	image: true, 
	imageWidth: 44, //92
	imageHeight: 15,
	submenuItems: []
};
menuItems[3] = {
	id: 'stockists', 
	image: true, 
	imageWidth: 58,
	imageHeight: 15,
	submenuItems: []
}
menuItems[4] = {
	id: 'info', 
	image: true, 
	imageWidth: 68, //35
	imageHeight: 15,
	submenuItems: []
}
menuItems[5] = {
	id: 'contact', 
	image: true, 
	imageWidth: 58,
	imageHeight: 15,
	submenuItems: []
}
menuItems[6] = {
	id: 'art', 
	image: true, 
	imageWidth: 28,
	imageHeight: 15,
	submenuItems: []
}




//// ********************************************************************************************************** //

//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      DO NOT EDIT BELOW THIS LINE       ********************************* //
//// *********************************                                        ********************************* //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //

//// ********************************************************************************************************** //


var isitIE = false;
var isitIE7 = false;
if (window.attachEvent && !window.opera) { //object-detect IE5+, exclude opera
	isitIE = true;
	if(navigator.appVersion.match(/MSIE 7/)) isitIE7 = true
}
//
//// turn off 'image toolbar' in older versions of IE
if(isitIE == true){
	document.write("<meta HTTP-EQUIV=\"imagetoolbar\" content=\"no\">");
}
//
// for IE6+ so we can use appendChild, etc...
if (!window.Node) {
	var Node = {
		ELEMENT_NODE: 1,
		ATTRIBUTE_NODE: 2,
		TEXT_NODE: 3,
		COMMENT_NODE: 8,
		DOCUMENT_NODE: 9,
		DOCUMENT_FRAGMENT_NODE: 11
	};
}

function randOrd(){
	return (Math.round(Math.random())-0.5);
}





function site_init() {
	//document.getElementsByTagName('title')[0].text = defaultTitle;
	getRootPath();
	makeMenu();
}




// these vars used in shwFade to define the ss container for image centering
// on this site, set to values from css
//var maxvpW = 568;
//var maxvpH = 425;

var maxvpW = 250; // 225 (2009)
var maxvpH = 380; // 340 (2009)





function makeMenu() {
	var menuParent = d.getElementById('hdr');
	var logoHome_p = d.createElement('p');
	var logoHome_a = d.createElement('a');
	logoHome_a.href = rootPath;
	var logoHome = new Image();
	logoHome.src = rootPath + 'img/blank.gif';
	logoHome.id = "logo";
	logoHome_p.appendChild(logoHome_a);
	logoHome_a.appendChild(logoHome);
	menuParent.appendChild(logoHome_p);
	
	var menu = d.createElement('ul');
	menu.className = 'menulist';
	menu.setAttribute('id', 'listMenuRoot');
	
	for (var i = 0; i < menuItems.length; i++) {
		menuItems[i].li = d.createElement('li');
		menuItems[i].a = d.createElement('a');
		menuItems[i].a.className = 'special';
		menuItems[i].a.id = menuItems[i].id + 'Lnk';
		var menuItemID_href = menuItems[i].id.replace(/\&nbsp;/, '_');
		menuItems[i].a.href = rootPath + menuItemID_href + '/';
		if (menuItems[i].image == false) {
			//menuItems[i].a.appendChild(d.createTextNode(menuItems[i].id));
			menuItems[i].a.innerHTML = menuItems[i].id;
		}
		else {
			menuItems[i].img = d.createElement('img');
			menuItems[i].img.style.width = menuItems[i].imageWidth + 'px';
			menuItems[i].img.style.height = menuItems[i].imageHeight + 'px';
			menuItems[i].img.src = rootPath + 'shw_menu/img/' + menuItems[i].id + '.png';
			if(!isitIE) {
				menuItems[i].img.onmouseover = function() {
					var newsrc = this.src.replace(/\.png/, '_on.png');
					this.src= newsrc;
				};
				menuItems[i].img.onmouseout = function() {
					var newsrc = this.src.replace(/_on\.png/, '.png');
					this.src= newsrc;
				};
			}
			menuItems[i].a.appendChild(menuItems[i].img);
			menuItems[i].a.style.display = "block";
			menuItems[i].a.style.overflow = "visible";
			menuItems[i].a.style.width = menuItems[i].imageWidth + 'px';
			menuItems[i].a.style.height = menuItems[i].imageHeight + 'px';
		}
		menuItems[i].li.style.display = "block";
		menuItems[i].li.style.width = menuItems[i].imageWidth + 18 + 'px'; // was 16 was 14
		menuItems[i].li.style.height = menuItems[i].imageHeight + 'px';
		menuItems[i].li.appendChild(menuItems[i].a);
		
		if (menuItems[i].submenuItems.length > 0) {
			menuItems[i].subMenu = d.createElement('ul');
			menuItems[i].subItems = new Array();
			for (var n = 0; n < menuItems[i].submenuItems.length; n++) {
				menuItems[i].subItems[n] = {
					li: d.createElement('li'),
					a: d.createElement('a')
				};
				menuItems[i].subItems[n].a.className = 'standard';
				var isDir = menuItems[i].submenuItems[n].search(/\/$/);
				//var submenuItem_href = (menuItems[i].submenuItems[n].replace('holiday&nbsp;2008', 'holiday_2008') && menuItems[i].submenuItems[n].replace('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', ''));
				//var submenuItem_href = menuItems[i].submenuItems[n].replace(/&nbsp;(?=&nbsp;)/g, ''); // replace any space with nothing, only when followed by another space
				//submenuItem_href = menuItems[i].submenuItems[n].replace(/^&nbsp;/, ''); // replace a space at the beginning of the string with nothing
				//submenuItem_href = menuItems[i].submenuItems[n].replace(/&nbsp;/, '_'); // replace any space that's left with an underscore
				var submenuItem_href = menuItems[i].submenuItems[n]
    			submenuItem_href = submenuItem_href.replace(/&nbsp;(?=&nbsp;)/g, ''); 
    			submenuItem_href = submenuItem_href.replace(/^&nbsp;/, '');
    			submenuItem_href = submenuItem_href.replace(/&nbsp;/g, '_');			
				submenuItem_href = submenuItem_href.replace(/clothing_\+_accessories/g, '');
				submenuItem_href = submenuItem_href.replace(/2009_/, '2009');
				
				submenuItem_href = submenuItem_href.replace(/previous/g, 'past');
				submenuItem_href = submenuItem_href.replace(/_collections/, '');
				
				submenuItem_href = submenuItem_href.replace(/designs/g, '');
				submenuItem_href = submenuItem_href.replace(/custom_/, 'custom');
			
				submenuItem_href = submenuItem_href.replace(/collection/g, '');
				submenuItem_href = submenuItem_href.replace(/2010_/, '2010');
				
				submenuItem_href = submenuItem_href.replace(/color_palette_2010/, 'custom/color_palette_2010');
				
				//if (menuItems[i].submenuItems) {
//					submenuItem_href = menuItems[i].submenuItems[n].replace('holiday&nbsp;2008', 'holiday_2008');
//					submenuItem_href = menuItems[i].submenuItems[n].replace('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', '');
//				};
				//var submenuItem_href = menuItems[i].submenuItems[n].replace(/\&nbsp;/, '_')
				if(isDir !== -1) {
					var linkText =  menuItems[i].submenuItems[n].replace(/\/$/, '');
					menuItems[i].subItems[n].a.href = rootPath + menuItemID_href + '/' + submenuItem_href;
					//menuItems[i].subItems[n].a.appendChild(d.createTextNode(linkText));
					menuItems[i].subItems[n].a.innerHTML = linkText;
				} else {
					menuItems[i].subItems[n].a.href = rootPath + menuItemID_href + '/' + submenuItem_href + '.html';
					//menuItems[i].subItems[n].a.appendChild(d.createTextNode(menuItems[i].submenuItems[n]));
					menuItems[i].subItems[n].a.innerHTML = menuItems[i].submenuItems[n];
				}
				if(menuItems[i].id == 'about') {
					menuItems[i].li.className = 'left';
				}
				menuItems[i].subItems[n].li.appendChild(menuItems[i].subItems[n].a);
				menuItems[i].subMenu.appendChild(menuItems[i].subItems[n].li);
			}
			menuItems[i].li.appendChild(menuItems[i].subMenu);
		}
		menu.appendChild(menuItems[i].li);
	}
	menuParent.appendChild(menu);
	activateMenu();
}
var listMenu = new Object();
function activateMenu() {
	listMenu = new FSMenu('listMenu', true, 'display', 'block', 'none');
	listMenu.animations[listMenu.animations.length] = FSMenu.animSwipeDown;
	listMenu.activateMenu("listMenuRoot", null);
	// Activation: Include the ID for your menu in here.
	setTimeout('activePageHighlight("listMenuRoot");',1);
}

