// siteSettings.js (c)2009 SugarHill Works LLC - http://www.sugarhillworks.com
var d = document, fullscr, ceibw, copy;

var rootPath = "";
function getRootPath() {
	for(var i = 2; i < rootPathNum; i++) {
		rootPath += "../";
	}
	return rootPath;
}

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; }
	document.write("<meta HTTP-EQUIV=\"imagetoolbar\" content=\"no\">");
}

var isitFF2 = false;
var isitFF2mac = false;
var userAgent = navigator.userAgent.toLowerCase();
if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
	var ffversion = new Number(RegExp.$1);
	if (ffversion < 3){
		isitFF2 = true;
	}
}
if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
	var ffversion = new Number(RegExp.$1);
	if ((ffversion < 3) && (userAgent.indexOf('mac') != -1)) {
		isitFF2mac = true;
	}
}

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);
}

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)); });
	}
}; 


var menuItems = new Array();


//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      DO NOT EDIT ABOVE THIS LINE       ********************************* //
//// *********************************                                        ********************************* //
//// *********************************         SET SITE OPTIONS BELOW         ********************************* //
//// *********************************                                        ********************************* //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
////
//
////// 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: 'mainpage.html',   // the page to link to (relative to site root)
////	subItems: ['sub item 1', 'sub item 2'],   // list submenu link texts here
////	subHrefs: ['page1.html', 'menu2.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: 'homeLnk',
	id: 'navHome',
	mLink: 'home',
	mHref: 'index.html', 
	subItems: '',
	subHrefs: ''
};

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

menuItems[menuItems.length] = {
	idHref: 'servicesLnk',
	id: 'navServices',
	mLink: 'services & prices',
	mHref: 'services/',
	subItems: '',
	subHrefs: ''
};

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

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

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










// this controls the plain links in the footer 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 = 'Copyright &copy; <a href=\"http://sugarhillworks.com\", onclick=\"newWin=window.open(this.href,\'newWin\');newWin.focus();return false;\">Site by SugarHill Works</a>.'; 
//	menuParent.appendChild(ftr_p);
//}

var newWin; //this opens the SHW site in another window
function makeCopyFtr() {
	var copyParent = d.getElementById('copy');
	copyParent.innerHTML = '';	
	//copyParent.className = '';
	var copy_p = d.createElement('p');
	copy_p.innerHTML = 'All images &copy; 2009 Your Name.&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);
}




// assign global vars  ----------------------------------------------
addEvent(window, 'load', function() {
	fullscr = d.getElementById('fullscr');
	ceibw = d.getElementById('ceibw');
	copy = d.getElementById('copy');
	ftr = d.getElementById('ftr');
});
// ------------------------------------------------------------------




// vertical centering  ----------------------------------------------
//var v_offset;
//function vCenter() {
//	v_offset = .5;// value from 0 to 2, 0 = top aligned, 1 = centered, 0.5 = closer to top, 1.5 = closer to bottom, 2 = bottom aligned
//	if (copy) { var copyH = copy.offsetHeight; } else { var copyH = 0; }
//	if (ftr) { var ftrH = ftr.offsetHeight; } else { var ftrH = 0; }
//	var t = Math.round((((fullscr.offsetHeight - copyH - ftrH) - (ceibw.offsetHeight)) / 2) * v_offset);
//	if (t < 0) { t = 0; }
//	ceibw.style.top = t + 'px';
//	var fh = (ceibw.offsetTop + ceibw.offsetHeight + copyH + ftrH);
//	if (fullscr.offsetHeight < (fh + 2)) { 
//		fullscr.style.height = fh + 'px';
//	} else {
//		fullscr.style.height = '100%';
//	}
//}
//addEvent(window, 'load', function() {
//	vCenter();
//});
//addEvent(window, 'resize', function() {
//	fullscr.style.height = '100%';
//	vCenter();
//});
// ------------------------------------------------------------------

function fixIE() { 
	if (!(isitIE7 === false && isitIE6 === false)) {
		var scr_div = d.getElementById('txt_cntr');
		var last_p = d.getElementById('last_p');
		var scr_bar = d.getElementById('txt_cntr_vscrollerbase');
		if (last_p.offsetTop < scr_div.offsetHeight) {
			if(scr_bar) { scr_bar.style.visibility = 'hidden'; }
		}
	}
}

addEvent(window, 'load', function() {
	getRootPath();
	makeMenu();
	//makeFtrMenu();
	//makeCopyFtr();
	fixIE();
});
//addEvent(window, 'load', new Function('listMenu.activateMenu("listMenuRoot", null)'));


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

