 if (!window.parent.CKEDITOR) {
            window.parent.CKEDITOR = {};
      }
      if (!window.parent.CKEDITOR._) {
            window.parent.CKEDITOR._ = {};
      }
      if (!window.parent.CKEDITOR._["contentDomReadycktextarea"]) {
            window.parent.CKEDITOR._["contentDomReadycktextarea"] = function () {};
      } 

function addMemberLoginLink(id) {
  $(document).ready(function() {
    $("div#" + id + " ul").append('<li class="level1 last"><a href="#" class="link3">Login</a></li>')
  });
}
function addMemberProfileLink(id) {
	$(document).ready(function() {
    $("div#" + id + " ul").append('<li class="level1"><a href="/user/profile" class="link1">My Account</a></li><li class="level1 last"><a href="/user/logout" class="link1">Logout</a></li>')
  });
}
window.onload = init;
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   var days = new Array(7);
   days[0] = "Sunday";
   days[1] = "Monday";
   days[2] = "Tuesday";
   days[3] = "Wednesday";
   days[4] = "Thursday";
   days[5] = "Friday";
   days[6] = "Saturday";
   var now         = new Date();
   var thisDay = now.getDay()
   var dayName = days[thisDay];
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = dayName +
                    ', ' +
					monthname +
                    ' ' +
                    monthday +
                    ', ' +
                    year;
   return dateString;
   alert (dateString);
} // function getCalendarDate()

function popEmail(url) {
newwindow=window.open(url,'name','height=700,width=685,scrollbars=1,resizeable=1,menubar=1,toolbar=1,titlebar=1');
if (window.focus) {newwindow.focus()}
return false;
}
function popVideo(url) {
newwindow=window.open(url,'video','height=540,width=670,scrollbars=0,resizeable=0,menubar=0,toolbar=0,titlebar=0');
if (window.focus) {newwindow.focus()}
return false;
}
function customInit() {};
function init() {
	getCalendarDate();
	$("#flowpanes").scrollable({size: 1}).circular().mousewheel(400).navigator({

		// select #flowtabs to be used as navigator
		navi: "#flowtabs",

		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',

		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current'

	});
			$("#section-3 .box3").tabs("#section-3 .box3 div.records", {tabs: 'h4', effect: 'slide', initialIndex: null});
			showOverlay();
			triggerNav();
			$("ul.level2 li:has(ul)").find("a:first").append(" &raquo; ");
			customInit();	 
		 	$("#section-4 .box1 .navigation ul.level1").tabs("#section-4 .box1 div.records").history(); 
	 		$("#section-4 .box2 .navigation ul.level1").tabs("#section-4 .box2 div.records").history()
		}
		
		function showOverlay() {
			$("a.overlay[rel]").overlay({ 
				expose: '#000000', 
				effect: 'apple', 
				onBeforeLoad: function() { 
					var wrap = this.getContent().find(".contentWrap"); 
					wrap.load(this.getTrigger().attr("href")); 
					var info = (this.getTrigger().attr("title")); 
					$(".overlay .info").html(info);
				} 
			}); 
		}
		function triggerNav() {
			$(".navigation-2 .link3").click(function() {
				$(".navigation-2 .link3").toggleClass("menu-open");
				$(".login-box").slideToggle(250);
			});
			$(function(){
				function megaHoverOver(){
					$(this).find(".sub-menu1").stop().fadeTo('fast', 1, function() {
					

					  $('#video1 object').hide();
					  $(this).fadeIn('fast'); 
					  $(".sub-menu1 ul.level2 li").hover(function(){
							$(this).find(".sub-menu2").stop().fadeTo('fast', 1, function() {
								$(this).fadeIn('fast');
								$(this).parent().addClass('active');
							});
						},
						function(){
							$(this).find(".sub-menu2").stop().fadeTo('fast', 0, function() {
																						
								$(this).parent().removeClass('active');
								$(this).hide(); 
							});
					
						});
				  });
					//Calculate width of all ul's
					(function($) { 
						jQuery.fn.calcSubWidth = function() {
							rowWidth = 0;
							//Calculate row
							$(this).find("ul").each(function() {					
								rowWidth += $(this).width(); 
							});	
						};
					})(jQuery); 
						$(this).calcSubWidth();
						//Set Width
						//$(this).find(".sub-menu1").css({'width' : rowWidth});	
				}
				function megaHoverOut(){ 
				  $(this).find(".sub-menu1").stop().fadeTo('fast', 0, function() {
					  $(this).hide(); 
					   $('#video1 object').show();
				  });
				}
				var config = {    
					 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
					 interval: 100, // number = milliseconds for onMouseOver polling interval    
					 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
					 timeout: 500, // number = milliseconds delay before onMouseOut    
					 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
				};
				$(".navigation-1 ul li .sub-menu1").css({'opacity':'0'});
				$(".navigation-1 ul li").hoverIntent(config);

			});
		}
		
		function replaceNewlines(str)
                           		{
                           		str =  str.replace(/\n/g, '<br/>');
                           		}
