/* This script takes care of a CSS hover bug in IE */

var chaos_text0 = 'mouse over menu<br >try it!'; 
var chaos_text1 = 'click on arrow<br >to go to website';

var des0 = 'Paul de Jong worked as the Help Desk supervisor for <a href=http://laughingsquid.com>Laughing Squid</a> for nearly five years before branching off on his own. He is very familiar with web hosting issues and trouble shooting and will be able to help you get up to speed while building your web site. He specializes in intuitive interfaces that get the message across and are search engine optimized (SEO). He will work hard to make the navigation both intuitive and fun. Most of his web sites are designed using W3C strict XHTML and CSS with some JavaScript and/or PHP. You can see examples of his work by moving your mouse over the chaos symbol on the left or by using the menu in the upper left corner. If you click on the arrows or menu items you will go to the actual website. For questions or for quotes please email Paul de Jong by clicking on the email address listed above. '; 
var screenshot0 = 'images/screenshots/placeholder_600x600.gif';
var screenshot_link0 = 'index.html' ;

var des9 = 'This is a custom image page that displays the various images as you move your mouse over the images. If you click on the image you will get a fullsized image. Click on the center of the chaos menu to go to this pages.';
var screenshot9 = 'images/screenshots/deidredefranceaux-pms-600.gif';
var screenshot_link9 = 'http://deidredefranceaux.com/possible_mother_series.html';
							
var des8 = 'I can also install custom BLOG pages so you can make regular blog posts.';
var screenshot8 = 'images/screenshots/thehammockhangout-blog-600.gif';
var screenshot_link8 = 'http://thehammockhangout.com/wp/';

var des7 = 'This is a story book page that can be added to or edited on at the whim of the owner of the site simple by uploading images along with a text file with the same name.';
var screenshot7 = 'images/screenshots/thehammockhangout-storybook.gif';
var screenshot_link7 = 'http://thehammockhangout.com/~bm_2003/imagesPage.cgi?00.Overview';

var des6 = 'The images on this page are links to image folders with the same name as the caption below the image. This list is automatically generated based on the image folders that have been created by the owner of the site. The script also formats the images and creates the thumbnails once they are uploaded. ';
var screenshot6 = 'images/screenshots/firewoodfarms-menu-600.gif';
var screenshot_link6 = 'http://firewoodfarms.com/~carvings/';

var des5 = 'This is a list on 13,000 karaoke song. The viewer can click on a letter to see all the songs and artists listed for that letter. You can view this page by clicking on the arrow then clicking on the link for the list. The username and password is listed on the page.';
var screenshot5 = 'images/screenshots/karaoke_list-600.gif';
var screenshot_link5 = 'http://beyondkaraoke.us/';

var des4 = 'Sometimes keeping it simple is the best thing. This site is a gateway to numerous sites and project pages. I went for a clean simple link pages. Click on the arrow to go to the webpages.';
var screenshot4 = 'images/screenshots/pauldejong-600.gif';
var screenshot_link4 = 'http://pauldejong.com/';

var des3 = 'This is an auotomated photo system that reads the photos in the directory and makes thumbnails of the images. If you mouse over the thumbnails you see the images at the top of the page and if you click on it you see the full-size image. This menu system was writen in Perl. Click on the arrow to go to the website.';
var screenshot3 = 'images/screenshots/santon-600.gif';
var screenshot_link3 = 'http://bigrider.com/~thehauntedbarn/imagesPage.cgi?2003';

var des2 = 'The Odeon Bar website was a bar content management system that automatically updated the content of the website when when new shows were added. The viewer could choose between month, week, day or band views. They could also find out more about the bands that have played at the venue or see photos of pasts event etc. The Odeon Bar was sold March of 2005. ';
var screenshot2 = 'images/screenshots/odeonbar-month-600.gif';
var screenshot_link2 = 'http://pauldejong.com/odeonbar/bar-index-month.html';

var des1 = 'This is an artist website made for Deidre DeFranceaux. It features her paintings, sculptures, articles in the press as well as her CV. The site is laid out in various styles to accomidate the subject matter. Check it out at <a href=http://deidredefranceaux.com/ >deidredefranceaux.com</a>';
var screenshot1 = 'images/screenshots/deidredefranceaux-home-600.gif';
var screenshot_link1 = 'http://deidredefranceaux.com/';
							
betterMenu = {
	
	showItem: function(e) {
		var targ = window.event ? window.event.srcElement : e ? e.target : null ;
		if( !targ ) return ;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;

		var idName = targ.id;
		var desNumArray = idName.match( /\d$/ );
		var desNum = desNumArray[0];
		var descriptionNum = 'description' + desNum ;
		var desVar = 'des' + desNum ;
		var thisDescr = eval( desVar ) ;
		var site_text = $('site_text') ;
		site_text.className = descriptionNum ;
		site_text.innerHTML =  thisDescr;
		var screenshot = $('screenshot') ;
		screenshot.src = eval( 'screenshot' + desNum );
		var chaos_text = $('chaos_text');
		chaos_text.className = 'chaos_text1' ;
		chaos_text.innerHTML = eval( 'chaos_text1' );
		var screenshot_link = $('screenshot_link');
		screenshot_link.href = eval( 'screenshot_link' + desNum );
	},
	
	hideItem: function() {
		var chaos_text = $('chaos_text');
		chaos_text.className = 'chaos_text0' ;
		chaos_text.innerHTML = eval( 'chaos_text0' );
	},
	
	selectCSS: function(e) {
		var targ = window.event ? window.event.srcElement : e ? e.target : null ;
		if( !targ ) return ;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;

		var idName = targ.id;
		var matchArray = idName.match( /\d$/ );
		var cssNum = matchArray[0];
//		var cssId = 'css' + cssNum ;
		for( i = 0; i < 3; i++ ){
			if( cssNum == i ){
				document.styleSheets[i].disabled = false;
			}else{
				document.styleSheets[i].disabled = true;
			}
		}
		var subBreak = $('subBreak');
		if( cssNum == 3 ){
			subBreak.style.display = block;
		} else {
			subBreak.style.display = none;
		}
//		alert('stylesheet = ' + cssEnableId );
	},
	
	showNote: function() {
		//show a note next to link explaining what the click does, don't until hover for 500ms
	},
	
	hideNote: function() {
		
	},
	
	stopClick: function(e) {
		if( sindow.event && windoe.event.returnValue ){
			window.event.returnValue = false ;
		}
		if( e && e.preventDefault ){
			e.preventDefault();
		}
	},
	
	safariClickKiller: function() {
		return false; //ugly Safari bug fix...
	},
	
	makeMenu:  function(e) {
		var targ = window.event ? window.event.srcElement : e ? e.target : null ;
		if( !targ ) return ;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;

		for (i=0; i < targ.childNodes.length; i++) {
			node = targ.childNodes[i];
			if (node.nodeName=="li") {
				node.onmouseover=function() {
					this.className+=" over";
  				}
  				node.onmouseout=function() {
  					this.className=this.className.replace(" over", "");
   				}
   			}
  		}
	},
	
	init: function() {
		var nav = $('nav');
		betterMenu.addEvent( nav, 'mouseover', betterMenu.makeMenu, false );
		var nav2 = $('nav2');
		betterMenu.addEvent( nav2, 'mouseover', betterMenu.makeMenu, false );
		
		for( i = 0; i < 10; i++ ){
			var menu = 'menu0' + i ;
			menu = $( menu );
			betterMenu.addEvent( menu, 'mouseover', betterMenu.showItem, false );
			betterMenu.addEvent( menu, 'mouseout', betterMenu.hideItem, false );
		}
		for( i = 0; i < 10; i++ ){
			var chaos = 'chaos0' + i ;
			chaos = $( chaos );
			betterMenu.addEvent( chaos, 'mouseover', betterMenu.showItem, false );
			betterMenu.addEvent( chaos, 'mouseout', betterMenu.hideItem, false );
		}
		for( i = 0; i < 3; i++ ){
//			var cssSheet = 'css' + i;
			var cssLink  = $('style' + i);
			betterMenu.addEvent( cssLink, 'load', betterMenu.stopClick, false );
			cssLink.onclick = betterMenu.safariClickKiller; 
			betterMenu.addEvent( cssLink, 'click', betterMenu.selectCSS, false );
			betterMenu.addEvent( cssLink, 'mouseover', betterMenu.showNote, false );
			betterMenu.addEvent( cssLink, 'mouseout', betterMenu.hideNote, false );
		}
		document.styleSheets[0].disabled = false;
		document.styleSheets[1].disabled = true;
		document.styleSheets[2].disabled = true;
	},
	
	addEvent: function( elm, evType, fn, useCapture, str ) {
		if(elm.addEventListener){
			elm.addEventListener( evType, fn, useCapture, str );
			return true;
		} else if( elm.attachEvent) {
			var r = elm.attachEvent( 'on' + evType, fn );
			EventCache.add( elm, evType, fn );
			return r;
		} else {
			elm[ 'on' + evType ] = fn;
		}
	},
	
	removeEvent: function( elm, evType, fn, useCapture ) {
		if(elm.removeEventListener){
			elm.removeEventListener( evType, fn, useCapture );
			return true;
		} else if( elm.detachEvent ){
			var r = elm.detachEvent( 'on' + evType, fn );
			EventCache.remove( elm, evType, fn );
			return r;
		} else {
			elm[ 'on' + evType ] = '';
		}
	}

};

imageHandeling = {

	imageList: function() {
		var urls = new Array( 
								"images/screenshots/deidredefranceaux-home-600.gif", 
								"images/screenshots/deidredefranceaux-pms-600.gif", 
								"images/screenshots/firewoodfarms-menu-600.gif", 
								"images/screenshots/karaoke_list-600.gif", 
								"images/screenshots/odeonbar-day-600.gif", 
								"images/screenshots/odeonbar-month-600.gif", 
								"images/screenshots/odeonbar-week-600.gif", 
								"images/screenshots/pauldejong-600.gif", 
								"images/screenshots/placeholder_600x600.gif", 
								"images/screenshots/santon-600.gif", 
								"images/screenshots/thehammockhangout-blog-600.gif", 
								"images/screenshots/thehammockhangout-storybook.gif", 
								"images/screenshots/chaos_menu2_maroon_300b.gif" 
								);
		imageHandeling.preloadImages(urls); 
	},

	preloadImages: function(urls) {
		var img = new Array();
		for (var i=0; i < urls.length; i++) {
			img[img.length] = new Image();
			img[img.length - 1].src = urls[i];
		}
	},

	addEvent: function( elm, evType, fn, useCapture ) {
		if(elm.addEventListener){
			elm.addEventListener( evType, fn, useCapture );
			return true;
		} else if( elm.attachEvent) {
			var r = elm.attachEvent( 'on' + evType, fn );
			EventCache.add( elm, evType, fn );
			return r;
		} else {
			elm[ 'on' + evType ] = fn;
		}
	}

};

/* standard functions */
function createXMLHttpRequest( ) {
      try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
      try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
      try { return new XMLHttpRequest( ); } catch(e) {}
      alert("XMLHttpRequest not supported");
      return null;
}

function $(id) {
	if( document.getElementById && document.getElementById(id) ){
		return document.getElementById(id);
	} else {
		alert( 'id not found: ' + id );
	}
}
/* end standard functions */

betterMenu.addEvent( window, 'load', betterMenu.init, false );
imageHandeling.addEvent( window, 'load', imageHandeling.imageList, false );
