	   //Get and set Hash (#) value
	   var HashSearch = new function () {
	       var params;

	       this.set = function (key, value) {
	          params[key] = value;
	          this.push();
	       };

	       this.remove = function (key, value) {
	          delete params[key];
	          this.push();
	       };


	       this.get = function (key, value) {
	           return params[key];
	       };

	       this.keyExists = function (key) {
	           return params.hasOwnProperty(key);
	       };

	       this.push= function () {
	           var hashBuilder = [], key, value;

	           for(key in params) if (params.hasOwnProperty(key)) {
	               key = escape(key), value = escape(params[key]); // escape(undefined) == "undefined"
	               hashBuilder.push(key + ( (value !== "undefined") ? '=' + value : "" ));
	           }

	           window.location.hash = hashBuilder.join("&");
	       };

	       (this.load = function () {
	           params = {}
	           var hashStr = window.location.hash, hashArray, keyVal
	           hashStr = hashStr.substring(1, hashStr.length);
	           hashArray = hashStr.split('&');

	           for(var i = 0; i < hashArray.length; i++) {
	               keyVal = hashArray[i].split('=');
	               params[unescape(keyVal[0])] = (typeof keyVal[1] != "undefined") ? unescape(keyVal[1]) : keyVal[1];
	           }
	       })();
	    }

		<!-- load home image
		function loadhome() {
			$('#banner-container').html('');
			$('#loader').css("padding", "0");
			$('#loader').css("overflow", "hidden");
			$('#loader').html('');
			
			var img = new Image();
			$(img).load(function () {
				//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
				$(this).hide();
				
				var linkTo = "";

				//alert(x[0].getElementsByTagName("link")[0]);

				if ( x[0].getElementsByTagName("link")[0] != undefined ){
					linkTo = x[0].getElementsByTagName("link")[0].childNodes[0].nodeValue;
				}
				
				if( linkTo != "" && linkTo != undefined ) {
					//alert('there is a link');
					//$('#banner-container').removeClass('loading').append('<a href="'+x[0].getElementsByTagName("link")[0].childNodes[0].nodeValue+'"></a>');
					$('#banner-container').removeClass('loading').append('<a href="'+linkTo+'" onclick="executeLink()"></a>');
					
					$('#banner-container a').append(this);
				} else {
					//alert('there is no link');
					$('#banner-container').removeClass('loading').append(this);
				}
				$('#banner-container img').attr("class","banner-image");			
				$(this).fadeIn();
			}).error(function () {
				// notify the user that the image could not be loaded
			}).attr('src', x[0].getElementsByTagName("bigimage")[0].childNodes[0].nodeValue);

			//track in GA
			_gaq.push(['_trackEvent', 'Product Banner', 'Home', thisproduct]);
		};	
		//-->
		
		<!-- load image thumbs
		function loadimages() {
			// Image Sources
			$('#loader').html('');
			$('#loader').css("padding", "20px");
			$('#loader').css("overflow", "hidden");
			var images = new Array();


			for (a = 1; a < x.length; a++) {
				//alert(y[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
				//images[a] = (y[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
				images.push(x[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
			}
			
			// images length
			var max = $(images).length;
			// at least 1 image exist
			if(max>0) {
				// create the UL element
				var div = $('<div id="loader"></div>');
				// append to div#wrapper
				$(div).appendTo($('#wrapper'));
				// load the first image
				LoadImage(0,max);
			}
			// function of loading image
			// params: (int) index of image in array, (int) length of images array
			function LoadImage(index,max) {
				// if current index is lower then max element (max-1)
				if(index<max) {
					// create the LI, add loading class
					var first = "";
					
					if(index%6 == 0) {
						first = "-first";
					}
					var index1 = parseInt(index)+parseInt(1);
					var list = $('<div class="article all-elements'+first+'"><div class="loading article all-elements-thumb" id="image_'+index+'"><a href="#image='+index1+'" onclick="loadimage\('+index1+'\)"></a></div></div>');
					// append to UL
					$('div#loader').append(list);
					// current LI
					var curr = $("div#loader div#image_"+index+" a");
					// new image object
					var img = new Image();
					// image onload
					$(img).load(function () {
						//$(this).css('display','none'); // since .hide() failed in safari
						$(curr).removeClass('loading').append(this);
					//	$(curr).append('<span>'+y[index].getElementsByTagName("headline")[0].childNodes[0].nodeValue+'</span>');
					//	$(curr).prepend('<img alt="" src="http://localhost/tc-helicon2010/wp-content/themes/tc-helicon/images/playbutton.png" class="playbutton" />');
						
						//$(this).attr("onClick", "loadvideo\("+index+"\)");
						$(this).attr("class", "attachment-thumbnail");
						$(this).attr("style", "padding:5px 20px;");
						$(this).attr("width", "90");
						$(this).attr("height", "90");
						LoadImage(index+1,max);
						/*$(this).fadeIn('fast',function(){
							// once the current loaded, trigger the next image
							LoadImage(index+1,max);
						}); */
					}).error(function () {
						// on error remove current
						$(curr).remove();
						// trigger the next image
						LoadImage(index+1,max);
					}).attr('src', images[index]);
				}
			}
			
			$('html, body').animate({scrollTop : 530},800);	

			//track in GA
			_gaq.push(['_trackEvent', 'Product Banner', 'Images', thisproduct]);
		};	
		//-->	
		
		 <!-- load the a specific image in full
		function loadimage(i) {
				
			$('#banner-container').html('');
			$('#banner-container').css("background-color", "#ffffff");
			var img = new Image();
			$(img).load(function () {
				//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
				$(this).hide();
				$('#banner-container').removeClass('loading').append(this);
				$('#banner-container img').attr("class","banner-image");			
				$(this).fadeIn();
			}).error(function () {
				// notify the user that the image could not be loaded
			}).attr('src', x[i].getElementsByTagName("bigimage")[0].childNodes[0].nodeValue);


		    $('html, body').animate({scrollTop : 0},800);

			//track in GA
			_gaq.push(['_trackEvent', 'Product Banner', 'Image Show', thisproduct+' | '+ i]);
		};
		//-->	
			
			
		<!-- load video thumbs
		function loadvideos() {
			// Image Sources
			$('#loader').html('');
			$('#loader').css("margin", "0");
			$('#loader').css("padding", "20px");
			$('#loader').css("overflow", "hidden");			
			var images = new Array();
			
			for (a = 0; a < y.length; a++) {
				//alert(y[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
				//images[a] = (y[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
				images.push('http://kidman.itide.dk/tccinema/tc-helicon/'+y[a].getElementsByTagName("thumb")[0].childNodes[0].nodeValue);
				
			}
			
			// images length
			var max = $(images).length;
			// at least 1 image exist
	
			if(max>0) {
				// create the UL element
				var div = $('<div id="loader"></div>');
				// append to div#wrapper
				$(div).appendTo($('#wrapper'));
				// load the first image
				LoadImage(0,max);
			}
			// function of loading image
			// params: (int) index of image in array, (int) length of images array
			function LoadImage(index,max) {
				// if current index is lower then max element (max-1)
				if(index<max) {
					// create the LI, add loading class
					var first = "";
					
					if(index%6 == 0) {
						first = "-first";
					}

					var videoIndex = Number(index)+1;


					var list = $('<div class="article all-elements'+first+'"><div class="loading article all-elements-thumb" id="image_'+index+'"><h3 class="video-headline"><a href="#video='+videoIndex+'" onclick="loadvideo\('+index+'\)"></a></h3></div></div>');
					// append to UL
					$('div#loader').append(list);
					// current LI
					var curr = $("div#loader div#image_"+index+" h3 a");
					// new image object
					var img = new Image();
					// image onload
					$(img).load(function () {
						//$(this).css('display','none'); // since .hide() failed in safari
						$(curr).removeClass('loading').append(this);
						$(curr).append('<span>'+y[index].getElementsByTagName("headline")[0].childNodes[0].nodeValue+'</span>');
						$(curr).prepend('<img alt="" src="http://www.tc-helicon.com/wp-content/themes/tc-helicon/images/playbutton.png" class="playbutton" />');
						
						//$(this).attr("onClick", "loadvideo\("+index+"\)");
						$(this).attr("class", "attachment-thumbnail");
						$(this).attr("width", "120");
						$(this).attr("height", "90");
						LoadImage(index+1,max);
						/*$(this).fadeIn('fast',function(){
							// once the current loaded, trigger the next image
							LoadImage(index+1,max);
						}); */
					}).error(function () {
						// on error remove current
						$(curr).remove();
						// trigger the next image
						LoadImage(index+1,max);
					}).attr('src', images[index]);
				}
			}

			$('html, body').animate({scrollTop : 530},800);	

			//track in GA
			_gaq.push(['_trackEvent', 'Product Banner', 'Videos', thisproduct]);
		};		
		//-->	
			
			

			
			
			
		 <!-- load the a specific video in full
		function loadvideo(i) {

			$('#banner-container').html('');

			var videopath = y[i].getElementsByTagName("path")[0].childNodes[0].nodeValue;
			var videothumbpath = y[i].getElementsByTagName("embedthumbpath")[0].childNodes[0].nodeValue;
			var videopath_mp4 = videopath.substring(0, (videopath.length)-3)+"mp4";

			var embedpath = '<form id="embedform" name="embedform"><label>Embed this video (copy the code below)</label><br><textarea readonly="" name="embedcode" rows="3" onclick="select_all(\'embedcode\')"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="570" height="360"><param name="movie" value="http://www.tc-helicon.com/files/flashfiles/player.swf?file='+videopath+'&image='+videothumbpath+'" /><param name="quality" value="high" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed height="360" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" width="570" src="http://www.tc-helicon.com/files/flashfiles/player.swf?file='+videopath+'&image='+videothumbpath+'" allowscriptaccess="always" quality="high" allowfullscreen="true" /></object></textarea></form>'

			$('#banner-container').html('<script type="text/javascript"> var flashvars = {}; var params = {allowfullscreen: "true"}; var attributes = {}; swfobject.embedSWF("http://www.tc-helicon.com/files/flashfiles/player.swf?file='+videopath+'&image='+videothumbpath+'&autoplay=true", "video", "570", "360", "9.0.0", "expressInstall.swf",flashvars, params, attributes);</script><div id="video-container"><div id="video"><video id="banner-video" width="570" height="320" controls="controls" autoplay="autoplay" poster="http://kidman.itide.dk/tccinema/tc-helicon/'+videothumbpath+'" onplay="_gaq.push([\'_trackEvent\', \'Product Banner\', \'Video Play\', \''+thisproduct+' | '+ i +'\']);" onpause="_gaq.push([\'_trackEvent\', \'Product Banner\', \'Video Pause\', \''+thisproduct+' | '+ i +'\']);"><source src="http://kidman.itide.dk/tccinema/tc-helicon/'+videopath_mp4+'" ></video></div>'+embedpath+'</div><div id="banner-video-description"><h2>'+y[i].getElementsByTagName("headline")[0].childNodes[0].nodeValue+'</h2>'+y[i].getElementsByTagName("description")[0].childNodes[0].nodeValue+'</div></div><script type="text/javascript"> var video = document.getElementById("banner-video"); 	video.addEventListener("click",function(){  video.play();	},false); </script>');


			$('#banner-container').css("background-color", "#000000");
			thisproduct+' | '+ i
			
			function fakeClick(fn) {
				var $a = $('<a href="#" id="fakeClick"></a>');
					$a.bind("click", function(e) {
						e.preventDefault();
						fn();
					});

				$("body").append($a);

				var evt, 
					el = $("#fakeClick").get(0);

				if (document.createEvent) {
					evt = document.createEvent("MouseEvents");
					if (evt.initMouseEvent) {
						evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
						el.dispatchEvent(evt);
					}
				}

				$(el).remove();
			}

			$(function() {
			/*	var video = $("#banner-video").get(0);

				fakeClick(function() {
					video.play();
				});
			*/	
			});
				
			$('html, body').animate({scrollTop : 0},800);	
			
			//track in GA (this is tracked inside the video element)

		};
		//-->			
		

		function executeLink() {
			//load video or image if a direct link
			var link = x[0].getElementsByTagName("link")[0].childNodes[0].nodeValue;

			//alert("Index of first #: " + link.indexOf("#"));
			if(link.indexOf("#") == "0") {
				//var trimmedLink = str.replace(/^#$/g, '') ;
				//alert("trimmed link "+trimmedLink)

				while(link.charAt(0) == '#') {
					link = link.substr(1);
				}
				//alert ("yes " +link.indexOf("video"));
				if(link.indexOf("video") == "0") { //if a #video

					HashSearch.set(link);
					HashSearch.load();
					var hashkey = HashSearch.get('video');

					hashkey = Number(hashkey) - Number(1);
					var theindex = Number(link.split("=")[1] - Number(1) );
					loadvideo(theindex);	

				} else if (link.indexOf("image") == "0") { //if a #image

					HashSearch.set(link);
					HashSearch.load();
					var hashkey = HashSearch.get('image');
					var theindex = link.split("=")[1];
					//alert(hashkey);
					loadimage(theindex);	

				}
			}


		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		

