/**
 * General Cms page view functions to run on page start
 */

/* SD: Initialize lightbox 
 *$(document).ready(
 *	function() {
 *		$('a.galleryLB').each(
 *			function(i) {
 *				$(this).lightBox();
 *			}
 *		);
 *	}
 *);
*/

/* JM: Hackery 11-6-08 */
$(document).ready(
	function() {
		$('a.galleryLB').each(
			function(i) {
				$('a.galleryLB').lightBox();
			}
		);
	}
);

jQuery.fn.center = function (options) {
	windowHeight = $(window).height();
	windowWidth = $(window).width();
	/* If % set the top of element to the viewable screen area*/
	if(options.top.search('%')) {
		topOffset = parseInt(options.top);
		if(topOffset > 0) {
			topOffset = windowHeight / topOffset;
		}	
    	top = topOffset + $(window).scrollTop();
	} else {
    	top = ( windowHeight - this.outerHeight() ) / 2+$(window).scrollTop();
	}

    this.css("position","absolute");
    left = ( windowWidth - this.outerWidth() ) / 2+$(window).scrollLeft();
    if(top < 0) { top = 0; }
    if(left < 0) { left = 0; }
    this.css("top", top + "px");
    this.css("left", left + "px");
    return this;
}



/* Growl Template */
$.growl.settings.noticeTemplate = ''
  + '<div>'
  + '<div style="float: right; background-image: url(' + CENTRAL_JS_ROOT_FOLDER + 'jquery/growl/normalTop.png); position: relative; width: 259px; height: 16px; margin: 0pt;"></div>'
  + '<div style="float: right; background-image: url(' + CENTRAL_JS_ROOT_FOLDER + 'jquery/growl/normalBackground.png); position: relative; display: block; color: #ffffff; font-family: Arial; font-size: 12px; line-height: 14px; width: 259px; margin: 0pt;">'
  + '  <img style="margin: 14px; margin-top: 0px; float: left;" src="%image%" />'
  + '  <h3 style="margin: 0pt; margin-left: 77px; padding-bottom: 10px; font-size: 13px;">%title%</h3>'
  + '  <p style="margin: 0pt 14px; margin-left: 77px; font-size: 12px;">%message%</p>'
  + '</div>'
  + '<div style="float: right; background-image: url(' + CENTRAL_JS_ROOT_FOLDER + 'jquery/growl/normalBottom.png); position: relative; width: 259px; height: 16px; margin-bottom: 10px;"></div>'
  + '</div>';
	
/*
 * Dynamic js loader

if(typeof($) != 'function') {
	function jsAppend(js_file) {
	  js_script = document.createElement('script');
	  js_script.type = "text/javascript";
	  js_script.src = js_file;
	  document.getElementsByTagName('head')[0].appendChild(js_script);
	}

	//Load Jquery if not already loaded
	jsAppend(CENTRAL_JS_ROOT_FOLDER + "jquery/jquery-1.2.6.js");
}*/