    window.ondom = function(fn){
        window.__ondom_functionArray.push(fn);
    };
    (function(){
        window.__ondom_functionArray = [];
        function _runFunctions(){
            for (var i in window.__ondom_functionArray){
                (window.__ondom_functionArray[i])();
            }
        };
        var _khtml = /(WebKit|khtml)/i.test(navigator.userAgent);
        if(document.addEventListener && !_khtml){
            document.addEventListener("DOMContentLoaded", _runFunctions, false);
        }else if(_khtml){
            var _timer = setInterval(function(){
                if(/loaded|complete/.test(document.readyState)){
                    clearInterval(_timer);
                    _runFunctions();
                }
            }, 10);
        }else{
            document.write("<script id=__ie_ondom defer src=javascript:void(0)><\/script>");
            var script = document.getElementById("__ie_ondom");
            script.onreadystatechange = function(){
                if(this.readyState == "complete"){
                    _runFunctions();
                }
            };
        }
    })();
	
	window.onload = function()
	{
		if (typeof onloadLoader == "function") onloadLoader();
		
		// function used for the FAQ pages, show/hide answers.
		initShowHideAnswers();
		
		// begin *** check photo size
		
		var pageContainerContainer = document.getElementById("page-content");
		if (pageContainerContainer) resizeDivPhotos(pageContainerContainer);
		
		// end *** check photo size
	}
	
	// functions used for the FAQ pages, show/hide answers.
	// FAQ show/hide answers - begin
	
	function initShowHideAnswers()
	{
		var answers = document.getElementsByTagName('div');
		var answersCounter = 1;
		for (var no = 0; no < answers.length; no++)
		{
			if (answers[no].className == 'answer')
			{
				answers[no].id = 'question' + answersCounter + 'answer';
				answersCounter++;
			}
		}
		var questions = document.getElementsByTagName('a');
		var questionsCounter = 1;
		for (var no = 0; no < questions.length; no++)
		{
			if (questions[no].className == 'question')
			{
				questions[no].onclick = function(){showHideAnswer(this.id);};
				questions[no].id = 'question' + questionsCounter;
				
				if (questions[no].name != "" && questions[no].name == location.hash.replace("#", "")) showHideAnswer(questions[no].id);
				
				questionsCounter++;
			}
		}
	}
	
	function showHideAnswer(objID)
	{
		var answerID = objID + "answer";
		
		if (document.getElementById(answerID).style.display != "block")
		{
			document.getElementById(answerID).style.display = "block";
		}
		else
		{
			document.getElementById(answerID).style.display = "none";
		}
		
		return false;
	}
	
	// FAQ show/hide answers - end
	
	//

	function jump(object)
	{
		if (object.value != "")
		{
			window.open(object.value);
		}
	}

	// function for section menu
	
	function showHide(id, state)
	{
		if (state == 'show')
		{
			document.getElementById(id).style.display = '';
			document.getElementById(id + 'link').style.display = 'none';
		}
		else
		{
			document.getElementById(id).style.display = 'none';
			document.getElementById(id + 'link').style.display = '';
		}
	}

	var state = new Object();
	
	//
	
	function toggleItemsUnderSectionMenu(aItem, ulLevelId)
	{
	
		if (document.getElementById(ulLevelId) == null) return true;
	
		parentNodeItemsLevel = document.getElementById(ulLevelId).parentNode;
		classParentNodeItemsLevel = getClassAttribute(parentNodeItemsLevel);
		
		documentLocation = document.location.href.indexOf("#") != -1 ? document.location.href.substring(0, document.location.href.indexOf("#")) : document.location.href;
		
		if (documentLocation != aItem.href && aItem.href.match(/.*\#$/) == null)
		{
			return true;
		}
		
		if (classParentNodeItemsLevel.indexOf('selected') != -1)
		{
			setClassAttribute(parentNodeItemsLevel, classParentNodeItemsLevel.replace(/\bselected\b/g, ''));
			document.getElementById(ulLevelId).style.display = "none";
		}
		else
		{
			var navUl = document.getElementById("section-menu-items").getElementsByTagName('ul');
			for (var i=0; i<navUl.length; i++)
			{
				if (navUl[i].id.match(/^section-menu-[0-9]{1,2}-[0-9]{1,2}$/))
				{
					anothersParentNodeItemsLevel = document.getElementById(navUl[i].id).parentNode;
					anothersClassParentNodeItemsLevel = getClassAttribute(anothersParentNodeItemsLevel)
					setClassAttribute(anothersParentNodeItemsLevel, anothersClassParentNodeItemsLevel.replace(/\bselected\b/g, ''));
					document.getElementById(navUl[i].id).style.display = "none";
				}
			}
			
			document.getElementById(ulLevelId).style.display = "block";
			setClassAttribute(parentNodeItemsLevel, classParentNodeItemsLevel + " selected");
		}
		
		if (!aItem.href.match(/.*\#$/) && classParentNodeItemsLevel.indexOf('selected') == -1 && classParentNodeItemsLevel.indexOf('opened') == -1)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function setClassAttribute(elem, valueAttr)
	{
		navigator.userAgent.indexOf('MSIE') != -1 ? elem.setAttribute("className", valueAttr) : elem.setAttribute("class", valueAttr);
	}
	
	function getClassAttribute(elem)
	{
		classValue = navigator.userAgent.indexOf('MSIE') != -1 ? elem.getAttribute("className") : elem.getAttribute("class");
		return classValue != null ? classValue : "";
	}
	
	// custom Show Hide - Toggle Destinations
	
	function toggleDestinations(id, state)
	{		
		if (state == 'show') 
		{
			document.getElementById(id).style.display = '';
		}
		else
		{
			document.getElementById(id).style.display = 'none';
		}
	}

	function reveal(id, dir, height) {
		var dim = getDims(id);
		var step = 5;
		var alphaStep = (step*100)/dim.height;
		
		if (dir == 'down') 
		{
			if (typeof (height) == 'undefined') {
				height = 0;
				alpha = 0;
			}
			if (height < dim.height) 
			{
				height += step;
				alpha += alphaStep;
				setOpacity(document.getElementById(id), alpha); 
				document.getElementById(id).style.clip = "rect(0px," + dim.width + "px," + height + "px,0px)";
				setTimeout('reveal("' + id + '", "down", ' + height + ');', 10);
			}
		state[id] = 'show';
		} 
		else if (dir == 'up') 
		{
			if (typeof (height) == 'undefined') {
				height = dim.height;
				alpha = 100;
			}
			if (height > 0) 
			{
				height -= 5;
				alpha -= alphaStep;
				setOpacity(document.getElementById(id), alpha);  
				document.getElementById(id).style.clip = "rect(0px," + dim.width + "px," + height + "px,0px)";
				setTimeout('reveal("' + id + '", "up", ' + height + ');', 10);
			}
		state[id] = 'none';
		}
	}
	
	function setOpacity(e,opacity){
	  var o=e.style;
	  o.opacity=(opacity/100); //Opera
	  o.MozOpacity=(opacity/100); //Mozilla+Firefox
	  o.KhtmlOpacity=(opacity/100); //Konqueror
	  //o.filter="alpha(opacity="+opacity+")"; //IE
	}

	function getDims(id) 
	{
		var x = document.getElementById(id).offsetWidth;
		var y = document.getElementById(id).offsetHeight;
		
		return {"width" : x, "height" : y};
	}
	
	// custom Show Hide - Specials Prices
	pricesClicked = 0;
	function showHidePricesBox()
	{
		if (document.getElementById("specialsPrices"))
		{
			if (document.getElementById("specialsPrices").style.display == 'none')
			{
				document.getElementById("specialsPrices").style.display = '';
			}
			else
			{
				document.getElementById("specialsPrices").style.display = 'none';
			}
		}
		
		pricesClicked = 1;
		
	}
	
	function hidePricesBox()
	{
		if (document.getElementById("specialsPrices"))
		{
			if (pricesClicked == 0) {
				document.getElementById("specialsPrices").style.display = 'none';
			} else {
				pricesClicked = 0;
			}
		}
	}
	
	function stopProp(e) {
		if (e && e.stopPropogation) 
			e.stopPropogation();
		else if (window.event && window.event.cancelBubble)
			window.event.cancelBubble = true;
	}
	
	function bookmarkLink()
	{
		title = document.title;
		url = location.href;

		if (window.sidebar)
		{
			window.sidebar.addPanel(title, url,"");
		}
		else if ( window.external )
		{
			window.external.AddFavorite( url, title);
		}
		else if (window.opera && window.print)
		{
			return true;
		}
	}

	function validateMyProjectsAbroadLoginForm()
	{
		var msg = 'Mandatory fields:\n\n';
		var fields = '';
		if ((document.login.login_username.value == '') || (document.login.login_username.value == '[username]')) fields += 'Name \n';
		if ((document.login.login_password.value == '') || (document.login.login_password.value == '[password]')) fields += 'Password \n';

		if (fields != '')
		{
			alert(msg + fields);
		} else {
			document.login.submit();
		}
	}

    clickInputs = [
        {
            id: 'search_box',
            text: '[search]'
        },
        {
            id: 'name_box',
            text: '[name]'
        },
        {
            id: 'email_box',
            text: '[e-mail]'
        },
        {
            id: 'username_box',
            text: '[username]'
        },
        {
            id: 'password_box',
            text: '[password]'
        }
    ];

    window.ondom(function() {
        var input_element;
        for (var i = 0; i < clickInputs.length; i++) {
            var input_element = document.getElementById(clickInputs[i].id)
            if (input_element) {
                input_element.setAttribute('alt', clickInputs[i].text);
                input_element.onfocus = function() {
                    if (this.value == this.getAttribute('alt')) {
                        this.value = '';
                    }
                }
                input_element.onblur = function() {
                    if (this.value == '') {
                        this.value = this.getAttribute('alt');
                    }
                }

            }
        }
    });
	
	function openNewWindowForDownloadsSWF(path, filename, title, width, height)
	{
		var swfWin = window.open("","playswf","width=" + width + ",height=" + height + "status=no,toolbar=no,menubar=no");
		var output = "";
		swfWin.document.open();
			output += '<html><head><title>' + title + '</title></head>';
			output += '<body style="margin: 0px;">';
			output += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '">';
			output += '<param name="movie" value="' + path + filename + '" />';
			output += '<param name="quality" value="high" />';
			output += '<embed src="' + path + filename + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>';
			output += '</object>';
			output += '</body>';
			output += '</html>';
		swfWin.document.write(output);
		swfWin.document.close();
	}
	
	function openNewWindowForStaffProfile(membername, profiledata, pathname)
	{
		var profileWin = window.open("","teamprofile","width=" + 600 + ",height=" + 310 + "status=no,toolbar=no,menubar=no");
		var output = "";
		profileWin.document.open();
			output += '<html>';
			output += '<head>';
			output += 	'<title>' + membername + '</title>';
			output += 	'<style type="text/css">';
			output += 		'body {margin: 0px; padding: 0px;}';
			output += 		'div.profile-data {padding: 20px 20px 0px 40; color: #00573d; font-size: 11px; font-family: Arial, Helvetica, sans-serif;)';
			output += 	'</style>';
			output += '</head>';
			output += '<body>';
			output += 	'<table width="600" height="310" border="0">';
			output += 		'<tr>';
			output += 			'<td height="93" background="/_design/about-us/bg-popup-profile.jpg">';
			output += 				'<table width="100%" height="310"  border="0">';
			output += 					'<tr>';
			output += 						'<td width="65%" height="21"><img src="/_photos/_global/staff/recruitment-team/' + pathname + '-tag.jpg" width="163" height="25"></td>';
			output += 						'<td width="35%" rowspan="2" valign="top">';
			output += 							'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="203" height="222">';
			output += 								'<param name="movie" value="/_photos/_global/staff/recruitment-team/' + pathname + '.swf">';
			output += 								'<param name=quality value=high>';
			output += 								'<embed src="/_photos/_global/staff/recruitment-team/' + pathname + '.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="203" height="222"></embed>';
			output += 							'</object></td>';
			output += 					'</tr>';
			output += 					'<tr>';
			output += 						'<td valign="top">';
			output += 							'<div class="profile-data">';
			output += profiledata;
			output += 							'</div>';
			output += 						'</td>';
			output += 					'</tr>';
			output += 					'<tr>';
			output += 						'<td>&nbsp;</td>';
			output += 						'<td>&nbsp;</td>';
			output += 					'</tr>';
			output += 				'</table></td>';
			output +=		'</tr>';
			output += 	'</table>';
			output += '</body>';
			output += '</html>';
		profileWin.document.write(output);
		profileWin.document.close();
	}

    function scrollToElement(element)
    {
        var posX = 0;
        var posY = 0;

        while (element != null) {
            posX += element.offsetLeft;
            posY += element.offsetTop;
            element = element.offsetParent;
        }
        window.scrollTo(posX, posY);
    }
	
	resizeDivPhotos = function(container)
	{
		items = container.getElementsByTagName("div");
		
		for (var item in items)
		{
			if (String(items[item].className).indexOf("photo") != -1)
			{
				items[item].getElementsByTagName("strong")[0].style.width = items[item].getElementsByTagName("img")[0].width - 10 + "px";
			}
		}
	}
	
	//video
	$(document).ready( function() {		
		$('video').each(function(){
			jwplayer(this.id).setup({
				flashplayer: "/_videos/jw_player/player.swf",
				controlbar: "bottom",
				skin: "/_videos/jw_player/skin_min.zip",
				stretching: "fill"
			});
		});
	});


