

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// GLOBAL VARIABLES /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// stores the active category the website is in at a given time
var globActiveCategory = 'home'; // may be 'home','showreel',tbc...
// MENU GLOBAL: stores the default distance from top to slide it to that position on site load and when menuGlobalMove() restores default position again
var menuGloablDistanceTop = '20%'; // value in %
// stores height of viewport and bodyResize() changes content accordingly onresize
if (document.body) var globalDocumentHeight = document.body.clientHeight;
function bodyResize() {
	if (document.body.clientHeight != globalDocumentHeight) {
		$('contentVVariable').style.height = document.body.clientHeight-200 + 'px';
		// update variable that stores actual document height
		globalDocumentHeight = document.body.clientHeight;
	}
}
// stores various loadstates
// 0:	not loaded
// 1:	loaded
// 2:	loaded, but nees update
var contentResumeLoadstate = 0;
var contentContactLoadstate = 0;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END GLOBAL VARIABLES /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// GLOBAL FUNCTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// counts number of digits before the point and returns the count
function globCountDigits(number) {
	var digitCount = 0;
	while (number>=1) {
		number = number/10;
		digitCount++;
	}
	return digitCount;
}

function globalSendReport(sourceOfTrouble, error) {
	var contactEnquiry = 'There is trouble on Isotoxin.de! ' + sourceOfTrouble + ' has reported an error: ' + error;
	new Ajax.Request('sendmsg.php?contactName=Isotoxin.de Trouble Reporter&contactEmail=trouble@isotoxin.de&contactEnquiry=' + contactEnquiry);
}

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////// COOKIE /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	function Set_Cookie( name, value, expires, path, domain, secure ) {
		// set time, it's in milliseconds
		var today = new Date();
		today.setTime( today.getTime() );
		
		/*
		if the expires variable is set, make the correct 
		expires time, the current script below will set 
		it for x number of days, to make it for hours, 
		delete * 24, for minutes, delete * 60 * 24
		*/
		if ( expires )
		{
		expires = expires * 1000 * 60 * 60 * 24;
		}
		var expires_date = new Date( today.getTime() + (expires) );
		
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}
	
	// this fixes an issue with the old method, ambiguous values
	// with this test document.cookie.indexOf( name + "=" );
	function Get_Cookie( check_name ) {
		// first we'll split this cookie up into name/value pairs
		// note: document.cookie only returns name=value, not the other components
		var a_all_cookies = document.cookie.split( ';' );
		var a_temp_cookie = '';
		var cookie_name = '';
		var cookie_value = '';
		var b_cookie_found = false; // set boolean t/f default f
		
		for ( i = 0; i < a_all_cookies.length; i++ )
		{
			// now we'll split apart each name=value pair
			a_temp_cookie = a_all_cookies[i].split( '=' );
			
			
			// and trim left/right whitespace while we're at it
			cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		
			// if the extracted name matches passed check_name
			if ( cookie_name == check_name )
			{
				b_cookie_found = true;
				// we need to handle case where cookie has no value but exists (no = sign, that is):
				if ( a_temp_cookie.length > 1 )
				{
					cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
				// note that in cases where cookie is initialized but no value, null is returned
				return cookie_value;
				break;
			}
			a_temp_cookie = null;
			cookie_name = '';
		}
		if ( !b_cookie_found )
		{
			return null;
		}
	}
	
	// this deletes the cookie when called
	function Delete_Cookie( name, path, domain ) {
		if ( Get_Cookie( name ) ) document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
	
	function cookieRead() {
		var varCookie = "na";
		if (document.cookie) varCookie = document.cookie;
		return varCookie;
	}
	function cookieUpdate(viewType) {
		// calculate exiry date
		var ablauf = new Date();
		var infuenfTagen = ablauf.getTime() + (5 * 24 * 60 * 60 * 1000);
		ablauf.setTime(infuenfTagen);
		// update cookie
		document.cookie = "galleryViewType=" + viewType;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////// END COOKIE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////// CONTACT SEND /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function contactSend(inquiry,name,email,destinationId,confirmationCodeId) {
		// progress: visual feedback
		// confirmationCodeId:	0: contact form
		//						1: help form
		if (confirmationCodeId == '0') {}
		else if (confirmationCodeId == '1') {
			$('helpBarSendButton').disabled = 'disabled';
		}
		
		// check if content is correctly formatted (email) and all fields filled in
		var errorReport = ''; // stores error msg during checking process and spits them out at the end
		var errorTarget = ''; // stores target id, where error occurred (inquiry field or email field etc.)
			// inquiry message
			if (inquiry == '') {
				errorReport = errorReport + "<li>Please enter a message.</li>";
				if (confirmationCodeId == 0) { errorTarget = 'contactEnquiryInput'; }
				if (confirmationCodeId == '1') $('helpBarInquiry').style.background = '#d97000';
			}
			/*else if (inquiry != '') {
				if (!/^[a-zA-Z0-9\`\~\!\@\#\$\%\^\&\*\(\)\-\_\ \=\+\\\|\[\{\]\}\;\:\'\n\"\,\<\.\>\/\?]+$/.test(inquiry)) {
					errorReport = errorReport + "<li>Please do not use special characters in your message</li>";
					$('helpBarInquiry').style.background = '#d97000';
				}
			}*/
			//email
			if (email == '') {
				//errorReport = errorReport + "<li>Please enter your email address.</li>";
				//if (confirmationCodeId == '1') $('helpBarEmail').style.background = '#d97000';
			} else {
				if (!/^((([a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+\.)+)?[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+)@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}$/.test(email)) {
					errorReport = errorReport + "<li>Your email address has an invalid format</li>";
					if (confirmationCodeId == 0) { errorTarget = 'contactEmailInput'; }
					if (confirmationCodeId == '1') $('helpBarEmail').style.background = '#d97000';
				}
			}
			// name
			/*if (name == '') {
				errorReport = errorReport + "<li>Please enter your name.</li>";
				if (confirmationCodeId == '1') $('helpBarName').style.background = '#d97000';
			} else {
				if (!/^[a-zA-Z ]+$/.test(name)) {
					errorReport = errorReport + "<li>Please do not use special characters and/or numbers in your name</li>";
					if (confirmationCodeId == '1') $('helpBarName').style.background = '#d97000';
				}
			}*/
			// show error warning
			if (errorReport != '') {
				errorReport = "<ul style='position:relative; left:-25px'>" + errorReport + "</ul>";
				globalMessageBox('1',errorReport,errorTarget);
				// help form
				// reactivating submit button
				$('helpBarSendButton').disabled = '';
				// deactivating trigger layers to keep according msg box open
				if (confirmationCodeId == '1') $('helpBarTrigger').style.display = 'none';
			} else {
				// contact form
				// enable transmission-in-progress throbber
				new Effect.Opacity($('contactButtonSend'), {from:1.0, to:0.0, duration:0});
				$('contactButtonSendProgress').style.visibility = 'visible';
				// set variables
				inquiry = convertStringToEntities(inquiry,0);
				inquiry = escape(inquiry);
				name = convertStringToEntities(name,0);
				name = escape(name);
				email = convertStringToEntities(email,0);
				email = escape(email);
				url = 'sendmsg.php';
				data = 'contactName='+name+'&contactEmail='+email+'&contactEnquiry='+inquiry+'&destinationId='+destinationId+'&confirmationCodeId='+confirmationCodeId;
				// send ajax request	
				var aj = new Ajax.Request(  
				  url, {  
				   method:'get',  
				   parameters: data,  
				   onComplete: contactGetResponse  
				   }  
				);
			}
	}
	
	function contactGetResponse(oReq) {
		// check if first 7 characters are "//5Xd8(" to make sure no error has occured while sending the mail (no error msg was returned from sendmsg.php but this checksum plus the rest) and evaluate, otherwise throw error alert
		if (oReq.responseText.charAt(2) == "5" && oReq.responseText.charAt(3) == "X" && oReq.responseText.charAt(4) == "d" && oReq.responseText.charAt(5) == "8" && oReq.responseText.charAt(6) == "(") {
			// msg: message text returned from sendmsg.php
			// destinationId: destination id (div id) returned from sendmsg.php
			// confirmationCodeId: id (int, indicating which contact form was used)
			eval(oReq.responseText);
			// resetting contact form
			if (confirmationCodeId == '0') {
				// preparing errorTarget for globalMessageBox() further down
				var errorTarget = 'contactEnquiryInput';
			}
			else if (confirmationCodeId == '1') {
				$('helpBarSendButton').disabled = '';
				$('helpBarInquiry').value = '';
				$('helpBarName').value = '';
				$('helpBarEmail').value = '';
				
				$('helpBarEmailContainer').style.display = 'none';
				$('helpBarNameContainer').style.display = 'none';
				$('helpBarOptionsButton').style.display = 'block';
			}
			// shout report msg popup
			globalMessageBox('1',msg,errorTarget);
			// reset contact form
			contactReset(0);
		}
		else {
			alert("An error has occurred while sending the message. The Administrator has been notified.");
			globalSendReport("One mail feature", "While making an Ajax request and trying to send a mail via the sendmail.php script an error has occurred.");
		}
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////// END CONTACT SEND /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//	mode:
//		0: hide box
//		1: show box
function globalMessageBox(mode,msg,errorTarget) {
	// update msg
	$('globalMessageBoxContent').innerHTML = msg;
	// show/hide box layer
	if (mode == '1') {
		$('globalMessageBox').style.display = 'block';
		$('globalMessageBoxOkayButton').onclick = function () { globalMessageBox(0,"",errorTarget); };
	}
	else if (mode == '0') {
		$('globalMessageBox').style.display = 'none';
		// contact form
		// focus on <errorTarget> input
		if (contentContactLoadstate == 1) {
			$(errorTarget).focus();
			$(errorTarget).select();
		}
	}
}


// Checks if the browsers is IE or another.
// document.all will return true or false depending if its IE
// If its not IE then it adds the mouse event
if (!document.all)
document.captureEvents(Event.MOUSEMOVE)
// On the move of the mouse, it will call the function getPosition
document.onmousemove = getMousePosition; 
// These varibles will be used to store the position of the mouse
var X = 0
var Y = 0 
// This is the function that will set the position in the above varibles
function getMousePosition(args)
{
  // Gets IE browser position
  if (document.all)
  {
    X = event.clientX + document.body.scrollLeft
    Y = event.clientY + document.body.scrollTop
  }
  // Gets position for other browsers
  else
  { 
    X = args.pageX
    Y = args.pageY
  } 
}

// This prototype extends the Array object to allow for searches
// within the Array. It will return false if nothing is found. If
// item(s) are found you'll get an array of indexes back which matched
// your search request. It accepts strings, numbers, and regular expressions as search
// criteria. 35 is different than '35' and vice-versa.
//
// [http://snippets.dzone.com/posts/show/3631]
Array.prototype.find = function(searchStr) {
	var returnArray = false;
	for (i999=0; i999<this.length; i999++) {
		if (typeof(searchStr) == 'function') {
			if (searchStr.test(this[i999])) {
				if (!returnArray) { returnArray = [] }
				returnArray.push(i999);
			}
		} else {
			if (this[i999]===searchStr) {
				if (!returnArray) { returnArray = [] }
				returnArray.push(i999);
			}
		}
	}
	return returnArray;
}

// converts all characters except the latin alphabet + numeric characters 0-9 into numeric HTML entities (&#nnnn;)
// outputMode:
//	0:	special characters to numeric html entities (&#nnnn;)
//	1:	special characters to numeric unicode codes (115 e.g.)
//	2:	NOT FINALIZED YET: numeric unicode codes to character (115 -> 's' e.g.)
//	3:	special characters to unicode hex
function convertStringToEntities(origStringLocation,outputMode) {
	var nCode = new Array();
	// read character codes from each position in origStringLocation into array 'nCode'
	for (i=0; i<origStringLocation.length; i++) {
		nCode[i] = origStringLocation.charCodeAt(i);
	}
	// holds converted string...
	var convertedString = '';
	// conversion
	switch (outputMode) {
		case 0:
			// array: stores alphabet (no special characters) + numbers 0-9
			alphabetNumbers = new Array('a','a','A','b','B','c','C','d','D','e','E','f','F','g','G','h','H','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','q','Q','r','R','s','S','t','T','u','U','v','V','w','W','x','X','y','Y','z','Z','0','1','2','3','4','5','6','7','8','9',' ');
			for (i=0; i<nCode.length; i++) {
				if (alphabetNumbers.find(String.fromCharCode(nCode[i])) != false) {
					convertedString += String.fromCharCode(nCode[i]);
				} else if (nCode[i] == '10') {
					convertedString += "<br />";
				} else {
					convertedString += "&#" + nCode[i] +";"
				}
			}
			break;
		case 1:
			for (i=0; i<nCode.length; i++) {
				convertedString += nCode[i];
			}
			break;
		case 2:
			// would have to read the orig string (which would be unicode codes seperated by commas e.g.) and translate that back into characters 
			for (i=0; i<nCode.length; i++) {
				convertedString += String.fromCharCode(nCode[i]);
			}
			break;
		case 3: 
			for (i=0; i<nCode.length; i++) {
				convertedString += so_asciiToUniHex(parseInt(nCode));
			}
			break;
		default:
			alert("Please set a valid mode");
			break;
	}
	// returns result
	return convertedString;
}

function so_asciiToUniHex(asciiCode) {
	un = asciiCode.toString(16);
	while(un.length<4) un = "0" + un;
	return "\\u" + un;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END GLOBAL FUNCTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// MENU GLOBAL //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	/// MENU CONTROL //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function menuGlobalHover() {
	// slide out menu
	new Effect.Morph('menuGlobal',{ style: { right:'0px' }, duration:0.4 });
	// disable hoverA to activate buttons underneath
	$('menuGlobalHoverA').style.width = '0px';
	// enable hoverB
	$('menuGlobalHoverB').style.width = '100%';
}
function menuGlobalOut() {
	// slide menu back in
	new Effect.Morph('menuGlobal',{ style: { right:'-550px' }, duration:0.4 });
	// enable in hoverA again
	$('menuGlobalHoverA').style.width = '70px';
	// disable hoverB
	$('menuGlobalHoverB').style.width = '0%';
}
// moves the menu out of the way and back again
	// distanceTop: temp. distance the menu is to be moved to; can be relative or absolute (has to include the appropriate unit, "px" or "%")
	// status:	1: move to temp. position
	//			0: restore default
function menuGlobalMove(status,distanceTop) {
	// move the menu
	// if move to temp. position or...
	if (status == 1) {
		new Effect.Morph('menuGlobal',{ style: { top: distanceTop }, duration:0.4 });
	} else { // if restore to default position
		new Effect.Morph('menuGlobal',{ style: { top: menuGlobalDistanceTop }, duration:0.4 });
	}
}

	/// BUTTONS CONTROL ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
		/// LOCAL BUTTONS CONTROL (behaviour of each single button) ///////////////////////////////////////////////////////////////////////////////////////

		function switchCategory(newCategory) {
			// only do ANYTHING if target location is different to acutal location!
			if (newCategory != globActiveCategory) {
				if (newCategory == 'home') {
					// fade in desktop
					$('desktopOverlay').style.display = 'none';
				} else if (globActiveCategory == 'home') {
					// fade out desktop
					$('desktopOverlay').style.display = 'block';
				}
				if (newCategory == 'showreelSmall') {
					// play showreel
					demoreelMenuPlayMedium();
				} else if (globActiveCategory == 'showreelSmall') {
					// close showreel category
					showreelMenuClose();
				}
				if (newCategory == 'showreelMedium') {
					// play showreel
					demoreelMenuPlayHigh();
				} else if (globActiveCategory == 'showreelMedium') {
					// close showreel category
					showreelMenuClose();
				}
				if (newCategory == 'resume') {
					// show resume
					resumeShow();
				} else if (globActiveCategory == 'resume') {
					// hide resume
					$('resume').style.top = '-5000px';
				}
				if (newCategory == 'contact') {
					// show contact
					msgboxShowB();
				} else if (globActiveCategory == 'contact') {
					// hide contact
					msgboxHideB();
				}
				// set 'globActiveCategory' to new category
				globActiveCategory = newCategory;
				// set location hash to new category
				document.location = "#" + newCategory;
			}
		}

		/// GLOBAL BUTTONS CONTROL (actions that take place each time one of the buttons is pressed (no matter what button)) //////////////////////////////
		
			// - STILL EMPTY -

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END MENU GLOBAL //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// SHOWREEL /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showreelMenuClose() {
	// deactivate video box bgs
	$('showreelHighResWindowBg').style.display = 'none';
	$('showreelMediumResWindowBg').style.display = 'none';
	// deactivate video players
	$('showreelVideoHigh').style.display = 'none';
	$('showreelVideoMedium').style.display = 'none';
	// move menu global back to default position
	menuGlobalMove(1,menuGloablDistanceTop);
	// empty content (ajax loaded, the video itself)
	$('showreelVideoHigh').innerHTML = "<div style='position:absolute; left:427px; top:280px; width:31px; height:31px; background:url(img/throbber/throbber3.gif)'></div>";
	$('showreelVideoMedium').innerHTML = "<div style='position:absolute; left:303px; top:220px; width:31px; height:31px; background:url(img/throbber/throbber3.gif)'></div>";
}

function demoreelMenuPlayHigh() {
	// activateBlackBackgroundForHigh
	$('showreelHighResWindowBg').style.display = 'block';
	// fade out desktop
	$('desktopOverlay').style.display = 'block';
	// activate video high player
	$('showreelVideoHigh').style.display = 'block';
	// move menu global
	menuGlobalMove(1,'0%');
	// load iframe
	var showreelHighIframe = "<iframe src='demoreel.php?val=0&qt=" + haveqt + "' width='853' height='496' frameborder='0' scrolling='no' style='position:absolute; left:19px; top:18px'>Your browser cannot display iframes. You can open the showreel <a href='demoreel.php?val=0&qt=" + haveqt + "' target='_blank'>in a new window</a>.</iframe>";
	$('showreelVideoHigh').innerHTML = showreelHighIframe;
}

function demoreelMenuPlayMedium() {
	// activateBlackBackgroundForMedium
	$('showreelMediumResWindowBg').style.display = 'block';
	// fade out desktop
	$('desktopOverlay').style.display = 'block';
	// activate video Medium player
	$('showreelVideoMedium').style.display = 'block';
	// move menu global
	menuGlobalMove(1,'3%');
	// load iframe
	var showreelMediumIframe = "<iframe src='demoreel.php?val=1&qt=" + haveqt + "' width='608' height='358' frameborder='0' scrolling='no' style='position:absolute; left:19px; top:18px'>Your browser cannot display iframes. You can open the showreel <a href='demoreel.php?val=1&qt=" + haveqt + "' target='_blank'>in a new window</a>.</iframe>";
	$('showreelVideoMedium').innerHTML = showreelMediumIframe;
}

function demoreelMenuShake() {
	// moved to end of index.php
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END SHOWREEL /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// DESKTOP //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function personalProfileMover(mode) {
	if (mode == '1') {
		new Effect.Morph('personalProfile',{ style: { height:'280px' }, duration:0.1 });
		// show trigger layer
		$('personalProfileTrigger').style.display = 'block';
	} else if (mode == '0') {
		new Effect.Morph('personalProfile',{ style: { height:'40px' }, duration:.3, delay:0 });
		// hide trigger layer again
		$('personalProfileTrigger').style.display = 'none';
	}
}

function helpBarMover(mode,suppressTriggerLayer) {
	if (mode == '1') {
		new Effect.Morph('helpBar',{ style: { height:'280px' }, duration:0.1 });
		// show trigger layer
		if (suppressTriggerLayer != '1') $('helpBarTrigger').style.display = 'block';
	} else if (mode == '0') {
		new Effect.Morph('helpBar',{ style: { height:'33px' }, duration:.3, delay:0 });
		// hide trigger layer again
		$('helpBarTrigger').style.display = 'none';
	}
}

function helpBarExpandOptions() {
	$('helpBarEmailContainer').style.display = 'block';
	$('helpBarNameContainer').style.display = 'block';
	$('helpBarOptionsButton').style.display = 'none';
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END DESKTOP //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// CONTACT FORM /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function msgboxShowA() {
	window.setTimeout("msgboxShowB()", 500);
}
function msgboxShowB () {
	// slide in msgbox
	new Effect.Morph('msgbox01',{ style: { top:'0px' }, duration:0.4 });
	// load content via AJAX
	if (contentContactLoadstate == 0) {
		new Ajax.Updater(
			'contactContentBox',
			'contentContact.php', {
				parameters: {	
				},
				evalScripts: true,
				onComplete: function(transport) {
					// if returned status code okay...
					if (transport.status >= 200 && transport.status <= 206)  {
						// set loadstate to 1
						contentContactLoadstate = 1;
					} else { // if returned status code not okay, display notice and send error report
						alert("There is a problem with this subpage. Please try again; the administrator has been notified.");
						globalSendReport("The Contact Form", "While making an Ajax request a non-successful code was returned.");
					}
				}
			}
		);
	} else {
		// focus on msg input field
		$('contactEnquiryInput').focus();
		$('contactEnquiryInput').select();
	}
}

function msgboxHideA () {
	window.setTimeout("msgboxHideB()", 1000);
	$('msgbox01Overlay').style.display = 'none';
}

function msgboxHideB () {
	// slide up msgbox
	new Effect.Morph('msgbox01',{ style: { top:'-203px' }, duration:0.4 });
}

function contactUpdateWidth(This,bgRight,bgTop,bgBottom) {

	var characterCount = $(This).value.length;
	if (characterCount > 8 ) {
		var newWidth = characterCount * 6 + 25;
	} else {
		var newWidth = 70;
	}
	new Effect.Morph($(bgTop),{style:"width:" + newWidth + "px", duration:.2});
	new Effect.Morph($(bgBottom),{style:"width:" + newWidth + "px", duration:.2});
	var newDistanceLeftForBgRight = newWidth + 4;
	new Effect.Morph($(bgRight),{style:"left:" + newDistanceLeftForBgRight + "px", duration:.2});	
	new Effect.Morph(This,{style:"width:" + newWidth + "px", duration:.2});
}

function contactFocus(target) {
	new Effect.Opacity(target, {duration:0.3, from:0.2, to:1.0});
}
function contactBlur(target) {
	new Effect.Opacity(target, {duration:0.3, from:1.0, to:0.2});
}

function contactStepTwo() {
	// Move inquiry box and step two button to left, nam, email to right
	new Effect.Move($('contactEnquiry'),{ x: -200, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonStepTwo'),{ x: -200, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonReset'),{ x: -200, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactName'),{ x: 160, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactEmail'),{ x: 160, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonSend'),{ x: 160, y: 0, mode: 'relative', duration:.3});
	// unhide and fade in name, email, sendButton
	$('contactName').style.visibility = 'visible';
	$('contactEmail').style.visibility = 'visible';
	$('contactNameInput').focus();
	$('contactNameInput').select();
	if (globalNav != 'msie') new Effect.Opacity($('contactEmail'), {from:0.0, to:0.2});
	$('contactButtonSend').style.opacity = "1"; $('contactButtonSend').style.filter = "alpha(opacity=100)";

	
	// Step Two Button
	// deactivating event handler and pointer cursor for step-two-button, activating for reset button
	$('contactButtonStepTwo').onclick = null;
	$('contactButtonStepTwo').style.cursor = "";
	$('contactButtonStepTwo').style.opacity = "0.2";
	$('contactButtonStepTwo').style.filter = "alpha(opacity=20)";
	
	// Reset Button
	$('contactButtonReset').style.cursor = "pointer";
	$('contactButtonReset').style.opacity = "1.0";
	$('contactButtonReset').style.filter = "alpha(opacity=100)";
	
	$('contactButtonReset').onclick = contactReset;
}

//	mode:
//		0: delete contents
//		1: leave contents
function contactReset(mode) {
	// reset input fields, values and size
	if (mode == 0) {
		$('contactNameInput').value = "";
		$('contactNameInput').style.width = "70px";
		$('contactEmailInput').value = "";
		$('contactEmailInput').style.width = "70px";
		$('contactEnquiryInput').value = "";
	}
	// ... and borderShadows
	contactUpdateWidth("contactNameInput","contactNameBgRight","contactNameBgTop","contactNameBgBottom");
	contactUpdateWidth("contactEmailInput","contactEmailBgRight","contactEmailBgTop","contactEmailBgBottom");
	
	// slide back fields into default position
	new Effect.Move($('contactName'),{ x: -160, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactEmail'),{ x: -160, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonSend'),{ x: -160, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactEnquiry'),{ x: 200, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonStepTwo'),{ x: 200, y: 0, mode: 'relative', duration:.3});
	new Effect.Move($('contactButtonReset'),{ x: 200, y: 0, mode: 'relative', duration:.3});
	// fade out and deactivate email/name/sendButton
	if (globalNav != 'msie') new Effect.Opacity($('contactButtonSend'), {from:.3, to:0.0, duration:0.1});
	$('contactButtonSendProgress').style.visibility = 'hidden';
	setTimeout("$('contactName').style.visibility = 'hidden'; $('contactEmail').style.visibility = 'hidden';",100);
	// reset ajaxOutput field
	$('contactAjaxResult').innerHTML = "";
	
	// Step Two Button
	// enable step-two-button event handler again
	$('contactButtonStepTwo').onclick = contactStepTwo;
	// give steptwo button cursor again and make alpha=100
	$('contactButtonStepTwo').style.cursor = "pointer";
	$('contactButtonStepTwo').style.opacity = "1.0";
	$('contactButtonStepTwo').style.filter = "alpha(opacity=100)";
	
	// select first (enquiry) field
	$('contactEnquiryInput').focus();
	$('contactEnquiryInput').select();
	// deactivating reset-button event handler
	$('contactButtonReset').onclick = null;
	
	// Reset Button
	$('contactButtonReset').style.cursor = "";
	$('contactButtonReset').style.opacity = "0.2";
	$('contactButtonReset').style.filter = "alpha(opacity=20)";
}

function contactAjaxRequest(url,data) {
	var aj = new Ajax.Request(  
		url, {  
			method:'get',  
			parameters: data,  
			onComplete: contactGetResponse  
		}  
	);
}  



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END CONTACT FORM /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// RESUME ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function resumeShow() {
	// move container down
	$('resume').style.top = '0px';
	// load content via AJAX
	if (contentResumeLoadstate == 0) {
		new Ajax.Updater(
			'resumeContentBox',
			'contentResume.php', {
				parameters: {	
				},
				evalScripts: true,
				onComplete: function(transport) {
					// if returned status code okay...
					if (transport.status >= 200 && transport.status <= 206)  {
						// set loadstate to 1
						contentResumeLoadstate = 1;
					} else { // if returned status code not okay, display notice and send error report
						alert("There is a problem with this subpage. Please try again; the administrator has been notified.");
						globalSendReport("The Resume", "While making an Ajax request a non-successful code was returned.");
					}
				}
			}
		);
	}
}

function resumeToggleRecord(recordNumber) {
	var recordNameA = 'resumeRecord' + recordNumber + 'a';
	var recordNameB = 'resumeRecord' + recordNumber + 'b';
	var expandButton = 'resumeRecord' + recordNumber + 'ExpandCollapseButton';
	// check if expanded or collapsed and expand/collapse
	if ($(recordNameA).style.display == 'none') {
		$(recordNameA).style.display = 'block';
		$(recordNameB).style.display = 'none';
		// toggle expand/collapse button
		$(expandButton).src = 'img/resumeTimelineExpand.png';
	} else {
		$(recordNameA).style.display = 'none';
		$(recordNameB).style.display = 'block';
		// toggle expand/collapse button
		$(expandButton).src = 'img/resumeTimelineCollapse.png';
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// END RESUME ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// new Effect.Opacity(nodeBg, {duration:0.2, from:1.0, to:0.2});
// opacity=0.2; filter=alpha(opacity=20)
// new Effect.Morph('menuGlobal',{ style: { left:'0px' }, duration:0.4 });