//	vitaanteacta/libs/functions.js

			var close_delay = 2000;
			
			var main_max = 0.8;
			var main_min = 0.5;

			var thumb_max = 1.0;
			var thumb_min = 0.6;

			var front_max = 0.8;
			var front_min = 0.6;

			var gs_t = null;
			var gs_si;	//	interval for gallery slideshow
			var gs_d = 5000;
			var ss_d = gs_d * 1.5;

//	gs-navigation menu
			var gs_opacity_max = 0.5;
			var gs_opacity_min = 0.0;
			var gs_showhide = true;
			var gs_opacity_delay = 'fast';

//	longtail mediaplayer			
			var player;

			$j = jQuery.noConflict();

//	don't show/hide the gs navigation
			gs_showhide = ! $j.browser.msie && ! isiphone();
			ss_use = ! ( $j.browser.msie && $j.browser.version < 7);

			$j(document).ready(
				function() {
				
//	horizontal rules
					jQuery('hr').hide().before("<div class='hr'>&nbsp;</div>");
//	centred h3s
					jQuery('h3').each(function(){
//							alert(jQuery(this).attr('style'));
						if ( jQuery(this).attr('style') ) {
							if ( jQuery(this).attr('style').indexOf('center') ) {
//								alert(jQuery(this).attr('style'));
								jQuery(this).addClass('aligncentre');
							}
						}
					});
				
//	news articles
					the_id = null;
					if ( window.location.hash ) {						
						the_id = window.location.hash.substring(1, window.location.hash.length);
					}
					
					if ( the_id )
						$j('.post.category-news:not(.' + the_id + ') .post-content').hide();					
					else
						$j('.post.category-news .post-content').hide();
					$j('.post.category-news h3 a').click(function() {
						node = $j(this).parents('.post').find('.post-content');
						
						node.toggle();
						
						return false;
					});
					

					$j('input[type=checkbox]').checkbox();

//	override defaults	
					if ($j('.gallery').attr('rel') ) {
						args = $j('.gallery').attr('rel');
						tuples = args.split('&');
						for ( i = 0; i < tuples.length; i++ ) {
							t = tuples[i].split('=');
							if ( t[0] == 'speed' ) {
								gs_d = t[1] * 1000;
								ss_d = gs_d * 1.5;
							}
						}
					}
					
					
/* 	MAIN MENU		*/
/*
//	disabled - its ugly
//	fade in ( but not out ) on hover the menu items
					$j('#mainmenu li').hover(
						function() {
							$j('#mainmenu').fadeTo('slow', main_max);
						}, 
						function() {
						}
					);

//	fade out ( but not in ) when we leave the menu altogether
					$j('#mainmenu').hover(
						function() {
						}, 
						function() {
							$j('#mainmenu').fadeTo('slow', main_min);
						}
					);
*/

/*	fixes for ie6 - requires http://allinthehead.com/retro/338/supersleight-jquery-plugin	*/
//					$j('#mainmenu').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});
					$j('#header').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});
//					$j('#submenu').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});
					$j('.button').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});
//					$j('#ss-navigation').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});
//					$j('#gs-navigation').supersleight({shim: '/cms/wp-content/themes/vita-ante-acta/images/blank.gif'});

/*	child page dropdown menu */
					$j("#mainmenu li").hover(
//	launch on mainmenu over
						function() {
//	hide all visible uls from the parent
//							$j(this+':parent').find('li ul:visible').css({zIndex: 99}).slideUp('slow');
							$j(this).siblings().find('ul:first:visible').slideUp('fast');
//							$j(this).find(':parent').slideUp('fast');
							
							if ( $j.browser.msie ) {
							//	alert($j(this).width());
								margin_adjust = ( -1 * ( parseInt($j(this).width()) + 20 ) ) + 'px';
								$j(this).find('ul:first:hidden').css({marginLeft: margin_adjust});
							}
//	show this one

							$j(this).find('ul:first:hidden').css({visibility: "visible",display: "none", zIndex: 100}).slideDown('fast')
							
							$j("#mainmenu").stopTime("closing");
							
							$j("#mainmenu").css({zIndex: 100});
							
						},
						function() {
//	set a timer and close it up
							$j("#mainmenu").stopTime("closing");
							$j("#mainmenu").oneTime(close_delay, "closing", function() {
								$j("#mainmenu li ul").slideUp('fast');
								$j("#mainmenu").css({zIndex: 90});
							});
						}
					);
					
					$j("#mainmenu li ul").hover(
						function() {
							$j(this).css({ zIndex: 100 })
						},
//	close on ul out
						function() {
							$j(this).slideUp('fast');
							$j("#mainmenu").css({zIndex: 90});
						}
					);
					
/*	transition background colour on hover */
					$j('#mainmenu li ul li a').hover(
						function() {
							$j(this).css({ color: "#666666" }).animate({ color: "black" }, 'fast');
						},
						function() {
							$j(this).animate({ color: '#666666' }, 'slow');
						}
					);


/*	start video if the large image is clicked */
/*	//	not required - a href will do the job
					$j('.video img').click(
						function() {
							id = $j('.video')[0].id;
							alert(id);
							source = '';
							poster = $(this).src;
							
							alert(poster);
						}
					);
*/


/*	full screen slideshow	*/

		function build_supersized(ss_id, no_controls, options) {
			if ( ! options ) {
				options = { 
					permit_enlargements: 0,
					scale_to_fill: 0,
					scale_on_resize: 1,
					auto_start: 0,
					startwidth: 640,  
					startheight: 480,
					vertical_center: 1,
					slideshow: 1,
					navigation: 1,
					transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
					pause_hover: 0,
					slide_counter: 1,
					slide_captions: 1,
					slide_interval: ss_d  
				};
			}
				
//	if there are no gallery-nodes we shouldn't do any of this 

//	create the supersized container
			if ( ! ss_id )
				ss_id = 'supersize';
			ss = document.createElement('div');
			ss.id = ss_id;
			
			ss_count = $j('.gallery .gallery-node').not('.exclude').size();
			
			$j('.gallery-content').after(ss);
//		<a id='ss-page-12-attachment-13' href="file:///Users/rossetti/Documents/jobs/laudanum/vincentward/Rain%20of%20the%20Children/ROTC_%20Young%20Puhi%20-%20Bliss_NN000124.jpg"><img src="file:///Users/rossetti/Documents/jobs/laudanum/vincentward/Rain%20of%20the%20Children/ROTC_%20Young%20Puhi%20-%20Bliss_NN000124.jpg" title="Young Puhi On A Branch"/></a>

			$j('.gallery .gallery-node').not('.exclude').each(
				function() {
//	containing a tag
					node = document.createElement('a');
					node.id = 'ss-' + $j(this)[0].id;
					node.setAttribute('href', $j(this).children('a').attr('href'));
					node.setAttribute('rel', $j(this).children('a').attr('rel'));
//	image
					img = document.createElement('img');
					img.setAttribute('src', $j(this).children('a').attr('href'));
					img.setAttribute('title', $j(this).find('img').attr('title'));
					img.setAttribute('longdesc', $j(this).find('img').attr('longdesc'));
//	join the two together
					node.appendChild(img);
//	add it to supersize parent
					$j('#'+ss_id).append(node);
				}
			);
			
//	create the supersized controls
			if ( ! no_controls ) {
				build_ss_controls(ss_count);
			}
			
//			$j.fn.supersized.options = options;
//	        $j('#supersize').hover(function(){$j('#supersize').supersized()}); 
//			$j('#supersize').supersized(); 
		}


		function build_ss_controls(ss_count, ss_selector) {
			if ( ! jQuery('#ss-content').size() ) {
//				alert(ss_selector);
				ss_controls = "<div id='ss-content' class='count-" + ss_count + "'><div id='contentframe'><div id='slidecounter'><span class='slidenumber'></span>/<span class='totalslides'></span></div><div id='slidecaption'><h3></h3><div class='description'></div></div><div id='ss-navigation'><a href='#' id='ss-prevslide' class='multiple'>&nbsp;</a><a href='#' id='ss-pauseplay'>&nbsp;</a><a href='#' id='ss-nextslide' class='multiple'>&nbsp;</a><a href='#' id='ss-slower' class='multiple'>&nbsp;</a><a href='#' id='ss-faster' class='multiple'>&nbsp;</a><a href='#' id='ss-close'>&nbsp;</a></div></div></div>";
				$j('#fullscreen').append(ss_controls);
			}
		}
		
		
		if ( ss_use ) {
			if ( $j('.page-template-template-home-php').size() ) {
				options = { 
					permit_enlargements: 1,
					scale_to_fill: 1,
					scale_on_resize: 1,
					auto_start: 1,
					startwidth: 640,  
					startheight: 480,
					vertical_center: 1,
					slideshow: 1,
					navigation: 1,
					transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
					pause_hover: 0,
					slide_counter: 1,
					slide_captions: 1,
					slide_interval: 8000
				};
				build_supersized('supersize', true, options);
			//	fullscreen();
			} else {
				build_supersized();
			}
		}
//	fade in front page content area
			$j('.page-template-template-home-php .content').hover(
				function(){
					$j(this).fadeTo('slow', front_max);
				},
				function(){
					$j(this).fadeTo('slow', front_min);
				}
			);
			
//	fade in thumbnails on hover
			$j('.gallery-content .thumbnails ul li a').hover(
				function(){
					$j(this).fadeTo('fast', thumb_max);
				},
				function(){
					$j(this).fadeTo('fast', thumb_min);
				}
			);
			
//	enlarge to fullscreen on gallery-node on click
			$j('.gallery-node a').not('.exclude').click(
				function() {
//					alert('a');
//					alert($j('#supersize .activeslide')[0].id);
//					slideshow_interval = setInterval("gallery_next()", options.slide_interval);
//					$j('#supersize').resizenow();

//	if its a video gallery-node then just follow the link ( iphones for example )
					if ( $j(this).parent().hasClass('exclude') ) {
//						alert('video')
						return true;
					}
					
					if ( $j.browser.msie && $j.browser.version < 7 )
						return true;

//					fullscreen();						
					return false;
				}
			);
		
//	enlarge thumbnail on click
			$j('.gallery-content .thumbnails li a').click(
				function() {
					stopSlideshow();
					showNode($j(this).attr('rel'));
				}
			);
			
//	enlarge videos in clips lists on click
			$j('.clip-list a').click(
				function() {
					source = $j(this).attr('href');
					if ( $j(this).attr('lowsrc') && $j('#highquality:checked').length == 0 ) {
						source = $j(this).attr('lowsrc');
					} else {
						source = $j(this).attr('href');
					}
					id = $j(this).attr('rel');
					poster = $j(this).find('img').attr('src');
					
//	create the container if required
					temp = id.split('-');
					target = temp[0] + '-' + temp[1] + '-video';
					
					container = document.createElement('div');
					container.setAttribute('id', target);
					container.setAttribute('class', 'video-container-fullscreen');
					container.className = 'video-container-fullscreen';
					
					closer = document.createElement('a');
					closer.setAttribute('href', '.');
					closer.setAttribute('class', 'video-container-close');
					closer.className = 'video-container-close';
		//			closer.setAttribute('style', 'position : fixed');
		//			closer.setAttribute('onclick', 'closeVideo()');
					
//					text = document.createTextNode("oi");
					
//					closer.appendChild(text);
//					container.appendChild(closer);
					
					$j('body').append(container);
					$j('body').append(closer);

/*
					alert($j('#' + target).css('position'));
					alert($j('#' + target).css('z-index'));
					alert($j('#' + target).css('top'));
*/					
					$j('a.video-container-close').click(
						function () {
							closeVideo();
							return false;
						}
					);

//	vw wants videos to run at their true size
//					showVideo(id, source, poster, '100%', '100%');
					v_width = '100%';
					v_height = '100%';
					
					img = $j(this).find('img');

					if ( img.css('max-width') != 'none' ) {
						v_width = img.css('max-width');
					}
					if ( img.css('max-height') != 'none'  ) {
						v_height = img.css('max-height');
					}

					showVideo(id, source, poster, v_width, v_height);
					return false;
				}
			);
			


			if ( $j('.clip-list a').size() ) {
			
				
				$j(window).keydown(function (e) {
					switch(e.which) {
						case 27:	//	esc
						case 8:		//	delete / backspace
						case 88:	//	x
							$j('.video-container-close').remove();
							$j('.video-container-fullscreen').remove();
							break;
						default:
							break;
					}
				});
			}
			
//	show gs-controls on hover
			$j('.gallery').hover(
				function() {
//				alert(100);
//						$j('#gs-navigation').show("slide", { direction: "right" }, 'slow');
//	do not display control for video galleries
						if ( $j('.gallery .video').size() ) {
							return;
						}
						if ( gs_showhide )
							$j('#gs-navigation').show(gs_opacity_delay);
//	ie6 doesn't do the buttons nicely and ie7 messes up the show so use opacity
						else if ( $j.browser.msie && $j.browser.version > 6 )
							$j('#gs-navigation').fadeTo(gs_opacity_delay, gs_opacity_max);
//						clearTimeout(gs_t);
				},
				function() {
						if ( gs_showhide )
							$j('#gs-navigation').hide(gs_opacity_delay);
						else if ( $j.browser.msie )
							$j('#gs-navigation').fadeTo(gs_opacity_delay, gs_opacity_min);
//	this is the delay before hiding the toolbar
/*
					gs_t = setTimeout(function() {
//	there is a long slide to the right ( as it probably slides to screen right )
						$j('#gs-navigation').hide("slide", { direction: "right" }, 2000);
					}, 3000);
//					$j('#gs-navigation').hide("slide", { direction: "right" }, 1500);
*/
				}
			);
			
//	callbacks for gs-controls
			$j('#gs-playpause').click(
				function() {
					if ( $j(this).hasClass('play') ) {
						startSlideshow();
					} else {
						stopSlideshow();
					}
				}
			);

	
			$j('#gs-navigation .next').click(
				function() {
					stopSlideshow();
					showNode(1);
				}
			);

			
			$j('#gs-navigation .previous').click(
				function() {
					stopSlideshow();
					showNode(-1);
				}
			);


			$j('#gs-navigation .faster').click(
				function() {
					gs_d = parseInt(gs_d / 1.5);
					$j(".gallery").stopTime("playing");
					startSlideshow(true);
				//	clearInterval(gs_si);
				//	gs_si = setInterval("showNode(1)", gs_d);
				}
			);


			$j('#gs-navigation .slower').click(
				function() {
					gs_d = parseInt(gs_d * 1.5);
					$j(".gallery").stopTime("playing");
					startSlideshow(true);
				//	clearInterval(gs_si);
				//	gs_si = setInterval("showNode(1)", gs_d);
				}
			);


			$j('#gs-navigation .fullscreen').click(
				function() {
					start_fullscreen();
				}
			);

/*
			function faster(obj) {
				gs_d = parseInt(gs_d / 1.5);
				clearInterval(gs_si);
				gs_si = setInterval("showNode(1)", gs_d);
			}
			
			
			function slower(obj) {
				gs_d = parseInt(gs_d * 1.5);
				clearInterval(gs_si);
				gs_si = setInterval("showNode(1)", gs_d);
			}
			
*/
			function startSlideshow(delayed) {
//	if there's only one gallery-node don't play
				if ( $j('.gallery-node').size() < 2 ) {
					return;
				}
					
				if ( ! delayed )
					showNode(1);
				$j('#gs-playpause').addClass('pause');
				$j('#gs-playpause').removeClass('play');
				$j('.gallery').everyTime(gs_d, "playing", function() {
					showNode(1);
				});
//				gs_si = setInterval("showNode(1)", gs_d);
			}


			function stopSlideshow() {
				$j('#gs-playpause').addClass('play')
				$j('#gs-playpause').removeClass('pause')
				$j(".gallery").stopTime("playing");
//				clearInterval(gs_si);
			}
			
			
			function toggleSlideshow() {
//	its paused
				if ( $j('#gs-playpause').hasClass('play') )
					startSlideshow();
				else
					stopSlideshow();
			}


//	jump slideshow on thumbnail click
			function showNode(id) {
				transition = 1;
//	the current slide
	    		var gallery_current = $j('.gallery .activeslide');
//	the next slide
				var gallery_next;
//	if id == 1 we are advancing
				if ( id == 1 ) {
					gallery_next = gallery_current.next('.gallery-node').length ? gallery_current.next() : $j('.gallery .gallery-node:first');

					id = gallery_next[0].id;
//	if id == -1 we are reversing
				} else if ( id == -1 ) {
					gallery_next =  gallery_current.prev('.gallery-node').length ? gallery_current.prev() : $j('.gallery .gallery-node:last');
					id = gallery_next[0].id;
//	otherwise we are jumping
				} else {
//					stopSlideshow();
					gallery_next = $j('#'+id);
				}

//	do nothing				
				if ( gallery_next.hasClass('activeslide') ) {
					if ( $j.browser.msie )
						alert('nuh uh')
					return;
				}
//	kill all old slides ( set z-index = 0 )
				$j('.gallery .prevslide').removeClass('prevslide');
//	hide and put the new slide on top ( set z-index = 2 )
				gallery_next.hide().addClass('activeslide')
//	put the current slide under the new slide ( set z-index = 1 )
				gallery_current.addClass('prevslide').removeClass('activeslide');
//	show the new slide
				if ( transition == 0 )
					gallery_next.show();
				else if ( transition == 1 )
					gallery_next.fadeIn(parseInt(gs_d/10));

/*	dont do this here - do it before we display supersize	
//	when we generate supersize gallery we're going to give them id's
//	also set activeslide on the supersize Gallery
				$j('#supersize .activeslide').removeClass('activeslide');
				$j('#ss-' + id).addClass('activeslide');
*/
//	toggle the description
				$j('.post-content .activeslide').removeClass('activeslide');
				$j('#description-' + id).addClass('activeslide');
				
//	fade up the thumbnail
				$j('.gallery-content .thumbnails ul li a').fadeTo(0, thumb_min);
				$j('.gallery-content .thumbnails ul li a[rel="' + id + '"]').fadeTo(0, thumb_max);
			}

			
			fullscreen_id = 'gallery_container';
			fullscreen_selector = '#' + fullscreen_id;
			
			$j(fullscreen_selector + ' div.active-item a img').bind(
				'load',
				function() {
//					alert('laoded');
				}
			);

			
			default_options = {
				'source_selector' : 'div.gallery-node:not(.exclude)',
				'info_selector' : '#slidecaption .description',
				'title_selector' : '#slidecaption h3',
				'previous_selector' : '#ss-prevslide',
				'next_selector' : '#ss-nextslide',
				'close_selector' : '#ss-close',
				'pause_selector' : '#ss-pauseplay',
				'faster_selector' : '#ss-faster',
				'slower_selector' : '#ss-slower',
				'container_selector' : '#fullscreen',
				'start_selector' : 'div.gallery-node.activeslide a', 
				'onShowDescription' : function() {
						fullscreen_showDescription(jQuery(this));
					}
			}

//	fails for ie7
			options = $j('.gallery').attr('rel');

			if ( options ) {
				pairs = options.split('&');
				for ( i = 0; i < pairs.length; i++ ) {
					pair = pairs[i].split('=');
					if ( pair[0] == 'speed' )
						default_options.interval = pair[1] * 1000;
					else if ( pair[0] == 'next_gallery' ) {
						default_options.next_gallery = pair[1];
//	and don't loop
						default_options.loop = false;
					}
				}
			}
			
			the_fullscreen = $j('.gallery').fullscreen(default_options);
			build_ss_controls(0, '#fullscreen');

			start_fullscreen = function() {
				the_fullscreen.start();
				return false;
			}
			
			function fullscreen_2(obj) {
				if ( $j('.gallery .activeslide').size() ) {
					id = $j('.gallery .activeslide')[0].id;
					src = $j('.gallery .activeslide a').attr('href');
				} else {				
					id = $j('.gallery .gallery-node')[0].id;
					src = $j('.gallery .gallery-node a')[0].attr('href');
				}
				
//				do we have a container yet ?
				gallery_container = $j(fullscreen_selector);
				if ( ! gallery_container.size() )
					gallery_container = $j('body').append('<div id="' + fullscreen_id + '">Loading...</div>');
					
//	quickly draw the correct image to the Div if we don't have it
				current_item = $j('#full-' + id);
				if ( ! current_item.size() )
					current_item = $j(gallery_container).append('<div class="active-item" id="full-' + id + '"><a><img src="' + src + '" /></a></div>');

				current_item.find('img').bind(
					'load',
					function() {
						alert('laoded');
//	create future and past items
//	set a timeout and then call next
					}
				);

				
//				gallery_container
					
					
				return false;
			}
			
			
//			_createNewSlide = function(parent, src,)
			
			
			function fullscreenold(obj) {
				if ( isiphone() ) {
//					alert('iphone');
					
					toggleSlideshow();
					return false;
				}

//	msie6 messes up fullscreen
				if ( $j.browser.msie && $j.browser.version < 7 ) {
					alert('oi')
					return true;
				}
				
				stopSlideshow();
//	the id of the currently active gallery slide if there is one
				if ( $j('.gallery .activeslide').size() ) {
					id = $j('.gallery .activeslide')[0].id;					
				} else {				
					id = $j('.gallery .gallery-node')[0].id;
				}
				
//	set the active supersized slide
				$j('#supersize .activeslide').removeClass('activeslide');				
				$j('#ss-' + id).addClass('activeslide');
				
//	update the caption
				updatecaption($j('#supersize .activeslide').find('img').attr('title'), $j('#supersize .activeslide').find('img').attr('longdesc'));
				$j('#supersize').start();
			}


//	if we have videos dont autoplay
			if ( $j('.gallery-node').size() && ! $j('.gallery .video').size() )
				startSlideshow(true);
				
				
			if ( $j('#ss_front').size() ) {
				alert('go');
			//	build_supersized('ss_front');
				
			}

//	end jquery
				}
			);



//	gallery footers 
			$j('font[size=1]').addClass('gallery_foot');

//	gallyer footers in fullscreen
			function fullscreen_showDescription(item) {
				if ( $j('#slidecaption .description').size() ) {					
					$j('font[size=1]').addClass('gallery_foot');
				}
			}
			
//	start the fullscreen slideshow


			function showVideo(id, source, poster, _w, _h) {
				if ( source.match(/mp4$/i) && isiphone() ) {
//					alert(source);
					location.href = source;
					return false;
				}
				
				if ( ! _w ) {
					_w = 480;
					_h = 270;
				}
				//	page-pid-attachment-aid
				temp = id.split('-');
				target = temp[0] + '-' + temp[1];
//			alert(target)
//			alert(source)
				var s1 = new SWFObject('/cms/wp-content/themes/vita-ante-acta/libs/mediaplayer/player.swf','player_'+id,_w,_h,'9');
				s1.addParam('allowfullscreen','true');
				s1.addParam('allowscriptaccess','always');
				s1.addParam("wmode","opaque");
				s1.addParam('flashvars','&image=' + poster + '&autostart=true&file=' + source + '&backcolor=000000&frontcolor=888888&lightcolor=CCCCCC&controlbar=over');
//	so.addParam('flashvars','&author=Vincent Ward&description=desc&image=xxxx&title=Title');

				s1.write(target + '-video');

//	show the description too
//				id = target;
				$j('.post-content .activeslide').removeClass('activeslide');
				$j('#description-' + id).addClass('activeslide');
				
//	fade up the thumbnail
				$j('.gallery-content .thumbnails ul li a').fadeTo(0, thumb_min);
				$j('.gallery-content .thumbnails ul li a[rel="' + id + '"]').fadeTo(0, thumb_max);
			}


			function closeVideo(obj) {
//	ie freaks out if you close the video before stoping it
				if ( player )
					player.sendEvent('STOP');

				$j().oneTime(100, function() {
					
					if ( $j('.video-container-close').length )
						$j('.video-container-close').remove();
	//			alert('removing full')
					if ( $j('.video-container-fullscreen').length )
						$j('.video-container-fullscreen').remove();
//				return false;
				});
			}			
			
			
			function videoResized(obj) {
//	we're leaving fullscreen
//	this crashes safari every time
				if ( ! obj.fullscreen )
					closeVideo(obj);
			}
			
			
			function stateChanged(obj) {
				if ( obj.newstate == 'COMPLETED' )
					closeVideo(obj);
				else
					if ( location.search.indexOf('debug') > 1 ) 
		alert(					obj.newstate)
			}
			
		
			function isiphone() { 
				var agent = navigator.userAgent.toLowerCase();
				if ( agent.match(/iPhone/i) || agent.match(/iPod/i) )
					return true;
				else
					return false;
			} 


			function build_ss_node(id, href, rel, title, longdesc) {

//	containing a tag
					node = document.createElement('a');
					node.id = 'ss-' + id;
					node.setAttribute('href', href);
					node.setAttribute('rel', rel);
//	image
					img = document.createElement('img');
					img.setAttribute('src', href);
					img.setAttribute('title', title);
					img.setAttribute('longdesc', longdesc);
//	join the two together
					node.appendChild(img);
					
					return node;
			}
			
			
			function BackgroundImage(id, src, rel, title, description) {
				ss_id = 'ss_front';
				if ( ! $j('#'+ss_id).size() )
					createSSParent(ss_id);

				this.image = new Image();
				this.image.onload = function () {
					alert('loaded ' +  src); 
				}
				
				node = build_ss_node(id, src, rel, title, description);

					
				$j('#'+ss_id).append(node);
				alert('done ' + src);
				return this;
			}


			function createSSParent(ss_id) {
				alert('creating '  +ss_id);
				ss = document.createElement('div');
				ss.id = ss_id;
				$j('#wrapper').append(ss);
			}

			
			function playerReady(obj) {
				return;
				player = document.getElementById(obj['id']);
				if ( player ) {
//	crashes safari
					if ( ! $j.browser.safari )
						player.addControllerListener("RESIZE", "videoResized");
					if ( ! $j.browser.msie )
						player.addModelListener('STATE', 'stateChanged');
				}
			}
			
			