if(window.MRT===undefined){var MRT={}}MRT.fsm_state=function(d,f,g){var h,transitions={},entry_actions,exit_actions;function raise_error(a){g(['State:',d].concat(a))}function call_actions(a,b,c){if(b!==undefined){$.each(b,function(i,e){debug.info(a+' action: '+e);f[e].apply(null,c||[])})}}h={entry:function(a){if(entry_actions!==undefined){raise_error(['Entry actions ALREADY DEFINED'])}entry_actions=a.constructor===Array?a:[a];return h},exiting:function(a){if(entry_actions!==undefined){raise_error(['Exit actions ALREADY DEFINED'])}entry_actions=a.constructor===Array?a:[a];return h},transition:function(a,b){if(transitions[a]!==undefined){raise_error('Transition:',a,'ALREADY DEFINED')}transitions[a]=b;return h},actions:function(){return(entry_actions||[]).concat(exit_actions||[])},transition_states:function(){return $.map(transitions,function(v,k){return v})},enter:function(a){call_actions('Entry',entry_actions,a)},exit:function(a){call_actions('Exit',exit_actions,a)},state_from_trigger:function(a){return transitions[a]}};return h};MRT.fsm=function(d,e){var f,states={},state;function raise_error(a){throw['FSM:'].concat(a).join(' ');}function check_undefined_state(a){if(states[a]!==undefined){raise_error([d,'State:',a,'ALREADY DEFINED'])}}function get_actions(){return $.map(states,function(v,k){return v.actions()})}function get_transition_states(){return $.map(states,function(v,k){return v.transition_states()})}function check_methods_exist_for_actions(){var i,actions=get_actions(),length=actions.length,action;for(i=0;i<length;i++){action=actions[i];if(e[action]===undefined||e[action].constructor!==Function){raise_error([d,'Action method:',action,'NOT DEFINED'])}}}function check_states_exist_for_transitions(){var i,transition_states=get_transition_states(),length=transition_states.length,transition_state;for(i=0;i<length;i++){transition_state=transition_states[i];if(states[transition_state]===undefined){raise_error([d,'Transition state:',transition_state,'NOT DEFINED'])}}}f={define:function(a){check_undefined_state(a);states[a]=MRT.fsm_state(a,e,raise_error);if(state===undefined){state=states[a]}return states[a]},begin:function(){check_methods_exist_for_actions();check_states_exist_for_transitions();state.enter()},trigger:function(a,b){var c=state.state_from_trigger(a);debug.info(d+' Trigger: '+a);if(c){debug.info(d+' State: '+c);state.exit(b);state=states[c];state.enter(b)}else{debug.warn(d+' Unexpected trigger: '+a)}}};return f};





if(!Array.indexOf){Array.prototype.indexOf=function(a){var i;for(i=0;i<this.length;i++){if(this[i]===a){return i}}return-1}}var OTI={};OTI.slide=function(a,b){return{get_src:function(){return a},get_alt:function(){return b}}};OTI.slideshow_defs=(function(){var d={};return{add_slide:function(a,b,c){if(d[a]===undefined){d[a]=[]}d[a].push(OTI.slide(b,c))},get_slides:function(a){return d[a]}}}());OTI.define_slideshow=function(c){function add_slide(a,b){OTI.slideshow_defs.add_slide(c,a,b);return add_slide}return add_slide};





OTI.define_slideshow('a-global-player')
  ('difc.jpg', 'OTI head office located in the Dubai International Financial Centre')
  ('2.jpg', 'OTI head office');

OTI.define_slideshow('strategy-and-team')
  ('oti-team.jpg', 'Staff members of OTI')
  ('2.jpg', 'Trading floor, Dubai');





OTI.slideshow=function(b,c){var d,actions,fsm,slides,index=0,$img,timeout_id,$img_old,$images,$caption;function reference_elements(){var a=$('#'+c);$images=a.find('.images');$caption=a.find('.caption p')}function first_image_loaded_handler(){fsm.trigger('first_image_loaded')}function kill_timer(){clearTimeout(timeout_id);timeout_id=null}function timer_handler(){kill_timer();fsm.trigger('paused')}function start_timer(){timeout_id=setTimeout(timer_handler,5000)}function increment_index(){index=++index>=slides.length?0:index}function decrement_index(){index=--index<0?slides.length-1:index}function get_src(){return'images/'+b+'/'+slides[index].get_src()}function load_handler(){$img.unbind();fsm.trigger('loaded')}function load_image(){increment_index();$img_old=$img;$img=$('<img />');$img.bind('load readystatechange',load_handler);$img.attr('src',get_src())}function swap_depths(){$img.css({zIndex:2});if($img_old!==undefined){$img_old.css({zIndex:1})}}function revealed_handler(){$img.unbind();fsm.trigger('revealed')}function animate_image(){$img.css({opacity:0}).appendTo($images).animate({opacity:1},1000,'swing',revealed_handler)}function animate_caption(){$caption.css({opacity:0}).text(slides[index].get_alt()).animate({opacity:1},'slow','linear')}actions={initialise:function(){slides=OTI.slideshow_defs.get_slides(b);reference_elements();fsm.trigger('initialised')},load_first_image:function(){var a=$images.find('img'),inline=a[0];if(inline.complete||inline.readyState==='complete'){fsm.trigger('first_image_loaded')}else{a.bind('load readystatechange',first_image_loaded_handler)}},pause:function(){start_timer()},stop_loading:function(){$img.unbind();$img=$img_old;$img_old=undefined;decrement_index();fsm.trigger('stopped')},stop_pausing:function(){kill_timer();fsm.trigger('stopped')},stop_revealing:function(){$img.stop(true,false).css({opacity:1});fsm.trigger('stopped')},load:function(){load_image()},reveal:function(){swap_depths();animate_caption();animate_image()}};fsm=MRT.fsm('Slideshow ('+b+')',actions);fsm.define('initialising').entry('initialise').transition('initialised','first_image_loading');fsm.define('first_image_loading').entry('load_first_image').transition('first_image_loaded','idling').transition('start_received','first_image_loading_then_starting');fsm.define('first_image_loading_then_starting').transition('first_image_loaded','pausing').transition('stop_received','first_image_loading');fsm.define('idling').transition('start_received','pausing');fsm.define('pausing').entry('pause').transition('paused','loading').transition('stop_received','pause_stopping');fsm.define('load_stopping').entry('stop_loading').transition('stopped','idling');fsm.define('pause_stopping').entry('stop_pausing').transition('stopped','idling');fsm.define('reveal_stopping').entry('stop_revealing').transition('stopped','idling');fsm.define('loading').entry('load').transition('loaded','revealing').transition('stop_received','load_stopping');fsm.define('revealing').entry('reveal').transition('revealed','pausing').transition('stop_received','reveal_stopping');fsm.begin();d={start:function(){fsm.trigger('start_received')},stop:function(){fsm.trigger('stop_received')}};return d};OTI.home_panels=(function(){var c,delay_duration=500,fade_duration=1000;function in_handler(a){$(a.currentTarget).find('a').addClass('selected')}function out_handler(a){$(a.currentTarget).find('a').removeClass('selected')}function click_handler(a){window.location=$(a.currentTarget).find('a').attr('href')}function reference_elements(){c=$('#home-page #panels .panel')}function add_pointer_cursor(){c.css({cursor:'pointer'})}function reveal(){c.each(function(a,b){$(b).delay((a+1)*delay_duration).css({opacity:0,visibility:'visible'}).animate({opacity:1},fade_duration,'linear')})}function add_listeners(){c.hover(in_handler,out_handler).click(click_handler)}return{initialise:function(){reference_elements();add_pointer_cursor();add_listeners();reveal()}}}());OTI.trading_panels=(function(){var c,$container,$panels,$close_buttons,current_index,CLOSED=1,OPENING=2,OPENED=3,CHANGING=4,CLOSING=5,state=CLOSED,z_index=0,animation_duration=500;function in_handler(a){$(a.currentTarget).find('a').addClass('selected')}function out_handler(a){$(a.currentTarget).find('a').removeClass('selected')}function opened_handler(){state=OPENED;$.scrollTo('#panels',animation_duration,{easing:'swing'})}function increment_z_index(){z_index++}function open(a){state=OPENING;current_index=a;increment_z_index();$panels.eq(current_index).css({zIndex:z_index});$container.animate({height:412},animation_duration,'swing',opened_handler)}function closed_handler(){state=CLOSED}function close(){state=CLOSING;$container.animate({height:0},animation_duration,'swing',closed_handler)}function close_handler(a){a.preventDefault();if(state===OPENED){close()}}function changed_handler(){state=OPENED}function change(a){if(a!==current_index){state=CHANGING;increment_z_index();current_index=a;$panels.eq(current_index).css({zIndex:z_index,top:-400}).animate({top:0},animation_duration,'swing',changed_handler)}}function select(a){switch(state){case CLOSED:open(a);break;case OPENED:change(a);break}}function select_handler(a){a.preventDefault();var b=$(a.currentTarget).data('index');select(b)}function reference_elements(){c=$('#trading-page #panels .panel');$container=$('#tabs');$close_buttons=$container.find('.close');$panels=$container.find('.tab')}function store_button_indexes(){c.each(function(a,b){$(b).data('index',a)})}function add_pointer_cursor(){c.css({cursor:'pointer'})}function add_listeners(){c.hover(in_handler,out_handler).click(select_handler);$close_buttons.click(close_handler)}function show_close_buttons(){$close_buttons.css({visibility:'visible'})}return{initialise:function(){reference_elements();store_button_indexes();add_pointer_cursor();add_listeners();show_close_buttons()}}}());OTI.flash_animation=function(b){var c,actions,swf;function set_swf(){if(swf===undefined){swf=swfobject.getObjectById('flash-content-'+b)}}function flash_send(a){set_swf();if(swf){swf[a]()}}actions={play:function(){flash_send('startAnim')},stop:function(){flash_send('stopAnim');c.trigger('stopped')}};c=MRT.fsm('Flash '+b,actions);c.define('loading').transition('loaded','idling').transition('play_received','loading_then_playing');c.define('idling').transition('play_received','playing');c.define('loading_then_playing').transition('loaded','playing').transition('stop_received','loading');c.define('playing').entry('play').transition('stop_received','stopping');c.define('stopping').entry('stop').transition('stopped','idling');c.begin();return{play:function(){c.trigger('play_received')},stop:function(){c.trigger('stop_received')},loaded:function(){c.trigger('loaded')},reset:function(){flash_send('resetAnim')}}};OTI.about_panels=(function(){var c,$nexts,$content,IDLE=0,SCROLLING=1,state=IDLE,hashes=[],hash,content_y,slideshows={},swfs=[],swf_last;function remove_ids_and_get_hashes(){$('.about-panel').each(function(a,b){hashes.push(b.id);b.id='about-'+b.id})}function get_content_y(){if(content_y===undefined){content_y=$content.position().top}return content_y}function reference_elements(){$content=$('#content');c=$('#about-page #secondary-navigation a');$nexts=$('#about-page .pagination')}function get_hash(){var h=window.location.hash.replace(/^#/,'');return h.length===0||hashes.indexOf(h)===-1?hashes[0]:h}function highlight_navigation(){var a=hashes.indexOf(get_hash());c.removeClass('selected').eq(a).addClass('selected')}function initialise_slideshows(){slideshows[1]=OTI.slideshow('a-global-player','about-a-global-player');slideshows[2]=OTI.slideshow('strategy-and-team','about-strategy-and-team')}function stop_slideshow(a){var b=hashes.indexOf(a);if(slideshows[b]!==undefined){slideshows[b].stop()}}function start_slideshow(){var a=hashes.indexOf(hash);if(slideshows[a]!==undefined){slideshows[a].start()}}function initialise_swfs(){var i;for(i=0;i<3;i++){swfs[i]=OTI.flash_animation(i)}}function play_swf(){var a=swfs[hashes.indexOf(hash)];a.play();if(swf_last!==undefined){swf_last.reset()}swf_last=a}function stop_swf(a){swfs[hashes.indexOf(a)].stop()}function content_scrolled_handler(){state=IDLE;start_slideshow();play_swf();address_change_handler()}function init_scroll(){$content.scrollTo('#about-'+hash,0)}function scroll_content(){$content.scrollTo('#about-'+hash,500,{easing:'swing',onAfter:content_scrolled_handler})}function scroll_window(){if(window.scrollY>get_content_y()){$.scrollTo('#content','fast',{easing:'swing',onAfter:scroll_content})}else{scroll_content()}}function address_change_handler(){highlight_navigation();if(state===IDLE){state=SCROLLING;var a=hash;hash=get_hash();if(hash!==a){stop_slideshow(a);stop_swf(a);scroll_window()}else{state=IDLE}}}function add_listeners(){$(window).hashchange(address_change_handler)}return{initialise:function(){remove_ids_and_get_hashes();reference_elements();highlight_navigation();hash=get_hash();initialise_slideshows();initialise_swfs();start_slideshow();play_swf();add_listeners();init_scroll()},flash_loaded_handler:function(a){swfs[a].loaded()}}}());OTI.application=(function(){function current_page(){var a=$('body').attr('id');return a?$('body').attr('id').replace(/-page$/,''):''}return{initialise:function(){if(window.debug!==undefined){debug.setLevel(0)}switch(current_page()){case'home':OTI.home_panels.initialise();break;case'trading':OTI.trading_panels.initialise();break;case'about':OTI.about_panels.initialise();break}}}}());$(function(){OTI.application.initialise()});jQuery(function(){$('a[rel="external"]').live('click',function(){this.target="_blank"})});
