/* 

  Affiniscape Creative Services jQuery Plugins
-------------------------------------------------

	GLOBAL JAVASCRIPT INCLUDE FUNCTIONS
	AUTHOR:	Marcus Ellis
	DATE:	26 May 2010
	
*/


(function ($) {


/* CMS Fixes
-------------------------------------------------*/

	$.fn.extend({
	
		// Identify Operating System
		detectOS: function(){
			return this.each(function() {
				var os =  (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0];
				$(this).addClass(os);
			});
		},
	
				
		// Identify Browser
		detectBrowser: function(){
			return this.each(function() {
				var b = '';
				if ($.browser.msie) { b = 'ie'; }					// Internet Explorer (All versions)
				else if ($.browser.mozilla) { b = 'mozilla'; }		// Firefox
				else if ($.browser.webkit) { b = 'webkit'; }		// Safari & Chrome
				else if ($.browser.opera) { b = 'opera'; }			// Opera
				else { b = 'other'; }								// All other browsers
				$(this).addClass(b);
			});
		},
	
				
		// Adjust Module Pages Function
		adjustModule: function() {
			return this.each(function() {
				if ($('#stucturaltable').length == 0 && $('body > table:first').attr('id') == '') {
					$('body > table:first').attr('id','structuraltable');
				}
				if ($(this).length != 0 && $('#maincontentsubcell').length == 0) {
					if ($('#content').length != 0) {
						$(this).addClass('m360');
					} else {
						$(this).addClass('module');
					}
				}
			});
		},

		
		// Identify Banner Table
		bannerID: function(){
			return this.each(function() {
				if ($(this).length != 0) {
					$(this).siblings('table:first-child').attr('id','bannertable');
				}
			});
		},


		// Left Navigation Fix Function
		// Adds classes to nav <li> elements which allows custom negative top margins.  Setting a custom top margin let's designers fix the misalignment of flyout menus when the image button is taller than its siblings.
		fixNavleft: function(){
			return this.each(function() {
				var i = 0;
				$(this).children('li').each(function () {
					$(this).addClass("nav-left-sub_"+i);
					i++;
				});
			});
		},
		

		// Top Navigation Fix Function
		// Adds classes to the first and last flyouts which allows customization of flyout posistioning.
		fixNavtop: function(){
			return this.each(function() {
				
				// Add class to first flyout
				if ($(this).children('li:first').children('a').length) {
					$(this).children('li:first').children('ul').addClass('first');
				
				// Account for left spacer image
				} else {
					$(this).children('li:first').next('li').children('ul').addClass('first');
				}
				
				// Add class to last flyout
				if ($(this).children('li:last').children('a').length) {
					$(this).children('li:last').children('ul').addClass('last');					
				
				// Account for right spacer image
				} else {
					$(this).children('li:last').prev('li').children('ul').addClass('last');					
				}
				
			});
		},
	
	
		// Fix Login Screen
		// Adjusts sizes and attributes for certain login screens (eg, Member Dues)
		fixLoginScreen: function(){
			return this.each(function() {
				var o = $(this).children('tbody').children('tr:eq(1)').children('td').children('table:eq(1)');
				if(o.attr('width') == '80%') {
					o.attr('width','100%')
						.attr('border',0)
						.attr('bgcolor','')
						.attr('id',function(){
							if ($(this).attr('id') == ""){
								$(this).attr('id','pageheadertable');
							}
						})
						.css('display','table')
						.prev('table')
							.attr('id','pageheadertable')
							.attr('bgcolor','')
							.css('display','table');
				}
			});
		},
		
		
		// Fix Taylor Theme
		// Applies a few fixes to the Taylor Theme
		fixTaylor: function(){
			return this.each(function() {
				$(this).children('td:first').addClass('first');
				$(this).children('td:last').addClass('last');
			});
		}
		
	});
    
	
	


/* Utility Methods
-------------------------------------------------*/

	$.fn.extend({   
	
		// Clickable Logo
		addClickableLogo: function(settings){
			var defaults = {  
				name: 'Association',
				url: '/'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
				var obj = $(this);
				var s = settings;
				
				if ($('#structuraltable').length) {
					obj.append('<div id="logo-click"><a href="'+ s.url +'"><h1>' + s.name + '</h1></a></div>');
				}
			});
		},
		
		
		// Mega Footer
		addMegaFooter: function(){
			return this.each(function() {
				var obj = $(this);
				obj.append('<div id="assnfooter"></div>');
				var ftr = $('#assnfootercell, #footertablecell').html();
				$('#assnfooter').html('<div class="container_24">'+ ftr +'<div class="clear" /></div>');
				$('#assnfooterrow, #footertable').remove();
			});
		},
		
		


		// Sliding Flyouts
		// Adds a sliding effect to the Flyouts for the Brando theme
		addSlidingFlyouts: function(){
			return this.each(function() {
				var obj = $(this);
				obj.children('li').children('ul').hide().bind('mouseover',function(){
					$(this).stop(true, true).slideDown();
				});
				obj.children('li').hover(
					function(){
						$(this).children('ul').stop(true,true).slideDown('fast');
					},
					function(){
						$(this).children('ul').stop(true,true).slideUp('slow');
					}        
				);
			});
		},
		
		
		// Navigation Hover Class
		// Adds a class of "hover" to nav items and retains that class while hovered over flyouts
		addNavHoverClass: function(){
			return this.each(function() {
				var obj = $(this);
				obj.children('li').children('a').hover(
					function (){
						$(this).addClass('hover');
					},
					function (){
						$(this).removeClass('hover');
					}
				);
				obj.children('li').children('ul').hover(
					function (){
						$(this).prev().addClass('hover');
					},
					function (){
						$(this).prev().removeClass('hover');
					}
				);
			});
		},
	
				
		// Navleft Flyouts
		// Fixes issue with flyouts sticking in IE when Doctype is turned on
		fixLeftFlyouts: function(){
			return this.each(function() {
				var obj = $(this);
				obj.children('li').children('a').hover(
					function (){
						$(this).siblings('ul').show();	
					},
					function (){
						$(this).siblings('ul').hide();
					}
				);
				obj.children('li').children('ul').hover(
					function (){
						$(this).show();
					},
					function (){
						$(this).hide();
					}
				);
			});
		},
	
				
		// Adjust Nobackground Table Function
		// Sets cellpadding and cellspacing to zero for the nobackground table
		adjustNobackground: function() {
			return this.each(function() {
				var obj = $(this);
				obj.children('#miniheadercontenttable').attr('cellpadding','0').attr('cellspacing','0').attr('width','100%');
			});
		},
	
				
		// Adjust Board of Directors Page Function
		// Hides the hyoerlink table at the top of the Board of Directors page
		adjustBoard: function() {
			return this.each(function() {
				var u = window.location.href;
				var b = "displayboard.cfm";
				if (u.indexOf(b) != -1) {
					$('table:first', this).hide();
				}
			});
		}

	});
	
	


/* Utility Methods (Deprecated but still in use)
-------------------------------------------------*/

	// Clickable Logo
	$.fn.clickableLogo = function(text,url){	
		var str = '<div id="logo-click"><h1>' + text + '</h1></div>';
		$('#structuraltable').after(str);
		$("#logo-click h1").click(function() {
            if (url) {
                window.location = url;
            } else {
                window.location = "/";
            }
		});
	};


	// Sliding Flyouts Function
/*    $.fn.slidingFlyouts = function(){
        $('#navtop1 li ul, #navtop2 li ul, #navtop1list li ul, #navtop2list li ul')
            .hide()
            .bind('mouseover',function(){
                $(this)
                    .stop(true, true)
                    .slideDown();
            });
        $('#navtop1 > li, #navtop2 > li, #navtop1list > li, #navtop2list > li').hover(
            function(){
                var $this = $(this);
                $('ul', $this)
                    .stop(true,true)
                    .slideDown('fast');
            },
            function(){
                var $this = $(this);
                $('ul', $this)
                    .stop(true,true)
                    .slideUp('slow');
            }        
        );
    }
*/
    


/* Add-On Widgets
-------------------------------------------------*/
	
	$.fn.extend({   
	
	
		// Rotating Sponsor Box Function
		// Takes a <ul> with the id of "sponsors" and turns it into a simple, random slideshow.
		incSponsorBox: function(settings) {
			
			var defaults = {  
				time: 6,
				shuffle: true,
				caption: false
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
									  
				var obj = $(this);
				var i = obj.attr('id');
				var s = settings;
				var t = s.time * 1000;
				var r = s.shuffle ? 1 : 0;
				var c = s.caption;
				var h = 0;
				
				// Get height of tallest image
				obj.children().each(function(){
					var ht = $(this).children('a').children('img').height() || $(this).children('img').height();
					if (h < ht) {
						h = ht;
					}
				});
				
				// Add caption element
				if (c) {
					obj.after('<span id="'+ i +'-caption" class="sponsorBox-caption"></span>');
				}
				
				// Call "Cycle" plugin
				obj.addClass('imageRotation')
					.cycle({
						fx: 'fade',
						random: r,
						timeout: t,
						before: function(){
							if (c){
								$('#'+ i +'-caption').fadeTo(250, 0.01);
							}
						},
						after: function(){
							if (c && $('img', this).attr('alt') != ''){
								$('#'+ i +'-caption').html($('img', this).attr('alt')).fadeTo(100,1);
							}
						}
					})
					.attr('style', function(){
						if (h > 0) {
							return 'height:'+ h +'px';
						}
					});
				
			});  
		},


		// Header Banner Widget
		// Takes a <ul> with a passed id and turns it into a simple slideshow for use in the header of the website.
		incHeaderBanner: function(settings) {
			
			var defaults = {  
				time: 6,
				shuffle: false
			}  
			var settings = $.extend(defaults, settings);
			
			return this.hide().each(function() {
									  
				var o = $(this);
				var s = settings;
				var t = s.time * 1000;
				var r = s.shuffle ? 1 : 0;
				var h = 0;
				
				// Get height of tallest image
				o.children().each(function(){
					var ht = $(this).children('a').children('img').height() || $(this).children('img').height();
					if (h < ht) {
						h = ht;
					}
				});
							
				// Call "Cycle" plugin
				o.addClass('imageRotation')
					.cycle({
						fx: 'fade',
						random: r,
						timeout: t
					})
					.attr('style', function(){
						if (h > 0) {
							return 'height:'+ h +'px';
						}
					})
					.wrap('<div id="header-banner-widget"></div>');
				
			}).fadeIn();  
		},


		// Login Widget Include Function
		// Adds iframe to cafe.cfm, which in turn replaces the contents of the loginform element
		incLoginWidget: function(settings) {
			
			var defaults = {
				buttonImage: '/global/imgs/btn_login.png',
				hoverImage: '/global/imgs/btn_login-over.png'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
				var s = settings;
				var obj = $(this);

				var str = '<iframe id="iflogin" src="/cafe.cfm?act=member.showlogin&spanid='+ obj.attr('id') +'" frameborder="0" width="0" height="0"></iframe>';
				obj.after(str);
				obj.find('#loginbutton').live('mouseover mouseout load', function(event) {
					if (event.type == 'mouseover') {
						$(this).attr('src',s.hoverImage);
					} else {
						$(this).attr('src',s.buttonImage);
					}
				});
		
			});
		},


		// Search Widget Include Function
		// Inserts a simple form into an element with the id of Search-widget
		incSearchWidget: function(settings) {
			
			var defaults = {
				action: '/searchsite.cfm',
				showLabel: true,
				label: 'Search', 
				showButton: true,
				buttonType: 'button',
				buttonText: 'Search',
				buttonImage: '/global/imgs/btn_search.png',
				hoverImage: '/global/imgs/btn_search-over.png'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
				var s = settings;
				var obj = $(this);
				
				obj.append('<form action="' +s.action +'" method="get" name="searchsite" id="search-form"></form>');
				if (s.showLabel){
					obj.children('#search-form').append('<label for="search-field">' + s.label +'</label>');
				}
				obj.children('#search-form').append('<input type="text" name="searchvalue" id="search-field" />')
				if (s.showButton){
					if (s.buttonType == 'button'){
						obj.children('#search-form').append('<input type="submit" name="submit" id="search-button" value="'+ s.buttonText +'" />');
					} else {
						obj.children('#search-form').append('<input type="image" name="submit" id="search-button" src="'+ s.buttonImage +'" />');
						$('#search-button').hover(
							function(){
								$(this).attr('src',s.hoverImage);
							},
							function(){
								$(this).attr('src',s.buttonImage);
							}
						);
					}
				}
				obj.addClass('loaded');
			});
		},


		// 360 Calendar Include Function
		// Inserts the 360 Calendar.  Requires some server side configuration. See Twiki documentation.
		inc360events: function(settings) {
			
			var defaults = {  
				url: 'http://internal.affiniscape.com/calendar.aspx',  
				style: 'full',  
				items: 4,
				showLink: true,
				linkText: 'View All Events'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
				var s = settings;
				var num = s.items - 1;
				var obj = $(this);

				var pro = s.url.split(/\/+/g)[0];
				var dom = s.url.split(/\/+/g)[1];
				var base = pro +'//'+ dom;

				obj.addClass('events-widget').addClass('loading');
				$.ajax({
					url: s.url,
					type: 'GET',
					dataType: 'html',
					success: function(data) {
						
						// Get Server Response & insert into document
						var content = $(data.responseText).find('#content').html();
						obj.hide().html(content);
						
						// Remove unnecessary HTML elements
						$('script, .filter, *:empty, h3, #page_title_area, #ctl00_phUserMessage, .event_table', obj).remove();

						// Move rows into first table
						$('.event_list:first-child', obj).attr('id', 'calendar-list');
						$('#calendar-list', obj)
							.append($('.event_list tr', obj))
							.removeAttr('class')
							.parent()
								.before('<ul id="events-list"></ul>');
								
						if (s.showLink){
							var viewLink = '<div id="view-calendar"><a href="' + s.url + '">'+ s.linkText +'</a></div>';
							obj.append(viewLink);
						}
						
						// Limit number of rows 
						$('#calendar-list tr:gt('+ num +')', obj).remove();
												
						// Add sequential & odd/even ids & classes
						$('#calendar-list tr', obj).each(function(i){
							i++;
							$('#events-list', obj).append('<li id="row-' + i + '"></li>');
							$(this).children('td').each(function(n){
								var c = $(this).attr('class') || 'event_details';
								$('#row-' + i).append('<div class="' + c + '"></div>');
								$(this).children().each(function(){
									$('#row-' + i).children('div').eq(n).append($(this));
								});
								n++;
							});
						});
						$('#events-list li:odd', obj).addClass('even_row');
						$('#events-list li:even', obj).addClass('odd_row');
						
						// Update Hyperlinks
						var c = location.href;
						var p = c.split(/\/+/g)[0];
						var d = c.split(/\/+/g)[1];
						var curr = p +'//'+ d;
						var l = 0;
						$('#events-list li a').each(function(){
							var ref = $(this).attr('href');
							if (ref.indexOf('://') == -1) {
								if (ref.indexOf('/') != 0) {
									ref = "/" + ref;
								}
								ref = base + ref;
								$(this).attr('href', ref);
								l++;
							} else if (ref.indexOf(curr) != -1) {
								var i = curr.length;
								ref = base + ref.slice(i);
								$(this).attr('href', ref);
								l++;
							}
						});
						
						// Remove old/unused tables & show Calendar
						$('#calendar-list', obj).parent().remove();
						obj.addClass(s.style).removeClass('loading').show();
						
						// Do callback function
						if (typeof s.callback == 'function'){
    					    s.callback.call(this, data);
	    				}
						
					}
				});
			});  
		},
		
	
		// Rotating Sponsor Box Function
		// Takes a <ul> of text or links and turns it into a simple slideshow.
		incNewsWidget: function(settings) {
			
			var defaults = {  
				time: 6,
				charLimit: 100,
				shuffle: false,
				effect: 'slide',
				direction: 'up'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
									  
				var obj = $(this);
				var s = settings;
				var t = s.time * 1000;
				var r = s.shuffle ? 1 : 0;
				var f = s.effect;
				var d = s.direction;
				var l = s.charLimit;
				
				// Truncate text
				obj.children('li').children('a').each(function(){
					var text = $(this).html();
					if (text.length > l) {
						text = text.substr(0, l-3);
						text += '...';
						$(this).html(text);
					}
				});
				
				// Set direction for slide
				if (f == 'slide') {
					d = d.charAt(0).toUpperCase() + d.substr(1);
					f = 'scroll' + d;
				}

				// Call "Cycle" plugin
				obj.cycle({
					fx: f,
					random: r,
					timeout: t
				});
				
			});  
		},

		
		// Google Translate Widget
		// Creates a list of links to Google Translate
		incTranslationWidget: function(settings) {
			
			var defaults = {  
				languages: 'all'
			}  
			var settings = $.extend(defaults, settings);
			
			return this.each(function() {
				var s = settings;
				var obj = $(this);
		
				// Setup language array
				var langs = new Array();
					langs['sq'] = "Albanian";
					langs['ar'] = "Arabic";
					langs['bg'] = "Bulgarian";
					langs['ca'] = "Catalan";
					langs['zh'] = "Chinese";
					langs['hr'] = "Croatian";
					langs['cs'] = "Czech";
					langs['da'] = "Danish";
					langs['nl'] = "Dutch";
					langs['en'] = "English";
					langs['et'] = "Estonian";
					langs['tl'] = "Filipino";
					langs['fi'] = "Finnish";
					langs['fr'] = "French";
					langs['gl'] = "Galician";
					langs['de'] = "German";
					langs['el'] = "Greek";
					langs['iw'] = "Hebrew";
					langs['hi'] = "Hindi";
					langs['hu'] = "Hungarian";
					langs['id'] = "Indonesian";
					langs['it'] = "Italian";
					langs['ja'] = "Japanese";
					langs['ko'] = "Korean";
					langs['lv'] = "Latvian";
					langs['lt'] = "Lithuanian";
					langs['mt'] = "Maltese";
					langs['no'] = "Norwegian";
					langs['fa'] = "Persian";
					langs['pl'] = "Polish";
					langs['pt-PT'] = "Portuguese";
					langs['ro'] = "Romanian";
					langs['ru'] = "Russian";
					langs['sr'] = "Serbian";
					langs['sk'] = "Slovak";
					langs['sl'] = "Slovenian";
					langs['es'] = "Spanish";
					langs['sv'] = "Swedish";
					langs['th'] = "Thai";
					langs['tr'] = "Turkish";
					langs['uk'] = "Ukrainian";
					langs['vi'] = "Vietnamese";
		
				// Construct translation URL
				var new_url = 'http://www.google.com/translate?u='
				var url = location.href;
				var u_idx = url.indexOf('&u=');
				if (u_idx == -1) {
					new_url += encodeURIComponent(url);
				} else {
					var s = u_idx + 3;
					url = url.slice(s);
					var e = url.indexOf('&');
					url = url.slice(0,e);
					new_url += url;
				}
				new_url += '&sl=en&tl=';
				
				// Create list of languages
				var n = 0;
				var list = '';
				for (var l in langs) {
					if (n < 42) {
						if (s.languages == 'all' || s.languages.indexOf(langs[l]) != -1){
							list += '    <li><a href="'+ new_url + l +'" target="_top" title="Translate to '+ langs[l] +'">'+ langs[l] +'</a></li>\n';
						}
					}
					n++;
				}

				// Create widget HTML & add to document
				var str = '<div id="translate-widget">\n  <span class="translate-button">Translate</span>\n  <ul class="translate-links">\n' + list + '  </ul>\n</div>\n';
				if ($('#structuraltable').length){
					obj.append(str);
				}
				
				// Bind hover triggers
				$('.translate-button').hover(
					function(){ $('.translate-links').show(); },
					function(){ $('.translate-links').hide(); }
				);
				$('.translate-links').hover(
					function(){ $(this).show(); },
					function(){ $(this).hide(); }
				);
				
			});
		}
		
	});  
	
	
    


/* Add-On Widgets (Non-Standard)
-------------------------------------------------*/

	// Rotating Banner Function
	// Takes a <ul> with a passed id and turns it into a simple slideshow. User has control over timing, randomness and effect. See Twiki for documentation.
	$.fn.slideshow = function(id){
		
		// Get height of tallest image
		var ht = 0;
		$('#'+id).addClass('imageRotation').children().each(function(){
			var h = $(this).children('a').children('img').height() || $(this).children('img').height();
			if (ht < h) { ht = h; }
		});
		
		// Get settings
		var e = $('#'+id).attr('effect') || 'fade';
		var t = ($('#'+id).attr('time') || 6) * 1000;
		var r = $('#'+id).attr('random') || false;
		if (r == true) { r = 1; } else { r = 0; }
		
		// Call "Cycle" plugin
		return $('#'+id).cycle({ fx: e, random: r, timeout: t }).attr('style', function(){ if (ht > 0) { return 'height:'+ ht +'px'; } });
	};
	
	
    


/* Add-On Widgets (Deprecated, but still in use)
-------------------------------------------------*/

    // Login Widget Include Function
	// Adds iframe to cafe.cfm, which in turn replaces the contents of the loginform element
	$.fn.incLogin = function(){
		var str = '<iframe id="iflogin" src="/cafe.cfm?act=member.showlogin&spanid=loginform" frameborder="0" width="0" height="0"></iframe>';
		var id = null;
		$('#loginbutton').live('mouseover', function(){
			var btn_src = $('#loginbutton').attr('src');
			var s = btn_src.indexOf('associations') + 13;
			var e = btn_src.indexOf('imgs') - 1;
			var l = e - s;
			id = btn_src.substr(s,l);
			$(this).attr('src','/associations/'+ id +'/imgs/btn_login-over.png');
		});
		$('#loginbutton').live('mouseout', function(){ $(this).attr('src','/associations/'+ id +'/imgs/btn_login.png'); });
		return $('#loginform').after(str);
	};


	// Rotating Sponsor BoxFunction
	// Takes a <ul> with the id of "sponsors" and turns it into a simple, random slideshow.
	$.fn.sponsorBox = function(id){
		if (!id) { id = 'sponsors';	 }
		
		// Get height of tallest image
		var height = 0;
		$('#' + id).children().each(function(){
			var h = $(this).children('a').children('img').height() || $(this).children('img').height();
			if (height < h) { height = h; }
		});
		
		// Call "Cycle" plugin
		$('#' + id).addClass('imageRotation').after('<span id="' + id + '-caption"></span>')
			.cycle({
				fx: 'fade',
				random: 1,
				timeout: 6000,
				before: function(){ $('#' +id + '-caption').fadeTo(250, 0.01); },
				after: function(){ if ($('img', this).attr('alt') != ''){ $('#' +id + '-caption').html($('img', this).attr('alt')).fadeTo(100,1); } }
			})
			.attr('style', function(){ if (height > 0) { return 'height:'+ height +'px'; } });
	};


	// Search Widget Include Function
	// Inserts a simple form into an element with the id of Search-widget
	$.fn.incSearch = function(id){
		var str = '<form action="searchsite.cfm" method="get" name="searchsite" id="search-form"><label for="search-field">Search</label><input type="text" name="searchvalue" id="search-field" /><input type="image" name="submit" id="search-button" src="/associations/'+ id +'/imgs/btn_search.png" /></form>';
        $('#search-widget').html(str).addClass('loaded');
		$('#search-button').hover(
            function(){ $(this).attr('src','/associations/'+ id +'/imgs/btn_search-over.png'); },
            function(){ $(this).attr('src','/associations/'+ id +'/imgs/btn_search.png'); }
        );
		return $('#search-widget');
	};
	
	
	// 360 Calendar Include Function
	// Inserts the 360 Calendar.  Requires some server side configuration. See Twiki documentation.
	$.fn.inc360calendar = function(assnnbr, limit){
		var str = '<iframe id="if360cal" name="if360cal" src="/associations/'+ assnnbr +'/cafe/widget-360calendar.cfm?container=calendar360&limit='+ limit +'" frameborder="0" width="0" height="0"></iframe>';
		$('#calendar360').addClass('loading').html('Loading Calendar Events...').after(str);
	};


    


/* Miscellaneous Functions
-------------------------------------------------*/

    // Meebo Bar Function
    /*$.fn.meeboBar = function(){
        if (typeof Meebo == 'undefined') {
        Meebo=function(){(Meebo._=Meebo._||[]).push(arguments)};
        (function(_){var d=document,b=d.body,c;if(!b){c=arguments.callee;
        return setTimeout(function(){c(_)},100)}var a='appendChild',c='createElement',
        m=b.insertBefore(d[c]('div'),b.firstChild),n=m[a](d[c]('m')),i=d[c]('iframe');
        m.style.display='none';m.id='meebo';i.frameBorder="0";n[a](i).id="meebo-iframe";
        function s(){return['<body onload=\'var d=document;d.getElementsByTagName("head")[0].',
        a,'(d.',c,'("script")).src="http',_.https?'s':'','://',_.stage?'stage-':'',
        'cim.meebo.com','/cim?iv=2&network=',_.network,_.lang?'&lang='+_.lang:'',
        _.d?'&domain='+_.d:'','"\'></bo','dy>'].join('')}try{
        d=i.contentWindow.document.open();d.write(s());d.close()}catch(e){
        _.d=d.domain;i.src='javascript:d=document.open();d.write("'+s().replace(/"/g,'\\"')+'");d.close();'}})
        ({ network: 'affiniscapedesign_qe14pi', stage: false });
        }
        setTimeout("Meebo('domReady');Meebo('unhide');", 500);
    };*/

})(jQuery);



// Global "Document Ready" Function
// These functions get run on all websites that are using the global library
var j = jQuery.noConflict();
j(document).ready(function($){

	$('body').detectOS().detectBrowser();
	$('#maincontenttable').adjustModule();
	$('#nobackground').adjustNobackground();
    $('#structuraltable').fixLoginScreen();
    $('#returnlinktable').fixTaylor();
	$('#navleft').fixNavleft();
	$('#navtop1, #navtop1list').fixNavtop();
    $('#navtop2, #navtop2list').fixNavtop();

});

