/** BEGIN dimensions.js */
var Dimensions = function() {};

Dimensions.center = function(element) {
	try {
		element = document.getElementById(element);
	} catch(e) {
		return;
	}
	var my_width  = 0;
	var my_height = 0;
	if (typeof(window.innerWidth) == 'number') {
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}
	element.style.position = 'absolute';
	element.style.zIndex = '1000';
	var scrollY = 0;
	if (document.documentElement && document.documentElement.scrollTop) {
		scrollY = document.documentElement.scrollTop;
	} else if (document.body && document.body.scrollTop) {
		scrollY = document.body.scrollTop;
	} else if (window.pageYOffset) {
		scrollY = window.pageYOffset;
	} else if (window.scrollY) {
		scrollY = window.scrollY;
	}
	var elementDimensions = new Dimensions.getWidthHeight(element);
	var setX = (my_width - elementDimensions.width ) / 2;
	var setY = (my_height - elementDimensions.height) / 2 + scrollY;
	setX = (setX < 0) ? 0 : setX;
	setY = (setY < 0) ? 0 : setY;
	element.style.left = setX+'px';
	element.style.top = setY+'px';
};

Dimensions.getWidthHeight = function(element) {
	var els = element.style;
	var display = els.display;
	if (display != 'none' && display != null) {
		return {width: element.offsetWidth, height: element.offsetHeight};
	}
	var originalVisibility = els.visibility;
	var originalPosition = els.position;
	var originalDisplay = els.display;
	els.visibility = 'hidden';
	els.position = 'absolute';
	els.display = 'block';
	var originalWidth = element.clientWidth;
	var originalHeight = element.clientHeight;
	els.display = originalDisplay;
	els.position = originalPosition;
	els.visibility = originalVisibility;
	return {width: originalWidth, height: originalHeight};
};
/** END dimensions.js */

/** BEGIN jquery-form-serialize.js */
jQuery.fn.fastSerialize = function() {
	var a = [];
	jQuery('input,textarea,select,button', this).each(function() {
		var n = this.name;
		var t = this.type;
		if (!n || this.disabled || t == 'reset'
		|| (t == 'checkbox' || t == 'radio') && !this.checked
		|| (t == 'submit' || t == 'image' || t == 'button') && this.form.clicked != this
		|| this.tagName.toLowerCase() == 'select' && this.selectedIndex == -1) {
			return;
		}
		if (t == 'image' && this.form.clicked_x) {
			return a.push(
				{name: n+'_x', value: this.form.clicked_x},
				{name: n+'_y', value: this.form.clicked_y}
			);
		}
		if (t == 'select-multiple') {
			jQuery('option:selected', this).each( function() {
				a.push({name: n, value: this.value});
			});
			return;
		}
		a.push({name: n, value: this.value});
	});
	return a;
};/** END jquery-form-serialize.js */

/** BEGIN jquery-tabs.js */
/**
 * Tabs - jQuery plugin for accessible, unobtrusive tabs
 * @requires jQuery v1.1.1
 *
 * http://stilbuero.de/tabs/
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 2.7.4
 */
(function($){$.extend({tabs:{remoteCount:0}});$.fn.tabs=function(initial,settings){if(typeof initial=='object')settings=initial;settings=$.extend({initial:(initial&&typeof initial=='number'&&initial>0)?--initial:0,disabled:null,bookmarkable:$.ajaxHistory?true:false,remote:false,spinner:'Loading&#8230;',hashPrefix:'remote-tab-',fxFade:null,fxSlide:null,fxShow:null,fxHide:null,fxSpeed:'normal',fxShowSpeed:null,fxHideSpeed:null,fxAutoHeight:false,onClick:null,onHide:null,onShow:null,navClass:'tabs-nav',selectedClass:'tabs-selected',disabledClass:'tabs-disabled',containerClass:'tabs-container',hideClass:'tabs-hide',loadingClass:'tabs-loading',tabStruct:'div'},settings||{});$.browser.msie6=$.browser.msie&&($.browser.version&&$.browser.version<7||/MSIE 6.0/.test(navigator.userAgent));function unFocus(){scrollTo(0,0);}return this.each(function(){var container=this;var nav=$('ul.'+settings.navClass,container);nav=nav.size()&&nav||$('>ul:eq(0)',container);var tabs=$('a',nav);if(settings.remote){tabs.each(function(){var id=settings.hashPrefix+(++$.tabs.remoteCount),hash='#'+id,url=this.href;this.href=hash;$('<div id="'+id+'" class="'+settings.containerClass+'"></div>').appendTo(container);$(this).bind('loadRemoteTab',function(e,callback){var $$=$(this).addClass(settings.loadingClass),span=$('span',this)[0],tabTitle=span.innerHTML;if(settings.spinner){span.innerHTML='<em>'+settings.spinner+'</em>';}setTimeout(function(){$(hash).load(url,function(){if(settings.spinner){span.innerHTML=tabTitle;}$$.removeClass(settings.loadingClass);callback&&callback();});},0);});});}var containers=$('div.'+settings.containerClass,container);containers=containers.size()&&containers||$('>'+settings.tabStruct,container);nav.is('.'+settings.navClass)||nav.addClass(settings.navClass);containers.each(function(){var $$=$(this);$$.is('.'+settings.containerClass)||$$.addClass(settings.containerClass);});var hasSelectedClass=$('li',nav).index($('li.'+settings.selectedClass,nav)[0]);if(hasSelectedClass>=0){settings.initial=hasSelectedClass;}if(location.hash){tabs.each(function(i){if(this.hash==location.hash){settings.initial=i;if(($.browser.msie||$.browser.opera)&&!settings.remote){var toShow=$(location.hash);var toShowId=toShow.attr('id');toShow.attr('id','');setTimeout(function(){toShow.attr('id',toShowId);},500);}unFocus();return false;}});}if($.browser.msie){unFocus();}containers.filter(':eq('+settings.initial+')').show().end().not(':eq('+settings.initial+')').addClass(settings.hideClass);$('li',nav).removeClass(settings.selectedClass).eq(settings.initial).addClass(settings.selectedClass);tabs.eq(settings.initial).trigger('loadRemoteTab').end();if(settings.fxAutoHeight){var _setAutoHeight=function(reset){var heights=$.map(containers.get(),function(el){var h,jq=$(el);if(reset){if($.browser.msie6){el.style.removeExpression('behaviour');el.style.height='';el.minHeight=null;}h=jq.css({'min-height':''}).height();}else{h=jq.height();}return h;}).sort(function(a,b){return b-a;});if($.browser.msie6){containers.each(function(){this.minHeight=heights[0]+'px';this.style.setExpression('behaviour','this.style.height = this.minHeight ? this.minHeight : "1px"');});}else{containers.css({'min-height':heights[0]+'px'});}};_setAutoHeight();var cachedWidth=container.offsetWidth;var cachedHeight=container.offsetHeight;var watchFontSize=$('#tabs-watch-font-size').get(0)||$('<span id="tabs-watch-font-size">M</span>').css({display:'block',position:'absolute',visibility:'hidden'}).appendTo(document.body).get(0);var cachedFontSize=watchFontSize.offsetHeight;setInterval(function(){var currentWidth=container.offsetWidth;var currentHeight=container.offsetHeight;var currentFontSize=watchFontSize.offsetHeight;if(currentHeight>cachedHeight||currentWidth!=cachedWidth||currentFontSize!=cachedFontSize){_setAutoHeight((currentWidth>cachedWidth||currentFontSize<cachedFontSize));cachedWidth=currentWidth;cachedHeight=currentHeight;cachedFontSize=currentFontSize;}},50);}var showAnim={},hideAnim={},showSpeed=settings.fxShowSpeed||settings.fxSpeed,hideSpeed=settings.fxHideSpeed||settings.fxSpeed;if(settings.fxSlide||settings.fxFade){if(settings.fxSlide){showAnim['height']='show';hideAnim['height']='hide';}if(settings.fxFade){showAnim['opacity']='show';hideAnim['opacity']='hide';}}else{if(settings.fxShow){showAnim=settings.fxShow;}else{showAnim['min-width']=0;showSpeed=1;}if(settings.fxHide){hideAnim=settings.fxHide;}else{hideAnim['min-width']=0;hideSpeed=1;}}var onClick=settings.onClick,onHide=settings.onHide,onShow=settings.onShow;tabs.bind('triggerTab',function(){var li=$(this).parents('li:eq(0)');if(container.locked||li.is('.'+settings.selectedClass)||li.is('.'+settings.disabledClass)){return false;}var hash=this.hash;if($.browser.msie){$(this).trigger('click');if(settings.bookmarkable){$.ajaxHistory.update(hash);location.hash=hash.replace('#','');}}else if($.browser.safari){var tempForm=$('<form action="'+hash+'"><div><input type="submit" value="h" /></div></form>').get(0);tempForm.submit();$(this).trigger('click');if(settings.bookmarkable){$.ajaxHistory.update(hash);}}else{if(settings.bookmarkable){location.hash=hash.replace('#','');}else{$(this).trigger('click');}}});tabs.bind('disableTab',function(){var li=$(this).parents('li:eq(0)');if($.browser.safari){li.animate({opacity:0},1,function(){li.css({opacity:''});});}li.addClass(settings.disabledClass);});if(settings.disabled&&settings.disabled.length){for(var i=0,k=settings.disabled.length;i<k;i++){tabs.eq(--settings.disabled[i]).trigger('disableTab').end();}};tabs.bind('enableTab',function(){var li=$(this).parents('li:eq(0)');li.removeClass(settings.disabledClass);if($.browser.safari){li.animate({opacity:1},1,function(){li.css({opacity:''});});}});tabs.bind('click',function(e){var trueClick=e.clientX;var clicked=this,li=$(this).parents('li:eq(0)'),toShow=$(this.hash),toHide=containers.filter(':visible');if(container['locked']||li.is('.'+settings.selectedClass)||li.is('.'+settings.disabledClass)||typeof onClick=='function'&&onClick(this,toShow[0],toHide[0])===false){this.blur();return false;}container['locked']=true;if(toShow.size()){if($.browser.msie&&settings.bookmarkable){var toShowId=this.hash.replace('#','');toShow.attr('id','');setTimeout(function(){toShow.attr('id',toShowId);},0);}var resetCSS={display:'',overflow:'',height:''};if(!$.browser.msie){resetCSS['opacity']='';}function switchTab(){if(settings.bookmarkable&&trueClick){$.ajaxHistory.update(clicked.hash);}toHide.animate(hideAnim,hideSpeed,function(){$(clicked).parents('li:eq(0)').addClass(settings.selectedClass).siblings().removeClass(settings.selectedClass);toHide.addClass(settings.hideClass).css(resetCSS);if(typeof onHide=='function'){onHide(clicked,toShow[0],toHide[0]);}if(!(settings.fxSlide||settings.fxFade||settings.fxShow)){toShow.css('display','block');}toShow.animate(showAnim,showSpeed,function(){toShow.removeClass(settings.hideClass).css(resetCSS);if($.browser.msie){toHide[0].style.filter='';toShow[0].style.filter='';}if(typeof onShow=='function'){onShow(clicked,toShow[0],toHide[0]);}container['locked']=null;});});}if(!settings.remote){switchTab();}else{$(clicked).trigger('loadRemoteTab',[switchTab]);}}else{alert('There is no such container.');}var scrollX=window.pageXOffset||document.documentElement&&document.documentElement.scrollLeft||document.body.scrollLeft||0;var scrollY=window.pageYOffset||document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop||0;setTimeout(function(){window.scrollTo(scrollX,scrollY);},0);this.blur();return settings.bookmarkable&&!!trueClick;});if(settings.bookmarkable){$.ajaxHistory.initialize(function(){tabs.eq(settings.initial).trigger('click').end();});}});};var tabEvents=['triggerTab','disableTab','enableTab'];for(var i=0;i<tabEvents.length;i++){$.fn[tabEvents[i]]=(function(tabEvent){return function(tab){return this.each(function(){var nav=$('ul.tabs-nav',this);nav=nav.size()&&nav||$('>ul:eq(0)',this);var a;if(!tab||typeof tab=='number'){a=$('li a',nav).eq((tab&&tab>0&&tab-1||0));}else if(typeof tab=='string'){a=$('li a[@href$="#'+tab+'"]',nav);}a.trigger(tabEvent);});};})(tabEvents[i]);}$.fn.activeTab=function(){var selectedTabs=[];this.each(function(){var nav=$('ul.tabs-nav',this);nav=nav.size()&&nav||$('>ul:eq(0)',this);var lis=$('li',nav);selectedTabs.push(lis.index(lis.filter('.tabs-selected')[0])+1);});return selectedTabs[0];};})(jQuery);/** END jquery-tabs.js */

/** BEGIN jquery-lightbox.js */
var LightBox = function() {};
var rotatorPosition = false;

LightBox.show = function(width) {
	//var dim = new Dimensions.getWidthHeight(document.getElementsByTagName('body')[0]);
	
	// Hide input elements in IE6 so they don't show through the overlay.
	if (jQuery.browser.msie && jQuery.browser.version < 7) {
		jQuery('select').css({visibility:'hidden'});
		// Re-show the input elements that are IN the overlay.
		jQuery('#LightBoxContent select').css({visibility:'visible'});
	}
	jQuery('#flashContainer, #flashObject, iframe, embed, #ufoObj').css({visibility:'hidden'});
	jQuery('#LightBoxContent embed').css({visibility:'visible'});

	jQuery('#LightBoxOverlay').css({display:'block'});
	jQuery('#LightBoxOverlay').height(document.getElementsByTagName('body')[0].scrollHeight);
	jQuery('#LightBoxOverlay').width(document.getElementsByTagName('body')[0].scrollWidth);
	jQuery('#LightBoxOverlay').click(function() {
		new LightBox.hide();
	});

	new Dimensions.center('LightBox');
	jQuery('#LightBox').show();
	return false;
};

LightBox.hide = function() {
	if (typeof(tourny) != 'undefined') {
		window.location = '/tournaments/details/'+tourny;
	}
	if (typeof(forceauth) != 'undefined') {
		window.location = '/';
	}
	if (rotatorPosition) {
		changeStartPosition(rotatorPosition);
	}
	jQuery('iframe').css({visibility:'visible'});
	jQuery('embed').css({visibility:'visible'});
	if (jQuery.browser.msie && jQuery.browser.version < 7) {
		jQuery('select').css({visibility:'visible'});
	}
	if (jQuery.browser.msie) {
		jQuery('#LightBoxContent').html('');
	}
	jQuery('#medumrect').css({visibility:'visible'});
	jQuery('#flashContainer').css({visibility:'visible'});
	jQuery('#flashObject').css({visibility:'visible'});
	jQuery('#leaderboard').css({visibility:'visible'});
	jQuery('#ufoObj').css({visibility:'visible'});
	jQuery('#uploader-userfile').css({visibility:'visible'});
	jQuery('#LightBox').hide('normal');
	jQuery('#LightBoxOverlay').hide();
	jQuery('#LightBoxOverlay').unbind('click');
	return false;
};

LightBox.load = function(url,params,width) {
	jQuery('#LightBox').css({visibility: 'visible',display: 'block'});
	jQuery('#LightBoxOverlay').css({visibility: 'visible',display: 'block'});
	jQuery('#LightBoxContent').load(url, params, function() {
		new LightBox.show(width);
	});
};

LightBox.loadText = function(text,params,width) {
	jQuery('#LightBox').css({visibility: 'visible',display: 'block'});
	jQuery('#LightBoxOverlay').css({visibility: 'visible',display: 'block'});
	jQuery('#LightBoxContent').html(text);
	new LightBox.show(width);
}

LightBox.init = function() {
	jQuery('a.lightBox').unbind();
    jQuery('a.lightBox').click(function() {
		var width = jQuery(this).attr("size");
		width = width ? width : 350;
		if (/\.html$/.test(this.href) || /\.php/.test(this.href)) {
			new LightBox.load(this.href,{},width);
		} else {
			new LightBox.load(this.href+'/ajax=1',{},width);
		}
        return false;
    });
};

jQuery(document).ready(function() {
	new LightBox.init();
});

function lightify(obj) {
	var width = jQuery(obj).attr('size');
	width = width ? width : 350;
	if (/\.html$/.test(obj.href) || /\.php/.test(obj.href)) {
		new LightBox.load(obj.href, {}, width);
	} else {
		new LightBox.load(obj.href+'/ajax=1', {}, width);
	}
	return false;
}

function lightifyText(text) {
	var width = jQuery(text).attr('size');
	width = width ? width : 350;
	new LightBox.loadText(text, {}, width);
	return false;
}
/** END jquery-lightbox.js */

/** BEGIN jquery-colorBlend.js */
(function($){var ver='1.4.0';var gObj=[];$.fn.colorBlend=function(opts){if(!opts){opts=[{}];}
var arrySelected=[];this.each(function(){arrySelected[arrySelected.length]=$.data($(this).get(0));});return this.each(function(){var uId=$.data($(this).get(0));var $cont=$(this);var isFlagAll=false;if(udf(gObj[uId])){gObj[uId]=[];}
$.each(opts,function(i,v){var isFound=false;opts[i]=$.extend({},$.fn.colorBlend.defaults,opts[i]);opts[i].queue=[];opts[i].internals=$.extend({},$.fn.colorBlend.internals);opts[i].parent=$cont;if(opts[i].param=="all"){isFlagAll=FlagAll(opts[i].action);}
$.each(gObj[uId],function(j,w){if(gObj[uId][j].param==opts[i].param){if(!gObj[uId][j].internals.animating){gObj[uId].splice(j,1,setOptions(opts[i]));}
isFound=true;return false;}});if(!isFound){gObj[uId].push(setOptions(opts[i]));}});if(!isFlagAll){$.each(gObj[uId],function(i,v){var ani=gObj[uId][i].internals.animating;var isStopped=false;$.each(opts,function(j,w){if(gObj[uId][i].param!=opts[j].param){return true;}
switch(opts[j].action){case"stop":case"pause":clearTimeout(gObj[uId][i].internals.tId);if(opts[j].action=="stop"){isStopped=true;gObj[uId][i].internals.animating=false;}
break;case"resume":go(gObj[uId][i]);ani=true;break;default:if(!ani){gObj[uId][i]=setOptions(opts[j]);}else{if(gObj[uId][i].isQueue&&gObj[uId][i].cycles>0){gObj[uId][i].queue.push(setOptions(opts[j]));}}
break;}});if(!ani&&!isStopped){go(gObj[uId][i]);}});}});function FlagAll(action){var res=false;$.each(arrySelected,function(i,v){var curObj=gObj[v];$.each(curObj,function(j,w){switch(action){case"stop":case"pause":res=true;clearTimeout(curObj[j].internals.tId);if(action=="stop"){curObj[j].internals.animating=false;}
break;case"resume":res=true;go(curObj[j]);break;}});});return res;};};$.fn.colorBlend.defaults={fps:30,duration:1000,param:"background-color",cycles:0,random:false,isFade:true,fromColor:"current",toColor:"opposite",alpha:"100,100",action:"",isQueue:true};$.fn.colorBlend.internals={aniArray:[],alphaArry:[],pos:0,currentCycle:0,direction:1,frames:0,delay:0,fromRand:false,toRand:false,animating:false,isAlpha:false,tId:0};function setOptions(Opts){var alphaParam=Opts.alpha.split(",");switch(Opts.fromColor.toLowerCase()){case"current":Opts.fromColor=Opts.parent.css(Opts.param);break;case"parent":case"transparent":Opts.fromColor=checkParentColor(Opts.parent,Opts.param);break;case"opposite":Opts.fromColor=OppositeColor(Opts.toColor);break;case"random":Opts.fromColor=rndColor();Opts.internals.fromRand=true;break;}
switch(Opts.toColor.toLowerCase()){case"current":Opts.toColor=Opts.parent.css(Opts.param);break;case"parent":case"transparent":Opts.toColor=checkParentColor(Opts.parent,Opts.param);break;case"opposite":Opts.toColor=OppositeColor(Opts.fromColor);break;case"random":Opts.toColor=rndColor();Opts.internals.toRand=true;break;}
Opts.internals.currentCycle=Opts.cycles>0?Opts.cycles:0;Opts.internals.frames=Math.floor(Opts.fps*(Opts.duration/1000));Opts.internals.delay=Math.floor(Opts.duration/(Opts.internals.frames+1));if(Opts.random){Opts.isFade=false;Opts.fromColor=rndColor();Opts.toColor=rndColor();}
if(Opts.isFade){Opts.internals.currentCycle=Opts.internals.currentCycle*2;Opts.internals.delay=Math.floor(Opts.internals.delay/2);Opts.internals.frames=Math.floor(Opts.internals.frames/2);}
if((alphaParam.length==1&&alphaParam[0]!=100)||(alphaParam.length==2&&(alphaParam[0]!=100||alphaParam[1]!=100))){var obj=Opts.parent.get()[0];var wdth=Opts.parent.width();var higt=Opts.parent.height();wdth=udf(obj.clientWidth)?wdth:obj.clientWidth;higt=udf(obj.clientHeight)?higt:obj.clientHeight;if(alphaParam.length==2){Opts.parent.width(wdth+"px");Opts.parent.height(higt+"px");if(parseInt(alphaParam[0])!=parseInt(alphaParam[1])){Opts.internals.isAlpha=true;Opts.internals.alphaArry=buildAlphaAni(alphaParam[0],alphaParam[1],Opts.internals);}else{setAlpha(Opts.parent,alphaParam[0]);}}else{if(parseInt(alphaParam[0])){Opts.parent.width(wdth+"px");Opts.parent.height(higt+"px");setAlpha(Opts.parent,alphaParam[0]);}}}
Opts.internals.aniArray=buildAnimation(Opts.fromColor,Opts.toColor,Opts.internals);return Opts;}
function go(Opts){var sendStop=false;Opts.internals.animating=true;if(Opts.fromColor!=Opts.toColor){Opts.parent.css(Opts.param,Opts.internals.aniArray[Opts.internals.pos]);}
if(Opts.internals.isAlpha){setAlpha(Opts.parent,Opts.internals.alphaArry[Opts.internals.pos]);}
Opts.internals.pos+=Opts.internals.direction;if(Opts.internals.pos<0||Opts.internals.pos>=Opts.internals.aniArray.length){Opts.internals.currentCycle-=Opts.internals.currentCycle!=0?1:0;Opts.internals.direction=Opts.internals.direction*-1;Opts.internals.pos+=Opts.internals.direction;if(Opts.random){Opts.fromColor=Opts.toColor;Opts.toColor=rndColor();Opts.internals.aniArray=buildAnimation(Opts.fromColor,Opts.toColor,Opts.internals);}
if(!Opts.isFade){Opts.internals.direction=1;Opts.internals.pos=0;}
if(Opts.internals.currentCycle==0&&Opts.cycles>0){sendStop=true;}}
if(!sendStop){Opts.internals.tId=setTimeout(function(){go(Opts);},Opts.internals.delay);}else{Opts.internals.animating=false;clearTimeout(Opts.internals.tId);if(Opts.isQueue&&Opts.queue.length>0){var tmp=Opts.queue.concat();tmp.splice(0,1);Opts=$.extend(Opts,Opts.queue.shift());Opts.queue=tmp.concat();Opts.internals.tId=setTimeout(function(){go(Opts);},Opts.internals.delay);}}}
function setAlpha(elm,opacity){if($.browser.msie){elm.css("filter","alpha(opacity="+opacity+")");}else{elm.css("-moz-opacity",parseFloat(opacity/100));elm.css("opacity",parseFloat(opacity/100));}}
function buildAlphaAni(startOpacity,endOpacity,intOpts){var frames=intOpts.frames;var frame=0;var res=[];var h=0;for(frame=0;frame<=frames;frame++){h=Math.floor(startOpacity*((frames-frame)/frames)+endOpacity*(frame/frames));res[res.length]=h}
if(h!=endOpacity){res[res.length]=parseInt(endOpacity);}
return res;}
function buildAnimation(startColor,endColor,intOpts){var frames=intOpts.frames;var frame=0;var r,g,b,h;var res=[];startColor=toHexColor(startColor);endColor=toHexColor(endColor);var fc=ColorHexToDec(startColor).split(', ');var tc=ColorHexToDec(endColor).split(', ');for(frame=0;frame<=frames;frame++){r=Math.floor(fc[0]*((frames-frame)/frames)+tc[0]*(frame/frames));g=Math.floor(fc[1]*((frames-frame)/frames)+tc[1]*(frame/frames));b=Math.floor(fc[2]*((frames-frame)/frames)+tc[2]*(frame/frames));h=ColorDecToHex(r,g,b);res[res.length]=h;}
if(h.toLowerCase()!=endColor.toLowerCase()){res[res.length]=endColor;}
return res;}
function getHexColorByName(colorName){return allColorsByName()[colorName.toLowerCase()];}
function allColorsByName(){var colors=[];colors["aliceblue"]="F0F8FF";colors["antiquewhite"]="FAEBD7";colors["aqua"]="00FFFF";colors["aquamarine"]="7FFFD4";colors["azure"]="F0FFFF";colors["beige"]="F5F5DC";colors["bisque"]="FFE4C4";colors["black"]="000000";colors["blanchedalmond"]="FFEBCD";colors["blue"]="0000FF";colors["blueviolet"]="8A2BE2";colors["brown"]="A52A2A";colors["burlywood"]="DEB887";colors["cadetblue"]="5F9EA0";colors["chartreuse"]="7FFF00";colors["chocolate"]="D2691E";colors["coral"]="FF7F50";colors["cornflowerblue"]="6495ED";colors["cornsilk"]="FFF8DC";colors["crimson"]="DC143C";colors["cyan"]="00FFFF";colors["darkblue"]="00008B";colors["darkcyan"]="008B8B";colors["darkgoldenrod"]="B8860B";colors["darkgray"]="A9A9A9";colors["darkgreen"]="006400";colors["darkkhaki"]="BDB76B";colors["darkmagenta"]="8B008B";colors["darkolivegreen"]="556B2F";colors["darkorange"]="FF8C00";colors["darkorchid"]="9932CC";colors["darkred"]="8B0000";colors["darksalmon"]="E9967A";colors["darkseagreen"]="8FBC8F";colors["darkslateblue"]="483D8B";colors["darkslategray"]="2F4F4F";colors["darkturquoise"]="00CED1";colors["darkviolet"]="9400D3";colors["deeppink"]="FF1493";colors["deepskyblue"]="00BFFF";colors["dimgray"]="696969";colors["dodgerblue"]="1E90FF";colors["firebrick"]="B22222";colors["floralwhite"]="FFFAF0";colors["forestgreen"]="228B22";colors["fuchsia"]="FF00FF";colors["gainsboro"]="DCDCDC";colors["ghostwhite"]="F8F8FF";colors["gold"]="FFD700";colors["goldenrod"]="DAA520";colors["gray"]="808080";colors["green"]="008000";colors["greenyellow"]="ADFF2F";colors["honeydew"]="F0FFF0";colors["hotpink"]="FF69B4";colors["indianred"]="CD5C5C";colors["indigo"]="4B0082";colors["ivory"]="FFFFF0";colors["khaki"]="F0E68C";colors["lavender"]="E6E6FA";colors["lavenderblush"]="FFF0F5";colors["lawngreen"]="7CFC00";colors["lemonchiffon"]="FFFACD";colors["lightblue"]="ADD8E6";colors["lightcoral"]="F08080";colors["lightcyan"]="E0FFFF";colors["lightgoldenrodyellow"]="FAFAD2";colors["lightgreen"]="90EE90";colors["lightgrey"]="D3D3D3";colors["lightpink"]="FFB6C1";colors["lightsalmon"]="FFA07A";colors["lightseagreen"]="20B2AA";colors["lightskyblue"]="87CEFA";colors["lightslategray"]="778899";colors["lightsteelblue"]="B0C4DE";colors["lightyellow"]="FFFFE0";colors["lime"]="00FF00";colors["limegreen"]="32CD32";colors["linen"]="FAF0E6";colors["magenta"]="FF00FF";colors["maroon"]="800000";colors["mediumaquamarine"]="66CDAA";colors["mediumblue"]="0000CD";colors["mediumorchid"]="BA55D3";colors["mediumpurple"]="9370DB";colors["mediumseagreen"]="3CB371";colors["mediumslateblue"]="7B68EE";colors["mediumspringgreen"]="00FA9A";colors["mediumturquoise"]="48D1CC";colors["mediumvioletred"]="C71585";colors["midnightblue"]="191970";colors["mintcream"]="F5FFFA";colors["mistyrose"]="FFE4E1";colors["moccasin"]="FFE4B5";colors["navajowhite"]="FFDEAD";colors["navy"]="000080";colors["oldlace"]="FDF5E6";colors["olive"]="808000";colors["olivedrab"]="6B8E23";colors["orange"]="FFA500";colors["orangered"]="FF4500";colors["orchid"]="DA70D6";colors["palegoldenrod"]="EEE8AA";colors["palegreen"]="98FB98";colors["paleturquoise"]="AFEEEE";colors["palevioletred"]="DB7093";colors["papayawhip"]="FFEFD5";colors["peachpuff"]="FFDAB9";colors["peru"]="CD853F";colors["pink"]="FFC0CB";colors["plum"]="DDA0DD";colors["powderblue"]="B0E0E6";colors["purple"]="800080";colors["red"]="FF0000";colors["rosybrown"]="BC8F8F";colors["royalblue"]="4169E1";colors["saddlebrown"]="8B4513";colors["salmon"]="FA8072";colors["sandybrown"]="F4A460";colors["seagreen"]="2E8B57";colors["seashell"]="FFF5EE";colors["sienna"]="A0522D";colors["silver"]="C0C0C0";colors["skyblue"]="87CEEB";colors["slateblue"]="6A5ACD";colors["slategray"]="708090";colors["snow"]="FFFAFA";colors["springgreen"]="00FF7F";colors["steelblue"]="4682B4";colors["tan"]="D2B48C";colors["teal"]="008080";colors["thistle"]="D8BFD8";colors["tomato"]="FF6347";colors["turquoise"]="40E0D0";colors["violet"]="EE82EE";colors["wheat"]="F5DEB3";colors["white"]="FFFFFF";colors["whitesmoke"]="F5F5F5";colors["yellow"]="FFFF00";colors["yellowgreen"]="9ACD32";return colors;}
function OppositeColor(value){value=toHexColor(value).split("#").join('').split('');var hexVals="0123456789ABCDEF";var revHexs=hexVals.split('').reverse().join('');var currentPos;for(var i=0;i<value.length;i++){currentPos=hexVals.indexOf(value[i]);value[i]=revHexs.substring(currentPos,currentPos+1);}
return"#"+value.join('');}
function ColorDecToHex(r,g,b){r=r.toString(16);if(r.length==1)r='0'+r;g=g.toString(16);if(g.length==1)g='0'+g;b=b.toString(16);if(b.length==1)b='0'+b;return"#"+r+g+b;}
function ColorHexToDec(value){var res=[];value=value.replace("#","");for(var i=0;i<3;i++){res[res.length]=parseInt(value.substr(i*2,2),16);}
return res.join(', ');}
function toHexColor(value){value=udf(value)?"#FFFFFF":value;if(value.indexOf("rgb(")>-1){value=value.replace("rgb(","").replace(")","");value=eval('ColorDecToHex('+value+')');}else{if(value.indexOf("#")>-1){value=value.replace("#","");if(value.length==3){var s=value.split('');$.each(s,function(i){s[i]=s[i]+s[i];});value=s.join('');}}else{var colName=getHexColorByName(value);value=!udf(colName)?colName:"black";}}
return"#"+value.toUpperCase().split('#').join('');}
function checkParentColor(elm,param){var pColr="#ffffff";$(elm).parents().each(function(){var result=$(this).css(param);if(result!='transparent'){pColr=result;return false;}});return pColr;}
function rndColor(){var res=[];var cm;for(var i=0;i<3;i++){cm=randRange(0,255).toString(16);if(cm.length==1)cm='0'+cm;res[res.length]=cm;}
return"#"+res.join('');}
function randRange(lowVal,highVal){return Math.floor(Math.random()*(highVal-lowVal+1))+lowVal;}
function rndId(){var result=[];for(var i=0;i<10;i++){result[result.length]=randRange(0,9);}
return result.join('');}
function udf(val){return typeof(val)=='undefined'?true:false;}})(jQuery);/** END jquery-colorBlend.js */

/** BEGIN emuse.js */
// IE PNG fix
/*
jQuery(document).ready(function() {
	// Using document.body.filters causes script error on IE 6.0.2800.1106.  Works fine on 6.0.2900 though.
	//var arVersion = navigator.appVersion.split("MSIE")
	//var version = parseFloat(arVersion[1])
	//if ((version >= 5.5) && (document.body.filters)) {
	if (jQuery.browser.msie && jQuery.browser.version >= 5.5 && jQuery.browser.version < 7.0) {
		jQuery('img[@src$=png]').each(function() {
			jQuery(this).css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"',sizingMethod='scale');"});
			jQuery(this).attr('src','/img/pixel.gif');
		});
	}
});
*/

function fbs_click() { u=location.href;	t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); return false;}

function clearOnce(e) {
	if (jQuery(e).val() == 'Add your comment here. 300 character Max.') {
		jQuery(e).val('');
		jQuery("input[@name=addVideoComment]").attr({disabled: false});
		return true;
	} else {
		return true;
	}
}

function mustLoginMessage(insEl) {
	var msg = '<p id="commError" align="center" style="margin-top: 10px; background-color: yellow;"><strong>You will need to either ';
	msg += '<a class="general" href="/user/inlineAuth/ajax=1/" onclick="lightify(this); return false;">login</a> or ';
	msg += '<a class="general" href="/user/signup">signup</a> to use this feature.</strong></p>';
	if (jQuery('#commError').length > 0) {jQuery('#commError').remove();}
	jQuery('#'+insEl).before(msg);
	return false;
}

function refreshEverything(href) {
	if (!href) {
		href = window.location.href;
	}
	/* Reload ad zones */
	if (navigator.platform != 'Nintendo Wii' && navigator.platform != 'iPhone' && navigator.platform != 'iPod') {
		jQuery('#leaderboard').get(0).contentWindow.location.reload(true);
        if (jQuery('#mediumrect').length > 0) {
            jQuery('#mediumrect').get(0).contentWindow.location.reload(true);
        }
		jQuery('#leftSkyscraper').get(0).contentWindow.location.reload(true);
	}
	updateAnalytics(href);
}

function pageUserItems(action, uid, filter, page) {
	jQuery('#contentContainer').load('/user/'+action+'/ajax=1/uid='+uid+'/type='+filter+'/page='+page+'/');
	refreshEverything('/user/'+action+'/'+uid+'/page='+page);
}

function filterMedia(url) {
	jQuery('#ajaxLoader').html('<img src="http://media.ebaumsworld.com/img/ajax-loader2.gif" />');
	refreshEverything();
	jQuery('#contentContainer').load(url+'/ajax=1');
}

function filterVideos(filterType, tag, module, page) {
	var pars = '';
	if (page) {pars += 'page='+page;}
	//if (window.navigator.userAgent.indexOf('MSIE') != -1) {var iever = msieversion();}
	//if (iever && iever < 7) {
	if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) {
		jQuery('#right-col').css({'margin-top':'10px'});
    } else {
		jQuery('#right-col').css({'padding-top':0});
    }
	jQuery('#contentContainer').load('/'+module+'/'+filterType+'/'+tag+'/ajax=1/?'+pars);
}

function getMediaList(list, page, filter, tagId, module) {
	if (jQuery('#videoStatBox').length > 0) {jQuery('#videoStatBox').remove();}
	if (jQuery('#relatedContainer').length > 0) {jQuery('#relatedContainer').remove();}

	switch (list) {
		case 'views':
			var getPage = 'popular';
			var active = 'popular';
			break;
		case 'created':
			var getPage = 'newest';
			var active = 'newest';
			break;
		case 'featured':
			var getPage = 'featured';
			var active = 'featured';
			break;
		case 'comments':
			var getPage = 'comments';
			var active = 'comments';
			break;
		case 'favorites':
			var getPage = 'favorites';
			var active = 'favorites';
			break;
	}

	createCookie('activeTab', getPage, 1);

	var url = '/'+module+'/'+getPage+'/ajax=1/type='+list+'/';
	if (page) {url += 'page='+page+'/';}
	if (filter) {url += 'datefilter='+filter+'/';}
	if (tagId) {url += 'tagId='+tagId+'/';}

	refreshEverything('/tagId='+tagId+'/page='+page);
	jQuery('#contentContainer').load(url);
}

function setMeActive(node) {
	if (!node) {
		return false;
	}
	jQuery('#tabs li').each(function() {
		jQuery(this).removeClass('selected');
	});
	if (jQuery('#'+node).attr('id') == 'featured') {
		var bg = 'url(http://media.ebaumsworld.com/img/slant_on.gif) no-repeat';
	} else {
		var bg = 'url(http://media.ebaumsworld.com/img/norm_on.gif) no-repeat';
	}
	
	jQuery('#'+node).addClass('selected').css('background', bg );
	return true;
}

function pageThumbList(type, datefilter, tagId, module, page) {
	jQuery('#ajaxLoader').html('<img src="http://media.ebaumsworld.com/img/ajax-loader2.gif" />');
	if (type == 'views') {var action = 'popular';}
	if (type == 'created') {var action = 'newest';}
	if (type == 'featured') {var action = 'featured';}
	if (type == 'category') {var action = 'category';}
	var pars = 'ajax=1/type=' + type + '/datefilter=' + datefilter + '/tagId=' + tagId + '/page=' + page + '/';

	refreshEverything('/tagId='+tagId+'/page='+page);
	jQuery('#contentContainer').load('/'+module+'/'+action+'/'+pars);
	document.forms[0][0].focus();
}

var currentPage = 1;
var currentSortOrder = "newest";
function pageListing(url, page, container, callback, reload_ads) {
	if(!callback && typeof(scrollToCommentAndHighlight) != "undefined") {
		callback = scrollToCommentAndHighlight;
	}
	
	jQuery('#ajaxLoader').html('<img src="http://media.ebaumsworld.com/img/ajax-loader2.gif" />');
	
	if (typeof(reload_ads) != undefined) {
		refreshEverything(url+'/page='+page);
	}
	
	var cont = 'contentContainer';
	if (navigator.platform == 'Nintendo Wii') {
		cont = 'contentContainerFull';
	}
    if (container) {
        cont = container;
    }
	url = url.replace(/\/(page|ajax)=[^\/]*/i, "");
    jQuery("#" + cont).load(url+'/page='+page+'/sortBy='+currentSortOrder+'/ajax=1/', {}, callback);
    currentPage = page;
}

jQuery(document).ready(function () {
	if(typeof getCommentIdFromUrl == "function") {
		var id = getCommentIdFromUrl();
		if (id && jQuery("#comment-" + id)) {
			jQuery.getJSON('/comment/getPage/' + id + '/ajax=1/', function(data) {
				if(data.message.page > 1) {
					commentIdData = location.href.match(/\/((view=)?)([0-9]+)\/.*/);
					pageListing("/comment/list/vid=" + commentIdData[3], data.message.page,
							"video_comments", scrollToCommentAndHighlight);
				}
			});
		}
	}
});

function sortedPageListing(url, sortBy, container, page) {
	if(!page) {
		page = 1;
	}
	currentSortOrder = sortBy;
	url = url.replace(/\/sortBy=[^\/]*/i, "");
	pageListing((url + "/sortBy=" + sortBy), page, container);
}

function pageUserList(page, filter) {
	if (filter) {pars += '&filter=' + filter;}
	jQuery('#contentContainer').load('/user/search/ajax=1/page='+page+'/?'+pars);
}

function updateUserPref(uid, pref, newval, vid) {
	var url = '/comment/toggle/';
	var pars = 'ajax=1&uid=' + uid + '&' + pref + '=' + newval;

	if (pref == 'show_comments') {
		switch (newval) {
		case '1':
			if (uid == '') {
				eraseCookie('showComments');
			}
			if ($('commError')) {
            	Element.remove($('commError'));
            }
			$('commentsDisabled').style.display = 'none';
			$('commentSection').style.visibility = 'visible';
			pars += '&vid=' + vid;
			break;

		case '0':
			if (uid == '') {
				createCookie('showComments', '0', 1);
				var msg = '<p id="commError" align="center" style="margin-top: 10px; background-color: yellow;">';
				msg += '<strong>Comments have been disabled.  You may have to disable them again the next time you visit the site.  You can permanently disable comments by logging in and editing your user preferences.</strong>';
			    if ($('commError')) {
            		Element.remove($('commError'));
			    }
			    new Insertion.Before($('commentSection'), msg);
				$('commentSection').style.visibility = 'hidden';
				$('commentsDisabled').style.display = 'block';
				return false;
				break;
			}
			$('commentSection').style.visibility = 'hidden';
			$('commentsDisabled').style.display = 'block';
			break;
		case '3':
            mustLoginMessage('commentSection');
            return false;
            break;
		}

	}

	var request = new Ajax.Updater(
		'video_comments',
		url,
		{
			method: 'post',
			parameters: pars
		}
	);
	return true;
}

function flagForRemoval(vid) {
	jQuery('#inappropriate').load('/media/flagMedia/ajax=1/vid='+vid);
}

function updateThumb(vid, path) {
	jQuery.get('/user/editMediaThumb/ajax=1/',{vid:vid,path:path},function(resp) {
		window.location = resp;
	});
}

/* Update Analytics */
function updateAnalytics(args) {
	var pageloc = /:\/\/.*?(\/.*?)$/.exec(String(window.location));
	var querystring = pageloc[1];
	querystring += args;
	pageTracker._trackPageview(querystring);
}

/* BEGIN COOKIE FUNCTIONS */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
		document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
/* END COOKIE FUNCTIONS */

var trp = 0;
//var automated_rotate = 0;
function rotateFrontpageTabs() {
	if (tabrotate == 1) {
		jQuery('li.tabs-selected').removeClass('tabs-selected');
		trp++;
		trp = trp > 2 ? 0 : trp;
		jQuery('#tabBox li:eq(' + trp + ')').addClass('tabs-selected');
		jQuery('div.tabs-container').addClass('tabs-hide');
		var showDiv = jQuery('li.tabs-selected a').attr('href');
		jQuery(showDiv).removeClass('tabs-hide');
		setTimeout(rotateFrontpageTabs, 5000);
	}
}

/* gameId is optional, currently only used on the tournaments page. */
function showUserOptions(el, user, gameId) {
    if (window.location.href.indexOf('/tournaments') != -1) {
        window.clearTimeout(indexTimeout);
    }
	jQuery('.userDrop').each( function() {
		if (jQuery(this).attr('id')) {
			jQuery(this).html('');
			jQuery(this).removeClass('userOpts').removeAttr('id').removeAttr('style');
		}
	});
	
	var xtra = false;
	var optBox = '<div class="userOptsContent"><div style="text-align:center;background-color:#fff;color:#000;">' + user + '</div>'
    + '<span style="float:right;"><a href="#" onclick="showUserOptions(this);return false;">X</a></span>'
	+ '<a href="/user/options/user='+user+'/do=sendmessage/">Send Message</a><br />'
	+ '<a href="/user/options/user='+user+'/do=addbuddy/">Add to Buddy List</a><br />'
	+ '<a href="/user/profiles/'+user+'/">View Profile</a>';
	if (window.location.href.indexOf('/tournaments') != -1 || window.location.href.indexOf('/highscores') != -1) {
		xtra = true;
		optBox += '<br />--------------------';
		optBox += '<br /><a href="/tournaments/1on1/'+gameId+'/uname='+user+'/">Challenge '+user+' 1 on 1</a>';
	}
	if (window.location.href.indexOf('/elinks/') != -1) {
		xtra = true;
		optBox += '<br />--------------------';
		optBox += '<br /><a href="/elinks/fromuser/'+user+'/">eLinks From '+user+'</a>';
		optBox += '<br /><a href="/elinks/votedby/'+user+'/">eLinks '+user+' Voted</a>';
	}
	optBox += '</div>';
	
	jQuery(el).prev().addClass('userOpts');
	if (xtra) {
		jQuery(el).prev().addClass('userOptsElinks');
	}
	jQuery(el).prev().html(optBox).attr({ id: user });
	jQuery(el).prev().show("slow");
}

function setAsFavorite(vid, user) {
	if (user == '') {
		mustLoginMessage('videoDetail');
		return false;
	}
    jQuery('div.inlineError').remove();
	jQuery.getJSON('/user/favorites/' + user + '/do=add/media=' + vid + '/ajax=1', function(resp) {
		if (resp.error) {
			var eDiv = '<div class="inlineError" style="text-align:center;">'+resp.error+'</div>';
			jQuery('#videoDetail').before(eDiv);
			return false;
		} else {
            var eDiv = '<div class="inlineError" style="text-align:center;">'+resp.message+'</div>';
			jQuery('#videoDetail').before(eDiv);
			return true;
		}
	});
    return true;
}

function addToList(adder, addee, list, confirmed) {
	if (list == 'buddies') {
		var el = 'addbuddy';
	} else {
		var el = 'blockbuddy';
	}
	jQuery.getJSON('/user/addToList/'+adder+'/buddy='+addee+'/list='+list+'/confirmed='+confirmed+'/ajax=1/', function(resp) {
		if (resp.error) {
            var disp = resp.error;
			/*jQuery('#'+el).html(resp.error);*/
		} else {
            var disp = resp.message
			/*jQuery('#'+el).html(resp.message);*/
		}
        alert(disp);
        jQuery('#' + list).remove();
	});
}
function $(id) {
	return document.getElementById(id);
}
/** END emuse.js */

/** BEGIN jquery-rating.js */
// JavaScript Document
/*************************************************
Star Rating System
First Version: 21 November, 2006
Author: Ritesh Agrawal
Inspriation: Will Stuckey's star rating system (http://sandbox.wilstuckey.com/jquery-ratings/)
Demonstration: http://php.scripts.psu.edu/rja171/widgets/rating.php
Usage: $('#rating').rating('www.url.to.post.com', {maxvalue:5, curvalue:0});

arguments
url : required -- post changes to
options
	maxvalue: number of stars
	curvalue: number of selected stars

************************************************/
/* Hacked to add callback to AJAX call, remove cancel button, and do half-stars. -PG */

jQuery.fn.rating = function(url, options) {
	if(url == null) return;
	var settings = {
		url       : url, // post changes to
		maxvalue  : 5,   // max number of stars
		curvalue  : 0,    // number of selected stars
		callback  : false
	};
	if(options) {
		jQuery.extend(settings, options);
	};

	jQuery.extend(settings, {cancel: (settings.maxvalue > 1) ? true : false});

	var container = jQuery(this);
	jQuery.extend(container, {averageRating: settings.curvalue,url: settings.url});
	for(var i= 1; i <= settings.maxvalue ; i++){
		var size = i
		var div = '<div class="star dyn"><a href="#'+i+'" title="Give it '+i+'/'+settings.maxvalue+'">'+i+'</a></div>';
		container.append(div);
	}

	var stars = jQuery(container).children('.star');
	var cancel = jQuery(container).children('.cancel');

	stars.mouseover(function(){
		event.drain();
		event.fill(this);
	}).mouseout(function(){
		event.drain();
		event.reset();
	}).focus(function(){
		event.drain();
		event.fill(this)
	}).blur(function(){
		event.drain();
		event.reset();
	});

	stars.click(function(){
		if(settings.cancel == true){
			settings.curvalue = stars.index(this) + 1;
			settings.response = jQuery.post(container.url, {
				"rating": jQuery(this).children('a')[0].href.split('#')[1]
			}, function(){settings.callback(settings);});
			return false;
		} else if(settings.maxvalue == 1){
			settings.curvalue = (settings.curvalue == 0) ? 1 : 0;
			$(this).toggleClass('on');
			settings.response = jQuery.post(container.url, {
				"rating": jQuery(this).children('a')[0].href.split('#')[1]
			}, function(){settings.callback(settings);});
			return false;
		}
		return true;
	});

	var event = {
		fill: function(el){ // fill to the current mouse position.
			var index = stars.index(el) + 1;
			stars
				.children('a').css('width', '100%').end()
				.slice(0, index).addClass('hover').end();
		},
		drain: function() { // drain all the stars.
			stars
				.filter('.on').removeClass('on').end()
				.filter('.half').removeClass('half').end()
				.filter('.hover').removeClass('hover').end();
		},
		reset: function(){ // Reset the stars to the default index.
			stars.slice(0, settings.curvalue).addClass('on').end();
			var ceiling = Math.ceil(settings.curvalue);
			if (ceiling - settings.curvalue <= 0.25) {
				stars.eq(ceiling - 1).addClass('on').end();
			} else if (0.25 < ceiling - settings.curvalue && ceiling - settings.curvalue < 0.75) {
				stars
					.eq(ceiling - 1).removeClass('on').end()
					.eq(ceiling - 1).addClass('half').end();
			} else {
				stars.eq(ceiling - 1).addClass('off').end();
			}
		}
	}
	event.reset();
	return(this);
}

// Callbacks and jQuery for putting ratings on media items.
// This used to be in the media/module.js, but with per-module loading,
// this is now as good a place for it as any.

function toggleShowVote(user_mode) {

		var rate_data = jQuery('#ratings').attr('rel').split(':');
		var user_rating = rate_data[0];
		var avg_rating = rate_data[1];
		
		var star_value = user_mode ? user_rating : avg_rating;
		var half_class = user_mode ? 'half' : 'halfrated';
		var on_class = user_mode ? 'on' : 'rated';
	
		//var label = jQuery('#ratings').children().eq(0).children('strong');
		var label = jQuery('#ratings .votes_label')
		var stars = jQuery('#ratings').children('.star');
	
		if (user_mode) {
			label.children('.off').hide();
			label.children('.on').show();
		} else {
			label.children('.on').hide();
			label.children('.off').show();
		}
		
		stars.filter('.on').removeClass('on').end()
		     .filter('.half').removeClass('half').end()
		     .filter('.rated').removeClass('rated').end()
		     .filter('.halfrated').removeClass('halfrated').end()
		     .filter('.off').removeClass('off').end();
		
		stars.slice(0, star_value).addClass(on_class).end();
		var ceiling = Math.ceil(star_value);
		stars.slice(ceiling).addClass('off').end();
		
		if (ceiling - star_value <= 0.25) {
			stars.eq(ceiling - 1).addClass(on_class).end();
		} else if (0.25 < ceiling - star_value && ceiling - star_value < 0.75) {
			stars.eq(ceiling - 1).addClass(half_class).end();
		} else {
			stars.eq(ceiling - 1).addClass('off').end();
		}	
}

function updateVoteDisplay(settings) {
	var vote_text = jQuery('#votes').html();
	if (! vote_text) {
		var vote_text = jQuery('.votes_number').html();
	}
	var num_votes = vote_text.replace(/^\((\d+) R.*$/, '$1');
	var content = '';

	var resp = eval('(' + settings.response.responseText + ')');
	if (resp.success == 1) {
		jQuery('#rating').prev().remove();
		
		num_votes = parseInt(num_votes) + 1;
		jQuery('#votes').html('('+num_votes+' Ratings)');

		var title = settings.curvalue + ' stars';
		for (i = 1; i <= settings.maxvalue; i++) {
			star_class = (i <= settings.curvalue ? 'star rated' : 'star off');
			content += '<div title="'+title+'" class="'+star_class+'">'+i+'</div>';
		}
	
		content = '<div style="float: left; margin-right: 3px;">Vote saved!</div><div style="float: left">'
				+ content + '</div>';
				
		jQuery('#rating').after(content);
		jQuery('#rating').remove();
	} else {
		var value = resp.message;
		jQuery('#LightBoxContent').html('<p>' + value + '</p>');
		new LightBox.show();
	}
}

jQuery(document).ready(function(){

	var rel_data = jQuery('#rating').attr('rel');
	
	if (rel_data) {
		var rating_data = rel_data.split(":")
		var media_id = rating_data[0];
		var avg_rating = rating_data[1];
	}
	
	var max_rating = jQuery('#rating').attr('max');
	if (max_rating) {
		max_rating = parseInt(max_rating);
	} else {
		max_rating = 5;
	}
	
	jQuery('#rating').rating('/media/addVote/'+media_id+'/', 
	                         {maxvalue:max_rating, curvalue:avg_rating, callback:updateVoteDisplay});
	
	var has_user_rating = jQuery('#ratings').attr("rel");
	if (has_user_rating) {
		jQuery('#ratings').hover(
			function() { toggleShowVote(true); },
			function() { toggleShowVote(false); }
		);
	}
});
/** END jquery-rating.js */

/** BEGIN jquery.dimensions.js */
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate$
 * $Rev$
 *
 * Version: @VERSION
 *
 * Requires: jQuery 1.2+
 */

(function($){
	
$.dimensions = {
	version: '@VERSION'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){
	
	// innerHeight and innerWidth
	$.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		return this.css('display') != 'none' ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};
	
	// outerHeight and outerWidth
	$.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		options = $.extend({ margin: false }, options || {});
		
		var val = this.css('display') != 'none' ? 
				this[0]['offset' + name] : 
				num( this, name.toLowerCase() )
					+ num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
					+ num(this, 'padding' + torl) + num(this, 'padding' + borr);
		
		return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
	};
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
	$.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;
		
		return val != undefined ?
		
			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo( 
						name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : $(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :
			
			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
					$.boxModel && document.documentElement[ 'scroll' + name ] ||
					document.body[ 'scroll' + name ] :
				this[0][ 'scroll' + name ];
	};
});

$.fn.extend({
	position: function() {
		var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
		
		if (elem) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();
			
			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();
			
			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');
			
			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');
			
			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}
		
		return results;
	},
	
	offsetParent: function() {
		var offsetParent = this[0].offsetParent;
		while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return $(offsetParent);
	}
});

function num(el, prop) {
	return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);/** END jquery.dimensions.js */

/** BEGIN jquery.hoverintent.js */
/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
*	interval: 50,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 100,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @return    The object (aka "this") that called hoverIntent, and the event object
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);
/** END jquery.hoverintent.js */

/** BEGIN jquery.cookie.js */
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};/** END jquery.cookie.js */

/** BEGIN rte/jquery.rte.js */
/*
 * jQuery RTE plugin 0.2 - create a rich text form for Mozilla, Opera, and Internet Explorer
 *
 * Copyright (c) 2007 Batiste Bieler
 * Distributed under the GPL (GPL-LICENSE.txt) licenses.
 */

// Map over the $ in case of overwrite
if ( typeof $ != "undefined" )
    var _$ = $;

// Map the jQuery namespace to the '$' one
window.$ = jQuery;

// define the rte light plugin
jQuery.fn.rte = function(css_url) {

    if(document.designMode || document.contentEditable)
    {
        $(this).each( function(){
            var textarea = $(this);
            enableDesignMode(textarea);
        });
    }
    
    function formatText(iframe, command, option) {
        iframe.contentWindow.focus();
        try{
            iframe.contentWindow.document.execCommand(command, false, option);
        }catch(e){console.log(e)}
        iframe.contentWindow.focus();
    }
    
    function tryEnableDesignMode(iframe, doc, callback) {
        try {
            iframe.contentWindow.document.open();
            iframe.contentWindow.document.write(doc);
            iframe.contentWindow.document.close();
        } catch(error) {
            console.log(error)
        }
        if (document.contentEditable) {
            iframe.contentWindow.document.designMode = "On";
            callback();
            return true;
        }
        else if (document.designMode != null) {
            try {
                iframe.contentWindow.document.designMode = "on";
                callback();
                return true;
            } catch (error) {
                console.log(error)
            }
        }
        setTimeout(function(){tryEnableDesignMode(iframe, doc, callback)}, 250);
        return false;
    }
    
    function enableDesignMode(textarea) {
        // need to be created this way
        var iframe = document.createElement("iframe");
        iframe.frameBorder=0;
        iframe.frameMargin=0;
        iframe.framePadding=0;
        if(textarea.attr('class'))
            iframe.className = textarea.attr('class');
        if(textarea.attr('id'))
            iframe.id = textarea.attr('id');
        if(textarea.attr('name'))
            iframe.title = textarea.attr('name');
		if(textarea.attr('name'))
			iframe.name = textarea.attr('name');
        textarea.after(iframe);
        var css = "";
        if(css_url)
            var css = "<link type='text/css' rel='stylesheet' href='"+css_url+"' />"
        var content = textarea.val();
        // Mozilla need this to display caret
        if($.trim(content)=='')
            content = '<br>';
        var doc = "<html><head>"+css+"</head><body class='frameBody'>"+content+"</body></html>";
        tryEnableDesignMode(iframe, doc, function() {
            $(iframe).before(toolbar(iframe));
            textarea.remove();
        });
    }
    
    function disableDesignMode(iframe, submit) {
        var content = iframe.contentWindow.document.getElementsByTagName("body")[0].innerHTML;
        if(submit==true)
            var textarea = $('<input type="hidden" />');
        else
            var textarea = $('<textarea></textarea>');
        textarea.val(content);
        t = textarea.get(0);
        if(iframe.className)
            t.className = iframe.className;
        if(iframe.id)
            t.id = iframe.id;
        if(iframe.title)
            t.name = iframe.title;
        $(iframe).before(textarea);
        if(submit!=true)
            $(iframe).remove();
    }
    
    function toolbar(iframe) {
        var tb = $("<div class='rte-toolbar'><div>\
            <p>\
                <select>\
                    <option value=''>Bloc style</option>\
                    <option value='p'>Paragraph</option>\
                    <option value='h3'>Title</option>\
                </select>\
            </p>\
            <p>\
                <a href='#' class='bold'><img src='/js/rte/bold.gif' alt='bold' title='bold' /></a>\
                <a href='#' class='italic'><img src='/js/rte/italic.gif' alt='italic' title='italic' /></a>\
            </p>\
            <p>\
                <a href='#' class='unorderedlist'><img src='/js/rte/unordered.gif' alt='unordered list' title='unordered list' /></a>\
                <!--<a href='#' class='link'><img src='/js/rte/link.jpg' alt='link' /></a>-->\
                <!--<a href='#' class='image'><img src='/js/rte/image.jpg' alt='image' /></a>-->\
                <!--<a href='#' class='disable'><img src='/js/rte/close.gif' alt='close rte' /></a>-->\
            </p></div></div>");
        $('select', tb).change(function(){
            var index = this.selectedIndex;
            if( index!=0 ) {
                var selected = this.options[index].value;
                formatText(iframe, "formatblock", '<'+selected+'>');
            }
        });
        $('.bold', tb).click(function(){ formatText(iframe, 'bold');return false; });
        $('.italic', tb).click(function(){ formatText(iframe, 'italic');return false; });
        $('.unorderedlist', tb).click(function(){ formatText(iframe, 'insertunorderedlist');return false; });
        $('.link', tb).click(function(){ 
            var p=prompt("URL:");
            if(p)
                formatText(iframe, 'CreateLink', p);
            return false; });
        $('.image', tb).click(function(){ 
            var p=prompt("image URL:");
            if(p)
                formatText(iframe, 'InsertImage', p);
            return false; });
        $('.disable', tb).click(function(){ disableDesignMode(iframe); tb.remove(); return false; });
        $(iframe).parents('form').submit(function(){ 
            disableDesignMode(iframe, true); });
        var iframeDoc = $(iframe.contentWindow.document);
        
        var select = $('select', tb)[0];
        iframeDoc.mouseup(function(){ setSelectedType(getSelectionElement(iframe), select);return true;});
        iframeDoc.keyup(function(){ setSelectedType(getSelectionElement(iframe), select);return true;});
        
        return tb;
    }
        
    function setSelectedType(node, select) {
        while(node.parentNode) {
            var nName = node.nodeName.toLowerCase();
            for(var i=0;i<select.options.length;i++) {
                if(nName==select.options[i].value){
                    select.selectedIndex=i;
                    return true;
                }
            }
            node = node.parentNode;
        }
        select.selectedIndex=0;
        return true;
    }
    
    function getSelectionElement(iframe) {
        if (iframe.contentWindow.document.selection) {
            // IE selections
            selection = iframe.contentWindow.document.selection;
            range = selection.createRange();
            try {
                node = range.parentElement();
            }
            catch (e) {
                return false;
            }
        } else {
            // Mozilla selections
            try {
                selection = iframe.contentWindow.getSelection();
                range = selection.getRangeAt(0);
            }
            catch(e){
                return false;
            }
            node = range.commonAncestorContainer;
        }
        return node;
    }
}
/** END rte/jquery.rte.js */

/** BEGIN swfobject.js */
/*	SWFObject v2.0 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
/** END swfobject.js */

/** BEGIN module.js */
function confirm_join(tid) {
	var ln = jQuery("#joinLinkDiv").html();
	jQuery("#joinLinkDiv").html('');
	var join = confirm("Do you really want to join this tournament?");
	if(!join){
		jQuery("#joinLinkDiv").html(ln);
		jQuery("joinLink").click(function() {
			confirm_join(tid);
		});
		return false;
	}
	if(join){
		var url = '/tournaments/join/' + tid;
		parent.location = url;
	}
	return false;
}
function playasguest(tid) {
	jQuery.facebox(function() {
		jQuery.get('/tournaments/playasguest/' + tid, function(data) {
			jQuery.facebox(data);
		});
	});
}
function getGameDetails(id){
	var url="/tournaments/getGameDetails/" + id + "/ajax=1/";
	jQuery('#gameDetails').load(url);
}

function pageSponsored(url, page) {
	jQuery('#ajaxLoader').html('<img src="http://media.ebaumsworld.com/img/ajax-loader2.gif" />');
	jQuery("#sponsoredTable").load(url+'/page='+page+'/ajax=1/');
	/*jQuery('#ajaxLoader').html('');*/
}
function confirm_delete(tid) {
    var resp = confirm("Do you really want to delete this tournament?");
    if(!resp){
        return false;
    }
    if(resp){
        var url = '/tournaments/admin_remove/' + tid;
        window.location = url;
    }
    return false;
}

function updatePlayerInfo(tid) {
    jQuery("#detailLinks").load("/tournaments/updateActions/" + tid + "/ajax");
	jQuery("#queueContainer").load("/tournaments/updateBracketQueue/" + tid + "/ajax");
	setTimeout("updatePlayerInfo(" + tid + ");", 10000);
}
function updateTime() {
    var curr = jQuery('#seconds').text();
    if (curr <= 1) {
        curr = 11;
    }
    jQuery('#seconds').text(curr - 1);
    setTimeout("updateTime()", 1000);
}
function countdown(expire, elid) {
    var current = new Date();
    var now = current.getTime();
    var diff = Math.floor((expire - now) / 1000);
    
    if (diff < 0) {
        jQuery('#' + elid + ' span').html('Expired');
        return true;
    }

    var days = Math.floor(diff / 86400);
    var hours = Math.floor((diff - (days * 86400)) / 3600);
    var minutes = Math.floor((diff - (hours * 3600)) / 60);
    var seconds = Math.floor((diff - ((minutes * 60) + (hours * 3600))));
    
    jQuery('#' + elid + ' span').html(days + 'd ' + hours + ':' + minutes + ':' + seconds);
}/** END module.js */
