function sleep(delay) { var start = new Date().getTime(); while (new Date().getTime() < start + delay); }
function is_ie6() { return ($.browser.msie && $.browser.version=="6.0") }
function report_link(el) { window.open($(el).attr('rel')); }

var rtl = false;

(function($) {
	  var cache = [];
	  // Arguments are image paths relative to the current page.
	  $.preLoadImages = function() {
	    var args_len = arguments.length;
	    for (var i = args_len; i--;) {
	      var cacheImage = document.createElement('img');
	      cacheImage.src = arguments[i];
	      cache.push(cacheImage);
	    }
	  }
	})(jQuery);

$(function(){
	
	rtl = $('body').hasClass('rtl');
	
	setTimeout('Customs.bindEvents();',200);
	Customs.newsTicker('#newstick .view-content ul', 'li.newsitem', 'slideUp');
	
	Customs.handleTypography();
	Customs.makeSubmitHref();
	
	Customs.autoSizeSearch();
	Customs.highlightCompany();
	Customs.initPlatformVideos();
	Customs.fixFooter();
	Customs.fixButtons();
	
	Customs.fixFlow();
	
	if($("body").hasClass('home')) {
		$(".abcd:last .first .cnt").prepend('<span class="hp-icon1"></span>');
		$(".sidebar .cnt").prepend('<span class="hp-icon2"></span>');

		// New Homepage Banners
		
		// Default = EN
		lang = 'en';
		banner_path = '/sites/all/themes/agricola/images/hp-banners/';
			
		if($("body").hasClass('de')) { lang = 'de'; }
		if($("body").hasClass('es')) { lang = 'es'; }
		if($("body").hasClass('fr')) { lang = 'fr'; }
		if($("body").hasClass('it')) { lang = 'it'; }
		if($("body").hasClass('nl')) { lang = 'nl'; }
		if($("body").hasClass('pt-br')) { lang = 'pt'; }
		if($("body").hasClass('ro')) { lang = 'ro'; }
		if($("body").hasClass('ru')) { lang = 'ru'; }
		if($("body").hasClass('sv')) { lang = 'sv'; }
		if($("body").hasClass('tr')) { lang = 'tr'; }
		if($("body").hasClass('ar')) { lang = 'ar'; }
		if($("body").hasClass('pl')) { lang = 'pl'; }
		
		// Preload all the over modes
		jQuery.preLoadImages(banner_path + "open-live/open-live-over-" + lang + ".png",
							 banner_path + "upgrade-live/upgrade-live-over-" + lang + ".png",
							 banner_path + "open-demo/open-demo-over-" + lang + ".png",
							 banner_path + "deposit/deposit-over-" + lang + ".png",
							 banner_path + "video-tutorial/video-tutorial-over-" + lang + ".png",
							 banner_path + "live-chat/live-chat-over-" + lang + ".png");

		/* Open Live */
		$(".home .sidebar .hpbanner-open-live").css("background-image", 
							"url('" + banner_path + "open-live/open-live-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "open-live/open-live-over-" + lang + ".png')");
				}, function () {
					$(this).css("background-image", 
							"url('" + banner_path + "open-live/open-live-" + lang + ".png')");
				});
		
		/* Upgrade Live */
		$(".home .sidebar .hpbanner-upgrade-live").css("background-image", 
							"url('" + banner_path + "upgrade-live/upgrade-live-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "upgrade-live/upgrade-live-over-" + lang + ".png')");
				}, function () {
					$(this).css("background-image", 
							"url('" + banner_path + "upgrade-live/upgrade-live-" + lang + ".png')");
				});
		
		/* Open demo */
		$(".home .sidebar .hpbanner-open-demo").css("background-image", 
							"url('" + banner_path + "open-demo/open-demo-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "open-demo/open-demo-over-" + lang + ".png')");
				}, function () {
					$(this).css("background-image", 
							"url('" + banner_path + "open-demo/open-demo-" + lang + ".png')");
				});
				
		/* Deposit */
		$(".home .sidebar .hpbanner-deposit").css("background-image", 
							"url('" + banner_path + "deposit/deposit-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "deposit/deposit-over-" + lang + ".png')");
				}, function () {
					$(this).css("background-image", 
							"url('" + banner_path + "deposit/deposit-" + lang + ".png')");
				});
		
		/* Video Tutorial */
		$(".home .sidebar .hpbanner-video-tutorial").css("background-image", 
							"url('" + banner_path + "video-tutorial/video-tutorial-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "video-tutorial/video-tutorial-over-" + lang + ".png')");
				},function () {
					$(this).css("background-image", 
							"url('" + banner_path + "video-tutorial/video-tutorial-" + lang + ".png')");
				});
		
		/* Live Chat */
		$(".home .sidebar .hpbanner-live-chat").css("background-image", 
							"url('" + banner_path + "live-chat/live-chat-" + lang + ".png')").hover(function () {
					$(this).css("background-image", 
							"url('" + banner_path + "live-chat/live-chat-over-" + lang + ".png')");
				},function () {
					$(this).css("background-image", 
							"url('" + banner_path + "live-chat/live-chat-" + lang + ".png')");
				});
	}
	
	if (is_ie6()) {
		$('html').addClass('ie6');
		// Fix png's
		var selectors = new Array(//'#nav li',
								  '#nav .submenu',
								  '#nav .submenu ul', 
								  'img', 
								  '.icon_java',
								  '.icon_gfc',
								  '.icon_mobile',
								  '.front-scrollables .navi a',
								  '#login-dropdown-form-wrapper',
								  '#lang-dropdown-arrow');
		
        DD_belatedPNG.fix(selectors.join(", "));
        updatePngFix = true;
	}
	
	
	$('form input[type=submit], form button[type=submit]').removeAttr('disabled');
	$('form').bind('submit',function(event) {
		$('input[type=submit], button[type=submit]', this).attr('disabled','disabled').css('opacity','0.5');
	});
	
	
	setTimeout('Customs.customTracking();',2000);
		
});

Customs = function () {
	var that = {};
	var lang_timer;

	that.customTracking = function() {
		$('.big_blue, .big_blue + .no-decoration').click(function (e) {
			if(typeof(custom_tracking_string) != 'undefined') {
				if(typeof(pageTracker) != 'undefined') {
					try {
						_gaq.push(['_trackEvent', 'TY Pages', 'Click', custom_tracking_string]);
						setTimeout('window.location = "' + $(this).attr('href') + '";' , 500);
					}
					catch(err) {}
				}
			}
			e.preventDefault();
		});
	}
	
	that.fixFlow = function () {
		if(typeof(A) != 'undefined') {
		for(X in A.Tabs) {
			tab = A.Tabs[X];
			if(tab.linkurl != "") {
				$(".front-scrollables").prepend('<a class="scrollable_overlay" href="' + tab.linkurl + '"></a>');
				return;
			}
		}
		}

	}
	
	that.fixButtons = function () {
		
		$(".buttons").removeClass("buttons").addClass("ubutton");
		$(".ubutton .yellow").removeClass("yellow").addClass("orange");
		$(".ubutton .b36").removeClass("b36").addClass("blue");
		$(".ubutton .b32").removeClass("b32").addClass("blue");
		
		
		$(".ubutton a, .ubutton button").each(function () {
			
			var path = '/sites/all/themes/agricola/images/buttons/';
			
			var color = 'blue';
			
			if($(this).hasClass('blue')) color = 'blue';
			if($(this).hasClass('orange')) color = 'orange';
			if($(this).hasClass('yellow')) color = 'yellow';
			
			var arrows = false;
			
			if($(this).hasClass('arrows')) arrows = true;
			
			var normal_filename = path + color + (arrows ? ' arrows' : '') + (rtl ? ' rtl' : '') + '.png'; 
			var hover_filename = path + color + (arrows ? ' arrows' : '') + ' hover' + (rtl ? ' rtl' : '') + '.png';
			
			$(this).css('background-image', 'url("' + normal_filename + '")');
			
			var k = Array();
			$(this).parents().each(function () { 
				if($(this).css('display') == 'none') {
					k.push(this);
					$(this).css('display', 'block').css('visibility','hidden');
				}
			});
			
			var text_width = $(this).outerWidth();
			
			if (is_ie6()) {
				text_width += 30;
			}
			
			if(k) {
				for(z in k) {
					$(k[z]).css('display', 'none').css('visibility','visible');
				}
			}

			
			
			var bg_position = (Math.round((text_width + 10) / 40)) * 40;
			var padding = '0px 10px';
			
			if(arrows) {
				if(rtl) {
					var padding = '0 0 0 10px';
				} else {
					var padding = '0 10px 0 0';
				}
			}
			
			$('span', this).css('padding', padding);
			
			$(this).css('background-position', (rtl ? '100%' : '0px') + ' -' + bg_position + 'px');
			$(this).css('width', bg_position + (arrows ? 70 : 55));
		     
			$(this).hover(function () {
				$(this).css('background-image', 'url("' + hover_filename + '")');
			}, function () {
				$(this).css('background-image', 'url("' + normal_filename + '")');
			});
			
			if(is_ie6()) DD_belatedPNG.fixPng(this);
			
		});
			
		
		$(".double-button").each(function () {
			
			var k = $(this).parent().width();
			var first = $(".ubutton:first", this);
			var last = $(".ubutton:last", this);

			if(rtl)
			{
				last.css("margin-left", "0");
			}
			else {
				last.css("margin-right", "0");
			}
			
			var first_width = parseInt(first.css("margin-left")) + parseInt(first.css("margin-right")) + parseInt(first.outerWidth()); 
			var last_width = parseInt(last.css("margin-left")) + parseInt(last.css("margin-right")) + parseInt(last.outerWidth());
			
			$(this).css("width", first_width + last_width);
			var new_width = (k - $(this).width()) / 2;
			
			$(this).css("margin-left", new_width);
			$(this).css("margin-right", new_width);
			
			$(this).css("zoom", "1");
			
		});
			
	}
	
	that.fixFooter = function () {
		$("#sitemap .stacked ul.menu li.expanded").each(function () {
			var el = $("a:first",this);
			if(el.outerHeight() > 20) {
				// Fix #3806
				el.html(el.html().replace(" ", "<br>"));
				el.css({'margin-top' : '-5px', 'z-index': '100', 'position': 'relative' , 'font-size' : '70%' , 'height': '20px'});
			}
		});
	}
	
	that.initPlatformVideos = function() {
		
		// Not platforms videos page
		if($("#platforms-video-selection li").size() == 0) return;
		
		// Wrap the container div
		$("#platforms-video-container").wrap('<div id="platforms-video-container-wrap"></div>');
		
		var education_videos_path = "/sites/all/files/en/gfc-platforms-video-guide/";
				
		function loadFlash(config_file, lang) {
			//console.log(config_file + " " + lang);
			flashvars = {'wmode': 'transparent', 'VideoConfigFile': config_file },
			params = {'wmode': 'transparent', 'allowFullScreen': 'true', 'play': 'false', 'loop': 'false'},
			attributes = {'wmode': 'transparent'};
			swfobject.embedSWF("/sites/all/files/" + lang + "/gfc-platforms-video-guide/GFCTrader-Video.swf", "platforms-video-container", "675", "512", "9.0.0","expressInstall.swf", flashvars, params, attributes);	
		}
		
		function playVideo(video_id) {
			
			var lang = $("body").attr("rel");
			var config_file = "/sites/all/files/" + lang + "/gfc-platforms-video-guide/" + video_id + ".xml";
			var config_file_en = "/sites/all/files/en/gfc-platforms-video-guide/" + video_id + ".xml";
			
			if(lang == "en" || lang == "en-us" || lang == "nl" || lang == "pt") {
				// These languages default to english video
				loadFlash(config_file_en, "en");
			}
			else {
				// Check if config file for current language is present
				$.ajax({
					url: config_file,
					type: "GET",
					cache: false,
					success: function () {
						loadFlash(config_file, lang);
					}, // Play english otherwise
					error: function () {
						loadFlash(config_file_en, "en");
					}
				});
			
			}

		}

		// Events for A / IMG click to play video
		$("#platforms-video-selection li a, #platforms-video-selection li span.icon").click(function (e) {
			e.preventDefault();
			var	video_id = $(this).parents("li").attr("className");
			playVideo(video_id);
		});
		
		// Autoplay First Video
			var	video_id = $("#platforms-video-selection li:first").attr("className");
			playVideo(video_id);
	}
	
	// Timer for hiding lang dropdown
	that.lang_hide = function () {
		$("#lang-dropdown").hide(); 
		$('#langbtn').css('visibility','visible');
	}
	
	that.highlightCompany = function () {
		
	    $("#content p.highlight-tm").each(function(){
	        var container = this,
	        	company = "GFC Markets",
	            content = container.innerHTML,
	            pattern = new RegExp(company),
	            replaceWith = '<span class="highlighted-tm">GFC <span>Markets</span></span>',
	            highlighted = content.replace(pattern,replaceWith);
	        container.innerHTML = highlighted;
	    });
	}
	
	that.autoSizeSearch = function () {
		
		var btn_width = $("#edit-search-submit-wrapper").outerWidth();
		var container = 180;
		
		var inner = $("body").hasClass("in");
		
		if(inner) {
			container = parseInt($("#google-search-form").parents("#inbar").css('width'));
		}
		else {
			container = parseInt($("#google-search-form").parents(".sidebar").css('width')) - 20;
		}
		
		var txt_width = container - btn_width - 16;
		
		// Some RTL IE6 tweaks
		if(is_ie6() && rtl) {
			if(inner) {
				txt_width = txt_width - 3;
			}
			else {
				txt_width = txt_width - 3;
			}
		}
				
		$("#edit-search-input").css("width", txt_width + "px");
		
	}
	
	that.handleTypography = function () {
		
		// Dirty fix -- ACT Real/Demo arent wrapped with a .wrap
		$(".act-real-container, .act-demo-container").wrapInner('<div class="wrap"></div>'); 
		
		
		$("#google-search-form").submit(function () {
			if($("#google-search-form-hidden").size() > 0)
			{
			    $(".gsc-input").attr("value", $("#edit-search-input").attr("value"));
			    $(".gsc-search-button").click();
				return false;
			}
		});
		
		$("#edit-search-submit").click(function (e) {
			if($("#google-search-form-hidden").size() > 0) {
				e.preventDefault();
				$(".gsc-input").attr("value", $("#edit-search-input").attr("value"));
				$(".gsc-search-button").click();
			}
		});

		// Init timer, 4 sec
		$("#lang-dropdown").mouseenter(function () {
			clearTimeout(lang_timer);
		}).mouseleave(function () {
			lang_timer = setTimeout("Customs.lang_hide()", 4000);
		});
		
		$(".content-box h3").each(function () {
			var id = '';
			if($(this).attr("id") != "") id = ' id="' + $(this).attr("id") + '-wrap"';
			$(this).wrap('<div class="h3-wrap"'+ id + '></div>');
		});
		
		$(".add-wrapper").each(function(i, obj) { $(obj).wrap('<div class="wrapper ' + obj.tagName + '-wrap"></div>'); });		
		// Legends
		$("#content form fieldset legend").wrap('<div class="legends"></div>');
		$('.in #content form fieldset').each(function(i,e) {
			$('.form-item:first',this).addClass('form-item-first'); /* The typo is on purpose */
		});
		
		$('#content form .help').live('mouseover',function() { $(this).addClass('hover-help'); $(this).attr('title',''); }).live('mouseout', function() { $(this).removeClass('hover-help'); });
		/*
		$('.form-item, fieldset.group').hover(
			function() {
				if ($('.form-item',this).length == 0) {
					$(this).addClass('hover');
				}
			},
			function() {
				$(this).removeClass('hover'); 
			}
		);
		
		
		$('.form-item input, fieldset.group select').bind('focus',
			function() { $(this).parent().addClass('focused'); }
		)
		.bind('blur',
			function() { $(this).parent().removeClass('focused'); }
		
		);
		*/
		
		$("#content table").each(function () {
			
				if(this.className == 'no-borders') {
					$(this).css({ border: "none" });
					$("tbody", this).css({ border: "none" });
					$("td", this).css({ border: "none" });
					return;
				}
			
			$(this).attr({ cellspacing: "0px", cellpadding: "0px" });
			if(!$(this).attr('width')) { $(this).css('width', '100%'); }
			
			if($("thead th", this).size() > 0 || $("tbody th", this).size() > 0) { 
				$(this).wrap('<div class="table_rounded_wrap">');
			}
			
		});
		
		$(".table_rounded_wrap").each(function () {
			var width = $("table", this).outerWidth();
			var height = $("table", this).height();
			$(this).css({ width: width });

			if($("table thead th", this).size() > 0) { 
				$(this).prepend('<div class="rounded_btl"></div><div class="rounded_btr"></div><div class="rounded_bl"></div><div class="rounded_br"></div>');
			}
			else {
				$(this).prepend('<div class="rounded_tl"></div><div class="rounded_tr"></div><div class="rounded_bl"></div><div class="rounded_br"></div>');
			}
			
			if($("table thead th h2", this).size() > 0) {
			   $("table tbody tr:first", this).addClass("double-header");
			}
				
			
			if($.browser.mozilla) {
				$('.rounded_tl, .rounded_btl').css({ top: '-1px', left: '-1px' });
				$('.rounded_tr, .rounded_btr').css({ top: '-1px', right: '0px' });
				$('.rounded_bl, .rounded_bbl').css({ bottom: '0px' , left: '-1px' });
				$('.rounded_br, .rounded_bbr').css({ bottom: '0px', right: '0px' });
			}
			
		});
		
		$("#faq-list .faq-item .h3-wrap").click(function () {
			var el = $(this).parent().find(".faq-text .faq-inner").toggle();
		});
		
		$("#faq-list .faq-item:first").find(".faq-text .faq-inner").show();
		
		$('a.submit').bind('click',function(e) {
			frm = $(this).parents('form').submit();
			e.stopPropagation();
			e.preventDefault();
		});
		counti = 0;
		$('form').bind('submit', function(e) {
			if (this.submitted) {
				e.preventDefault();
				e.stopPropagation();
			}
			$(this).addClass('submitted');
			this.submitted = true;
		})
	}
	
	that.bindEvents = function () {
		
		$(".cvv2-preview").append('<span class="cvv2-tooltip"></span>').hover(function () {
			$(".cvv2-tooltip").show();
		}, function () {
			$(".cvv2-tooltip").hide();
		});
		
		// Clicking outside lang select / login or pressing ESC to hide dropdowns
		$(document).click(function (e) {
	
			if($(e.target).parents(".langsel").size() == 0)	{
				$("#lang-dropdown").hide(); 
				$('#langbtn').css('visibility','visible');
			}
	
			if($(e.target).parents(".login").size() == 0)	{
				$("#login-dropdown").hide();
				$(".login p").css('visibility','visible');
			}
			
			if($(e.target).parents("#chart_instruments_title").size() == 0)	{
				$("#chart_instruments_dropdown").hide();
			}

		}).keypress(function(e) {
			 var kC = (window.event) ? event.keyCode : e.keyCode;
		     if(kC == 27) {
		    	 $("#lang-dropdown, #login-dropdown").hide(); 
				 $("#langbtn, .login p").css('visibility','visible');
				 $("#chart_instruments_dropdown").hide();
				 
		     }
		});
		
		
		$('#logbtn').click(function (e) {
			
			if($(".login p").css('visibility') == 'visible') {
				$(".login p").css('visibility','hidden');
			}
			else {
				$(".login p").css('visibility','visible');
			}
			
			$("#login-dropdown").toggle();
			
			e.preventDefault();
			
			// Do nothing if IE6 arabic --> CSS fix
			if(is_ie6() && $("body").hasClass("ar")) return;
			
			var delta = $("#login-dropdown fieldset").width() + $("#login-dropdown .custom-button").outerWidth() + 30;
			$("#login-dropdown-form-wrapper, #login-dropdown").css("width", delta + "px");
	
		});
		
		$('#login-email').focus(function () { $(this).select(); });
		
		// Lang Nav
		$('#lang-dropdown ul').prepend('<li class="first"></li>').append('<li class="last"></li>');
		$('#lang-dropdown').prepend('<span id="lang-dropdown-arrow"></span>');
		$('#lang-dropdown-arrow').click(function () { $("#lang-dropdown").hide(); $('#langbtn').css('visibility','visible'); });
		$('#langbtn').click(function (e) { e.preventDefault(); $("#lang-dropdown").show(); $('#langbtn').css('visibility','hidden'); });
		
		// Main Nav
		
		$('#nav ul li ul').each(function () {
			$("li:first", this).css("border","none");
		});
		
		
		$('#nav a').attr("title", "");
		
		$('#nav ul li.expanded').hoverIntent(that.positionSubMenu, that.hideSubMenu);
		/*mouseenter( function (e) {
			that.positionSubMenu(e, $("ul", this));
		}).mouseleave( function () {
			
			// $("#nav ul li ul").hide();
			
		});
		*/
		
		// Tabbed Boxes
		$(".tabbed-box .top ul li").click(function (e) {
			e.preventDefault();
			var id = $(this).prevAll().size();
			$(this).parents(".tabbed-box").find(".current").removeClass("current");
		
			$(this).addClass("current");
			$(this).parents(".tabbed-box").find(".tab-content").hide();
			var content = $(this).parents(".tabbed-box").find(".tab-content")[id];
			$(content).addClass("current").show();
			
		});
	
	}
	
	var getRight = function (obj) {
		var left = $(obj).position().left;
		var width = $(obj).outerWidth();
		var right = left + width;
		return right;
	}
	that.hideSubMenu = function (event) {
		obj = $('ul', this);
		obj.hide();
	}
	
	that.positionSubMenu = function (event) {
		obj = $('ul', this);
		
		if (!that.temp.posd) {
			that.temp.posd = {};
		}
		$(obj).show();
		if (!obj[0].positioned) {
			that.temp.hdWidth = hdWidth = $('#hd').outerWidth();
			that.temp.hdOffset = hdOffset = $('#hd').offset();
			hdLeft = that.temp.hdOffset.left;
			that.temp.hdOffset.right = hdRight = hdLeft + that.temp.hdWidth;
			
			var width = $(obj).outerWidth();
			var offset = $(obj).offset();
			var right = width + offset.left;
			var left = offset.left;
			var css = $(obj).css;
			
			if (right > hdRight || right > (hdRight - 30)) {
				delta = right - hdRight;
				if (rtl) {
					$(obj).css('right', delta + 'px');
				} else {
					$(obj).css('left', ($(obj).position().left - delta) + 'px');
				}
			}
			if (left < hdLeft || left < (hdLeft - 30)) {
				delta = left - hdLeft;
				if (rtl) {
					$(obj).css('right', delta + 'px');
				} else {
					$(obj).css('left', ($(obj).position().left - delta) + 'px');
				}
			}
		}
	}
	
	
	that.menuButtons = function (container) {
		var	container = 	$(container),
			widths = 		[],
			pointers =		[],
			totalItems = 	0,
			itemsWidth = 	0,
			containerWidth = container.width();
		
		$("ul.menu li.expanded", container).each(function () {
			var el = $("a:first", this);
			var el_html = el.attr("innerHTML");
			el.wrapInner('<span class="s"></span>').addClass("main");//.attr("innerHTML", el_html.replace(" ", "&nbsp;"));
		});
		
		var items =	$('ul li a.main', container);
				
		items.each(function(i, item){
			var origWidth = $('span.s', item).width();
			if (!origWidth) return;
			++totalItems;
			widths[i] = {'width': origWidth, 'item': item};
			itemsWidth += origWidth;
		});
		
		var delta = containerWidth - itemsWidth - 26;
		
		delta = parseInt(delta / totalItems / 2);
		
		if(is_ie6()) delta = (delta / 2) + 0.5;
		
		items.each(function(i, item){
			$(item).css("margin-left", delta + "px").css("margin-right", delta + "px");
		});
	};
	
	/**
	 Create a news ticker that moves the first item away from view,
	 and append it to the end of the list.
	 
	 Usage: Customs.NewsTicker(container string, target string, style string)
	 	
	 	container	- the selector to use to select the desired container
	 	target		- the selector to use to select the single items inside the container
	 	style		- currently supporting only two styles: 'moveUp' and 'slideUp', default is slideUp
	 	
	 Other options can be configured inside the script. someday, oneday, I may
	 create a better options configuration, but for now, I think this will do.
	 
	 Written by: Eli Sklar
	 Creation Date: 22 Nov 2009
	*/
	that.newsTicker = function () {
		var newsTicker = {};
		var me = {};
		
		me.Timeout = 3500;
		me.FadeoutTime = 750;
		me.Style = 'slideUp';
		me.mouseIn = false;
		
		newsTicker.init = function (container, selector, style) {
			me.container = container = $(container);
			me.Selector = selector;
			if (_.isFunction(me.styles[style])) {
				me.Style = style;
			}
			var items = $(selector, container);
			
			if (items.length > 0) {
				me.setTimer();
			}
			me.container
				.bind('mouseenter', me.mouseEnter)
				.bind('mouseleave', me.mouseLeave);
			
			return newsTicker;
		};
		
		
		me.changeTicker = function () {
			if (me.mouseIn) {
				return;
			}
			var item = $(me.Selector, me.container)[0];
			newItem = $(item).clone();
			
			me.styles[me.Style](item, me.container, function () { $(item).remove(); })
			
			$(me.container).append(newItem);
			
		};
		
		me.setTimer = function () {
			me.timerId = setInterval(me.changeTicker, me.Timeout);
		};
		me.mouseEnter = function () {
			me.mouseIn = true;
		};
		me.mouseLeave = function () {
			me.mouseIn = false;
		};
		
		me.styles = {};
		
		me.styles.moveUp = function (target, container, callbackFunction) {
			var target = $(target);
			var container = $(container);
			container.css('position', 'relative');
			var height = target.outerHeight();
			
			$(container).animate(
				{
					top: '-' + height + 'px'
				},
				me.FadeoutTime,
				function() { 
					callbackFunction();
					$(this).css('top','0');
				}
			);
		};
		
		me.styles.slideUp = function (target, fadeOutTime, callback) {
			$(target).slideUp(me.fadeoutTime, callback);
		};
		
		return newsTicker;
	}().init;
	
	
	that.makeSubmitHref = function () {
		$('form a.submit').click(function(e) {
			$(this).parents('form').submit();
			e.preventDefault();
			e.stopPropagation();
		});
	};
	
	that.temp = {};
	
	return that;
}();

