			// *** global variables ******
			var index;
			var items
			var imageWidths;
			var imageHeights;
			var currentSection;
			var lastGallerySection;
			var currentItemType = 'init';
			var infoOrGallery;
		
			//****************************
		 
			// *** AJAX ******************
			function instantiateRequest() {
		
				/* definition of requestObject */	
				var http_request = false;
      		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		      	http_request = new XMLHttpRequest();
				}

      	   if (http_request.overrideMimeType) {
         		http_request.overrideMimeType('text/xml');
        		}else if (window.ActiveXObject) { // IE
      			try {
         			http_request = new ActiveXObject("Msxml2.XMLHTTP");
	         	}catch (e) {
   	      		try {
      	      		http_request = new ActiveXObject("Microsoft.XMLHTTP");
         	   	} catch (e) {}
         		}
     			}
      		
				if (!http_request) {
      			alert('Giving up :( Cannot create an XMLHTTP instance');
      			return false;
      		}
				return http_request;
			}
			//****************************



			// set info methods
			function setInfo(infoSection){
				infoOrGallery = "info";
					//document.getElementById('mainImage').visibility="hidden";
					document.getElementById('mainImageCell').align='left';
					document.getElementById('mainImageCell').vAlign='top';
					document.getElementById('picNumbers').innerHTML = '&nbsp;';
				if(infoSection == 'bio') fetchBio();
				else if(infoSection == 'links') fetchLinks();
				else if(infoSection == 'contact') fetchContact();
				fixMenus(infoSection);
			}
		
			function fetchContact(){
				var script = 'getData.php?content=contact';
				var http_request = instantiateRequest();
				var temp;
				http_request.onreadystatechange = 
				function() { 
					if(http_request.readyState == 4){
      				if(http_request.status == 200){
							temp = http_request.responseText;
     						setContact(temp);
						}else{
        					alert('There was a problem with the AJAX request.');
        				}
      			}
				};
				http_request.open('GET', script, true);
				http_request.send(null);
			}
			function setContact(contact){
				document.getElementById('mainImageDiv').innerHTML = contact;
				
			}
			function fetchBio(){
				var script = 'getData.php?content=bio';
				var http_request = instantiateRequest();
				var temp;
				http_request.onreadystatechange = 
				function() { 
					if(http_request.readyState == 4){
      				if(http_request.status == 200){
							temp = http_request.responseText;
     						setBio(temp);
						}else{
        					alert('There was a problem with the AJAX request.');
        				}
      			}
				};
				http_request.open('GET', script, true);
				http_request.send(null);
			}
			function setBio(bio){
				document.getElementById('mainImageDiv').innerHTML = bio;
				
			}
			function fetchLinks(){
				var script = 'getData.php?content=links';
				var http_request = instantiateRequest();
				var temp;
				http_request.onreadystatechange = 
				function() { 
					if(http_request.readyState == 4){
      				if(http_request.status == 200){
							temp = http_request.responseText;
     						setLinks(temp);
						}else{
        					alert('There was a problem with the AJAX request.');
        				}
      			}
				};
				http_request.open('GET', script, true);
				http_request.send(null);
			}
			function setLinks(links_){
				document.getElementById('mainImageDiv').innerHTML = links_;
				
			}

			// *** set section methods ***
			function setGallery(gallerySection,project){
				document.getElementById('mainImageDiv').innerHTML = "<IMG id='mainImage' src='assets/images/basics/blank.jpg'>";
				document.getElementById('mainImageCell').align="center";
				document.getElementById('mainImageCell').vAlign="middle";
				infoOrGallery = "gallery";
				lastGallerySection = gallerySection;	
				var script = 'ajax.php?do=fetchItems&section='+gallerySection+'&project='+project;
				var http_request = instantiateRequest();

				http_request.onreadystatechange = 
				function() { 
					if(http_request.readyState == 4){
      				if(http_request.status == 200){
							instantiateGallery(http_request.responseText,gallerySection);
         			}else{
         				alert('There was a problem with the AJAX request.');
         			}
      			}
				};
				http_request.open('GET', script, true);
				http_request.send(null);
			}

		
			// untokenize the image location string of the current project
			function instantiateGallery(resultString,section){
				
				if(resultString == ''){
					document.getElementById('picNumbers').innerHTML = '&nbsp;'; 
					return; // the gallery is empty
				}

				//initialize variables
				var pic,width,height;
				var itemPointer = 0;
				items = new Array();
				imageWidths = new Array();
				imageHeights = new Array();
				
				// untokenize
				for(var i=0;i<resultString.length;i++){
					pic = '';
					width = '';
					height = '';
					while(resultString.charAt(i) != '#')	pic=pic+resultString.charAt(i++);
					i++;
					while(resultString.charAt(i) != '#')	width=width+resultString.charAt(i++);
					i++
					while(resultString.charAt(i) != '#')	height=height+resultString.charAt(i++);
					
					items[itemPointer] = pic;
					imageWidths[itemPointer] = width;
					imageHeights[itemPointer++] = height;
				}

				// set the item links in the bottom
				if(items.length>0){
					document.getElementById("picNumbers").innerHTML="<span style='cursor:pointer'><A href='' id='nr0' class='numbers' onclick='openPic(0);return false'>1<\A><\SPAN>";
					for(var i=2;i<=items.length;i++){
						var text = document.getElementById("picNumbers").innerHTML;
						document.getElementById("picNumbers").innerHTML= text+" / "+
						"<span style='cursor:pointer;'><A href='' id='nr"+(i-1)+"' class='numbers' onclick='openPic("+(i-1)+");return false'>"+i+"<\A><\SPAN>";
					}
				}
				openPic(0);	
				fixMenus(section);
				if(currentItemType == 'jpg') document.getElementById('mainImage').style.visibility='visible';
			}

			function fixMenus(section){
				if(section == currentSection)return;
				else if(infoOrGallery == "gallery" && section != "press"){
					document.open('selector.php?section='+section,'selectorFrame','');				
					if(section == 'advertising'){
						document.getElementById('advertisingLink').src='assets/images/basics/advertising_on.gif';
						document.getElementById('fashionLink').src='assets/images/basics/fashion_off.gif';
						document.getElementById('graphic_designLink').src='assets/images/basics/graphic_design_off.gif';

						document.getElementById('advertisingAnchor').onmouseout = null;
						document.getElementById('fashionAnchor').onmouseout = function onmouseout(event){swapImage('fashionLink','assets/images/basics/fashion_off.gif');}
						document.getElementById('graphic_designAnchor').onmouseout = function onmouseout(event){swapImage('graphic_designLink','assets/images/basics/graphic_design_off.gif');}
					}
					else if(section == 'fashion'){
						document.getElementById('advertisingLink').src='assets/images/basics/advertising_off.gif';
						document.getElementById('fashionLink').src='assets/images/basics/fashion_on.gif';
						document.getElementById('graphic_designLink').src='assets/images/basics/graphic_design_off.gif';
		
						document.getElementById('advertisingAnchor').onmouseout = function onmouseout(event){swapImage('advertisingLink','assets/images/basics/advertising_off.gif');}
						document.getElementById('fashionAnchor').onmouseout = null;
						document.getElementById('graphic_designAnchor').onmouseout = function onmouseout(event){swapImage('graphic_designLink','assets/images/basics/graphic_design_off.gif');}
					}
					else if(section == 'graphic_design'){
						document.getElementById('advertisingLink').src='assets/images/basics/advertising_off.gif';
						document.getElementById('fashionLink').src='assets/images/basics/fashion_off.gif';
						document.getElementById('graphic_designLink').src='assets/images/basics/graphic_design_on.gif';
	
						document.getElementById('advertisingAnchor').onmouseout = function onmouseout(event){swapImage('advertisingLink','assets/images/basics/advertising_off.gif');}
						document.getElementById('fashionAnchor').onmouseout = function onmouseout(event){swapImage('fashionLink','assets/images/basics/fashion_off.gif');}
						document.getElementById('graphic_designAnchor').onmouseout = null;
					}
					document.getElementById('bioLink').src='assets/images/basics/bio_off.gif';
					document.getElementById('contactLink').src='assets/images/basics/contact_off.gif';
					document.getElementById('pressLink').src='assets/images/basics/press_off.gif';
					document.getElementById('linksLink').src='assets/images/basics/links_off.gif';

					document.getElementById('bioAnchor').onmouseout = function onmouseout(event){swapImage('bioLink','assets/images/basics/bio_off.gif');}
					document.getElementById('contactAnchor').onmouseout = function onmouseout(event){swapImage('contactLink','assets/images/basics/contact_off.gif');}
					document.getElementById('pressAnchor').onmouseout = function onmouseout(event){swapImage('pressLink','assets/images/basics/press_off.gif');}
					document.getElementById('linksAnchor').onmouseout = function onmouseout(event){swapImage('linksLink','assets/images/basics/links_off.gif');}

				}else if(infoOrGallery == "info" || section == "press"){
					
					if(section == "bio"){
						document.getElementById('bioLink').src='assets/images/basics/bio_on.gif';
						document.getElementById('contactLink').src='assets/images/basics/contact_off.gif';
						document.getElementById('pressLink').src='assets/images/basics/press_off.gif';
						document.getElementById('linksLink').src='assets/images/basics/links_off.gif';

						document.getElementById('bioAnchor').onmouseout = null;
						document.getElementById('contactAnchor').onmouseout = function onmouseout(event){swapImage('contactLink','assets/images/basics/contact_off.gif');}
						document.getElementById('pressAnchor').onmouseout = function onmouseout(event){swapImage('pressLink','assets/images/basics/press_off.gif');}
						document.getElementById('linksAnchor').onmouseout = function onmouseout(event){swapImage('linksLink','assets/images/basics/links_off.gif');}
					}
					else if(section == "contact"){
						document.getElementById('bioLink').src='assets/images/basics/bio_off.gif';
						document.getElementById('contactLink').src='assets/images/basics/contact_on.gif';
						document.getElementById('pressLink').src='assets/images/basics/press_off.gif';
						document.getElementById('linksLink').src='assets/images/basics/links_off.gif';

						document.getElementById('bioAnchor').onmouseout = function onmouseout(event){swapImage('bioLink','assets/images/basics/bio_off.gif');}
						document.getElementById('contactAnchor').onmouseout = null;
						document.getElementById('pressAnchor').onmouseout = function onmouseout(event){swapImage('pressLink','assets/images/basics/press_off.gif');}
						document.getElementById('linksAnchor').onmouseout = function onmouseout(event){swapImage('linksLink','assets/images/basics/links_off.gif');}
					}
					else if(section == "press"){
						document.open('selector.php?section='+section,'selectorFrame','');
						document.getElementById('bioLink').src='assets/images/basics/bio_off.gif';
						document.getElementById('contactLink').src='assets/images/basics/contact_off.gif';
						document.getElementById('pressLink').src='assets/images/basics/press_on.gif';
						document.getElementById('linksLink').src='assets/images/basics/links_off.gif';

						document.getElementById('bioAnchor').onmouseout = function onmouseout(event){swapImage('bioLink','assets/images/basics/bio_off.gif');}
						document.getElementById('contactAnchor').onmouseout = function onmouseout(event){swapImage('contactLink','assets/images/basics/contact_off.gif');}
						document.getElementById('pressAnchor').onmouseout = null;
						document.getElementById('linksAnchor').onmouseout = function onmouseout(event){swapImage('linksLink','assets/images/basics/links_off.gif');}
					}
					else if(section == "links"){
						document.getElementById('bioLink').src='assets/images/basics/bio_off.gif';
						document.getElementById('contactLink').src='assets/images/basics/contact_off.gif';
						document.getElementById('pressLink').src='assets/images/basics/press_off.gif';
						document.getElementById('linksLink').src='assets/images/basics/links_on.gif';

						document.getElementById('bioAnchor').onmouseout = function onmouseout(event){swapImage('bioLink','assets/images/basics/bio_off.gif');}
						document.getElementById('contactAnchor').onmouseout = function onmouseout(event){swapImage('contactLink','assets/images/basics/contact_off.gif');}
						document.getElementById('pressAnchor').onmouseout = function onmouseout(event){swapImage('pressLink','assets/images/basics/press_off.gif');}
						document.getElementById('linksAnchor').onmouseout = null;
					}

					document.getElementById('advertisingLink').src='assets/images/basics/advertising_off.gif';
					document.getElementById('fashionLink').src='assets/images/basics/fashion_off.gif';
					document.getElementById('graphic_designLink').src='assets/images/basics/graphic_design_off.gif';
	
					document.getElementById('advertisingAnchor').onmouseout = function onmouseout(event){swapImage('advertisingLink','assets/images/basics/advertising_off.gif');}
					document.getElementById('fashionAnchor').onmouseout = function onmouseout(event){swapImage('fashionLink','assets/images/basics/fashion_off.gif');}
					document.getElementById('graphic_designAnchor').onmouseout = function onmouseout(event){swapImage('graphic_designLink','assets/images/basics/graphic_design_off.gif');}
				}
				currentSection = section;
			}	

			function swapImage(element,newImage) {
  				document.getElementById(element).src=newImage;
				return;
			}

			function openPic(targetIndex){
				//alert(items[0]);
				index = targetIndex;

				if(currentItemType == 'jpg'){
					document.getElementById('mainImage').src='assets/images/basics/blank.jpg';
	 				document.getElementById('mainImage').style.visibility='hidden';					
				}
			//alert("twee "+items[0]);
				// set a new movie file
				if(fetchExtention(items[index]) == 'mov' || fetchExtention(items[index]) == 'mpg' || fetchExtention(items[index]) == 'mp3'){
					if(currentItemType != 'mov'){
						document.getElementById('mainImageDiv').innerHTML = 
						"<EMBED id='mainMov' width=665 height=460 src='"+items[index]+"'>";
						currentItemType = 'mov';

					}else{
						document.getElementById('mainMov').src = items[index];
					}
				}
				// set a new image
				else{
						
					if(currentItemType != 'jpg'){

						document.getElementById('mainImageDiv').innerHTML = 
						"<IMG src='"+items[index]+"' id='mainImage' width=680 height=480>";
						currentItemType = 'jpg';
					}else{
						document.getElementById('mainImage').src=items[index];	
					}
					fixMainImageSize();
				}				
				//fix the link numbers at the bottom
				for(var i=0;i<items.length;i++){
					if(i == targetIndex){
						document.getElementById("nr"+i).className = 'numbersOn';
						document.getElementById("nr"+i).blur();
					}
					else document.getElementById("nr"+i).className = 'numbers';
				}
			}		

			function fetchExtention(target){
				var extention = '';
				for(var i=(target.length-1);i>(target.length-4);i--){
					extention = target.charAt(i) + extention;
				}
				return extention;
			}
		

			function fixMainImageSize(){
				var oldWidth = imageWidths[index];
				var oldHeight = imageHeights[index];
				var newWidth;
				var newHeight;
				var maxWidth = 700;
				var maxHeight = 520;
				if((oldWidth/oldHeight)*maxHeight>maxWidth){
					newWidth = maxWidth;
					newHeight = (oldHeight/oldWidth)*maxWidth;
				}else{
					newHeight = maxHeight;
					newWidth = (oldWidth/oldHeight)*maxHeight;
				}	
				document.getElementById('mainImage').width = newWidth;
				document.getElementById('mainImage').height = newHeight;
				setTimeout("document.getElementById('mainImage').style.visibility='visible'",250);
			}

			function poptastic(){
				newwindow=window.open(items[index],'name','height='+ imageHeights[index] + ', width=' + imageWidths[index]);
				if (window.focus) {newwindow.focus();}
			}
