/*******************************************************
IMAGE PRELOADING
*******************************************************/

var prefix = "/wp-content/themes/orland-media/images/";

//	Preload button images
var buttons = [ 'submit', 'reply'];
jQuery(buttons).each(function() { var image = jQuery('<img />').attr('src', prefix + 'btn-' + this + '-down.png'); });

//	Function to preload images
function preload(arrayOfImages) {
    jQuery(arrayOfImages).each(function()
	{
		jQuery('<img />').attr('src', prefix + this);
    });
};

/*******************************************************
DOMAIN SEARCH INPUT, AT TOP
*******************************************************/

function submitSearch() {
	var i = jQuery("[name=s]");
	if ( (i.val().length == 0) || (i.val() == i[0].defaultValue) )
	{
		i.val(i[0].defaultValue);
		i.blur();
		return false;
	} else {
		var s = i.val();
		i.val("Retrieving results...");
		i.blur();
		document.location.href = "/?s=" + s;
		return false;
	}
};

/*******************************************************
ON DOM LOAD:
*******************************************************/

jQuery(document).ready(function() {
	jQuery('[name="s"]').focus(function()
	{
		jQuery(this).removeClass("s").addClass("sFocus");
		if (this.value == this.defaultValue){
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	jQuery('[name="s"]').blur(function()
	{
		jQuery(this).removeClass("sFocus").addClass("s");
		if (jQuery.trim(this.value) == '') this.value = (this.defaultValue ? this.defaultValue : '');
	});
	var t = jQuery('.searchsubmit');
	t.css({"visibility":"visible"});
	t.fadeTo(0,.3);
	t.mouseover(function() { t.fadeTo("fast",.8) });
	t.mouseout(function() { t.fadeTo(400,.3) });
	jQuery.localScroll({duration:500});
	jQuery("#title-area").click(function() {window.location.href = "/";});
	jQuery(".fancybox").fancybox({overlayColor:"#000", overlayOpacity:.8});
	jQuery(".iframe").fancybox({width:"70%", height:"90%", overlayColor:"#000", overlayOpacity:.6});
	jQuery(".movie").fancybox({width:550, height:400, overlayColor:"#000", overlayOpacity:.6});
	jQuery('img[alt="captcha"]').css( {"position":"relative","top":"10px"} );
	jQuery('input[name="captcha-1"]').css( {"position":"relative","top":"5px"} );
	
	/*******************************************************
	HANDLE INPUT BUTTONS
	*******************************************************/
	s = jQuery('#submit');
	s.mousedown(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-submit-down.png)") });
	s.mouseout(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-submit-up.png)") });
	s.mouseup(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-submit-up.png)") });
	
	s = jQuery('.reply a');
	s.mousedown(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-reply-down.png)") });
	s.mouseout(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-reply-up.png)") });
	s.mouseup(function() { jQuery(this).css("background-image", "url(/wp-content/themes/orland-media/images/btn-reply-up.png)") });
	
});


/* Mixpanel
var mp_protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://'); document.write(unescape('%3Cscript src="' + mp_protocol + 'api.mixpanel.com/site_media/js/api/mixpanel.js" type="text/javascript"%3E%3C/script%3E'));
try {  var mpmetrics = new MixpanelLib('d22424921cccf03e89c7612ae9d55551'); } catch(err) { null_fn = function () {}; var mpmetrics = {  track: null_fn,  track_funnel: null_fn,  register: null_fn,  register_once: null_fn, register_funnel: null_fn }; }*/
