 
function strstr( haystack, needle, bool ) {
	var pos = 0;
	haystack += '';
	pos = haystack.indexOf( needle );
	if (pos == -1)
	{
		return false;
	}
	else
	{
		if( bool )
		{
			return haystack.substr( 0, pos );
		}
		else
		{
			return haystack.slice( pos );
		}
	}
}	

$(function()
{
	$('.ImageHolder a').lightBox();
	$('.GalleryRow dt a').lightBox();
});

$(function()
{
	$('#SlideShow').cycle({ 
		fx: 'scrollHorz'
		//delay:  -6000
	});
	$('#HeaderQuoteSlideshow').cycle({ 
		fx: 'fade',
		delay:  -4000,
		timeout: 6000	
	});
});

$(function()
{
	$('#Form textarea').autogrow();				
});

$(function()
{
	$(".ShowToolTip").tooltip({predelay:100, effect:'fade', events: { tooltip: "focus,mouseover"}});			
});
$(function(){

	$('.FAQToggle').click(function () 
	{
		var ResultID = this.id.replace('more_', '');
		//$('#detail_'+ResultID+'').slideToggle('fast');
		
		$( this ).toggleClass('FAQCollapse');
	}),

	$('.FAQToggleAll').click(function () 
	{
		$('.FAQAnswer').show('fast');
		$('.FAQToggle').addClass('FAQCollapse');
		
		$( this ).hide();
		$('.FAQCollapseAll').show();
	}),

	$('.FAQCollapseAll').click(function () 
	{
		$('.FAQAnswer').hide('fast');
		$('.FAQToggle').removeClass('FAQCollapse');
		
		$( this ).hide();
		$('.FAQToggleAll').show();
	})
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);

}; 
function kick_off_blockster() 
{
	var browserName=navigator.appName;
	if(browserName=="Microsoft Internet Explorer")
	{
		new Blockster({
		holder: '#HomeSlideShow',
		rows: 2,
		cols: 3,
		pause: 6000,
		random: true,
		blockAnimSpeed :400,
		animType : 'simple'
		});
	}	
	else
	{
		new Blockster({
		holder: '#HomeSlideShow',
		rows: 4,
		cols: 6,
		pause: 6000,
		random: true,
		animType : 'fade',
		startWithoutDelay: true
		});
	}	
};

function batch_confirm(action)
{
    if(confirm('Are you sure you want to perform the action "' + action + '" on the selected items?'))
    {
         BatchForm.submit();
    }
}

function check_or_uncheck_all(field, this_checked, ids)
{
    if(this_checked)
    {
        check_all(field, ids);
    }
    else
    {
        uncheck_all(field, ids);
    }
}

function check_all(field, ids)
{
    var field_chk = '';
    
    var ids_array = ids.split(',');
    
    for (i = 0; i < ids_array.length; i++)
    {
        field_chk = document.getElementById(field+'_'+ids_array[i]);
        field_chk.checked = true ;
    }
}

function uncheck_all(field, ids)
{
    var field_chk = '';
    
    var ids_array = ids.split(',');
    
    for (i = 0; i < ids_array.length; i++)
    {
        field_chk = document.getElementById(field+'_'+ids_array[i]);
        field_chk.checked = false ;
    }
}
