
var $j = jQuery.noConflict();

var RFPB = {};

RFPB.image_url = "http://www.rfpblaster.com/public/images/";

// custom configured lightbox function
jQuery.fn.lbox = function () {
	this.lightBox({
		fixedNavigation: true,
		imageLoading: RFPB.image_url + "lightbox/loading.gif",
		imageBtnClose: RFPB.image_url + "lightbox/close.gif",
		imageBtnPrev: RFPB.image_url + "lightbox/prev.gif",
		imageBtnNext: RFPB.image_url + "lightbox/next.gif",
		txtImage: "Sample"
	});
}


$j(function(){
	$j('#project-previews a').lbox();
	
	//var rfp_list_height = $j('#rfp_list li:first').height();
	
	$j('#rfp_list').accordian();
	
	// sets the container's minimum height to avoid the viewing area from
	// being squished as well as removing unattractive animations
	//$j('#rfp_list').css('min-height', rfp_list_height+'px');
});


/**
 * Creates one of those annoying pop-up windows from a link.
 * @see RFPB.popWindow
 */
RFPB.popLink = function (linkObj, wndname, fullscreen, width, height, top, left)
{
	RFPB.popWindow(linkObj.href, wndname, fullscreen, width, height, top, left);
}

/**
 * Creates one of those annoying pop-up windows.
 * @param string url URL to go to.
 * @param string wndname Window name. Re-use if you want multiple links to use the same pop-up window.
 * @param bool fullscreen Make it fullscreen? Overrides next four params if true.
 * @param int width Width of window in pixels.
 * @param int height Height of window in pixels.
 * @param int top Distance between top of screen to top edge of window in pixels.
 * @param int left Distance between left of screen to left edge of window in pixels.
 * @return object Returns newly created window object.
 */
RFPB.popWindow = function (url, wndname, fullscreen, width, height, top, left)
{
	if (fullscreen)
	{
		width  = screen.width;
		height = screen.height;
		left   = 0;
		top    = 20;
	}
	var settings = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left +
		",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win = window.open(url, wndname, settings);
	win.focus();
	
	return win;
}

RFPB.switchResource = function (resource_category, resource_slug)
{
	resource_id = parseInt(resource_slug);

	if (resource_category == 'life-cycle' || resource_category == 'service-time')
	{
		$j.get(RFPB.baseURL+"ajax/resource/"+resource_category, function (data)
		{
			$j('li.'+RFPB.switchTree.selectedClass).removeClass(RFPB.switchTree.selectedClass);
			$j("#"+resource_category+"_"+resource_id).parent().addClass(RFPB.switchTree.selectedClass);
		
			$j("#rfp_content_inner").hide();
			$j("#resource-content-inner").show().html(data);
		});
	}
	else if (resource_slug && (resource_slug != ""))
	{
		$j.get(RFPB.baseURL+"ajax/resource/"+resource_category+"/"+resource_slug, { resource_page: $j("body").attr("id") }, function (data)
		{
			$j('li.'+RFPB.switchTree.selectedClass).removeClass(RFPB.switchTree.selectedClass);
			$j("#"+resource_category+"_"+resource_id).parent().addClass(RFPB.switchTree.selectedClass);
		
			$j("#rfp_content_inner").hide();
			$j("#resource-content-inner").show().html(data);
		});
	}
	// Scroll the window to the top of the container (client request, ticket #74)
	window.scrollTo(0, document.getElementById('rfp-container').offsetTop);
}