// 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();
var ftrMenuItems = new Array();
var ceibw;

//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      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 = "SugarHill Works";
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.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
//};
//
//		


//menuItems[menuItems.length] = {
////idHref: 'AboutLnk',
//	id: 'navAbout',
//	mLink: 'Who We Are',
//  altTxt: 'WHO WE ARE',
//	mHref: 'about/',
//	subItems: '',
//	subHrefs: ''
//};

menuItems[menuItems.length] = {
//  idHref: 'servicesLnk',
	id: 'navServices',
	mLink: 'nav_svcs.gif',
	altTxt: 'SERVICES',
	mHref: '#', 
	subItems: ['scans','websites','gicl&eacute;e prints','retouching','graphic design','web hosting','pricelist (PDF)'],
	subHrefs: ['services/scans/','services/websites/','services/prints/','services/retouching/','services/design/','services/hosting/','services/PDFs/SugarHillWorks_Pricelist.pdf']
};

menuItems[menuItems.length] = {
//  idHref: 'workLnk',
	id: 'navWork',
	mLink: 'nav_work.gif',
	altTxt: 'WORK',
	mHref: '#',
	subItems: ['web portfolio','scan samples'],
	subHrefs: ['work/websites/','work/scans/']
};

menuItems[menuItems.length] = {
//	idHref: 'clientsLnk',
	id: 'navClients',
	mLink: 'nav_clnt.gif',
	altTxt: 'CLIENTS',
	mHref: '#',
	subItems: ['our clients','feedback'],
	subHrefs: ['clients/ourclients/','clients/testimonials/']
};

menuItems[menuItems.length] = {
//	idHref: 'infoLnk',
	id: 'navInfo',
	mLink: 'nav_info.gif',
	altTxt: 'INFO',
	mHref: '#',
	subItems: ['news','friends','who we are','contact','sugarhill post'],
	subHrefs: ['news/','info/links/','info/about/','info/contact/','info/post/signupForm.html'] // sweet@sugarhillworks.com
};

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

// ------------------------- these are for the footer menu links ------------------------- //
 
ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Home',
	mHref: 'index.html'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Scans',
	mHref: 'services/scans/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Websites',
	mHref: 'services/websites/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Gicl\&eacute\;e Prints',
	mHref: 'services/prints/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Retouching',
	mHref: 'services/retouching/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Graphic Design',
	mHref: 'services/design/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Web Hosting',
	mHref: 'services/hosting/'
};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Web Portfolio',
//	mHref: 'work/websites/'
//};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Scan Samples',
//	mHref: 'work/scans/'
//};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Our Clients',
//	mHref: 'clients/ourclients/'
//};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Feedback',
//	mHref: 'clients/testimonials/'
//};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Who We Are',
//	mHref: 'info/about/'
//};

//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'Friends',
//	mHref: 'info/friends/'
//};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'News',
	mHref: 'news/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Contact',
	mHref: 'info/contact/'
};



//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      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\">");
}
//
var isitFF2 = false;
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
	 var ffversion=new Number(RegExp.$1); // capture x.x portion and store as a number
	 if (ffversion < 3 && ffversion >= 2) {
		isitFF2 = true;
	 }
}
//var isitFF2mac = false;
// var userAgent = navigator.userAgent.toLowerCase();
//  if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
//    var ffversion = new Number(RegExp.$1);
//    if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
//      isitFF2mac = true;
//    }
//  }

// 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 topMargin() {
ceibw = d.getElementById("ceibw");
	if(screen.height >= 770) {
		ceibw.style.margin = "25px auto 0px auto";
	}
	else if(screen.height < 770) {
		ceibw.style.margin = "7px auto 0px auto";
	} 
}



function makeMenu() {
	var menuParent = d.getElementById('menu');
	menuParent.innerHTML = '';
	var menu = d.createElement('ul');
	menu.className = 'menulist';
	menu.setAttribute('id', 'listMenuRoot');
	var subsubMenus = new Array();
	for (var i = 0; i < menuItems.length; i++) {
		menuItems[i].li = d.createElement('li');
		// the following if statement classes the leftmost li tag to align correctly
		if(i == 0) {
			menuItems[i].li.className = 'nav_svcs';
		}
		if(i == 1) {
			menuItems[i].li.className = 'nav_work';
		}
		if(i == 2) {
			menuItems[i].li.className = 'nav_clnt';
		}
		if(i == 3) {
			menuItems[i].li.className = 'nav_info';
		}
		menuItems[i].a = d.createElement('a');
		menuItems[i].a.className = 'special';
		if(menuItems[i].id) {
			menuItems[i].a.id = menuItems[i].id; // id is on the a tag!
		}
		if(menuItems[i].mHref == '#') {
			menuItems[i].a.href = '#';
		} else {	
			menuItems[i].a.href = rootPath + menuItems[i].mHref;
		}
		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].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;');
				} else if (typeof menuItems[i].subItems[n] == 'object') { //sub-submenu items present
					if(menuItems[i].subHrefs[n][0] == '#') {
						sub_a.href = '#';
					} else {
						sub_a.href = rootPath + menuItems[i].subHrefs[n][0];
					}
					sub_a.innerHTML = menuItems[i].subItems[n][0].replace(/\s/g, '&nbsp;') + '&nbsp;&nbsp;&gt;';
					subsubMenus[n] = d.createElement('ul');
					var subsub_li = new Array();
					var subsub_a = new Array();
					for (var p = 1; p < menuItems[i].subItems[n].length; p++) { //create TEXT ONLY sub-submenu...
						subsub_li[p] = d.createElement('li');
						subsub_a[p] = d.createElement('a');
						subsub_a[p].className = 'standard';
						if(menuItems[i].subHrefs[n][p] == '#') {
							subsub_a[p].href = '#';
						} else {
							subsub_a[p].href = rootPath + menuItems[i].subHrefs[n][p];
						}
						subsub_a[p].innerHTML = menuItems[i].subItems[n][p].replace(/\s/g, '&nbsp;');
						subsub_li[p].appendChild(subsub_a[p]);
						subsubMenus[n].appendChild(subsub_li[p]);
					}
					sub_li.appendChild(subsubMenus[n]);
				}
				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);
	activateMenu();
}
var listMenu = new Object();
function activateMenu() {
	listMenu = new FSMenu('listMenu', true, 'display', 'block', 'none');
	// The parameters of the FSMenu object are:
	//  1) Its own name in quotes.
	//  2) Whether this is a nested list menu or not (in this case, true means yes).
	//  3) The CSS property name to change when menus are shown and hidden.
	//  4) The visible value of that CSS property.
	//  5) The hidden value of that CSS property.
	//
	// Next, here's some optional settings for delays and highlighting:
	//  * showDelay is the time (in milliseconds) to display a new child menu.
	//    Remember that 1000 milliseconds = 1 second.
	//  * switchDelay is the time to switch from one child menu to another child menu.
	//    Set this higher and point at 2 neighbouring items to see what it does.
	//  * hideDelay is the time it takes for a menu to hide after mouseout.
	//    Set this to a negative number to disable hiding entirely.
	//  * cssLitClass is the CSS classname applied to parent items of active menus.
	//  * showOnClick will, suprisingly, set the menus to show on click. Pick one of 4 values:
	//     0 = All levels show on mouseover.
	//     1 = Menu activates on click of first level, then shows on mouseover.
	//     2 = All levels activate on click, then shows on mouseover.
	//     3 = All levels show on click only (no mouseover at all).
	//  * hideOnClick hides all visible menus when one is clicked (defaults to true).
	//  * animInSpeed and animOutSpeed set the animation speed. Set to a number
	//    between 0 and 1 where higher = faster. Setting both to 1 disables animation.
	
	listMenu.showDelay = 0;
	listMenu.switchDelay = 0;
	listMenu.hideDelay = 0;
	listMenu.cssLitClass = 'highlighted';
	listMenu.showOnClick = 0;
	listMenu.hideOnClick = true;
	listMenu.animInSpeed = 0.07;
	listMenu.animOutSpeed = 1;
	
	// Now the fun part... animation! This script supports animation plugins you
	// can add to each menu object you create. I have provided 3 to get you started.
	// To enable animation, add one or more functions to the menuObject.animations
	// array; available animations are:
	//  * FSMenu.animSwipeDown is a "swipe" animation that sweeps the menu down.
	//  * FSMenu.animFade is an alpha fading animation using tranparency.
	//  * FSMenu.animClipDown is a "blind" animation similar to 'Swipe'.
	// They are listed inside the "fsmenu.js" file for you to modify and extend :).
	
	// I'm applying two at once to listMenu. Delete this to disable!
	//listMenu.animations[listMenu.animations.length] = FSMenu.animFade;
	//listMenu.animations[listMenu.animations.length] = FSMenu.animSwipeDown;
	//listMenu.animations[listMenu.animations.length] = FSMenu.animClipDown;

//// MENU REPOSITIONING: This will stop menus showing outside visible screen boundaries.
//// To activate:
////  1) Paste this after you create your "new FSMenu" object.
////  2) Make sure the last line contains the correct menu object name, and
////     duplicate for each of the menu objects to which you want this to apply.
//
//page.winW=function()
// { with (this) return Math.max(minW, MS?win.document[db].clientWidth:win.innerWidth) };
//page.winH=function()
// { with (this) return Math.max(minH, MS?win.document[db].clientHeight:win.innerHeight) };
//page.scrollX=function()
// { with (this) return MS?win.document[db].scrollLeft:win.pageXOffset };
//page.scrollY=function()
// { with (this) return MS?win.document[db].scrollTop:win.pageYOffset };
//
//function repositionMenus(mN) { with (this)
//{
// var menu = this.menus[mN].lyr;
//
// // Showing before measuring corrects MSIE bug.
// menu.sty.display = 'block';
// // Reset to and/or store original margins.
// if (!menu._fsm_origML) menu._fsm_origML = menu.ref.currentStyle ?
//  menu.ref.currentStyle.marginLeft : (menu.sty.marginLeft || 'auto');
// if (!menu._fsm_origMT) menu._fsm_origMT = menu.ref.currentStyle ?
//  menu.ref.currentStyle.marginTop : (menu.sty.marginTop || 'auto');
// menu.sty.marginLeft = menu._fsm_origML;
// menu.sty.marginTop = menu._fsm_origMT;
//
// // Calculate absolute position within document.
// var menuX = 0, menuY = 0,
//  menuW = menu.ref.offsetWidth, menuH = menu.ref.offsetHeight,
//  vpL = page.scrollX(), vpR = vpL + page.winW() - 16,
//  vpT = page.scrollY(), vpB = vpT + page.winH() - 16;
// var mp = page.elmPos(menu.ref);
// var pp = page.elmPos(this.menus[mN].par.ref);
// 
// // Compare position to viewport, reposition accordingly.
// var mgL = 0, mgT = 0;
// if (mp.x + menuW > vpR) mgL = pp.x - mp.x - menuW;
// if (mp.x + mgL < vpL) mgL = vpL - mp.x;
// if (mp.y + menuH > vpB) mgT = vpB - mp.y - menuH;
// if (mp.y + mgT < vpT) mgT = vpT - mp.y;
//
// if (mgL) menu.sty.marginLeft = mgL + 'px';
// if (mgT) menu.sty.marginTop = mgT + 'px';
//}};
//
//// Set this to process menu show events for a given object.
//addEvent(listMenu, 'show', repositionMenus, true);


	listMenu.activateMenu("listMenuRoot", null);
	// Activation: Include the ID for your menu in here.
	//setTimeout('activePageHighlight("listMenuRoot");',1);
}


// this controls the plain links in the footer "info" div
function makeFtrMenu() {
	var menuParent = d.getElementById('info');
	menuParent.innerHTML = '';
	var menu = d.createElement('ul');
	menu.className = 'ftrLnks';
	for (var i = 0; i < ftrMenuItems.length; i++) {
		ftrMenuItems[i].li = d.createElement('li');
		// the following if statement classes the leftmost li tag to align correctly
		if(i == 0) {
			ftrMenuItems[i].li.className = 'left';
		}
		ftrMenuItems[i].a = d.createElement('a');
		ftrMenuItems[i].a.className = 'txtlnk';
		if(ftrMenuItems[i].mLink == 'Client Login') {
			ftrMenuItems[i].a.className = 'nolnk';
		}
		if(ftrMenuItems[i].mHref == '#') {
			ftrMenuItems[i].a.href = '#';
		} else {
			ftrMenuItems[i].a.href = rootPath + ftrMenuItems[i].mHref;
		}
		ftrMenuItems[i].a.innerHTML = ftrMenuItems[i].mLink.replace(/\s/g, '&nbsp;');
		ftrMenuItems[i].li.appendChild(ftrMenuItems[i].a);
		
		menu.appendChild(ftrMenuItems[i].li);
	}
	menuParent.appendChild(menu);
	
	var ftr_p = d.createElement('p');
	//ftr_p.innerHTML = '&nbsp;';
	ftr_p.innerHTML = '&copy;&nbsp;2006-2010&nbsp;SugarHill Works LLC.'; 
	//&nbsp;&nbsp;&nbsp;Harlem, NYC. &nbsp;&nbsp;&nbsp;Tel: 917.270.9823.&nbsp;&nbsp;&nbsp;Fax: 917.677.8325.&nbsp;&nbsp;&nbsp;Email: sweet@sugarhillworks.com.
	menuParent.appendChild(ftr_p);
}


// things to do onload...
addEvent(window, 'load', function() {
	getRootPath();
	topMargin();
	makeMenu();
	makeFtrMenu();
	//makeCopyFtr();
});
//addEvent(window, 'load', function() {
//});


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