/* Colorbox */
function colorbox_iframe(link, w, h, title)
{
	$.fn.colorbox({ href: link, width: w, height: h, title: title, iframe: true, open: true });
}

/* Regex Selectors http://james.padolsey.com/javascript/regex-selector-for-jquery/ */
jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ? 
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

/* Preloader */
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

/* Main Image Rollover */
$(document).ready(function() {
	
	/* this functionality is added inline when using IE6 for the png fix to work as well */
	$(function()
	{
		$('img.hover').hover(function()
		{
			$(this).attr('src', $(this).attr('src').replace( /_orig/i, '_over' ));
		},
		function() 
		{
			$(this).attr('src', $(this).attr('src').replace( /_over/i, '_orig' ));
		});
	});
	
});

/* Side nav Image Rollover */
$(document).ready(function() {
	
	$(function()
	{
		$('.side_nav a').hover(function()
		{
			id = $(this).attr('id');
			$('#' + id + '_bullet').attr('src', '/public/images/bullet_large.png');
		},
		function() 
		{
			id = $(this).attr('id');
			$('#' + id + '_bullet').attr('src', '/public/images/bullet_small.png');
		});
	});
	
});

/* Side nav Image Rollover */
$(document).ready(function() {
	
	$(function()
	{
		$('.side_nav img').hover(function()
		{
			$(this).attr('src', '/public/images/bullet_large.png');
		},
		function() 
		{
			$(this).attr('src', '/public/images/bullet_small.png');
		});
	});
	
});

/* It came with the frame(work) */
function building_selector(value)
{
	new Ajax.Updater("building_id", site_base_url+"/admin/select_buildings", { method:"post", parameters:"area_id="+value });
	
	return false;
}
