

function keyHolder(textAreaId)
{
	if ($F(textAreaId).length >= 1000)
		return false;
}

function cutMsg(textAreaId, charsLeftId)
{
	enteredText = $(textAreaId).value;
	$(charsLeftId).update((1000 - enteredText.length > 0 ? 1000 - enteredText.length : 0));
	if (enteredText.length > 1000)
	{
		$(textAreaId).value = enteredText.substr(0, 1000);
		return false;
	}
}


function disableAnchor(id)
{
	if (!($(id).value.length > 0))
		return false;
}

function submitFormLoader(){
	// update the submit button styles and disable it to prevent any more clicks
	$('submit_animator').style.visibility='visible';
	$('overlay_submit_button').className ='button_send_deactive';
	$('overlay_submit_button').disabled = 'true';
}

/* BEGIN: SUCKERFISH :hover
 * 
 * The suckerfish hover method mimics the :hover pseudo-class
 * for IE6 on any element by dynamically adding the sfHover class.
 * More info: http://www.htmldog.com/articles/suckerfish/hover/
 * 
 * This is globally applied for navigation, footer, and rss hovers.
 * Application is per element.  Add more here as necessary.
 * And don't forget, this is for IE6 only.
 */
sfHover = function() {
	var sfEls = document.getElementById("eol_navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	if ($('edition_container')) {
		var sfEls = document.getElementById("edition_container");
		sfEls.onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls.onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	if ($('footer_edition_container')) {
		var sfEls = document.getElementById("footer_edition_container");
		sfEls.onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls.onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}


	var sfEls = $$(".rss_container");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}

	/* added for sub nav on the videos page */
//	var subNavEls = document.getElementById("custom_nav").getElementsByTagName("LI");
//	console.log("I found " + subNavEls.length +  " elements in the sub nav");
//
//	for (var i=0; i<subNavEls.length; i++) {
//		subNavEls[i].onmouseover=function() {
//			this.className+=" subNavHover";
//
//			console.log("Hovered over " + this.innerHTML); // ECHO REMOVE...
//
//		}
//		subNavEls[i].onmouseout=function() {
//
//			console.log("Moved off " + this.innerHTML); // ECHO REMOVE...
//
//			this.className=this.className.replace(new RegExp(" subNavHover\\b"), "");
//		}
//	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);
/* END: SUCKERFISH :hover */



/* BEGIN: THE VINE Popup Window Function
 * 
 * Use this to open THE VINE popup video player
 */
function openpopup(popurl){
	var winpops=window.open(popurl,"thevine_popup","width=920,height=655,scrollbars=no,resize=no,menubar=no,status=no")
}
function openpopuplivestream(popurl){
	var winpops=window.open(popurl,"thevine_popup","width=648,height=518,scrollbars=no,resize=no,menubar=no,status=no")
}
/* END: THE VINE Popup Window Function */



/* BEGIN: IMPROVED window.onload
 * 
 * This hijacks the onload event so that we can use it for our ads.
 * Other functions that need to be run at onLoad should be added here.
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
/* END: IMPROVED window.onload */



/* BEGIN: AD FUNCTIONS
 * 
 * These functions are used for iframe ads.
 */

   // Used for ad testing to display ad url in div below ad. DO NOT REMOVE. 
   var displayAd = "false"; //param used used for ad testing to display ad url in div below ad. DO NOT REMOVE. 
   function showAdRequest(){
  	 myQueryStr = window.location.search.substring(1);
	 myParams = myQueryStr.split('&');
	 for(i=0; i<myParams.length; i++){
		param = myParams[i].indexOf('displayAd',0);
		if(param==0){
			myParamPair = myParams[i].split('=');
			if(myParamPair[1] == 'true'){displayAd='true';}
			else{displayAd='false'};
		}
		
	 }
   }
   addLoadEvent(showAdRequest);
   
     // Used for ad testing to insert ad keyword all ad urls on page. DO NOT REMOVE. 
   var overrideAdKeyword = "";
   function overrideAdKeywordRequest(){
  	 myQueryStr = window.location.search.substring(1);
	 myParams = myQueryStr.split('&');
	 for(i=0; i<myParams.length; i++){
		param = myParams[i].indexOf('adKeyword',0);
		if(param==0){
			myParamPair = myParams[i].split('=');
			overrideAdKeyword = myParamPair[1];
		}
	 }
   }
   addLoadEvent(overrideAdKeywordRequest);
   
   // Used for ad testing to override edition for all ad urls on page. DO NOT REMOVE. 
   var overrideEdition = "false";
   var newEdition = "";
   function overrideEditionRequest(){
  	 myQueryStr = window.location.search.substring(1);
	 myParams = myQueryStr.split('&');
	 for(i=0; i<myParams.length; i++){
		param = myParams[i].indexOf('editionOverride',0);
		if(param==0){
			myParamPair = myParams[i].split('=');
			overrideEdition = "true";
			newEdition = myParamPair[1];
		}
	 }
   }
   addLoadEvent(overrideEditionRequest);
   
    var ary = new Array();
    var iframeExpandY;
    var iframeRetractY;
    var iframeExpandX;
    var iframeRetractX;

    /* Function that defines our ad object.  This is what is stored in the array and passed for injection. */
    function clsAd(strDivName, strAdURL, intAdWidth, intAdHeight) {
        this.DivName = strDivName;
        this.Url = strAdURL;
        this.Width = intAdWidth;
        this.Height = intAdHeight;
    }

     /*function InjectAd(objAd, j) {
	 pausecomp(25);
	 	var adsURL = objAd.Url;
	    adsURL = adsURL.substring(0, adsURL.indexOf("tile")) + "tile=" + j + ";" + adsURL.substring(adsURL.indexOf("pos="));
	    /* var adiframe = "iframe_" + objAd.DivName;
		document.getElementById(adiframe).src = adsURL + "?";
        $(objAd.DivName).innerHTML =
                '<IFRAME WIDTH='+ objAd.Width +' HEIGHT='+ objAd.Height +
                ' id="iframe_' + objAd.DivName + '" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO BORDERCOLOR=#FFFFFF ALLOWTRANSPARENCY=TRUE ' +
                ' src="' + adsURL + '?">' +
                '</IFRAME>'; 
    }*/
	var ord = Math.floor(Math.random()*(10000000000000000000));
	function InjectAd(objAd) {
	 	var adsURL = objAd.Url.replace("[ORD]",ord);
		
		//Used for ad testing to insert ad keyword into all ad urls on the page
		adsURL = adsURL.replace("akw=;", "akw=" + overrideAdKeyword + ";");
		//Used for ad testing to override edition for all ad urls on the page
		if(overrideEdition == "true"){
		myregexp = /\.[a-z]{2}\.eonline/;
		adsURL = adsURL.replace(myregexp, "." + newEdition + ".eonline");
		}
		
		// Used for ad testing to display ad url in div below ad. DO NOT REMOVE. 
		if (displayAd == "true"){   
		var displayframe = objAd.DivName + "_print";
		$(displayframe).style.display = "block";
		$(displayframe).innerHTML = adsURL;
		}
		
		$(objAd.DivName).innerHTML =
                '<IFRAME WIDTH='+ objAd.Width +' onLoad="LoadNextAd();" HEIGHT='+ objAd.Height +
                ' id="iframe_' + objAd.DivName + '" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO BORDERCOLOR=#FFFFFF ALLOWTRANSPARENCY=TRUE ' +
                ' src="' + adsURL + '?">' +
                '</IFRAME>'; 
		
	}
	
	/*Fix for galleries to generate new ord value */
	function InjectAdinGallery(objAd, ord) {
	 	var adsURL = objAd.Url.replace("[ORD]",ord);
		
        $(objAd.DivName).innerHTML =
                '<IFRAME WIDTH='+ objAd.Width +' onLoad="LoadNextAd();" HEIGHT='+ objAd.Height +
                ' id="iframe_' + objAd.DivName + '" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO BORDERCOLOR=#FFFFFF ALLOWTRANSPARENCY=TRUE ' +
                ' src="' + adsURL + '?">' +
                '</IFRAME>'; 
    }	
	globalTileIndex=1;
	 function LoadNextAd() {
	   if (globalTileIndex <= ary.length)
	    {
			if(ary[globalTileIndex-1])
			{
				InjectAd(ary[globalTileIndex-1]);
				globalTileIndex++;
	     	}
			else{
	  			globalTileIndex++;
				LoadNextAd();
	  		}
		 }
	  
   }
      /* Calls the function that injects the ad into the div.  Note that Array.each() function
    requires the prototype.js library.*/
    function LoadAds() {
	var ord = Math.floor(Math.random()*(10000000000000000000));
        ary.each(
			function(objAd){
				InjectAdinGallery(objAd, ord);
			}
			
		); 
    }
	

function LoadLeaderboard(adId, siteZone, edition, keyword){
	  var adRand = Math.floor(Math.random()*(10000000000000000000)); // regenerate the random number
	  if(keyword == "null"){
	  	keyword = "";
	  }
	  if(edition == 'us'){

	  	var url = 'http://ad.doubleclick.net/adi/' + siteZone + ';tile=1;sz=728x90;!category=default;akw=' + keyword + ';ord=' + adRand + ';dc_seed=' + adId + ';'
	  	  
	  document.getElementById("ad_leaderboard").innerHTML =
                '<IFRAME WIDTH=728 HEIGHT=90'+
                ' id="iframe_divAd_728x90_1' + '" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO BORDERCOLOR=#FFFFFF ALLOWTRANSPARENCY=TRUE ' +
                ' src="' + url + '?">' +
                '</IFRAME>';
		}
		
	}

    // Functions for expanding the iframe for our inhouse ads.
    function expandIframeHeight(iframeExpandY)
	{parent.document.getElementById("targetframe").height = iframeExpandY;}

	function retractIframeHeight(iframeRetractY)
	{parent.document.getElementById("targetframe").height = iframeRetractY;}

	function expandIframeWidth(iframeExpandX)
	{parent.document.getElementById("targetframe").height = iframeExpandY;}

	function retractIframeWidth(iframeRetractX)
	{parent.document.getElementById("targetframe").height = iframeRetractY;}

   // var adORD = Math.floor(Math.random()*(10000000000000000000));
   addLoadEvent(LoadNextAd);
   
/* END: AD FUNCTIONS */



/* BEGIN: footer tracking
 * 
 * This adds onclick google analytics tracking to footer links.
 * 
 * footerSections: elements with anchor tags to attach tracking events onto
 * gaTrackingPaths: corresponding event name to pass to google analytics
 */
footerTracking = function() {
	var footerSections = new Array('eonline_logo_footer', 'eonline_logo_footer_sm', 'style_logo_footer_sm', 'g4_logo_footer_sm', 'footer_news', 'footer_photos', 'footer_videos', 'footer_fashion', 'footer_redcarpet', 'footer_shows', 'footer_more', 'footer_extras', 'footer_about');
	var gaTrackingPaths = new Array('logo', 'logo', 'logo', 'logo', 'e_news', 'gossip', 'videos', 'fashion', 'red_carpet', 'e_shows', 'more', 'extras', 'about_us');
	
	$A(footerSections).each(function(section, index) {
		if ($(section)) {
			$A($(section).getElementsByTagName('A')).each(function(sectionLink) {
				Event.observe(sectionLink, 'click', function(){
					pageTracker._trackPageview('/events/footer/' + gaTrackingPaths[index]);
				});
			});
		};
	});
}
addLoadEvent(footerTracking);
/* END: footer tracking */



/* BEGIN: make title URL-safe
 * 
 * This encodes a title to be URL-safe. Used for google analytics event tracking.
 * Specifically, it strips HTML tags, converts spaces into underscores, and
 * removes punctuation/characters.  If a value greater than zero is passed, the
 * string will be truncated according to the count that was passed.
 */
makeURLsafe = function(str,chars) {
	var happyString = '';
	happyString = str.stripTags().replace(/[\.,;!#\$\/:\?'\(\)\[\]_\-\\]/g, "").replace(/^\s+|\s+$/g, '').replace(/ /gi, "_").replace("&nbsp", "_");
	if (chars > 0) {
		happyString = happyString.truncate(chars);
	}
	return happyString;
}
/* END: make title URL-safe */

//Cookie Stuff
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ){
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
}

	// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function SetCookie(cookieName,cookieValue,nDays, path, domain) {
 	var today = new Date();
 	var expire = new Date();
 	if (nDays==null || nDays==0) nDays=1;
 		expire.setTime(today.getTime() + 3600000*24*nDays);
 		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString()+";path="+path+";domain="+domain;
}
function SetSessionCookie(cookieName, cookieValue, path, domain) {
    document.cookie = cookieName+"="+escape(cookieValue) + ";path="+path+";domain="+domain;
}

//End Cookie Stuff

/** BEGIN: HTML place-holder video players
 */

var html_players = null;
var flash_players = null;
var player_loaded = false;
	
function showPlayer() {
	setTimeout("showFlashPlayer()", 2000);
	player_loaded = true;
}

// Safari bug fix
function sfShowPlayer() {
	if (!player_loaded) {
		showFlashPlayer();
	}
}
	
function showFlashPlayer() {
	html_players = $$('div.html_player');
	flash_players = $$('div.flash_player');
		
	for(i = 0; i<html_players.length; i++) {
		html_players[i].remove();
	}
		
	for(i = 0; i<flash_players.length; i++) {
		flash_players[i].addClassName('flash_player_loaded');
	}
}

loadHtmlPlayers = function() {
	html_players = $$('div.html_player');
			
	for(i = 0; i<html_players.length; i++) {
		html_players[i].onmouseover = function() {
			this.className+=" html_player_loading";
		}
	}
}
addLoadEvent(loadHtmlPlayers);
// If Flash hasn't triggered the showPlayer() function by 18 seconds, execute it 
// automatically.
setTimeout("sfShowPlayer()", 18000);
/* END: HTML place-holder video players */



//these functions are for the video player and the cookie it sets to count videos
function isReadyForVideoAd(){	
	var currentPosition  = getVideoAdCookie("videoAdCounter");
	if(currentPosition == null){
		currentPosition = 0;
	}
	
	return (currentPosition == 0);
}
function incrementVideoCounter(){
	var currentPosition = getVideoAdCookie("videoAdCounter");
	if(currentPosition == null){
		currentPosition = 0;
	}else{
		currentPosition++;
	}
	if(currentPosition > 2){
		currentPosition = 0;
	}
	
	setVideoAdCookie("videoAdCounter",currentPosition,7,'/');
}

function setVideoAdCookie( name, value, expires, path, domain, secure){
	var today = new Date();
	today.setTime( today.getTime());
	if (expires){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape(value) +
	( (expires) ? ";expires=" + expires_date.toGMTString() : "") +
	( (path) ? ";path=" + path : "") +
	( (domain) ? ";domain=" + domain : "") +
	( (secure) ? ";secure" : "");
}

function getVideoAdCookie(check_name){
	var a_all_cookies = document.cookie.split(';');
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; //set boolean t/f default f
	for (i = 0; i < a_all_cookies.length; i++) {
		a_temp_cookie = a_all_cookies[i].split('=');
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if (cookie_name == check_name) {
			b_cookie_found = true;
			if (a_temp_cookie.length > 1) {
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if (!b_cookie_found) {
		return null;
	}
}




// General EOL blog JavaScript functionality

Event.observe(window, 'load', function() {
	if ($('module_lists')) {
	var sfEls = document.getElementById("module_lists").getElementsByTagName("H3");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
		}
	}
});

Event.observe(window, 'load', function() {
	if ($('module_podcast')) {
	var sfEls = document.getElementById("module_podcast").getElementsByClassName("H4");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
		}
	}
});


//topics module js
function getTopicsList(edition){
	var pars = "";
	var seeAllFR = "Voir tous les th" + String.fromCharCode(232) +  "mes";
	var viewTop20FR = "Le top 20 des th" + String.fromCharCode(232) +  "mes";
	
	if ($('show_hide_topics').innerHTML == "See all" || $('show_hide_topics').innerHTML == "Alle" || $('show_hide_topics').innerHTML===seeAllFR || $('show_hide_topics').innerHTML == "Lista completa"){
		pars = 'topicMenu=showAll';
		topicsListPath = '/static/uberblog/topics/' + edition + '/topics-all.html';
	} else {
		pars = 'topicMenu=false';
		topicsListPath = '/static/uberblog/topics/' + edition + '/topics.html';
	};
	
	// this is a little hack to play nice with the accordion.
	$('hot_topics_list').parentNode.setStyle({
		height: 'auto'
	});
	
	new Ajax.Updater('hot_topics_list', '/uberblog/includes/jsp/railmods/topics.jsp', {
  		parameters: pars,
		onComplete: function(){
			if ($('show_hide_topics').innerHTML == "See all" || $('show_hide_topics').innerHTML == "Alle" || $('show_hide_topics').innerHTML===seeAllFR || $('show_hide_topics').innerHTML == "Lista completa"){
				$('show_hide_topics_val').value = $('show_hide_topics').innerHTML;
				if ( edition == 'de' || edition == 'it' ) {
					$('show_hide_topics').innerHTML = 'Top 20';
				} else if (edition == 'fr') {
					$('show_hide_topics').innerHTML = viewTop20FR;
				} else {
					$('show_hide_topics').innerHTML = 'View top 20';
				}
			} else {
				$('show_hide_topics').innerHTML = $('show_hide_topics_val').value;
				$('hot_topics_header').scrollTo();
			}
		}
	});
}

//topics module js
function getKristinTopicsList(edition){
	var pars = "";
	
	if ($('show_hide_topics').innerHTML==="See all"){
		new Ajax.Updater('categories_list', '/static/uberblog/modules/categories_watch_with_kristin-all.html', {
	  		parameters: pars,
			onComplete: function(){
				if ($('show_hide_topics').innerHTML==="See all"){
					$('show_hide_topics').update('View top 20');	
				} else {
					$('show_hide_topics').update('See all');
					$('hot_topics_header').scrollTo();
				}
			}
		});
	} else {
		new Ajax.Updater('categories_list', '/static/uberblog/modules/categories_watch_with_kristin.html', {
	  		parameters: pars,
			onComplete: function(){
				if ($('show_hide_topics').innerHTML==="See all"){
					$('show_hide_topics').update('View top 20');	
				} else {
					$('show_hide_topics').update('See all');
					$('hot_topics_header').scrollTo();
				}
			}
		});
	};
	
	// this is a little hack to play nice with the accordion.
	$('categories_list').parentNode.setStyle({
		height: 'auto'
	});
}
/* main accordion (top stories, hot topics, most commented) */
function loadAccordions() {
	var moduleLists = $('module_lists');
	if (moduleLists) {
		if ($$('accordion_toggle', moduleLists).size() > 0) {
			var photo_categories = new accordion('#module_lists', {
				onEvent: 'mouseover'
			});
			photo_categories.activate($$('#module_lists .accordion_toggle')[0]);
		}
	}
}
Event.observe(window, 'load', loadAccordions, false);

/* podcast player */ 
function loadPodcastPlayer() {
	var podcastModule = $('module_podcast');
	if (podcastModule) {
		if ($$('podcast_toggle', podcastModule).size() > 0) {
			var podcast_row = new accordion('#module_podcast', {
				classNames : {
					toggle : 'podcast_toggle',
					toggleActive : 'podcast_toggle_active',
					content : 'accordion_content'
				},
				onEvent: 'mouseover'
			});
			podcast_row.activate($$('#module_podcast .podcast_toggle')[0]);
		}
	}
}
Event.observe(window, 'load', loadPodcastPlayer, false);

/* load in-blog brightcove videos on demand */
function loadInBlogVideo(id) {
	$('inBlogVideo_'+id).update('<embed src="http://services.brightcove.com/services/viewer/federated_f8/1396519019" bgcolor="#FFFFFF" flashVars="videoRef='+id+'&playerId=1396519019&viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&servicesURL=http://services.brightcove.com/services&cdnURL=http://admin.brightcove.com&domain=embed&autoStart=true&" base="http://admin.brightcove.com" name="flashObj" width="425" height="366" seamlesstabbing="false" type="application/x-shockwave-flash" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent"></embed>');
}

// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
// used for font difference between mac/pc in right column modules
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();




//---------------------------  COMMENTS JS STUFF  --------------------------------

// COMMENTS: an object containing functions and attributes necessary to
// handle the progressive AJAX loading of comments
//
// NOTE: Also checks to see if comments exist and only performs
// 		the functionality if they were detected on the page!
//
// Charlie Markovich - 5/12/08

var memberId = null;
var contentId = null;

/*** captcha related ***/
var coID;

/*** form descriptor values ***/
var nameDescriptor = "Your name";
var uwordDescriptor = "Enter the code shown below";

/*** submit button text ***/
var memberSubmitButton = "Sign In & Post Comment";
var nonMemberSubmitButton = "Post Comment";

/*** required for comment retrieval ***/
var totalCommentsFound = 0;
var totalCommentsShowing = 50;
var totalCommentsPosted = 0;
var commentSetSize = 50; // Total comments limit set per query

/*** how to load first set (server-side vs ajax) ***/
var loadInitialSet = false; // if false, will load via ajax
if (loadInitialSet == false) {
	totalCommentsShowing = 0;
}

/*** store the form submission link ***/
var submitActive = false;


// an easier way to stick in a captcha (with room for improvement)
Captcha = {
	Load: function(el) {
		if($(el)){
			var captchaID = (Math.floor(Math.random()*191))+1;
			$(el).innerHTML = '<img src="http://images.eonline.com/static/redcarpet/globes2007/everywhere/shoutouts/images/'+captchaID+'.jpg" border="0" alt="" />'
							+ '<input type="hidden" value="'+captchaID+'" id="'+el+'_captchaID" class="hidden" />';
		}
	}
}

Comments = {
	AddFormDescriptors: function() {
		// adds form descriptors in the input fields themselves
		if ($('comment_guest')) {
			$('name').value = nameDescriptor;
			Event.observe('name', 'focus', function() {
				$('name').value = '';
			});
			Event.observe('name', 'blur', function() {
				if ($('name').value == '') {
					$('name').value = nameDescriptor;
				}
			});
			
			$('uword').value = uwordDescriptor;
			Event.observe('uword', 'focus', function() {
				$('uword').value = '';
			});
			Event.observe('uword', 'blur', function() {
				if ($('uword').value == '') {
					$('uword').value = uwordDescriptor;
				}
			});
		}
	},
	ChangeButtonStatus: function() {
		// changes submit button text depending on if user is logging in or not
		var buttonText = document.getElementById("anonPostButton");
		if (document.user_comments.passwd.value.length > 0) {
			buttonText.innerHTML = memberSubmitButton;
		} else {
			buttonText.innerHTML = nonMemberSubmitButton;
		}
	},
	DisableSubmitButton: function() {
		$("anonPostButton").innerHTML = "Posting...";
		$("comment_text").addClassName("disabled");
	},
	EnableSubmitButton: function() {
		$("anonPostButton").innerHTML = "Post Comment";
		$("comment_text").removeClassName("disabled");
	}
}

//To send/edit a comment
PostComments = {
	Save: function(blog, url, contentDBID, memberId, commentId) {
		if(submitActive != true) {	// check to see if a submission is already taking place
			submitActive = true;
			Comments.DisableSubmitButton();	// disable the submit button to prevent duplicate submissions
			var isMemberComment = false;
			var isValid = true;
			if ($('comments_message')) {
				$('comments_message').remove();
			}
		    Delete_Cookie("PostCookie","/",".eonline.com");
			SetCookie("PostCookie",coID,5,"/",".eonline.com");
			var captchaId = '';
			var captchaEntry = '';
			if ($('uword')) {
				captchaEntry = hex_md5(document.getElementById('uword').value);
				captchaId = $F('comment_captcha_captchaID');
			}
			if($('commentTextArea').value == '') {
				alert('You must enter a comment.');
				isValid = false;
			}
			var nextIndex = parseInt(totalCommentsFound)+1+totalCommentsPosted;
			var pars = 'mode=save'+'&contentDBID='+escape(contentDBID)+'&commentId='+escape(commentId)
					  +'&memberId='+escape(memberId)+'&pageURL='+escape(url)+'&blog='+escape(blog)+'&nextIndex='+escape(nextIndex)
					  +'&captchaId='+escape(captchaId)+'&comment='+escape($('commentTextArea').value);
			if($('usrEmail') && $('passwd')) {
				if ($('passwd').value != '') isMemberComment = true;
				pars= pars+'&memberEmail='+$('usrEmail').value+'&password='+$('passwd').value;
			}
			if ($('name') && !isMemberComment) {
				if($('name').value == 'Your name') {
					alert('You must enter a username.');
					isValid = false;
					Comments.EnableSubmitButton();	// enable the submit button to allow submitting again
					submitActive = false;
				}
				if($('uword').value == 'Enter the code shown below' || $('uword').value == '') {
					alert('You must enter a valid captcha entry.');
					isValid = false;
					Comments.EnableSubmitButton();	// enable the submit button to allow submitting again
					submitActive = false;
				}
				pars= pars+'&username='+$('name').value+'&captcha='+captchaEntry;
			}
			if(isValid) {
				new Ajax.Updater('comments_set', '/uberblog/includes/jsp/editComment.jsp?'+pars, {
					method:'post',
					postBody:pars,
					insertion: Insertion.Bottom,
					onComplete: function() {
						Captcha.Load('comment_captcha');	// reload the captcha after a submission
						if ($('uword')) $('uword').value = '';				// clear the captcha word field
						new Effect.Highlight('comments_message');
					},
					onSuccess: function() {
						$('commentTextArea').value = '';	// clear the textarea
						totalCommentsPosted++;
						$$('.total_comments').each(function(e) {
							e.update(parseInt(totalCommentsFound)+1);
						});
						if(isMemberComment) {
							$('comment_guest').hide();
							$('comment_member').hide();
						};
						alert("Thanks! Your comment has been sent to our moderators for review.");
						Comments.EnableSubmitButton();	// enable the submit button to allow submitting again
						submitActive = false;
					},
					onFailure: function() {
						Comments.EnableSubmitButton();	// enable the submit button to allow submitting again
						submitActive = false;
					}
				});
			}
		}
	},
	Delete: function(commentId) {
		var pars = 'commentId='+commentId+'&mode=delete';
		new Ajax.Request('/uberblog/includes/jsp/editComment.jsp?'+pars);
	},
	ReportAbuse: function(commentId) {
		var confirmReport = "Report this comment as inappropriate?\n\nIf you feel this comment is inappropriate and feel it should be removed from the E! Online site, let us know by clicking 'OK' below. This will notify us and we can take appropriate action.";
		var pars = 'commentId='+commentId+'&mode=report';
		if (confirm(confirmReport)) {
			new Ajax.Request('/uberblog/includes/jsp/editComment.jsp?'+pars, {
				onComplete: function() {
					alert ("Thank you for your input\n\nThis commment has been reported.  We will review this information and take appropriate action");
					$('report_'+commentId).update('This comment has been reported.');
					$('report_'+commentId).removeAttribute('href');
					$('report_'+commentId).addClassName('reported');
				}
			});
		}
	},
	GiveProps: function(commentId) {
		var pars = 'commentId='+commentId+'&mode=props';
		new Ajax.Request('/uberblog/includes/jsp/editComment.jsp?'+pars);
	}
}

GetComments = {

	CalculateNextSetSize: function(){
		// check to see if the comments remaining are less than the commentSetSize
		var commentsRemaining = totalCommentsFound - totalCommentsShowing; 
		if (commentsRemaining < commentSetSize) {
			commentSetSize = commentsRemaining;
		}
	},

	GetNextPage: function(){
		contentId = $('contentId').value; // Get content Id from dom hidden field
		memberId = $('memberId').value; // Get content Id from dom hidden field

		GetComments.CalculateNextSetSize();

		// Update the list with additional comments found
		new Ajax.Updater('display_next_set', '/uberblog/chatter/includes/jsp/getPageOfComments.jsp', {
			method: 'get',
			insertion: Insertion.Before,
			onComplete: function(){
				GetComments.TogglePreloader();
			},
			parameters: {offset: totalCommentsShowing, length: commentSetSize, memberId: memberId, contentId: contentId}
		});
		
		// increment total comments showing count
		totalCommentsShowing = totalCommentsShowing + commentSetSize;

		//Set the link text
		var linkText = "Im empty";
		var commentsRemaining = 0;
		if (totalCommentsShowing < totalCommentsFound){
			GetComments.CalculateNextSetSize();
			linkText = "Show the next " + (totalCommentsShowing + 1) + " - " + (totalCommentsShowing + commentSetSize) + " of " + totalCommentsFound + " comments";
			$('display_next_link').innerHTML = linkText;
		} else {
			$('display_next_set').hide();
		}
	},

	// If more comments available then display the preloader animation
	TogglePreloader : function(/*resultsShowing, totalResults*/){
		if ($('preloader_graphic').style.display == "block"){
			$('preloader_graphic').style.display = 'none';
		} else {
			$('preloader_graphic').style.display = 'block';
		}
	}
}

// Register the listeners after the page has been fully loaded
Event.observe( window, 'load', function() {
	// Determine if comments are on the page or not
	// if not then don't execute the following code
	if ($('comments_set')){
		totalCommentsFound = $('totalComments').value;

		// Register the event listener for the more comments button
		// if there is another set to load
		if ($('display_next_link')) {
			Event.observe('display_next_link', 'click', function() {
				GetComments.TogglePreloader();
				GetComments.GetNextPage(); // Add comments to the list
			});
		};
		
		// load first set via ajax if not loaded server-side
		if (loadInitialSet == false && totalCommentsFound > 0) {
			GetComments.TogglePreloader();
			GetComments.GetNextPage();
		}
		
		// Load captcha
		Captcha.Load('comment_captcha');
		
		// load form field descriptors
		Comments.AddFormDescriptors();
	}
});

//------------------------Cookie Stuff---------------------------
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ){
		return null;
	}
	if ( start == -1 ) return null; 
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
}

	// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function SetCookie(cookieName,cookieValue,nDays, path, domain) {
 	var today = new Date();
 	var expire = new Date();
 	if (nDays==null || nDays==0) nDays=1;
 		expire.setTime(today.getTime() + 3600000*24*nDays);
 		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString()+";path="+path+";domain="+domain;
}
//----------------------End Cookie Stuff---------------------------


//------------------------window reload on interval---------------------------
function refreshiframe(iframe,milli) {
    var refresh = $(iframe);
	setTimeout("refreshiframe('"+iframe+"','"+milli+"')", milli);
	refresh.src=refresh.src;

}
//----------------------End window reload on interval---------------------------
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/* ************************************************
 * Script: register.js
 * --------------------
 * 
 * AJAX based navigation for:
 * loggedin, post and thanks pages 
 * for Posting a Sighting
 **************************************************/
function subscribeForm(){
	$('news_fix_content').style.display="none";
	$('subscribe_content').style.display="block";

	 
}
function validateEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf("@")
		var lstr=str.length
		var ldot=str.indexOf(".")
		if (str.indexOf("@")==-1){return false}

		if (str.indexOf("@")==-1 || str.indexOf("@")==0 || str.indexOf("@")==lstr){return false}

		if (str.indexOf(".")==-1 || str.indexOf(".")==0 || str.indexOf(".")==lstr){return false}

		 if (str.indexOf("@",(lat+1))!=-1){return false}

		 if (str.substring(lat-1,lat)=="." || str.substring(lat+1,lat+2)=="."){return false}

		 if (str.indexOf(".",(lat+2))==-1){return false}
		
		 if (str.indexOf(" ")!=-1){return false}

 		 return true					
	}


function validateForm(thisform) {
 	var pars = "";
    var email=$F("news_email_input2");
    var country=$F("country_code");
    var i=0;  
    var year = document.subscribe_form.year.options[document.subscribe_form.year.selectedIndex].value;
    var month = document.subscribe_form.month.options[document.subscribe_form.month.selectedIndex].value;
    var daymonth = document.subscribe_form.daymonth.options[document.subscribe_form.daymonth.selectedIndex].value; 
	var optin = document.subscribe_form.optin_check.checked;
	var check = document.subscribe_form.terms_check.checked;

    if ((email==null)||(email=="")){
	$('email_error').style.display="block";
        i=1;

	}
	else{$('email_error').style.display="none";}
    if (validateEmail(email)==false){
	$('email_error').style.display="block";
        i=1;
    }
	else{$('email_error').style.display="none";}
    if ((year=="yyyy") || (month==0) || (daymonth=="dd") ){
        $('birthdate').style.display="none";
        $('birthdate_error').style.display="block";
        i=1;    
    }
    else{
    $('birthdate').style.display="block";
        $('birthdate_error').style.display="none";
    }
	if (check == false){   
         $('terms').style.display="none";
         $('terms_error').style.display="block";
        i=1;
    }
	else{$('terms').style.display="block";
         $('terms_error').style.display="none";
	
	}
    if(i==1){
        
    }
    else{
		pars = "country=" + country + "&email=" + email + "&dob=" + year + "/" + month + "/" + daymonth + "&optin=" + optin;
		new Ajax.Request('/about/newsletters/subscribe/subscribeWhatcounts.jsp',{
			method: 'get',
			parameters: pars,
       		onSuccess: function(){
		if($('news_fix_content')){$('news_fix_content').style.display="none";}
		$('subscribe_content').style.display="none";
        $('success_content').style.display="block";
		$('user_email').innerHTML= email;}
		});

    }
}
	 
	 
function cancelBackToNews(){
	 $('subscribe_content').style.display="none";
	 $('news_fix_content').style.display="block";
	

}
function doneBackToNews(){
	 $('success_content').style.display="none";
	 $('news_fix_content').style.display="block";
	

}
// lightWindow.js v1.1
//
// Copyright (c) 2007 Einstein Industries
// Author: Kevin P Miller | http://www.stickmanlabs.com
// 
// LightWindow is freely distributable under the terms of an MIT-style license.
//
// I don't care what you think about the file size...
//   Be a pro: 
//	    http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
//

/*-----------------------------------------------------------------------------------------------*/

if(typeof Effect == 'undefined')
  throw("lightWindow.js requires including script.aculo.us' effects.js library!");

var lightWindow = Class.create();	
lightWindow.prototype = {
	//
	//	Setup Variables
	//
	element : null,
	contentToFetch : null,
	boxOverFlow : 'hidden',
	retroIE : null,
	windowType : null,
	animating : false,
	scrollX : null,
	scrollY : null,
	imageArray : [],
	preloadImage : null,
	activeGallery : null,
	activeImage : 0,
	galleryDirection : null,
	showDataToggle : false,
	galleryToggle : false,
	showTitleToggle : false,
	//
	//	Initialize the lightWindow.
	//
	initialize : function(options) {
		this.options = Object.extend({
			resizeSpeed : 10,
			cushion : 0,
			dimensions : {
				image : {height : 250, width : 250},
				page : {height : 320, width : 387},
				inline : {height : 250, width : 387},
				media : {height : 250, width : 250},
				external : {height : 250, width : 250},
				dataHeight : 40,
				titleHeight : 25
			},
			classNames : {	
				standard : 'lWOn',
				action : 'lWAction'
			},
			fileTypes : {
				page : ['htm', 'html', 'rhtml', 'phtml', 'txt', 'php', 'shtml', 'php4', 'php3', 'php', 'php5', 'asp', 'aspx', 'vbs', 'pl', 'cgi', 'rb', 'jsp'],
				media : ['mpg', 'mp4', 'avi', 'mov', 'mp3', 'aif', 'wmv', 'wav', 'mpeg', 'flv', 'aiff', 'aac', 'ac3', 'asf', 'divx', 'qt', 'rm', 'ram', 'swf', 'wma', 'moov'],
				image : ['png', 'jpg', 'gif', 'bmp', 'tiff']
			},
			loadingDialog : {
				//message : 'Loading',
				message : '',
				image :  '/images/loading.gif',
				//options : '<a onclick="javascript: mylightWindow.deactivate();">Cancel</a>',
				options : '',
				delay : 3.0
			},
			authorLead : 'by ',
			galleryTab : {
				name : 'Galleries',
				height : 20,
				visible : true
			},
			overlay : {
				color : '#000000',
				opacity : 70,
				image : '/images/black-70.png'
			},
			formMethod : 'get',
			hideFlash : true,
			showTitleBar : false
		}, options || {})
		this.duration = ((11-this.options.resizeSpeed)*0.15);
		this.setupLinks();
		this.addLightWindowMarkup(false);
		this.setupDimensions(true);
	},
	// 
	//  Set Links Up
	//
	setupLinks : function () {
		var links = $$('.'+this.options.classNames.standard);
		links.each(function(link) {
			if (this.fileType(link.href) == 'image') {
				if (gallery = this.getGalleryInfo(link.rel)) {
					if (!this.imageArray[gallery[0]]) this.imageArray[gallery[0]] = new Array();
					if (!this.imageArray[gallery[0]][gallery[1]]) this.imageArray[gallery[0]][gallery[1]] = new Array();
					this.imageArray[gallery[0]][gallery[1]].push(new Array(link.href, link.getAttribute('title'), link.getAttribute('caption'), link.getAttribute('author'), link.getAttribute('rel'), link.getAttribute('params')));
				}
			}
			var url = link.getAttribute('href');
			if (link.href.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
			container = url.substring(url.indexOf('#')+1);
			if($(container)) $(container).style.display = 'none';
			Event.observe(link, 'click', this.activate.bindAsEventListener(this, link));
			link.onclick = function() {return false;};
		}.bind(this));	
	},
	//
	//  Initialize specific window
	//
	initializeWindow : function (id) {
		var link = $(id);
		if (this.fileType(link.href) == 'image') {
			if (gallery = this.getGalleryInfo(link.rel)) {
				if (!this.imageArray[gallery[0]]) this.imageArray[gallery[0]] = new Array();
				if (!this.imageArray[gallery[0]][gallery[1]]) this.imageArray[gallery[0]][gallery[1]] = new Array();
				this.imageArray[gallery[0]][gallery[1]].push(new Array(link.href, link.getAttribute('title'), link.getAttribute('caption'), link.getAttribute('author'), link.getAttribute('rel'), link.getAttribute('params')));
			}
		}
		var url = link.getAttribute('href');
		if (link.href.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
		container = url.substring(url.indexOf('#')+1);
		if($(container)) $(container).style.display = 'none';
		Event.observe(link, 'click', this.activate.bindAsEventListener(this, link));
		link.onclick = function() {return false;};
	},
	//
	//	Add the markup to the page.
	//
	addLightWindowMarkup : function(rebuild) {
	    if (!rebuild) {
			var overlay = document.createElement('div');
			overlay.setAttribute('id', 'overlay');
			if (this.checkBrowser('mac') && this.checkBrowser('firefox')) {
		    	overlay.style.backgroundImage = 'url('+this.options.overlay.image+')';
			    overlay.style.backgroundRepeat = 'repeat';
			} else {
				overlay.style.backgroundColor = this.options.overlay.color;
			    overlay.style.MozOpacity = '.'+this.options.overlay.opacity;
			    overlay.style.opacity = '.'+this.options.overlay.opacity;
			    overlay.style.filter = 'alpha(opacity='+this.options.overlay.opacity+')';
			}
			var lw = document.createElement('div');
			lw.setAttribute('id', 'lightWindow');
		} else {
			var lw = $('lightWindow');
		}

		if (this.options.showTitleBar) lw = this.addTitleBarMarkup(lw);
				
		var lwc = document.createElement('div');
		lwc.setAttribute('id', 'lightWindow-contents');
		
		var lwcc = document.createElement('div');
		lwcc.setAttribute('id', 'lightWindow-contents-container');
		lwc.appendChild(lwcc);						
						
		var lwl = document.createElement('div');
		lwl.setAttribute('id', 'lightWindow-loading');

		var lwi = document.createElement('img');
		lwi.setAttribute('src', this.options.loadingDialog.image);
		lwl.appendChild(lwi);

		var lwld = document.createElement('span');
		lwld.setAttribute('id', 'lightWindow-loading-message');
		lwld.innerHTML += this.options.loadingDialog.message;
		lwl.appendChild(lwld);
		
		var lwlo = document.createElement('span');
		lwlo.setAttribute('id', 'lightWindow-loading-options');
		lwlo.setAttribute('style', 'display:none;');
		lwlo.innerHTML += this.options.loadingDialog.options;
		lwl.appendChild(lwlo);
		
		lwc.appendChild(lwl);
		
		lw.appendChild(lwc);
		
		if (!rebuild) {
			var body = document.getElementsByTagName('body')[0];
			body.appendChild(overlay);
			body.appendChild(lw);	
			Event.observe(overlay, 'click', this.deactivate.bindAsEventListener(this), false);
			overlay.onclick = function() {return false;};
		}
		this.addDataWindowMarkup();
		this.actions('#lightWindow-loading-options');
	},
	//
	//	Add the Title Bar Markup
	//
	addTitleBarMarkup : function(lw) {
	
		var lwdt = document.createElement('div');
		lwdt.setAttribute('id', 'lightWindow-title-bar');
		lwdt.style.display = 'none';

		var lwdtt = document.createElement('div');
		lwdtt.setAttribute('id', 'lightWindow-title-bar-title');
		lwdt.appendChild(lwdtt);
				
		var lwdtc = document.createElement('div');
		lwdtc.setAttribute('id', 'lightWindow-title-bar-close');


		var lwdtca = document.createElement('a');
		lwdtca.setAttribute('id', 'lightWindow-title-bar-close-link');
		lwdtca.innerHTML = 'close';
		Event.observe(lwdtca, 'click', this.deactivate.bindAsEventListener(this));
		lwdtca.onclick = function() {return false;};
		lwdtc.appendChild(lwdtca);
		lwdt.appendChild(lwdtc);
		
		lw.appendChild(lwdt);
		return lw;
		
	},
	//
	//	Add the Data Window Markup
	//
	addDataWindowMarkup : function() {
		var lw = $('lightWindow');
		
		var lwd = document.createElement('div');
		lwd.setAttribute('id', 'lightWindow-data');	
		lwd.style.display = 'none';

		// This container needs to be here to get the data slide to slide as a group
		var lwds = document.createElement('div');
		lwds.setAttribute('id', 'lightWindow-data-slide');
		
		if (!this.options.showTitleBar) {
			var lwdt = document.createElement('div');
			lwdt.setAttribute('id', 'lightWindow-data-title');	
			lwds.appendChild(lwdt);
		}
		
		var lwdc = document.createElement('div');
		lwdc.setAttribute('id', 'lightWindow-data-caption');	
		lwds.appendChild(lwdc);
				
		var lwda = document.createElement('div');
		lwda.setAttribute('id', 'lightWindow-data-author');	
		lwds.appendChild(lwda);
				
		var lwdi = document.createElement('div');
		lwdi.setAttribute('id', 'lightWindow-data-image');	
		lwds.appendChild(lwdi);

		lwd.appendChild(lwds);
		lw.appendChild(lwd);
	},
	//
	//	Add Photo Window Markup
	//
	addPhotoWindowMarkup : function() {
		var lwc = $('lightWindow-contents');
		
		var lwpc = document.createElement('div');
		lwpc.setAttribute('id', 'lightWindow-photo-container');
		lwpc.style.display = 'none';
		
		if (images = parseInt(this.getParam('lWShowImages'))) {
			for (var x = 0; x < images; x++) {
				lwp = document.createElement('img');
	    		lwp.setAttribute('id', 'lightWindow-photo-'+x);
	    		lwpc.appendChild(lwp);
			}
		} else {
			lwp = document.createElement('img');
    		lwp.setAttribute('id', 'lightWindow-photo-0');
    		lwpc.appendChild(lwp);
		}
		
		// You ask why I do this?  I ask why you insist on using a browser worse than IE? ...Safari!
		lwps = document.createElement('img');
		lwps.setAttribute('id', 'lightWindow-photo-sizer');
		lwps.style.display = 'none';
		lwps.style.height = '1px';	
		lwpc.appendChild(lwps);

    	lwc.appendChild(lwpc);
	},
	//
	//	Add Gallery Window Markup
	//
	addGalleryWindowMarkup : function() {
		var lwpc = $('lightWindow-photo-container');

		var lwpg = document.createElement('div');
		lwpg.setAttribute('id', 'lightWindow-photo-galleries');
		lwpg.style.display = 'none';
		if (!this.options.galleryTab.visible) lwpg.style.visibility = 'hidden';
		
		var lwptc = document.createElement('div');
		lwptc.setAttribute('id', 'lightWindow-photo-tab-container');
		
		var lwpgt = document.createElement('a');
		lwpgt.setAttribute('id', 'lightWindow-photo-galleries-tab');
		lwpgt.className = 'up';
		lwpgt.innerHTML = this.options.galleryTab.name;
		Event.observe(lwpgt, 'click', this.getGallery.bindAsEventListener(this));
		lwpgt.onclick = function() {return false;};
		
		lwptc.appendChild(lwpgt);
		lwpg.appendChild(lwptc);
						
		var lwpgl = document.createElement('div');
		lwpgl.setAttribute('id', 'lightWindow-photo-galleries-list');	
		lwpg.appendChild(lwpgl);

    	lwpc.appendChild(lwpg);
	},
	//
	//	Activate the lightWindow.
	//
	activate : function(e, link){
		link.blur();
		this.element = link;
		this.element.title = link.getAttribute('title');
		this.element.author = link.getAttribute('author');
		this.element.caption = link.getAttribute('caption');
		this.element.rel = link.getAttribute('rel');
		this.element.params = this.element.getAttribute('params');
		this.windowType = this.fileType(this.contentToFetch = link.href);
		if (this.element.caption || this.element.author) this.showDataToggle = true;
		if (this.options.showTitleBar && this.element.title) this.showTitleToggle = true;
		else if (!this.options.showTitleBar && this.element.title) this.showDataToggle = true;
		if (this.getGalleryInfo(this.element.rel)) this.galleryToggle = true;
		this.prepareIE(true);
		this.toggleTroubleElements('hidden', false);
		this.displayLightWindow(true);
		this.setupDimensions(true);
		this.monitorKeyboard(true);	
		this.loadInfo();	
	},
	//
	//	Turn off the window
	//
	deactivate : function(){
		var queue = Effect.Queues.get('lightWindowAnimation').each(function(e) {e.cancel();});
		queue = Effect.Queues.get('lightWindowAnimation-loading').each(function(e) {e.cancel();});
		if ($('lightWindow-iframe')) Element.remove($('lightWindow-iframe'));
		Element.remove($('lightWindow-contents'));
		if ($('lightWindow-data')) Element.remove($('lightWindow-data'));
		if ($('lightWindow-title-bar')) Element.remove($('lightWindow-title-bar'));
		this.displayLightWindow(false);	
		this.boxOverFlow = 'hidden';
		this.prepareIE(false);
		this.setStatus(false);
		this.showDataToggle = this.galleryToggle = this.showTitleToggle = false;
		this.addLightWindowMarkup(true);
		this.setupDimensions(true);
		this.monitorKeyboard(false);
		this.toggleTroubleElements('visible', false);		
	},
	//
	//	Setup our actions
	//
	actions : function(prefix) {
		if (prefix) links = $$(prefix+' .'+this.options.classNames.action);
		else links = $$('.'+this.options.classNames.action);
		links.each(function(link) {
			Event.observe(link, 'click', this[link.rel].bindAsEventListener(this, link), false);
			link.onclick = function() {return false;};
		}.bind(this));
	},
	//
	//	Set the staus of our animation to keep things from getting clunky
	//
	setStatus : function(status) {
		this.animating = status;
		// We have to put this here to avoid a flicker in FF Mac
		if (this.showTitleToggle && !status && $('lightWindow-title-bar')) {
			$('lightWindow-title-bar').setStyle({ 
				display : 'block' 
			});
		}
	},
	//
	//	Setup Dimensions of lightWindow.
	//
	setupDataDimensions : function() {
		if ($('lightWindow-contents') && $('lightWindow-data') && this.showDataToggle) {
			$('lightWindow-data').setStyle({
				height : this.options.dimensions.dataHeight+'px',
		  		width : (parseFloat($('lightWindow-contents').style.width)+this.options.cushion*2)+'px'
			});
			$('lightWindow-data-slide').setStyle({
				height : this.options.dimensions.dataHeight+'px',
		  		overflow : 'hidden' // Because of IE
			});
		}	
		if (this.showTitleToggle && $('lightWindow-title-bar')) {
			$('lightWindow-title-bar').setStyle({
				height : this.options.dimensions.titleHeight+'px',
	  			width : (parseFloat($('lightWindow-contents').style.width)+this.options.cushion*2)+'px'
			});
		}
	},
	//
	//	Setup Dimensions of lightWindow.
	//
	setupDimensions : function(reset) {
		if (this.showDataToggle || (this.galleryToggle && this.options.galleryTab.visible)) var adjust = this.options.dimensions.dataHeight;
		else var adjust = 0;

		var originalHeight, originalWidth, titleHeight;
		switch (this.windowType) {
			case 'page' :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;

			case 'image' :
				originalHeight = this.options.dimensions.image.height;
				originalWidth = this.options.dimensions.image.width;
				break;
				
			case 'media' :
				originalHeight = this.options.dimensions.media.height;
				originalWidth = this.options.dimensions.media.width;
				break;
			
			case 'external' : 
				originalHeight = this.options.dimensions.external.height;
				originalWidth = this.options.dimensions.external.width;
				break;
				
			case 'inline' :
				originalHeight = this.options.dimensions.inline.height;
				originalWidth = this.options.dimensions.inline.width;
				break;
				
			default :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;
				
		}
		if (this.showTitleToggle) titleHeight = this.options.dimensions.titleHeight-1; // We subtract one to smooth out the hiccup when the title bar is added
		else titleHeight = 0;
		
		if (reset) {
			if (parseFloat($('lightWindow-contents').style.height) != originalHeight) {
				$('lightWindow-contents').setStyle({
					top : titleHeight+'px',
				  	width : (originalWidth+this.options.cushion)+'px',
				  	height : (originalHeight+this.options.cushion)+'px'
				});
			} else {
				$('lightWindow-contents').setStyle({
				  	width : (originalWidth+this.options.cushion)+'px',
				  	height : (originalHeight+this.options.cushion)+'px'
				});
			}
			$('lightWindow').setStyle({
				padding : '0 0 0 0',
			  	width : '0px',
			  	height : '0px',		
				margin : (-(((originalHeight+this.options.cushion*3)/2)+(adjust/2)+(titleHeight/2)))+'px 0 0 '+(-((originalWidth+this.options.cushion*3)/2))+'px'
			});
		} else {
			$('lightWindow').setStyle({
				padding : parseFloat($('lightWindow-contents').style.height)+2*this.options.cushion+titleHeight+'px 0 0 0',
	  			width : '0px',
	  			height : '0px',
				margin : (-(((parseFloat($('lightWindow-contents').style.height)+this.options.cushion*2)/2)+(adjust/2)+(titleHeight/2)))+'px 0 0 '+(-((parseFloat($('lightWindow-contents').style.width)+this.options.cushion*2)/2))+'px'
			});
			if (parseFloat($('lightWindow-contents').style.height) != originalHeight) {
				$('lightWindow-contents').setStyle({
					top : titleHeight+'px',
					left : '0px'
				});
			}
		}
	}, 
	// 
	// Setup the Overlay (Special Thanks to quirksmode.com and huddletogether.com)
	//
	setupOverlay : function() {

		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	

		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		
		$('overlay').style.height = pageHeight;
		$('overlay').style.width = pageWidth;
	},  
	//
	//	Display the lightWindow.
	//
	displayLightWindow : function(display) {
		if (display) {
			$('overlay').style.display = $('lightWindow').style.display = $('lightWindow-contents').style.display = 'block';	
		} else {
			$('overlay').style.display = $('lightWindow').style.display = 'none'; 	
		}
	},  
	//
	//	Is this IE?
	//
	checkBrowser : function(type) {
		var detect = navigator.userAgent.toLowerCase();
		var version = parseInt(navigator.appVersion);
		var place = detect.indexOf(type)+1;
		return place;
	},
	//
	//	Prepare the window for IE.
	//
	prepareIE : function(setup) {
		if (this.checkBrowser('msie')) {
			var height, overflowX, overflowY;
			if (setup) { 
				this.getScroll();
				this.setScroll(0, 0);
				var height = '100%';
			} else {
				var height = 'auto';
			}
			var body = document.getElementsByTagName('body')[0];
			var html = document.getElementsByTagName('html')[0];
			html.style.height = body.style.height = height;
			html.style.margin = body.style.margin = '0';
			this.setupOverlay();
			if (!setup) this.setScroll(this.scrollX, this.scrollY);				
		}
	},
	//
	//	Hide Selects from the page because of IE.
	//     We could use iframe shims instead here but why add all the extra markup for one browser when this is much easier and cleaner
	//
	toggleTroubleElements : function(visibility, content){
		if (content) var selects = $('lightWindow-contents').getElementsByTagName('select');
		else var selects = document.getElementsByTagName('select');
		for(var i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
		if (!content) {
			if (this.options.hideFlash){
				var objects = document.getElementsByTagName('object');
				for (i = 0; i != objects.length; i++) {
					objects[i].style.visibility = visibility;
				}
				var embeds = document.getElementsByTagName('embed');
				for (i = 0; i != embeds.length; i++) {
					embeds[i].style.visibility = visibility;
				}
			}
			var iframes = document.getElementsByTagName('iframe');
			for (i = 0; i != iframes.length; i++) {
				iframes[i].style.visibility = visibility;
			}
		}
	},
	//
	//	Get the scroll for the page.
	//
	getScroll : function(){
      	if(typeof(window.pageYOffset) == 'number') {
        	this.scrollY = window.pageYOffset;
        	this.scrollX = window.pageXOffset;
      	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        	this.scrollY = document.body.scrollTop;
        	this.scrollX = document.body.scrollLeft;
      	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        	this.scrollY = document.documentElement.scrollTop;
        	this.scrollX = document.documentElement.scrollLeft;
      	}
	},
	//
	//	Reset the scroll.
	//
	setScroll : function(x, y) {
		document.documentElement.scrollLeft = x; 
		document.documentElement.scrollTop = y; 
	},
	//
	//	Get the value from the params attribute string.
	//
	getParam : function(strParamName, strParams) {
        if (!strParams) {
			if (this.element.params) strParams = this.element.params;
			else return;
		}
		var strReturn;
        var aQueryString = strParams.split(',');
        var cmpstring = strParamName+'=';
        var cmplen = cmpstring.length;
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
        	if (aQueryString[iParam].substr(0, cmplen) == cmpstring) {
            	var aParam = aQueryString[iParam].split('=');
                strReturn = aParam[1];
                break;
            }
        }
		if (!strReturn) return false;
        else return unescape(strReturn);
    },
	//
	//	Get the domain from a string.
	//
	getDomain : function(url) {    
        var leadSlashes = url.indexOf('//');
        var domainStart = leadSlashes+2;
        var withoutResource = url.substring(domainStart, url.length);
        var nextSlash = withoutResource.indexOf('/');
        var domain = withoutResource.substring(0, nextSlash);
		if (domain.indexOf(':') > -1){
			var portColon = domain.indexOf(':');
			domain = domain.substring(0, portColon);
       	}
		return domain;
    },
	//
	//	Get the type of file.
	//
	fileType : function(url) {

		var image = new RegExp("[^\.]\.("+this.options.fileTypes.image.join('|')+")\s*$", "i");
		if (image.test(url)) return 'image';
				
		if (url.indexOf('#') > -1 && (document.domain == this.getDomain(url))) return 'inline';		
		if (url.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));

		var type = 'unknown';
		var page = new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$", "i");
		var media = new RegExp("[^\.]\.("+this.options.fileTypes.media.join('|')+")\s*$", "i");
		
		if (document.domain != this.getDomain(url)) type = 'external';
	  	if (media.test(url)) type = 'media';
	
		if (type == 'external' || type == 'media') return type;
			
	  	if (page.test(url) || url.substr((url.length-1), url.length) == '/') type = 'page';

		return type;
	},
	//
	//	Monitor the keyboard while this lightWindow is up
	//
	monitorKeyboard : function(status) {
		if (status) document.onkeydown = this.eventKeypress.bind(this); 
		else document.onkeydown = '';
	},
	//
	//  Perform keyboard actions
	//
	eventKeypress : function(e) {

		if (e == null) var keycode = event.keyCode;
		else var keycode = e.which;
		
		switch (keycode) { 
			case 27: 
				this.deactivate(); 
				break;
			
			case 13:
				return;
				
			default:
				break;
		}
	
		// Gotta stop those quick fingers
		if (this.animating || !this.galleryToggle) return;

		switch (String.fromCharCode(keycode).toLowerCase()) {
			case 'p':
				this.galleryDirection = -1;
				this.changeImage();
				break;
				
			case 'n':
				this.galleryDirection = 1;
				this.changeImage();
				break;
				
			default:
				break;
		}
	},  
	//
	//	Make the Data Box for the Window
	//
	showData : function() {
		if (this.galleryToggle) $('lightWindow-photo-galleries').style.display = 'block';
		this.setupDataDimensions();
		this.setupDimensions(false);		
		if (this.showDataToggle) {
			var showDatabox = new Effect.Parallel(
				[new Effect.SlideDown( 'lightWindow-data', {sync: true, duration: this.duration+1.0, from: 0.0, to: 1.0}), 
			 	new Effect.Appear('lightWindow-data', {sync: true, duration: 1.0}) ], 
				{duration: 0.65, afterFinish: this.setStatus.bind(this, false), queue: {position: 'end', scope: 'lightWindowAnimation'} } 
			);
		} else {
			 this.setStatus(false);
		}
	},
	//
	//	Insert Data into Window
	//
	insertData : function() {
		if (this.element.title) {
			if (this.showTitleToggle) $('lightWindow-title-bar-title').innerHTML = this.element.title; 
			else $('lightWindow-data-title').innerHTML = this.element.title;
		}
		if (this.element.caption) $('lightWindow-data-caption').innerHTML = this.element.caption;
		if (this.element.author) $('lightWindow-data-author').innerHTML = this.options.authorLead+this.element.author;	
	},
	//
	//	Reset the scroll.
	//
	getGalleryInfo : function(rel) {
		if (rel.indexOf('[') > -1) {
			return new Array(escape(rel.substring(0, rel.indexOf('['))), escape(rel.substring(rel.indexOf('[')+1, rel.indexOf(']'))));
		} else {
			return false;
		}
	},
	// 
	//	Choose a gallery/category
	//
	getGallery : function() {
		var isBadBrowser = this.checkBrowser('msie 6');
		if (!$('lightWindow-photo-galleries').style.height || parseInt($('lightWindow-photo-galleries').style.height) == this.options.galleryTab.height) {
			if (isBadBrowser) {
				var gallerySize = 100;
			} else {
				var gallerySize = ((parseInt($('lightWindow-contents').style.height)*0.95)/this.options.galleryTab.height)*100;
			}
			
			$('lightWindow-photo-galleries-list').setStyle({
				height : (parseInt($('lightWindow-contents').style.height)*0.95)-this.options.galleryTab.height+'px'
			});

			// Get out Galleries from the imageArray
			$('lightWindow-photo-galleries-list').innerHTML = '';
			var output = '';
			for (i in this.imageArray) {
				if (typeof this.imageArray[i] == 'object') {
					output += '<div class="lightWindow-photo-gallery-listing"><h1>'+unescape(i)+'</h1><ul>';
					for (j in this.imageArray[i]) {
						if (typeof this.imageArray[i][j] == 'object') {
							if (this.imageArray[i][j][0][5]) showImages = ',lWShowImages='+this.getParam('lWShowImages', this.imageArray[i][j][0][5]);
							else showImages = '';
							output += '<li><a href="#" params="lWGallery='+escape(i)+',lWCategory='+escape(j)+''+showImages+'" class="'+this.options.classNames.action+'" rel="reloadGallery" >'+unescape(j)+'</a></li>';
						}
					}
					output += '</ul></div>';
				}
			}
			new Insertion.Top('lightWindow-photo-galleries-list', output);
			this.actions('.lightWindow-photo-gallery-listing');

			// IE CSS support sucks and I cannot scale from the bottom....
			if (isBadBrowser) {
				$('lightWindow-photo-galleries').setStyle({
					height : (parseInt($('lightWindow-contents').style.height)*0.95)+'px',
					bottom : '0px'
				});				
				$('lightWindow-photo-galleries-tab').className = 'down';
			} else {
				var showGalleries = new Effect.CushionScale('lightWindow-photo-galleries', gallerySize, {duration: this.duration, afterFinish: function(){$('lightWindow-photo-galleries-list').style.overflow = 'auto'; $('lightWindow-photo-galleries-tab').className = 'down';}, scaleX: false, scaleY: true, scaleContent: false, scaleFromCenter: false, queue: {position: 'end', scope: 'lightWindowAnimation'}});		
			}
		} else {
			if (isBadBrowser) {
				var bottom = -(parseInt($('lightWindow-contents').style.height)*0.95)+this.options.galleryTab.height;			
			} else {
				var bottom = 0;
			}
			
			$('lightWindow-photo-galleries').setStyle({
				height : this.options.galleryTab.height+'px',
				bottom : bottom+'px',
				top : ''
			});
			$('lightWindow-photo-galleries-list').setStyle({
				overflow : 'hidden'
			});
			$('lightWindow-photo-galleries-tab').className = 'up';
		}
	},
	//
	//	Set the gallery up.
	//
	setupGallery : function(gallery, start) 
	{
		var lwc = $('lightWindow-photo-container');

		if (!(images = parseInt(this.getParam('lWShowImages')))) images = 1;		
		
		for (var x = 0; x < this.imageArray[gallery[0]][gallery[1]].length; x++) {
			if (this.imageArray[gallery[0]][gallery[1]][x][0] == this.contentToFetch) break;
		}

		this.activeImage = x;
		this.activeGallery = gallery;
		
		var lwn = document.createElement("div");
		lwn.setAttribute('id','lightWindow-navigation');
		lwc.appendChild(lwn);
				
		if (x != 0 && this.imageArray[gallery[0]][gallery[1]][x-images]) {
			var lwnp = document.createElement("a");
			lwnp.setAttribute('id','lightWindow-previous');
			lwnp.setAttribute('href','#');
			lwn.appendChild(lwnp);
			Event.observe(lwnp, 'click', this.changeImage.bindAsEventListener(this, this.imageArray[gallery[0]][gallery[1]][x-images][0], this.imageArray[gallery[0]][gallery[1]][x-images][1], this.imageArray[gallery[0]][gallery[1]][x-images][2], this.imageArray[gallery[0]][gallery[1]][x-images][3], this.imageArray[gallery[0]][gallery[1]][x-images][4]));
			lwnp.onclick = function(){return false;};
		}
		if ((x+1) < this.imageArray[gallery[0]][gallery[1]].length && this.imageArray[gallery[0]][gallery[1]][x+images]) {
			var lwnn = document.createElement("a");
			lwnn.setAttribute('id','lightWindow-next');
			lwnn.setAttribute('href','#');
			lwn.appendChild(lwnn);
			Event.observe(lwnn, 'click', this.changeImage.bindAsEventListener(this, this.imageArray[gallery[0]][gallery[1]][x+images][0], this.imageArray[gallery[0]][gallery[1]][x+images][1], this.imageArray[gallery[0]][gallery[1]][x+images][2], this.imageArray[gallery[0]][gallery[1]][x+images][3], this.imageArray[gallery[0]][gallery[1]][x+images][4]));
			lwnn.onclick = function(){return false;};
		}	
		if (images == 1) $('lightWindow-data-image').innerHTML = 'Image '+(x+1)+' of '+this.imageArray[gallery[0]][gallery[1]].length;
		this.addGalleryWindowMarkup();
	},
	//
	//	Get the contents for the window
	//
	loadInfo : function() {	
		var showLoadingOptions = new Effect.Appear('lightWindow-loading-options', {delay: this.options.loadingDialog.delay, duration: this.duration, queue: {position: 'front', scope: 'lightWindowAnimation-loading'}});
		switch (this.windowType) {
			case 'image' :
				this.preloadImage = new Array();
				if (!$('lightWindow-photo-container')) {
					this.addPhotoWindowMarkup();
					this.addDataWindowMarkup();
					this.addGalleryWindowMarkup();
				}
				var totalWidth = 0;
				var totalHeight = 0;
				var gallery = this.getGalleryInfo(this.element.rel);
				if (images = parseInt(this.getParam('lWShowImages'))) {
					for (var z = 0; z < this.imageArray[gallery[0]][gallery[1]].length; z++) {
						if (this.imageArray[gallery[0]][gallery[1]][z][0] == this.contentToFetch) break;
					}
					$('lightWindow-photo-container').style.display = 'none';
					this.loading = images-1;
					for (var x = 0; x < images; x++) {
						if (this.imageArray[gallery[0]][gallery[1]][x+z]) {
							this.preloadImage[x] = new Image();
							this.preloadImage[x].onload=function(){
								if ($('lightWindow-photo-container').style.display != 'block') {
									for (var t = 0; t <= x; t++) {
										if (this.preloadImage[t] && (this.preloadImage[t].width != 0 && this.preloadImage[t].height != 0)) {
											totalWidth = totalWidth+this.preloadImage[t].width;
											totalHeight = this.preloadImage[t].height;
											this.preloadImage.splice(t, 1);
											this.loading--;	
										}
									}
									if (this.loading < 0) {
										$('lightWindow-photo-container').setStyle({
											display : 'block'
										});
										$('lightWindow-photo-sizer').setStyle({
											width : totalWidth+'px',
											height : totalHeight+'px'
										});
										this.processInfo();
									}
								}
							}.bind(this, x);
							this.preloadImage[x].src = $('lightWindow-photo-'+x).src = this.imageArray[gallery[0]][gallery[1]][x+z][0];
						}
					}
					this.activeImage = this.activeImage+x-1;
					if (this.galleryToggle) this.setupGallery(this.getGalleryInfo(this.element.rel));
				} else {
					this.preloadImage[0] = new Image();
					this.preloadImage[0].onload=function(){
						totalWidth = this.preloadImage[0].width;
						totalHeight = this.preloadImage[0].height;
						$('lightWindow-photo-container').setStyle({
							display : 'block'
						});
						$('lightWindow-photo-sizer').setStyle({
							width : totalWidth+'px',
							height : totalHeight+'px'
						});
						this.processInfo();
					}.bind(this);
					this.preloadImage[0].src = $('lightWindow-photo-0').src = this.contentToFetch;
					if (this.galleryToggle) this.setupGallery(this.getGalleryInfo(this.element.rel));
				}
				break;
			
			case 'media' :	
				// Don't question it.... damn safari
				var lwi = '<iframe id="lightWindow-iframe" name="lightWindow-iframe" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>';
				new Insertion.Top($('lightWindow-contents'), lwi);
				parent.$('lightWindow-iframe').style.visibility = 'hidden';	
				this.processInfo();
				break;

			case 'external' :	
				// Don't question it.... damn safari
				var lwi = '<iframe id="lightWindow-iframe" name="lightWindow-iframe" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>';
				new Insertion.Top($('lightWindow-contents'), lwi);
				parent.$('lightWindow-iframe').style.visibility = 'hidden';
				this.processInfo();
				break;
					
			case 'page' :
				var newAJAX = new Ajax.Request(
        			this.contentToFetch,
        			{method: 'get', parameters: '', onComplete: this.processInfo.bind(this)}
				);
				break;
				
			case 'inline' : 
				var content = this.contentToFetch;
				if (content.indexOf('?') > -1) {
					content = content.substring(0, content.indexOf('?'));
				}
				content = content.substring(content.indexOf('#')+1);
				new Insertion.Top($('lightWindow-contents-container'), $(content).innerHTML);
				this.toggleTroubleElements('hidden', true); 
				this.processInfo();
				break;
				
			default : 
				throw('Page Type could not be determined, please amend this lightWindow URL '+this.contentToFetch);
				break;
			}
	},
	//
	//	Finish the loading process and clean up.
	//
	loadFinish : function() {
		this.actions();	
		this.insertData(false);
		switch (this.windowType) {
			case 'page' :
				var hideLoading = new Effect.Fade('lightWindow-loading', {duration: this.duration, afterFinish: this.windowAdjust.bind(this), queue: {position: 'end', scope: 'lightWindowAnimation'}});
				break;

			case 'image' :
				var hideLoading = new Effect.Fade('lightWindow-loading', {duration: this.duration, afterFinish: this.windowAdjust.bind(this), queue: {position: 'end', scope: 'lightWindowAnimation'}});
				break;
				
			case 'media' :
				parent.$('lightWindow-iframe').src = this.contentToFetch;
				var hideLoading = new Effect.Fade('lightWindow-loading', {duration: this.duration, afterFinish: this.windowAdjust.bind(this), queue: {position: 'end', scope: 'lightWindowAnimation'}});
				break;
			
			case 'external' : 
				parent.$('lightWindow-iframe').src = this.contentToFetch;
				var hideLoading = new Effect.Fade('lightWindow-loading', {duration: this.duration, afterFinish: this.windowAdjust.bind(this), queue: {position: 'end', scope: 'lightWindowAnimation'}});
				break;
				
			case 'inline' :
				var hideLoading = new Effect.Fade('lightWindow-loading', {duration: this.duration, afterFinish: this.windowAdjust.bind(this), queue: {position: 'end', scope: 'lightWindowAnimation'}});
				break;
				
			default :
				break;
		}
	},	
	// 
	//  Adjust the Window and add the data box if it needs it
	//
	windowAdjust : function() {
		if (this.windowType == 'external' || this.windowType == 'media') {
			// No I don't like this but it works with a small flicker, FF for the Mac is a little more buggy than I would have thought
			// Of Note this is really for the quicktime samples as far as I can tell....
			if (this.checkBrowser('mac') && this.checkBrowser('firefox')) {
				if ($('overlay').style.height == '100%' || !$('overlay').style.height) $('overlay').style.height = '101%';
				else $('overlay').style.height = '100%';
			}
			parent.$('lightWindow-iframe').style.visibility = 'visible';
		}
		$('lightWindow-contents').style.overflow = this.boxOverFlow;
		this.toggleTroubleElements('visible', true);
		if (this.showDataToggle || this.showTitleToggle) {
			this.showData();
		}
	},
	//
	//	Get the content into the window and show it off.
	//
	processInfo : function(response) {	
		if(this.checkBrowser('msie')) {
            var windowHeight = document.documentElement.clientHeight;
            var windowWidth = document.documentElement.clientWidth;   
        } else {
            var windowHeight = window.innerHeight;
            var windowWidth = window.innerWidth;
        }

		// What if the window size is ridiculously small? If so we need some overrides to make it fit and make it usable (even on set dimensions)
		if (this.showDataToggle) var dataWindow = this.options.dimensions.dataHeight;
		else var dataWindow = 0;
		if (this.options.showTitleBar) titleHeight = this.options.dimensions.titleHeight;
		else titleHeight = 0;
		var lWcWidth = parseInt($('lightWindow-contents').style.width);
		var lWcHeight = parseInt($('lightWindow-contents').style.height);
		var availableHeight = windowHeight-dataWindow-2*this.options.cushion-titleHeight;
		var availableWidth = windowWidth-2*this.options.cushion;
      	var boxWidth, boxScrollWidth, boxHeight, boxScrollHeight, scaleX, scaleY;	
		var totalHeight = 0;
		var totalWidth = 0;	
		switch (this.windowType) {
			case 'image' :
				if (!(images = parseInt(this.getParam('lWShowImages')))) images = 1;
				boxWidth = $('lightWindow-contents').offsetWidth;
				boxHeight = $('lightWindow-contents').offsetHeight;	
				if ($('lightWindow-photo-0').height > availableHeight) {
					var totalWidth = 0;
					for (var x = 0; x < images; x++) {
						$('lightWindow-photo-'+x).height = availableHeight;
						totalWidth = totalWidth+$('lightWindow-photo-'+x).width;
					}
					if (images > 1) totalWidth++; // This is needed for putting images side by side when we resize the iamge only
					boxScrollHeight = availableHeight;
					boxScrollWidth = totalWidth;
					$('lightWindow-photo-sizer').style.height = availableHeight+'px';
					$('lightWindow-photo-sizer').style.width = totalWidth+'px';
				} else {
					boxScrollHeight = parseInt($('lightWindow-photo-sizer').style.height);		
					boxScrollWidth = parseInt($('lightWindow-photo-sizer').style.width);
				}
				break;
				
			case 'external' :				
		    	boxWidth = $('lightWindow-contents').offsetWidth;
				boxHeight = $('lightWindow-contents').offsetHeight;			
				break;
			
			case 'media' :				
			    boxWidth = $('lightWindow-contents').offsetWidth;
				boxHeight = $('lightWindow-contents').offsetHeight;			
				break;
					
			case 'page' :
				new Insertion.Top($('lightWindow-contents-container'), response.responseText);
				this.toggleTroubleElements('hidden', true); 
				boxWidth = $('lightWindow-contents').offsetWidth;
				boxScrollWidth = $('lightWindow-contents').scrollWidth;
				boxHeight = $('lightWindow-contents').offsetHeight;
				boxScrollHeight = $('lightWindow-contents').scrollHeight;
				break;
			
			case 'inline' :
				boxWidth = $('lightWindow-contents').offsetWidth;
				boxScrollWidth = $('lightWindow-contents').scrollWidth;
				boxHeight = $('lightWindow-contents').offsetHeight;
				boxScrollHeight = $('lightWindow-contents').scrollHeight+3;
				break;
					
			default : 
				break;
				
		}

		// Were dimensions set?
		// This also resizes to fit the window, for things like flash!
		var ignorelWHeight = false;
      	if (lWWidth = this.getParam('lWWidth')) {
			boxScrollWidth = parseFloat(lWWidth);
			if (boxScrollWidth > (windowWidth*.95)) {
				tmp = boxScrollWidth;
				boxScrollWidth = 0.90*windowWidth;
				lWHeight = this.getParam('lWHeight'); // For this case I require a height to be set, why would you set width and not set height?
				boxScrollHeight = parseFloat(lWHeight);
				boxScrollHeight = boxScrollHeight * (boxScrollWidth/tmp)
				ignorelWHeight = true;
			}
		}

		if (lWHeight = this.getParam('lWHeight')) {
			if (!ignorelWHeight) {
				boxScrollHeight = parseFloat(lWHeight);
				if (boxScrollHeight > (windowHeight*.8)) {
					boxScrollHeight = 0.8*windowHeight;
				}
			}
		}
		
		if (lWOverflow = this.getParam('lWOverflow')) this.boxOverFlow = lWOverflow;

		if ((boxScrollHeight < (windowHeight*.8)) && this.windowType != 'external' && this.windowType != 'image') {
			scaleY = parseFloat((boxScrollHeight/boxHeight)*100);
		} else if (this.windowType == 'external' && !lWHeight) {
			scaleY = parseFloat((windowHeight/(1.2*boxHeight))*100);
		} else if (this.windowType == 'external' && lWHeight) {
			scaleY = parseFloat((boxScrollHeight/(boxHeight))*100);
		} else if (this.windowType == 'image' || this.windowType == 'media') {
			scaleY = parseFloat(((boxScrollHeight)/boxHeight)*100);
		} else {
			if (this.windowType != 'media') this.boxOverFlow = 'auto';
			$('lightWindow-contents-container').marginRight = '16px';
			scaleY = parseFloat((windowHeight/(1.2*boxHeight))*100);
		}
		if ((boxScrollWidth < (windowWidth*.8)) && this.windowType != 'external' && this.windowType != 'image' && this.windowType != 'media') {
			scaleX = parseFloat(((boxScrollWidth)/boxWidth)*100);
		} else if (this.windowType == 'external' && !lWWidth) {
			scaleX = parseFloat((windowWidth/(1.1*boxWidth))*100);
		} else if (this.windowType == 'external' && lWWidth) {
			scaleX = parseFloat((boxScrollWidth/(boxWidth))*100);
		} else if (this.windowType == 'image' || this.windowType == 'media') {
			scaleX = parseFloat(((boxScrollWidth)/boxWidth)*100);
		} else {
			if (this.windowType != 'media') this.boxOverFlow = 'auto';
			$('lightWindow-contents-container').marginRight = '16px';
			scaleX = parseFloat((windowWidth/(1.1*boxWidth))*100);
		}
		
		this.setStatus(true);
		var doDelay = 0;
		if (scaleX != 100 && lWcWidth != boxScrollWidth) {
			if (scaleY == 100) var doX = new Effect.CushionScale('lightWindow-contents', scaleX, {duration: this.duration, scaleX: true, scaleY: false, scaleCushion: {top: this.options.cushion, left: this.options.cushion}, afterFinish: this.loadFinish.bind(this), scaleFromCenter: true, scaleContent: false, queue: {position: 'front', scope: 'lightWindowAnimation'}});	
			else var doX = new Effect.CushionScale('lightWindow-contents', scaleX, {duration: this.duration, scaleX: true, scaleY: false, scaleCushion: {top: this.options.cushion, left: this.options.cushion}, scaleContent: false, scaleFromCenter: true, queue: {position: 'front', scope: 'lightWindowAnimation'}});	
			doDelay = this.duration/2;
		}
		if (scaleY != 100 && lWcHeight != boxScrollHeight) {
			var doY = new Effect.CushionScale('lightWindow-contents', scaleY, {duration: this.duration, delay: doDelay, scaleX: false, scaleY: true, scaleCushion: {top: this.options.cushion, left: this.options.cushion}, afterFinish: this.loadFinish.bind(this), scaleContent: false, scaleFromCenter: true, queue: {position: 'end', scope: 'lightWindowAnimation'}});
		}
		if ((!doX && !doY) || (doX && scaleY != 100 && !doY)) this.loadFinish();	
	},	
	//
	//	Reload the window with another location
	//
	reloadWindow : function(element) {
		Element.remove($('lightWindow-contents'));
		if ($('lightWindow-data')) Element.remove($('lightWindow-data'));
		this.element = element;
		this.contentToFetch = this.element.href;
		this.addLightWindowMarkup(true);
		this.setupDimensions(true);
		this.displayLightWindow(true);
		this.loadInfo();
	},
	//
	//  Reload the Gallery
	//
	reloadGallery : function(e, link) {
		this.element.params = link.getAttribute('params');
		var gallery = this.getParam('lWGallery', this.element.params);
		var category = this.getParam('lWCategory', this.element.paramse);
		this.element.rel = this.imageArray[gallery][category][0][4];
		this.element.title = this.imageArray[gallery][category][0][1];
		this.element.caption = this.imageArray[gallery][category][0][2];
		this.element.author = this.imageArray[gallery][category][0][3];
		this.contentToFetch = this.imageArray[gallery][category][0][0];
		Element.remove($('lightWindow-photo-container'));
		if ($('lightWindow-data')) Element.remove($('lightWindow-data'));
		if ($('lightWindow-title-bar')) $('lightWindow-title-bar').style.display = 'none';
		this.galleryToggle = true;
		this.activeGallery[0] = gallery
		this.activeGallery[1] = category;
		this.activeImage = 0;
		// Becuase of IE we have to use either Appear or setOpacity/show
		var showLoading = Effect.Appear('lightWindow-loading', {duration: 0, afterFinish: this.loadInfo.bind(this)});
	},
	//
	//	Change the Image
	//
	changeImage : function(e) {
	  	var data = $A(arguments);
	  	data.shift();
		if (data != '') {
			this.contentToFetch = data[0];
			this.element.title = data[1];
			this.element.caption = data[2];
			this.element.author = data[3];
			this.element.rel = data[4];
		} else {
			if (!(images = parseInt(this.getParam('lWShowImages')))) images = 1;
			if ((this.galleryDirection < 0 && (this.activeImage-1*images) < 0) || (this.galleryDirection > 0 && (this.activeImage+1*images) >= this.imageArray[this.activeGallery[0]][this.activeGallery[1]].length)) return false;
			this.element.title = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage+this.galleryDirection*images][1];
			this.element.caption = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage+this.galleryDirection*images][2];
			this.element.author = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage+this.galleryDirection*images][3];	
			this.element.params = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][0][5];				
			this.element.rel = unescape(this.activeGallery[0]+'['+this.activeGallery[1]+']');			
			this.contentToFetch = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage+this.galleryDirection*images][0];
			this.activeImage = this.activeImage+this.galleryDirection*images;	
		}
		// Preload the previous and next images
		if ((this.activeImage-1) >= 0) {
			var preloadNextImage = new Image();
			preloadNextImage.src = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage-1][0];
		}
		if ((this.activeImage+1) < this.imageArray[this.activeGallery[0]][this.activeGallery[1]].length) {
			var preloadPrevImage = new Image();
			preloadPrevImage.src = this.imageArray[this.activeGallery[0]][this.activeGallery[1]][this.activeImage+1][0];
		}
		Element.remove($('lightWindow-photo-container'));
		if ($('lightWindow-data')) Element.remove($('lightWindow-data'));
		if ($('lightWindow-title-bar')) $('lightWindow-title-bar').style.display = 'none';
		this.galleryToggle = true;
		$('lightWindow-loading-options').style.display = 'none';
		// Becuase of IE we have to use either Appear or setOpacity/show
		var showLoading = Effect.Appear('lightWindow-loading', {duration: 0, afterFinish: this.loadInfo.bind(this)});
	},
	//
	//	Submit a form to another lightWindow
	//
	insertForm : function(e) {
		var element = Event.element(e).parentNode;
		var parameterString = Form.serialize(this.getParam('lWForm', element.getAttribute('params')));
		if (this.options.formMethod == 'post') {
			var newAJAX = new Ajax.Request(
			    element.href,
			    {method: 'post', postBody: parameterString, onComplete: this.reloadWindow.bind(this, element)}
			);
		} else if (this.options.formMethod == 'get') {
			var newAJAX = new Ajax.Request(
			    element.href,
			    {method: 'get', parameters: parameterString, onComplete: this.reloadWindow.bind(this, element)}
			);			
		}
	}
}

/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', lightWindowInit, false);

//
//	Set up all of our links
//
var mylightWindow = null;
function lightWindowInit() {
	mylightWindow = new lightWindow();
}


/*-----------------------------------------------------------------------------------------------
	Problem:
		This effect does not take into account padding or a border on an element, especially an
		absolutely position element. 
	
	Added: 
		Options:
			scaleCushion: 0	// or {top, left} with provided values
			
			Example:
				scaleCushion: {top: 10, left: 10}
		
		Code:
			To setDimensions: function(height, width)
			
				Original:
		    		if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
	        		if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';					
				
				New:
			    	if(this.options.scaleCushion == 'none') {
		        		if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
		        		if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
					} else {
			        	if(this.options.scaleY) d.top = (this.originalTop-topd-this.options.scaleCushion.top-this.options.scaleCushion.bottom) + 'px';
			        	if(this.options.scaleX) d.left = (this.originalLeft-leftd-this.options.scaleCushion.right-this.options.scaleCushion.left) + 'px';		
					}
		
	Credit: Kevin P Miller http://www.stickmanlabs.com
-----------------------------------------------------------------------------------------------*/

Effect.CushionScale = Class.create();
Object.extend(Object.extend(Effect.CushionScale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo: percent,
	  scaleCushion: 'none'	   // 'none' or {} with provided values
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = this.element.getStyle('position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = this.element.getStyle('font-size') || '100%';
    ['em','px','%','pt'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.bind(this));
    
    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
    
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
    if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
  },
  update: function(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
    if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
	if(this.options.scaleX) d.width = width + 'px';
	if(this.options.scaleY) d.height = height + 'px';
	if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
	    if(this.options.scaleCushion == 'none') {
        	if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        	if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
		} else {
        	if(this.options.scaleY) d.top = (this.originalTop-topd-this.options.scaleCushion.top) + 'px';
        	if(this.options.scaleX) d.left = (this.originalLeft-leftd-this.options.scaleCushion.left) + 'px';			
		}
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    this.element.setStyle(d);
  }
});

/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */

/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

/*
 * Perform a simple self-test to see if the VM is working
 */
function md5_vm_test()
{
  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}

/*
 * Calculate the MD5 of an array of little-endian words, and a bit length
 */
function core_md5(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;

  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);

}

/*
 * These functions implement the four basic operations the algorithm uses.
 */
function md5_cmn(q, a, b, x, s, t)
{
  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Calculate the HMAC-MD5, of a key and some data
 */
function core_hmac_md5(key, data)
{
  var bkey = str2binl(key);
  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  return core_md5(opad.concat(hash), 512 + 128);
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left.
 */
function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Convert a string to an array of little-endian words
 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
 */
function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}

/*
 * Convert an array of little-endian words to a string
 */
function binl2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  return str;
}

/*
 * Convert an array of little-endian words to a hex string.
 */
function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}

/*
 * Convert an array of little-endian words to a base-64 string
 */
function binl2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}
function sendPollResults(poll_id, choice_selected, content_id, supp_id) {
	if(isNaN(choice_selected)){
		return false;
	}
	if(content_id!=null && content_id!=""){
		content_id="&content_id="+content_id;
	}
	else {
		content_id="";
	}
	var myAjax = new Ajax.Request("/services/processPoll.jsp",
		{
			method: 'get',
			parameters: "poll_id=" + poll_id + "&choice_selected=" + choice_selected+content_id + "&supp_id=" + supp_id,
			onComplete: updateCaptchaPoll
		});
		return true;
}
function sendPollResultsCaptcha(poll_id, choice_selected, content_id, supp_id, captcha) {
	if(isNaN(choice_selected)){
		return false;
	}
	if(content_id!=null && content_id!=""){
		content_id="&content_id="+content_id;
	}
	else {
		content_id="";
	}
	if(captcha!=null && captcha!=""){
		captcha="&captchaEntry="+captcha;
	}
	else {
		captcha="";
	}
    var myAjax = new Ajax.Request("/services/processPoll.jsp",
		{
			method: 'get',
			parameters: "poll_id=" + poll_id + "&choice_selected=" + choice_selected+content_id+captcha + "&supp_id=" + supp_id,
			onComplete: updateCaptchaPoll
		});
		return true;
}
function sendRateItPollResults(poll_id, choice_selected, content_id, sectionPath) {
	if(isNaN(choice_selected)){
		return false;
	}
	if(content_id!=null && content_id!=""){
		content_id="&content_id="+content_id;
	}
	else {
		content_id="";
	}
	var myAjax = new Ajax.Request(sectionPath+"services/processPoll.jsp",
	{
		method: 'get',
		parameters: "poll_id=" + poll_id + "&choice_selected=" + choice_selected+content_id,
		onComplete: updatePoll
	});
	return true;
}

function sendRateItPollResultsForGallery(poll_id, choice_selected, content_id, sectionPath) {
	if(isNaN(choice_selected)){
		return false;
	}
	if(content_id!=null && content_id!=""){
		content_id="&content_id="+content_id;
	}
	else {
		content_id="";
	}
	var myAjax = new Ajax.Request(sectionPath+"services/processPoll.jsp",
	{
		method: 'get',
		parameters: "poll_id=" + poll_id + "&choice_selected=" + choice_selected+content_id +"&isGallery=true",
		onComplete: updatePoll
	});
	return true;
}

/* NOT ONLY IS THIS FUNCTION NOT USED, IT ALSO BREAKS THE FOOTER MODAL WINDOW!!! */
/* it is being used for the customPoll --JChen*/
function collectChoiceSelected(form, choice_collected,choice_selected){
	var len = form.elements.length;
	var selected=choice_selected.value;
	var collected=choice_collected.value+","+selected;
	for(var i=0; i<len; i++){
		var curr = form.elements[i];
		if(curr.name==choice_selected.name){
			var currVal = curr.value;
			if(currVal!=selected && collected.indexOf(currVal)!=-1){
				collected=collected.replace(","+currVal,"");
			}
		}
	}
	choice_collected.value=collected;
}


function sendPollMultiQuestionResults(poll_id, choice_selected, content_id, coID) {
	if (coID > 0) {
    	var captcha = hex_md5(document.getElementById('poll_uword').value);
	    Delete_Cookie("PostCookie","/",".eonline.com");
	    SetCookie("PostCookie",coID,5,"/",".eonline.com");
	}

    var ary = choice_selected.value.split(",");
	for(var i=0; i<ary.length; i++){
		if(ary[i]!="" && !isNaN(ary[i])){		
			if (coID > 0) {
				sendPollResultsCaptcha(poll_id, ary[i], content_id, '', captcha);
			} else {
				sendPollResults(poll_id, ary[i], content_id);
			}
		}
	}
}
function updatePoll(response) {
	//alert('in updatePoll() start');
	//var resp = response.responseText;
	var jsonObj = null;
	//alert('responseText= ' + response.responseText);
	jsonObj = eval("(" + response.responseText + ")");
	 
	//alert('jsonObj= ' + jsonObj);
	//alert('jsonObj.answerSize= ' + jsonObj.answerSize);
	
	var pollResults = "";
	pollResults += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
	if (jsonObj.thankYouMessage) {
		pollResults += "<tr>";
		pollResults += "<td class=\"selection\">" + jsonObj.thankYouMessage + "</td>";
		pollResults += "</tr>";
	}
	else {	
		for(var i = 0; i < jsonObj.answerSize; i++) {
			pollResults += "<tr>";
		 	pollResults += "<td class=\"percentage\">" + eval("jsonObj.percentage" + i) + "</td>";
			pollResults += "<td class=\"selection\">" + eval("jsonObj.answer" + i) + "</td>";
			pollResults += "</tr>";
		}
	}
	pollResults +=  "</table>";
	$("poll-div").innerHTML = pollResults;
}
function updateCaptchaPoll(response) {
	var jsonObj = null;
	//alert('responseText= ' + response.responseText);
	jsonObj = eval("(" + response.responseText + ")");
	
	if (jsonObj.errorMessage!=null) {
		$('poll_captcha_message').update(jsonObj.errorMessage);
	} else {
		if (jsonObj.thankYouMessage) {
			Element.hide('poll-container-'+jsonObj.poll_id);	//hide poll
			Element.show('thank-you-'+jsonObj.poll_id);			//show thanks msg
		} else {
			$('voteBtn-'+jsonObj.poll_id).hide();				//hide vote submit button
			var poll_vote_array = $$('#poll-container-'+jsonObj.poll_id+' .vote_item input');	//hide vote radio buttons
			poll_vote_array.each(function(poll_vote_array){
				poll_vote_array.hide();
			});
			var poll_results_array = $$('#poll-container-'+jsonObj.poll_id+' .vote_item span');		//show results
			poll_results_array.each(function(poll_results_array){
				poll_results_array.show();
			});
			$('poll_captcha_'+jsonObj.poll_id).hide();						//hide captcha
		}
	}
}
GalleryPoll = {
	DisableVoting: function () {
		var poll_link_array = $$('.poll_choice_link');
		poll_link_array.each(function(poll_link_array){
			poll_link_array.removeAttribute('onclick');
		});
	}
}
BlogPoll = {
	Inject: function (pollID) {
		new Ajax.Updater("blog_poll_" + pollID, "/uberblog/includes/jsp/blog_poll.jsp?pollID=" + pollID, {
			onFailure: function() {
				$("blog_poll_" + pollID).update("There was an error loading the poll. Refresh the page to try again.");
			}
		});
	}
}
function changeFlashNavHeight(h){
		document.getElementById('franchise').style.height = h + "px";
		document.getElementById('RedCarpetNav').style.height = h + "px";
}
function VoxPopPageView() 
{ 	
  reportPageViewWithGoogleAnalytics();  
  LoadLeaderboard('', "redcarpet.us.eonline/games", "us", poseOffEvent);
}
 
function reportPageViewWithGoogleAnalytics()
{
   var pageTracker = _gat._getTracker("your_google_analytics_number_here");
   pageTracker._trackPageview();
}
