// 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 = "NYC Greeting Cards";
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: 'bioLnk',
	id: 'navBio',
	mLink: 'Bio',
	mHref: 'bio/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'collectionsLnk',
	id: 'navCollections',
	mLink: 'Print Collections',
	mHref: '#', 
	subItems: ['Backstage at the Opera','Landmarks','Parks'],
	subHrefs: ['collections/backstage_gallery','collections/landmarks_gallery','collections/parks_gallery']
};

menuItems[menuItems.length] = {
	idHref: 'shopLnk',
	id: 'navShop',
	mLink: 'Buy Cards',
	mHref: 'shop/greeting_cards/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'customLnk',
	id: 'navCustom',
	mLink: 'Custom Orders',
	mHref: 'custom_orders',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	idHref: 'contactLnk',
	id: 'navContact',
	mLink: 'Contact',
	mHref: 'info@nycgreetingcards.com',
	subItems: '',
	subHrefs: ''
};

//menuItems[menuItems.length] = {
//	idHref: 'wholesaleLnk',
//	id: 'navWholesale',
//	mLink: 'Wholesale',
//	mHref: '',
//	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;
var isitIE6 = false;
if (window.attachEvent && !window.opera) { //object-detect IE5+, exclude opera
	isitIE = true;
	if(navigator.appVersion.match(/MSIE 7/)) { isitIE7 = true; }
	if(navigator.appVersion.match(/MSIE 6/)) { isitIE6 = 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');
		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 = '#';
			if (!window.opera) {
				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;
			if (!window.opera) {
				menuItems[i].a.className = 'special';
			}
		} else {
			menuItems[i].a.href = rootPath + menuItems[i].mHref;
			if (!window.opera) {
				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');
				if (!window.opera) {
					sub_a.className = 'standard';
				} else {
					sub_a.className = 'standard_op';
				}
				
				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);
	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....
	if (!window.opera) {	
		listMenu.setLinkFading({
			'standard': { dim: [255,255,255], lit: [221,221,221] },//submenu items
			'highlighted': { dim: [255,255,255], lit: [255,255,255] },// ? maybe for use with highlight the current page module ? - check fsmenu_extras
			'special': { dim: [255,255,255], lit: [255,255,255] },//toplevel menu with href=# (items that only are there to have submenu items)
			'special highlighted': { dim: [255,255,255], lit: [255,255,255] }//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; Debra Schechter.&nbsp;&nbsp;&nbsp;Downloading or printing of images without written permission of the copyright holder is strictly forbidden.<br />Cards are printed on recycled paper.&nbsp;&nbsp;&nbsp;Made in the USA.&nbsp;&nbsp;&nbsp;<a href=\"http://sugarhillworks.com\" onclick=\"newWin=window.open(this.href,\'new_win\');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() {
//});
