// 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 = "ruth rodriguez";
var titleSeparator = " | ";

//// 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
// subItems (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 /contact/index.html
// NOTE: images are in the /img/ folder in the 'shw_menu' folder and images should be named 'id'.gif and 'id'_f2.gif - both files required - the _on.png file is for the mouse rollover event
//		See the example below and follow the pattern:
//
//menuItems[menuItems.length] = {
//	id: 'nav_main_menu',  // corresponds to #id rule in fsmenu_h.css
//	mLink: 'main menu',   // the text to be displayed in the menu (use HTML character codes)
//	mHref: 'menu.html',   // the page to link to (relative to site root)
//	subItems: ['sub item 1', 'sub item 2'],   // list submenu link texts here
//	subHrefs: ['menu.html', 'menu.html']      // list corresponding submenu pages to link to here
//};
//
//		

// NOTE THAT WHEN THE MENU IS UPDATED HERE, YOU *MUST* MANUALLY UPDATE THE ZEN CART categories.php TEMPLATE FILE TO MATCH

menuItems[menuItems.length] = {
	idHref: 'workLnk',
	id: 'navWork',
	mLink: 'work',
	mHref: 'portfolios/work/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'sketchbookLnk',
	id: 'navSketchbook',
	mLink: 'sketchbook',
	mHref: 'portfolios/sketchbook/', 
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'aboutLnk',
	id: 'navAbout',
	mLink: 'about',
	mHref: 'about/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'contactLnk',
	id: 'navContact',
	mLink: 'contact',
	mHref: 'contact/', //'ruth@ruthrodriguezstudio.com',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'linksLnk',
	id: 'navLinks',
	mLink: 'links',
	mHref: 'links/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'homeLnk',
	id: 'navHome',
	mLink: 'home',
	mHref: 'index.html',
	subItems: '',
	subHrefs: ''
};



//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      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);
}
// so we can dynamically add event watchers...
var addEvent = function( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener(type, fn, false);
	} else if (obj.attachEvent) {
		obj.attachEvent('on' + type, function() { return fn.apply(obj, new Array(window.event)); });
	}
}; 

function makeMenu() {
	var menuParent = d.getElementById('menu');
	var menu = d.getElementById('listMenuRoot');
	menu.innerHTML = '';
	menu.className = 'menulist';
	var subsubMenus = new Array();
	for (var i = 0; i < menuItems.length; i++) {
		menuItems[i].li = d.createElement('li');
		// the following if statement classes the top-level li tags to align correctly from the left
		if(i == 0) {
			//menuItems[i].li.className = 'left';
		}
		menuItems[i].a = d.createElement('a');
		if(menuItems[i].idHref) {
			menuItems[i].a.id = menuItems[i].idHref; // id is on the a tag!
		}
		if(menuItems[i].mHref == '#') {
			menuItems[i].a.href = '#';
			menuItems[i].a.className = 'special';
		} else if(menuItems[i].mHref.match(/^([a-zA-Z0-9_\.\'-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)) {
			menuItems[i].a.href = 'mailto:' + menuItems[i].mHref;
			menuItems[i].a.className = 'special';
		} else {
			menuItems[i].a.href = rootPath + menuItems[i].mHref;
			menuItems[i].a.className = 'special';
		}
		//if(menuItems[i].mLink.match(/(\.gif$)|(\.jpg$)/)) {
//			var linkImgExt = menuItems[i].mLink.match(/(\.gif$)|(\.jpg$)/);
//			var mLinkImg = d.createElement('img');
//			if(menuItems[i].altTxt) {
//				mLinkImg.alt = menuItems[i].altTxt;
//			}
//			mLinkImg.src = rootPath + 'shw_menu/img/' + menuItems[i].mLink;
//			mLinkImg.onmouseover = function() {
//				var menuItemsOver = this.src.replace(/(\.gif$)|(\.jpg$)/,'_f2');
//				this.src = menuItemsOver + linkImgExt[0];
//			}
//			mLinkImg.onmouseout = function() {
//				var menuItemsOut = this.src.replace(/(_f2\.gif$)|(_f2\.jpg$)/,'');
//				this.src = menuItemsOut + linkImgExt[0];
//			}
//			
//			menuItems[i].a.appendChild(mLinkImg);
//			
//		} else {
//			menuItems[i].a.innerHTML = menuItems[i].mLink.replace(/\s/g, '&nbsp;');
//		}
		menuItems[i].a.innerHTML = menuItems[i].mLink.replace(/\s/g, '&nbsp;');
		menuItems[i].li.appendChild(menuItems[i].a);
		if (menuItems[i].subItems.length > 0) { //create TEXT ONLY submenu... 
			menuItems[i].subMenu = d.createElement('ul');
			for (var n = 0; n < menuItems[i].subItems.length; n++) {
				var sub_li = d.createElement('li');
				var sub_a = d.createElement('a');
				sub_a.className = 'standard';
				if (typeof menuItems[i].subItems[n] == 'string') {
					if(menuItems[i].subHrefs[n] == '#') {
						sub_a.href = '#';
					} else {
						sub_a.href = rootPath + menuItems[i].subHrefs[n];
					}
					sub_a.innerHTML = menuItems[i].subItems[n].replace(/\s/g, '&nbsp;');
				} 
				sub_li.appendChild(sub_a);
				menuItems[i].subMenu.appendChild(sub_li);
			}
			menuItems[i].li.appendChild(menuItems[i].subMenu);
		}
		menu.appendChild(menuItems[i].li);
	}
	menuParent.appendChild(menu);
	menuParent.className = 'ie7menu';
	//--from fsMenu
	
	listMenu = new FSMenu('listMenu', true, 'display', 'block', 'none');
	listMenu.animations[listMenu.animations.length] = FSMenu.animSwipeDown;
	listMenu.activateMenu("listMenuRoot", null);
	//for the link fading, 'standard' class is for submenu items, special is for top level items, highlighted is who knows....
	listMenu.setLinkFading({
		'standard': { dim: [0,0,0], lit: [0,0,0] },//submenu items
		'highlighted': { dim: [0,0,0], lit: [0,0,0] },// ? maybe for use with highlight the current page module ? - check fsmenu_extras
		'special': { dim: [0,0,0], lit: [0,0,0] },//toplevel menu with href=# (items that only are there to have submenu items)
		'special highlighted': { dim: [0,0,0], lit: [0,0,0] }//toplevel menu when submenu is showing
	}, 10);
}


var newWin;
function makeCopyFtr() {
	var copyParent = d.getElementById('copy');
	copyParent.innerHTML = '';	
	//copyParent.className = '';
	var copy_p = d.createElement('p');
	copy_p.innerHTML = 'copyright &copy; 2008 ruth rodriguez.'; //&nbsp;&nbsp;&nbsp;<a href=\"http://sugarhillworks.com\" onclick=\"newWin=window.open(this.href,\'newWin\');newWin.focus();return false;\">site by sugarhill works</a>.'
	copyParent.appendChild(copy_p);
}




//var listMenu = new Object();
// things to do onload...
addEvent(window, 'load', function() {
	//document.getElementsByTagName('title')[0].text = defaultTitle;
	getRootPath();
	makeMenu();
	makeCopyFtr();
});
addEvent(window, 'load', function() {
});


//addEvent(window, 'load', function() {
//});
//addEvent(window, 'load', function() {
//});
