// 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 isitFF2mac = 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;
//	 }
//}
//function detectMacXFF2() {
 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;
    }
  }
//}

//////var testMenuItems = new Array();
//////testMenuItems[menuItems.length] = {
//////	id: 'pkgLnk',
//////	mLink: 'nav_packages.gif',
//////	altTxt: 'PACKAGES',
//////	mHref: 'packages/',
//////	subItems: ['PHOTOGRAPHY','VIDEO','PHOTO & VIDEO',['OTHER SERVICES &nbsp;&gt;','subsubItem3']],
//////	subHrefs: ['#','#','#','#'],
//////};
//////
////////alert(testMenuItems[0].subItems[1][1]);
//////alert(typeof testMenuItems[0].subItems[3])
//////






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

//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// ********************************************************************************************************** //
//// *********************************                                        ********************************* //
//// *********************************      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 = "Hawaii Wedding Photography & Video | Dream Maker | Images by John Lutfey";
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
// 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
//};
//
//		
menuItems[menuItems.length] = {
	id: 'photoLnk',
	mLink: 'nav_photo.gif',
	altTxt: 'PHOTOGRAPHY',
	mHref: 'galleries/gallery_one/',
	subItems: ['WEDDING GALLERY ONE','WEDDING GALLERY TWO','CIRCLE OF LIFE'],
	subHrefs: ['galleries/gallery_one/','galleries/gallery_two/','galleries/gallery_three/']
};

menuItems[menuItems.length] = {
	id: 'videoLnk',
	mLink: 'nav_video.gif',
	altTxt: 'VIDEO',
	mHref: 'video/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	id: 'pkgLnk',
	mLink: 'nav_packages.gif',
	altTxt: 'PACKAGES',
	mHref: 'packages/',
	subItems: '', //['CLIENT LOGIN'], when activated, remember to turn on link rollover in script below!
	subHrefs: '' //['#'] 
};

menuItems[menuItems.length] = {
	id: 'aboutLnk',
	mLink: 'nav_about.gif',
	altTxt: 'ABOUT',
	mHref: 'about/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	id: 'testisLnk',
	mLink: 'nav_testis.gif',
	altTxt: 'TESTIMONIALS',
	mHref: 'testimonials/',
	subItems: '',
	subHrefs: ''
};

menuItems[menuItems.length] = {
	id: 'contLnk',
	mLink: 'nav_contact.gif',
	altTxt: 'CONTACT',
	mHref: 'contact/',
	subItems: '',
	subHrefs: ''
};

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

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Photography',
	mHref: 'galleries/gallery_one/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Video',
	mHref: 'video/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'Packages',
	mHref: 'packages/'
};

ftrMenuItems[ftrMenuItems.length] = {
	mLink: 'About Us',
	mHref: 'about/'
};

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

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


//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: '(808) 537-6484',
//	mHref: '#'
//};
//
//ftrMenuItems[ftrMenuItems.length] = {
//	mLink: 'john@dreammakerhawaii.com',
//	mHref: 'mailto:john@dreammakerhawaii.com?subject='
//};

// --------------------------------------------------------------------------- //




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

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





// preload basic site images
var pld_01 = new Image();
pld_01.src = "img/";
var pld001 = new Image();
pld001.src = "img/";
var pld002 = new Image();
pld002.src = "img/";

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

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



function doLogo() {
	var logo = d.getElementById('logo');
	logo.onmouseover = function() {
		logo.src = rootPath + 'img/hdr_logo_on.gif';
	}
	logo.onmouseout = function() {
		logo.src = rootPath + 'img/hdr_logo.gif';
	}
}

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 = 'left';
		}
		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');
	listMenu.animations[listMenu.animations.length] = FSMenu.animSwipeDown;
	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() {
	if ((d.getElementsByTagName('body')[0].id == "members") || (d.getElementsByTagName('body')[0].id == "cg_admin")) {
		ftrMenuItems[ftrMenuItems.length] = {
			mLink: 'Logout',
			mHref: 'client_galleries/logout.php'
		};
	} else {
		ftrMenuItems[ftrMenuItems.length] = {
			mLink: 'Client Login',
			mHref: 'client_galleries/login.php'
		};
	}
	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].mHref = "#";
//			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 = '&copy; 2009 Dream Maker Photography &amp; Video LLC.&nbsp;&nbsp;&nbsp;(808) 537-6484.&nbsp;&nbsp;&nbsp;<a href=\"mailto:john@dreammakerhawaii.com\">Email: john@dreammakerhawaii.com</a>.&nbsp;&nbsp;&nbsp;<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);
}

