/* Gatlin Namespace */

Gatlin_Blog = {
	init: function() {
		// open some links in a new window
		$('a[rel="external"]').attr('target', '_blank');

		Gatlin_Blog.flashContent();
		Gatlin_Blog.toggleLanguageList();
		Gatlin_Blog.toggleSearchText();
		Gatlin_Blog.quickSearch();
	}, // end init()

	flashContent: function() {
		// add globe logo
		var size = 65;
		$('body.blog div#header h1').prepend('<span class="logo_globe"></span>').children(':first').flash({
			hasVersion: '9.0.0',
			height: size,
			params: { allowfullscreen: 'false', allowscriptaccess: 'sameDomain', quality: 'high', wmode: 'transparent' },
			swf: '/wp-content/themes/gatlin_international/media/globe_gg.swf',
			width: size
		});

		// header loop
		$('body.blog div#header h1').after('<span id="header_promo_loop"></span>').next().flash({
			hasVersion: '9.0.0',
			height: 39,
			params: { allowfullscreen: 'false', allowscriptaccess: 'sameDomain', quality: 'high', wmode: 'transparent' },
			swf: '/wp-content/themes/gatlin_international/media/header_loop.swf',
			width: 470
		});
	}, // end flashContent()

	quickSearch: function()	{
		$('form.quick_search input.search')
		.autocomplete('/wp-content/themes/gatlin_international/ac_search.php', {
			autoFill: false,
			max: 15,
			minChars: 3,
			selectFirst: true,
			scrollHeight: 220,
			width: 260
		});
	},

	toggleLanguageList: function() {
		$('a.lang_link:parent').hover(
			function () { $('#language-list').show("fast"); },
			//hide menu on mouseleave of list
			function () { $('#language-list').mouseleave(function(){$('#language-list').hide()});}
		);
	},

	toggleSearchText: function() {
		$('input.title-attribute-as-label')
		.focus(function() {
			// Make sure the title attribute is defined, if it isn't already
			if (!this.title.length) this.title = this.value;

			// If the value attribute equals the title attribute, clear out the value
			if (this.value == this.title)
				this.value = "";

			$(this).addClass('has-user-entered-text');
		})
		.blur(function() {
			// If there's no text in there, reset the field back to the
			// default text and remove the "has-user-entered-text" class
			if (!this.value.length) {
				this.value = this.title;
				$(this).removeClass('has-user-entered-text');
			}
		});
	} // end toggleSearchText()

}


$(document).ready(function() {
    Gatlin_Blog.init();
});
