/*
	Custom Functions for NuMuBu
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var ROOT_URL="http://www.numubu.com/";
if(Browser.Features.xhr === false)
{
	alert('Your browser does not support AJAX. AJAX is a required technology that all modern websites utilize. Please turn on/activate AJAX.');
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	switch between User accounts
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function switchAccount(id)
{
	window.location = 'switchAccounts.php?id='+id;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Live fader
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function livefuncblinker(act){
	if(act === true)
	{
		LIVEFXVAR.start('color', '#fff', '#FFA500').chain(function(){
			LIVEFXVAR.start('color', '#FFA500', '#fff').chain(function(){
				livefuncblinker(true);
																					})
																				})
	}
	else
	{
		LIVEFXVAR.cancel();
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
	Class for allowing styling of textareas
*/
var EasyText = new Class({
	Implements: [Options, Events],
	Binds: ['substr_replace', 'init', 'insertBoldItalicUnderlineCenter', 'insertUrl', 'insertImage', 'insertQuote', 'insertFontSize', 'insertEmoticon', 'insertFontColor', 'clearAll'],
	options:
	{
		textareael: null,
		controlpanel: null,
		menubgcolor: '#E9E9E9',
		menuborder: '1px solid #999999'
	},
	boldel: null,
	italicel: null,
	underlineel: null,
	urlel: null,
	sizeel: null,
	colorel: null,
	centerel: null,
	quoteel: null,
	emoticonel: null,
	imgel: null,
	fontMT: null,
	emoticonMT: null,
	fontcolorMT: null,
	initialize: function(options)
	{
		this.setOptions(options);
		this.init();
	},
	substr_replace: function(str, replacestr, start, length)
	{
		if(start < 0)
		{
			start = start + str.length;
		}
		
		length = length !== undefined ? length : str.length;
		
		if(length < 0)
		{
			length = length + str.length - start;
		}
		
		return str.slice(0, start)+replacestr.substr(0, length)+replacestr.slice(length)+str.slice(start+length);
	},
	init: function()
	{
		this.boldel = this.options.controlpanel.getElement('a[href*=bold]');
		this.italicel = this.options.controlpanel.getElement('a[href*=italic]');
		this.underlineel = this.options.controlpanel.getElement('a[href*=underline]');
		this.urlel = this.options.controlpanel.getElement('a[href*=addurl]');
		this.sizeel = this.options.controlpanel.getElement('a[href*=fontsize]');
		this.colorel = this.options.controlpanel.getElement('a[href*=fontcolor]');;
		this.centerel = this.options.controlpanel.getElement('a[href*=center]');
		this.quoteel = this.options.controlpanel.getElement('a[href*=quote]');
		this.emoticonel = this.options.controlpanel.getElement('a[href*=emoticon]');;
		this.imgel = this.options.controlpanel.getElement('a[href*=addimage]');
	
		//handle bold
		this.boldel.addEvent('click', function(e){
			e.stop();
			this.insertBoldItalicUnderlineCenter('[b]', '[/b]');
		}.bind(this));
		
		//handle italic
		this.italicel.addEvent('click', function(e){
			e.stop();
			this.insertBoldItalicUnderlineCenter('[i]', '[/i]');
		}.bind(this));
		
		//handle underline
		this.underlineel.addEvent('click', function(e){
			e.stop();
			this.insertBoldItalicUnderlineCenter('[u]', '[/u]');
		}.bind(this));
		
		//handle center
		this.centerel.addEvent('click', function(e){
			e.stop();
			this.insertBoldItalicUnderlineCenter('[center]', '[/center]');
		}.bind(this));
		
		//handle url insert
		this.urlel.addEvent('click', function(e){
			e.stop();
			this.insertUrl();
		}.bind(this));
		
		//handle image insert
		this.imgel.addEvent('click', function(e){
			e.stop();
			this.insertImage();
		}.bind(this));
		
		//handle quotes
		this.quoteel.addEvent('click', function(e){
			e.stop();
			this.insertQuote();
		}.bind(this));
		
		//handle font size
		this.sizeel.addEvent('click', function(e){
			e.stop();
			if(!$('et_fontcontainer'))
			{
				this.clearAll();
				this.sizeel.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.fontMT);
				}.bind(this));
				this.sizeel.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.fontMT);
					this.fontMT = (function(){if($('et_fontcontainer')){$('et_fontcontainer').destroy();}}).delay(1000);
				}.bind(this));
				
				var containerEL = new Element('div', {
					'id': 'et_fontcontainer',
					'styles': {
								'position':'absolute',
								'top':((this.sizeel.getCoordinates().top.toInt())+10)+'px',
								'left':this.sizeel.getCoordinates().left+'px',
								'border':this.options.menuborder,
								'width':'60px',
								'background':this.options.menubgcolor,
								'min-height':'15px',
								'text-align':'center',
								'z-index':'89898989'
							},
					'html':'<div style="font-size:12px"><strong>Text Size</strong></div>'
				}).inject(document.getElement('body'));
				
				new Element('a', {
					'href':'#',
					'class': 'fontsizefixes',
					'html':'<span style="font-size:7pt">7</span>'
				}).inject(containerEL);
				
				new Element('a', {
					'href':'#',
					'class': 'fontsizefixes',
					'html':'<span style="font-size:9pt">9</span>'
				}).inject(containerEL);
				
				new Element('a', {
					'href':'#',
					'class': 'fontsizefixes',
					'html':'<span style="font-size:11pt">11</span>'
				}).inject(containerEL);
				
				new Element('a', {
					'href':'#',
					'class': 'fontsizefixes',
					'html':'<span style="font-size:13pt">13</span>'
				}).inject(containerEL);
				
				new Element('a', {
					'href':'#',
					'class': 'fontsizefixes',
					'html':'<span style="font-size:15pt">15</span>'
				}).inject(containerEL);
				
				//mod all new anchors we injected
				containerEL.getElements('a').each(function(el){ 
					el.setStyles({'color':'#000', 'text-decoration':'none'});
					el.addEvent('mouseenter', function(e){
						el.setStyle('background','#929292');
					}.bind(this));
					el.addEvent('mouseleave', function(){
						el.setStyle('background','transparent');
					}.bind(this));
					
					//the true magic here
					el.addEvent('click', function(e){
						e.stop();
						this.insertFontSize(el.getElement('span').get('html'));
						$clear(this.fontMT);
						if($('et_fontcontainer'))
						{
							$('et_fontcontainer').destroy();
						}
					}.bind(this));
				}.bind(this));
				
				//same here aswell but show them now
				containerEL.getElements('a').each(function(el){ el.setStyle('display','block'); });
				
				//menu events
				containerEL.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.fontMT);
				}.bind(this));
				containerEL.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.fontMT);
					this.fontMT = (function(){if($('et_fontcontainer')){$('et_fontcontainer').destroy();}}).delay(1000);
				}.bind(this));
			}
			else
			{
				$('et_fontcontainer').getElements('').each(function(el){el.removeEvents();});
				$('et_fontcontainer').removeEvents();
				$('et_fontcontainer').destroy();
			}
			
		}.bind(this));
		
		//handle emoticons
		this.emoticonel.addEvent('click', function(e){
			e.stop();
			if(!$('et_emoticoncontainer'))
			{
				this.clearAll();
				this.emoticonel.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.emoticonMT);
				}.bind(this));
				this.emoticonel.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.emoticonMT);
					this.emoticonMT = (function(){if($('et_emoticoncontainer')){$('et_emoticoncontainer').destroy();}}).delay(1000);
				}.bind(this));
				
				var containerEL = new Element('div', {
					'id': 'et_emoticoncontainer',
					'styles': {
								'position':'absolute',
								'top':((this.emoticonel.getCoordinates().top.toInt())+10)+'px',
								'left':this.emoticonel.getCoordinates().left+'px',
								'border':this.options.menuborder,
								'width':'160px',
								'background':this.options.menubgcolor,
								'min-height':'15px',
								'text-align':'center',
								'z-index':'89898989'
							},
					'html':'<div style="font-size:12px"><strong>Emoticons</strong></div>'
				}).inject(document.getElement('body'));
				
				var emotearray = new Array(':)=et_smile.png', ';)=et_wink.png', ':(=et_frown.png', ';(=et_cry.png', ':p=et_tounge.png', ':D=et_grin.png', ':o=et_gasp.png', 'x(=et_upset.png', 'x|=et_grumpy.png', ':s=et_confused.png', ':-/=et_unsure.png', 'o:)=et_angel.png', '>:)=et_devil.png', 'B-)=et_sunglasses.png', '8-)=et_glasses.png', ':-3=et_curlylips.png', '*giggle*=et_hihi.png', '*kiss*=et_kiss.png', '<3=et_heart.png');
				var abovelength = emotearray.length;
				
				//now create the menu icons
				for(x=0;x<abovelength;x++)
				{
					var tempo = emotearray[x].split('=');
					new Element('a', {
						'href':'#',
						'styles': {
							'display':'none',
							'text-align':'center',
							'width':'14px'
						},
						'html':'<img src="'+IMG1_URL+'interface/'+tempo[1]+'" alt="'+tempo[0]+'" width="14"  height="14" style="border:none;margin:3px;position:relative;top:5px">'
					}).inject(containerEL);
				}
				
				//mod all new anchors we injected
				containerEL.getElements('a').each(function(el){ 
					el.setStyle('text-decoration','none');
					el.addEvent('mouseenter', function(e){
						el.setStyle('background','#929292');
					}.bind(this));
					el.addEvent('mouseleave', function(){
						el.setStyle('background','transparent');
					}.bind(this));
					
					//the true magic here
					el.addEvent('click', function(e){
						e.stop();
						this.insertEmoticon(el.getElement('img').getProperty('alt'));
						$clear(this.emoticonMT);
						if($('et_emoticoncontainer'))
						{
							$('et_emoticoncontainer').destroy();
						}
					}.bind(this));
				}.bind(this));
				
				//same here aswell but show them now
				containerEL.getElements('a').each(function(el){ el.setStyle('display','inline'); });
				
				//menu events
				containerEL.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.emoticonMT);
				}.bind(this));
				containerEL.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.emoticonMT);
					this.emoticonMT = (function(){if($('et_emoticoncontainer')){$('et_emoticoncontainer').destroy();}}).delay(1000);
				}.bind(this));
			}
			else
			{
				$('et_emoticoncontainer').getElements('').each(function(el){el.removeEvents();});
				$('et_emoticoncontainer').removeEvents();
				$('et_emoticoncontainer').destroy();
			}
		}.bind(this));
		
		//handle font color
		this.colorel.addEvent('click', function(e){
			e.stop();
			if(!$('et_fontcolorcontainer'))
			{
				this.clearAll();
				this.colorel.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.fontcolorMT);
				}.bind(this));
				this.colorel.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.fontcolorMT);
					this.fontcolorMT = (function(){if($('et_fontcolorcontainer')){$('et_fontcolorcontainer').destroy();}}).delay(1000);
				}.bind(this));
				
				var containerEL = new Element('div', {
					'id': 'et_fontcolorcontainer',
					'styles': {
								'position':'absolute',
								'top':((this.colorel.getCoordinates().top.toInt())+10)+'px',
								'left':this.colorel.getCoordinates().left+'px',
								'border':this.options.menuborder,
								'width':'160px',
								'background':this.options.menubgcolor,
								'min-height':'15px',
								'text-align':'center',
								'z-index':'89898989'
							},
					'html':'<div style="font-size:12px" id="et_fontcolorcontainertitleonlyhere"><strong>Text Color Picker</strong></div><div style="clear:both"><!-- --></div>'
				}).inject(document.getElement('body'));
				
				var colorarray = new Array(
									'ffffff', 'dcdcdc', 'bcbcbc', '939393', '6c6c6c', '474747', '232323', '000000',
									'ff7d7d', 'ff0000', 'df0000', 'bd0000', '9c0000', '760000', '500000', '360000',
									'ffd37d', 'ffa800', 'e29500', 'c78300', 'aa7000', '8d5d00', '6e4800', '4c3200', 
									'bd7dff', '7e00ff', '6d00dd', '5800b3', '4a0096', '3c0079', '300061', '210044', 
									'7d9fff', '0043ff', '0039d8', '0030b8', '00299d', '002385', '001961', '001140', 
									'7dffdc', '00ffba', '00e6a8', '00c892', '00a377', '00815e', '005e45', '00412f',
									'7dff86', '00ff12', '00df0f', '00c60e', '00a40b', '008609', '006707', '004a05',
									'd3ff7d', 'a9ff00', '97e400', '85c900', '72ad00', '5b8900', '446700', '2f4700',
									'fff77d', 'fff000', 'ddd000', 'bbb000', 'a09700', '7d7600', '645e00', '474300'
										);
				var abovelength = colorarray.length;
				
				//now create the menu icons
				for(x=0;x<abovelength;x++)
				{
					new Element('div', {
						'id':colorarray[x],
						'styles': {
							'display':'none',
							'float':'left',
							'width':'14px',
							'height':'14px',
							'min-width':'14px',
							'min-height':'14px',
							'margin':'1px 2px',
							'cursor':'pointer',
							'border':'1px solid '+this.options.menubgcolor,
							'background':'#'+colorarray[x]
						},

						'html':' <!-- --> '
					}).inject(containerEL);
				}
				
				//mod all new anchors we injected
				containerEL.getElements('div[id!=et_fontcolorcontainertitleonlyhere]').each(function(el){ 
					el.setStyle('text-decoration','none');
					el.addEvent('mouseenter', function(e){
						el.setStyle('border','1px solid #000');
					}.bind(this));
					el.addEvent('mouseleave', function(){
						el.setStyle('border','1px solid '+this.options.menubgcolor);
					}.bind(this));
					
					//the true magic here
					el.addEvent('click', function(e){
						e.stop();
						this.insertFontColor(el.getProperty('id'));
						$clear(this.fontcolorMT);
						if($('et_fontcolorcontainer'))
						{
							$('et_fontcolorcontainer').destroy();
						}
					}.bind(this));
				}.bind(this));
				
				//same here aswell but show them now
				containerEL.getElements('div').each(function(el){ el.setStyle('display','block'); });
				
				//menu events
				containerEL.addEvent('mouseenter', function(e){
					e.stop();
					$clear(this.fontcolorMT);
				}.bind(this));
				containerEL.addEvent('mouseleave', function(e){
					e.stop();
					$clear(this.fontcolorMT);
					this.fontcolorMT = (function(){if($('et_fontcolorcontainer')){$('et_fontcolorcontainer').destroy();}}).delay(1000);
				}.bind(this));
			}
			else
			{
				$('et_fontcolorcontainer').getElements('').each(function(el){el.removeEvents();});
				$('et_fontcolorcontainer').removeEvents();
				$('et_fontcolorcontainer').destroy();
			}
		}.bind(this));
	},
	clearAll: function()
	{
		//clear emoticon menu
		$clear(this.emoticonMT);
		if($('et_emoticoncontainer'))
		{
			$('et_emoticoncontainer').getElements('').each(function(el){el.removeEvents();});
			$('et_emoticoncontainer').removeEvents();
			$('et_emoticoncontainer').destroy();
		}
		
		//clear font size
		$clear(this.fontMT);
		if($('et_fontcontainer'))
		{
			$('et_fontcontainer').getElements('').each(function(el){el.removeEvents();});
			$('et_fontcontainer').removeEvents();
			$('et_fontcontainer').destroy();
		}
		
		//clear font color
		$clear(this.fontcolorMT);
		if($('et_fontcolorcontainer'))
		{
			$('et_fontcolorcontainer').getElements('').each(function(el){el.removeEvents();});
			$('et_fontcolorcontainer').removeEvents();
			$('et_fontcolorcontainer').destroy();
		}
	},
	insertBoldItalicUnderlineCenter: function(start, end)
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection
		
		var newselection = start+selection+end; //make the new version with the styling
	
		var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
	
		this.options.textareael.setProperty('value', newtav); //set the textareas new value
		
		this.options.textareael.focus(); //focus on the textarea
		
		if(selection.length > 0)
		{
			var plcecursor = tass+newselection.length;
		}
		else
		{
			var plcecursor = tass+start.length;
		}
		
		if(this.options.textareael.setSelectionRange)
		{
			this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
		}
		else
		{
			var range = this.options.textareael.createTextRange();
			range.collapse(true);
			range.moveEnd('character', plcecursor);
			range.moveStart('character', plcecursor);
			range.select();
		}
		
		this.options.textareael.fireEvent('keypress'); //to update remaining characters
	},
	insertUrl: function()
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection
		
		var promptresponse = '';
		var newselection = '';
		
		if(selection.substr(0,7) === 'http://' || selection.substr(0,8) === 'https://' || selection.substr(0,6) === 'ftp://' || selection.substr(0,3) === 'www')
		{
			promptresponse = prompt('Please enter the full URL:', selection); //show prompt
			if(promptresponse !== null)
			{
				if(promptresponse.substr(0,7) !== 'http://' && promptresponse.substr(0,8) !== 'https://' && promptresponse.substr(0,6) !== 'ftp://')
				{
					//if not a proper url, mfix it
					promptresponse = 'http://'+promptresponse;
				}
				newselection = '[url='+promptresponse+']'+promptresponse+'[/url]'; //make the new version with the styling
			}
		}
		else
		{
			promptresponse = prompt('Please enter the full URL:', 'http://'); //show prompt
			if(promptresponse !== null)
			{
				if(promptresponse.substr(0,7) !== 'http://' && promptresponse.substr(0,8) !== 'https://' && promptresponse.substr(0,6) !== 'ftp://')
				{
					//if not a proper url, mfix it
					promptresponse = 'http://'+promptresponse;
				}
				
				if(selection.length > 0)
				{
					newselection = '[url='+promptresponse+']'+selection+'[/url]'; //make the new version with the styling
				}
				else
				{
					newselection = '[url='+promptresponse+']'+promptresponse+'[/url]'; //make the new version with the styling
				}
			}
		}
		
		if(promptresponse !== null)
		{
			var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
		
			this.options.textareael.setProperty('value', newtav); //set the textareas new value
			
			this.options.textareael.focus(); //focus on the textarea
			
			var plcecursor = tass+newselection.length;
			
			if(this.options.textareael.setSelectionRange)
			{
				this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
			}
			else
			{
				var range = this.options.textareael.createTextRange();
				range.collapse(true);
				range.moveEnd('character', plcecursor);
				range.moveStart('character', plcecursor);
				range.select();
			}
			
			this.options.textareael.fireEvent('keypress'); //to update remaining characters
		}
	},
	insertImage: function()
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection
		
		var promptresponse = '';
		var newselection = '';
		
		if(selection.substr(0,7) === 'http://' || selection.substr(0,8) === 'https://' || selection.substr(0,6) === 'ftp://' || selection.substr(0,3) === 'www')
		{
			promptresponse = prompt('Please enter the full URL to your image:', selection); //show prompt
			if(promptresponse !== null)
			{
				if(promptresponse.substr(0,7) !== 'http://' && promptresponse.substr(0,8) !== 'https://' && promptresponse.substr(0,6) !== 'ftp://')
				{
					//if not a proper url, mfix it
					promptresponse = 'http://'+promptresponse;
				}
				newselection = '[img]'+promptresponse+'[/img]'; //make the new version with the styling
			}
		}
		else
		{
			promptresponse = prompt('Please enter the full URL to your image:', 'http://'); //show prompt
			if(promptresponse !== null)
			{
				if(promptresponse.substr(0,7) !== 'http://' && promptresponse.substr(0,8) !== 'https://' && promptresponse.substr(0,6) !== 'ftp://')
				{
					//if not a proper url, mfix it
					promptresponse = 'http://'+promptresponse;
				}
				newselection = '[img]'+promptresponse+'[/img]'; //make the new version with the styling
			}
		}
		
		if(promptresponse !== null)
		{
			var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
		
			this.options.textareael.setProperty('value', newtav); //set the textareas new value
			
			this.options.textareael.focus(); //focus on the textarea
			
			if(promptresponse.length > 0)
			{
				var plcecursor = tass+newselection.length;
			}
			else
			{
				var plcecursor = tass+5;
			}
			
			if(this.options.textareael.setSelectionRange)
			{
				this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
			}
			else
			{
				var range = this.options.textareael.createTextRange();
				range.collapse(true);
				range.moveEnd('character', plcecursor);
				range.moveStart('character', plcecursor);
				range.select();
			}
			
			this.options.textareael.fireEvent('keypress'); //to update remaining characters
		}
	},
	insertQuote: function()
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection
		
		var promptresponse = '';
		var newselection = '';
		
		if(selection.length > 1)
		{
			promptresponse = prompt('Who are you quoting?', selection); //show prompt
			if(promptresponse !== null)
			{
				newselection = '[quote='+promptresponse+']'+selection+'[/quote]'; //make the new version with the styling
			}
		}
		else
		{
			promptresponse = prompt('Who are you quoting?', ''); //show prompt
			if(promptresponse !== null)
			{
				newselection = '[quote='+promptresponse+'][/quote]'; //make the new version with the styling
			}
		}
		
		if(promptresponse !== null)
		{
			var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
		
			this.options.textareael.setProperty('value', newtav); //set the textareas new value
			
			this.options.textareael.focus(); //focus on the textarea
			
			if(selection.length > 0)
			{
				var plcecursor = tass+newselection.length;
			}
			else
			{
				var plcecursor = tass+promptresponse.length+8;
			}
			
			if(this.options.textareael.setSelectionRange)
			{
				this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
			}
			else
			{
				var range = this.options.textareael.createTextRange();
				range.collapse(true);
				range.moveEnd('character', plcecursor);
				range.moveStart('character', plcecursor);
				range.select();
			}
			
			this.options.textareael.fireEvent('keypress'); //to update remaining characters
		}
	},
	insertFontSize: function(size)
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection
		
		var newselection = '[size='+size+']'+selection+'[/size]'; //make the new version with the styling
		
		var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
	
		this.options.textareael.setProperty('value', newtav); //set the textareas new value
		
		this.options.textareael.focus(); //focus on the textarea
		
		if(selection.length > 0)
		{
			var plcecursor = tass+newselection.length;
		}
		else
		{
			var plcecursor = tass+size.length+7;
		}
		
		if(this.options.textareael.setSelectionRange)
		{
			this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
		}
		else
		{
			var range = this.options.textareael.createTextRange();
			range.collapse(true);
			range.moveEnd('character', plcecursor);
			range.moveStart('character', plcecursor);
			range.select();
		}
		
		this.options.textareael.fireEvent('keypress'); //to update remaining characters
	},
	insertEmoticon: function(emote)
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		
		//var selection = tav.substring(tass, tase); //get the actual selection
		
		var newselection = emote; //make the new version with the styling
		
		var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, 0); //phjs code 
	
		this.options.textareael.setProperty('value', newtav); //set the textareas new value
		
		this.options.textareael.focus(); //focus on the textarea
		
		var plcecursor = tass+emote.length;
		
		if(this.options.textareael.setSelectionRange)
		{
			this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
		}
		else
		{
			var range = this.options.textareael.createTextRange();
			range.collapse(true);
			range.moveEnd('character', plcecursor);
			range.moveStart('character', plcecursor);
			range.select();
		}
		
		this.options.textareael.fireEvent('keypress'); //to update remaining characters
	},
	insertFontColor: function(colorcode)
	{
		var tav = this.options.textareael.getProperty('value'); //textarea value
		if(document.selection)
		{
			var bm = document.selection.createRange().getBookmark();
			var sel = this.options.textareael.createTextRange();
			sel.moveToBookmark(bm);

			var sleft = this.options.textareael.createTextRange();
			sleft.collapse(true);
			sleft.setEndPoint("EndToStart", sel);
			var tass = sleft.text.length
			var tase = sleft.text.length + sel.text.length;
		}
		else
		{
			var tass = this.options.textareael.selectionStart; //selection start
			var tase = this.options.textareael.selectionEnd; //selection end
		}
		var selection = tav.substring(tass, tase); //get the actual selection

		var newselection = '';
		
		if(selection.length > 1)
		{
			newselection = '[color='+colorcode+']'+selection+'[/color]'; //make the new version with the styling
		}
		else
		{
			newselection = '[color='+colorcode+'][/color]'; //make the new version with the styling
		}

		var newtav = this.substr_replace(this.options.textareael.getProperty('value'), newselection, tass, selection.length); //phjs code 
	
		this.options.textareael.setProperty('value', newtav); //set the textareas new value
		
		this.options.textareael.focus(); //focus on the textarea
		
		if(selection.length > 0)
		{
			var plcecursor = tass+newselection.length;
		}
		else
		{
			var plcecursor = tass+colorcode.length+8;
		}
		
		if(this.options.textareael.setSelectionRange)
		{
			this.options.textareael.setSelectionRange(plcecursor, plcecursor); //the length of the first style tag
		}
		else
		{
			var range = this.options.textareael.createTextRange();
			range.collapse(true);
			range.moveEnd('character', plcecursor);
			range.moveStart('character', plcecursor);
			range.select();
		}
		
		this.options.textareael.fireEvent('keypress'); //to update remaining characters

	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	change state function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function changeState2(){
	if($('country').value == "CA"){
		if($('stateprovince').type == "select-one")
		{
			$('stateprovince').set('html','<option value="">All</option><option value="AB">Alberta</option><option value="BC">British Columbia</option><option value="MB">Manitoba</option><option value="NB">New Brunswick</option><option value="NL">Newfoundland</option><option value="NT">Northwest Territories</option><option value="NS">Nova Scotia</option><option value="NU">Nunavut</option><option value="ON">Ontario</option><option value="PE">Prince Edward Island</option><option value="QC">Quebec</option><option value="SK">Saskatchewan</option><option value="YT">Yukon</option>');
		}
		else
		{
			$('stateinput').set('html', '');
			new Element('select', {'id':'stateprovince', 'class':'stateprovince', 'name':'stateprovince'}).inject('stateinput');
			$('stateprovince').set('html','<option value="">All</option><option value="AB">Alberta</option><option value="BC">British Columbia</option><option value="MB">Manitoba</option><option value="NB">New Brunswick</option><option value="NL">Newfoundland</option><option value="NT">Northwest Territories</option><option value="NS">Nova Scotia</option><option value="NU">Nunavut</option><option value="ON">Ontario</option><option value="PE">Prince Edward Island</option><option value="QC">Quebec</option><option value="SK">Saskatchewan</option><option value="YT">Yukon</option>');
		}
	}
	else{
		if($('country').value == "US"){
			if($('stateprovince').type == "select-one")
			{
				$('stateprovince').set('html','<option value="">All</option><option value="AL">Alabama</option><option value="AK">Alaska</option><option value="AS">American Samoa</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="DC">District of Columbia</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="GU">Guam</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MH">Marshall Islands</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="MP">Northern Mariana Islands</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PW">Palau</option><option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VI">Virgin Islands</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option><option value="AA">Armed Forces Americas</option><option value="AE">Armed Forces</option><option value="AP">Armed Forces Pacific</option>');
			}
			else
			{
				$('stateinput').set('html', '');
				new Element('select', {'id':'stateprovince', 'class':'stateprovince', 'name':'stateprovince'}).inject('stateinput');
				$('stateprovince').set('html','<option value="">All</option><option value="AL">Alabama</option><option value="AK">Alaska</option><option value="AS">American Samoa</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="DC">District of Columbia</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="GU">Guam</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MH">Marshall Islands</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="MP">Northern Mariana Islands</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PW">Palau</option><option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VI">Virgin Islands</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option><option value="AA">Armed Forces Americas</option><option value="AE">Armed Forces</option><option value="AP">Armed Forces Pacific</option>');
			}
		}
		else{
			if(newFormCheck != null){newFormCheck.dispose($('stateprovince'));}
			$('stateinput').set("html", "<input type=\"text\" id=\"stateprovince\" name=\"stateprovince\" value=\"\"/>");
			
		}
	}
	
}

function changeState(){
	if($('country').value == "CA"){
		$('stateinput').set("html", "<select name=\"stateprovince\" onchange=\"updateNumberPoeple();\" id=\"stateprovince\" class=\"validate['required']\" ><option value=\"\">All</option><option value=\"AB\">Alberta</option><option value=\"BC\">British Columbia</option><option value=\"MB\">Manitoba</option><option value=\"NB\">New Brunswick</option><option value=\"NL\">Newfoundland</option><option value=\"NT\">Northwest Territories</option><option value=\"NS\">Nova Scotia</option><option value=\"NU\">Nunavut</option><option value=\"ON\">Ontario</option><option value=\"PE\">Prince Edward Island</option><option value=\"QC\">Quebec</option><option value=\"SK\">Saskatchewan</option><option value=\"YT\">Yukon</option></select>");
		if($('sufnmi')){
			if(newFormCheck != null){ newFormCheck.register($('stateprovince'));}
		}
	}
	else{
		if($('country').value == "US"){
			$('stateinput').set("html", "<select name=\"stateprovince\" onchange=\"updateNumberPoeple();\" id=\"stateprovince\" class=\"validate['required']\" ><option value=\"\">All</option><option value=\"AL\">Alabama</option><option value=\"AK\">Alaska</option><option value=\"AS\">American Samoa</option><option value=\"AZ\">Arizona</option><option value=\"AR\">Arkansas</option><option value=\"CA\">California</option><option value=\"CO\">Colorado</option><option value=\"CT\">Connecticut</option><option value=\"DE\">Delaware</option><option value=\"DC\">District of Columbia</option><option value=\"FL\">Florida</option><option value=\"GA\">Georgia</option><option value=\"GU\">Guam</option><option value=\"HI\">Hawaii</option><option value=\"ID\">Idaho</option><option value=\"IL\">Illinois</option><option value=\"IN\">Indiana</option><option value=\"IA\">Iowa</option><option value=\"KS\">Kansas</option><option value=\"KY\">Kentucky</option><option value=\"LA\">Louisiana</option><option value=\"ME\">Maine</option><option value=\"MH\">Marshall Islands</option><option value=\"MD\">Maryland</option><option value=\"MA\">Massachusetts</option><option value=\"MI\">Michigan</option><option value=\"MN\">Minnesota</option><option value=\"MS\">Mississippi</option><option value=\"MO\">Missouri</option><option value=\"MT\">Montana</option><option value=\"NE\">Nebraska</option><option value=\"NV\">Nevada</option><option value=\"NH\">New Hampshire</option><option value=\"NJ\">New Jersey</option><option value=\"NM\">New Mexico</option><option value=\"NY\">New York</option><option value=\"NC\">North Carolina</option><option value=\"ND\">North Dakota</option><option value=\"MP\">Northern Mariana Islands</option><option value=\"OH\">Ohio</option><option value=\"OK\">Oklahoma</option><option value=\"OR\">Oregon</option><option value=\"PW\">Palau</option><option value=\"PA\">Pennsylvania</option><option value=\"PR\">Puerto Rico</option><option value=\"RI\">Rhode Island</option><option value=\"SC\">South Carolina</option><option value=\"SD\">South Dakota</option><option value=\"TN\">Tennessee</option><option value=\"TX\">Texas</option><option value=\"UT\">Utah</option><option value=\"VT\">Vermont</option><option value=\"VI\">Virgin Islands</option><option value=\"VA\">Virginia</option><option value=\"WA\">Washington</option><option value=\"WV\">West Virginia</option><option value=\"WI\">Wisconsin</option><option value=\"WY\">Wyoming</option><option value=\"AA\">Armed Forces Americas</option><option value=\"AE\">Armed Forces</option><option value=\"AP\">Armed Forces Pacific</option></select>");
			if($('sufnmi')){
				 if(newFormCheck != null){newFormCheck.register($('stateprovince'));}
			}
		}
		else{
			$('stateinput').set("html", "<input type=\"text\" onchange=\"updateNumberPoeple();\" id=\"stateprovince\" name=\"stateprovince\" value=\"\"/>");
			if(newFormCheck != null){newFormCheck.dispose($('stateprovince'));}
		}
	}
	
}
function changeState1(){
	if($('billingCountry').value == "CA"){
		$('stateinput1').set("html", "<select name=\"billingState\" id=\"billingState\" ><option value=\"AB\">Alberta</option><option value=\"BC\">British Columbia</option><option value=\"MB\">Manitoba</option><option value=\"NB\">New Brunswick</option><option value=\"NL\">Newfoundland and Labrador</option><option value=\"NT\">Northwest Territories</option><option value=\"NS\">Nova Scotia</option><option value=\"NU\">Nunavut</option><option value=\"ON\">Ontario</option><option value=\"PE\">Prince Edward Island</option><option value=\"QC\">Quebec</option><option value=\"SK\">Saskatchewan</option><option value=\"YT\">Yukon</option></select>");
	}
	else{
		if($('billingCountry').value == "US"){
			$('stateinput1').set("html", "<select name=\"billingState\" id=\"billingState\" ><option value=\"AL\">Alabama</option><option value=\"AK\">Alaska</option><option value=\"AS\">American Samoa</option><option value=\"AZ\">Arizona</option><option value=\"AR\">Arkansas</option><option value=\"CA\">California</option><option value=\"CO\">Colorado</option><option value=\"CT\">Connecticut</option><option value=\"DE\">Delaware</option><option value=\"DC\">District of Columbia</option><option value=\"FM\">Federated States of Micronesia</option><option value=\"FL\">Florida</option><option value=\"GA\">Georgia</option><option value=\"GU\">Guam</option><option value=\"HI\">Hawaii</option><option value=\"ID\">Idaho</option><option value=\"IL\">Illinois</option><option value=\"IN\">Indiana</option><option value=\"IA\">Iowa</option><option value=\"KS\">Kansas</option><option value=\"KY\">Kentucky</option><option value=\"LA\">Louisiana</option><option value=\"ME\">Maine</option><option value=\"MH\">Marshall Islands</option><option value=\"MD\">Maryland</option><option value=\"MA\">Massachusetts</option><option value=\"MI\">Michigan</option><option value=\"MN\">Minnesota</option><option value=\"MS\">Mississippi</option><option value=\"MO\">Missouri</option><option value=\"MT\">Montana</option><option value=\"NE\">Nebraska</option><option value=\"NV\">Nevada</option><option value=\"NH\">New Hampshire</option><option value=\"NJ\">New Jersey</option><option value=\"NM\">New Mexico</option><option value=\"NY\">New York</option><option value=\"NC\">North Carolina</option><option value=\"ND\">North Dakota</option><option value=\"MP\">Northern Mariana Islands</option><option value=\"OH\">Ohio</option><option value=\"OK\">Oklahoma</option><option value=\"OR\">Oregon</option><option value=\"PW\">Palau</option><option value=\"PA\">Pennsylvania</option><option value=\"PR\">Puerto Rico</option><option value=\"RI\">Rhode Island</option><option value=\"SC\">South Carolina</option><option value=\"SD\">South Dakota</option><option value=\"TN\">Tennessee</option><option value=\"TX\">Texas</option><option value=\"UT\">Utah</option><option value=\"VT\">Vermont</option><option value=\"VI\">Virgin Islands</option><option value=\"VA\">Virginia</option><option value=\"WA\">Washington</option><option value=\"WV\">West Virginia</option><option value=\"WI\">Wisconsin</option><option value=\"WY\">Wyoming</option><option value=\"AA\">Armed Forces Americas</option><option value=\"AE\">Armed Forces</option><option value=\"AP\">Armed Forces Pacific</option></select>");
		}
		else{
			$('stateinput1').set("html", "<input type=\"text\" id=\"billingState\" name=\"billingState\" value=\"\"/>");
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Share User Pop-up
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function shareThisUser(id,type,name)
{
	if($('sTUDiv')===null)
	{
		var newDiv = new Element('div', {'id':'sTUDiv','html':'<img src="assets/loading.gif"/>'}).inject(document.body);
		new Request.HTML({
			evalScripts: true,
			evalResponse: true,
			noCache: false,
			method: 'post',
			url:'sharethisuser.php', 
			onSuccess: function(a, b, html) { 
				newDiv.set('html', html);
			}
		}).send('id='+id+'&type='+type+'&name='+name);
	}
	new Fx.Scroll(window).toElement('sTUDiv');
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Signup Form Check Account Type function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function checkAccTypeSF(){
	$('accnt').innerHTML = $('accountType').value;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Go to sign up page
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function goToSignup(){
	window.location = ROOT_URL+'signup.php';
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Remove selected Friend
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function removeFriend(theirID){
	window.location = ROOT_URL+'profile.php?removeF='+theirID;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Remove from radio function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function removeFromRadio(passedID){
	window.location = ROOT_URL+'radio.php?RemoveSong='+passedID;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Add to radio function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function addToRadio(songId, profileId){
	new Request.HTML({
		noCache: true,
		url: ROOT_URL+'php/addSongToRadio.php?SondRadio='+songId, 
		onSuccess: function(a, b, html) {
			alert(html);
		}
	}).post();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	GoTo Profile
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function goToProfile(pID){
	window.location = ROOT_URL+'profile.php?id='+pID;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	remove cursor styles when not in edit mode Function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function notEditable(){
	$$('#nmi_body .isEditable').addClass('noPointer');
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	makeScrollBar Function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){var steps=(horizontal?(content.getScrollSize().x-content.getSize().x):(content.getScrollSize().y-content.getSize().y))
var slider=new Slider(scrollbar,handle,{steps:steps,mode:(horizontal?'horizontal':'vertical'),onChange:function(step){var x=(horizontal?step:0);var y=(horizontal?0:step);content.scrollTo(x,y);}}).set(0);if(!(ignoreMouse)){$$(content,scrollbar).addEvent('mousewheel',function(e){e=new Event(e).stop();var step=slider.step-e.wheel*30;slider.set(step);});}$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	CreateFX function to scroll content in the profile to the top
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function createFX() {
	new Fx.Scroll('nmi_body_left_right', {duration: 'short'}).start(0, 0);
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Ajax Call to get data from the DB
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function getFromServer($url, $container){
	new Request.HTML({
		noCache: true,
		url:$url, 
		onSuccess: function(a, b, html) {
			$($container).set('html',html);
		}
	}).send();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Count the clicks for the ads
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function adClick($id){
	new Request.HTML({
		url:'addClick.php?id='+$id, 
		onSuccess: function(a, b, html){ 
			return true;
		}
	}).send();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	reload featured artist section
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function reloadFeat(tourl){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat.php?'+tourl, 
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere')){$('nmi_loadfeatarthere').set('html',html);}
		}
	}).get();
}
function reloadFeat_2(tourl){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat2.php?'+tourl, 
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere2')){$('nmi_loadfeatarthere2').set('html',html);}
		}
	}).get();
}
function reloadFeat_2org(){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat2.php', 
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere2')){$('nmi_loadfeatarthere2').set('html',html);}
		}
	}).get();
}
function reloadFeat_3(tourl){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat3.php?'+tourl, 
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere3')){$('nmi_loadfeatarthere3').set('html',html);}
		}
	}).get();
}
function reloadFeat_3org(){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat3.php',
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere3')){$('nmi_loadfeatarthere3').set('html',html);}
		}
	}).get();
}
function reloadFeat2(tourl){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subfeat1.php?'+tourl, 
		onSuccess: function(a, b, html) { 
			if($('nmi_loadfeatarthere')){$('nmi_loadfeatarthere').set('html',html);}
		}
	}).get();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	reload sub ads section
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function reloadSubAds(tourl){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'subads.php', 
		onSuccess: function(a, b, html) { 
			$('targetads').set('html',html);
		}
	}).get();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	When cancel button/link is pressed in profile
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function cancelField($edit){
	new Request.HTML({
		evalScripts: true,
		evalResponse: true,
		noCache: true,
		url:'php/edit_profile.php?Cancel='+$edit, 
		onSuccess: function(a, b, html) { 
			$($edit).set('html',html);
			$('contain'+$edit).setStyles({'background-color':'transparent','cursor':'pointer'});
			if($edit == "Location"){
				containLocationCall.setOptions({startState: 0});
			}
			else if($edit == "Contact"){
				containContactCall.setOptions({startState: 0});
			}
			else if($edit == "Name"){
				containNameCall.setOptions({startState: 0});
			}
			else if($edit == "Label"){
				containLabelCall.setOptions({startState: 0});
			}
			else if($edit == "Avatar"){
				containAvatarCall.setOptions({startState: 0});
			}
			else if($edit == "Style"){
				containStyleCall.setOptions({startState: 0});
			}
			else if($edit == "Email"){
				containEmailCall.setOptions({startState: 0});
			}
			getDoSize();
		}
	}).send();
	getDoSize();	
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	When save button/link is pressed in profile
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function saveField($edit){
	if($edit == "Location"){
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+'&City='+$('city').getProperty('value')+'&State='+$('stateprovince').getProperty('value')+'&Country='+$('country').getProperty('value'), 
			onSuccess: function(a, b, html) { 
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				$('contain'+$edit).setStyle('cursor', 'pointer');
				containLocationCall.setOptions({startState: 0});
			}
		}).send();
	}
	else if($edit == "Contact"){
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+'&NewUrl='+$('NewUrl').getProperty('value'), 
			onSuccess: function(a, b, html) { 
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				$('contain'+$edit).setStyle('cursor', 'pointer');
				containContactCall.setOptions({startState: 0});
			}
		}).send();
		
	}
	else if($edit == "Name"){
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+'&String='+$('New'+$edit).getProperty('value'), 
			onSuccess: function(a, b, html) {
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				$('contain'+$edit).setStyle('cursor', 'pointer');
				containNameCall.setOptions({startState: 0});
			}
		}).send();
	}
	else if($edit == "Label"){
		new Request.HTML({
			url:'php/edit_profile.php?Save='+$edit+'&String='+$('New'+$edit).getProperty('value'), 
			onSuccess: function(a, b, html) {
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				$('contain'+$edit).setStyle('cursor', 'pointer');
				containLabelCall.setOptions({startState: 0});
			}
		}).send();
	}
	else if($edit == "Avatar"){
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+'&String='+$('New'+$edit).getProperty('value'), 
			onSuccess: function(a, b, html) {
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				$('contain'+$edit).setStyle('cursor', 'pointer');
				containAvatarCall.setOptions({startState: 0});
			}
		}).send();
	}
	else if($edit == "Style"){
		$string = "";
		for(i = 1;i < 4;i++){
			$string += "&style" + i + "=" + $('genre'+i).getProperty('value') + "&mood" + i + "=" + $('mood'+i).getProperty('value');	
		}
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+$string, 
			onSuccess: function(a, b, html) { 
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				containStyleCall.setOptions({startState: 0});
				$('contain'+$edit).setStyle('cursor', 'pointer');
			}
		}).send();
	}
	else if($edit == "Email"){
		$string = "";
		new Request.HTML({
			noCache: true,
			url:'php/edit_profile.php?Save='+$edit+'&String='+$('Cemail').getProperty('value'), 
			onSuccess: function(a, b, html) { 
				$($edit).set('html',html);getDoSize();
				$('contain'+$edit).setStyle('background-color', 'transparent');
				containEmailCall.setOptions({startState: 0});
				$('contain'+$edit).setStyle('cursor', 'pointer');
			}
		}).send();
	}
	getDoSize();	
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Adjust the profiles heights in certain areas
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function getDoSize(){
	if($('nmi_checker_id_only_on_profile') && $('nmi_body_left_right')){
		var daSizes;
		var pLR = $('nmi_body_left_right').getStyle('height').toInt();
		if($('dacontent')){
			var getSizes = $('nmi_profilecontent').getScrollSize().y;	
			var getSizes2 = $('nmi_inner_artistinfo').getScrollSize().y;
			if(getSizes > pLR && getSizes>=getSizes2) {
				daSizes=getSizes+15;
				$('dacontent').setStyle('height', daSizes+'px');
				$('nmi_artistinfo').setStyle('height', '100%');
			}
			else if(getSizes > pLR && getSizes<getSizes2) {
				daSizes=getSizes2+15;
				$('dacontent').setStyle('height', daSizes+'px');
				$('nmi_artistinfo').setStyle('height', '100%');
			}
			else if(getSizes <= pLR && getSizes2 > pLR) {
				daSizes=getSizes2+15;
				$('dacontent').setStyle('height', '100%');
				$('nmi_artistinfo').setStyle('height', daSizes+'px');
			}
			else if(getSizes <= pLR){
				daSizes=pLR;
				$('dacontent').setStyle('height', '100%');
				$('nmi_artistinfo').setStyle('height', daSizes+'px');
			}
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Function to display the edit fields once inline elements are clicked on the profile
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function showEditField($edit){
	new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		url:'php/edit_profile.php?Field='+$edit, 
		onSuccess: function(a, b, html) {
			$($edit).set('html',html);
			$('top'+$edit).setStyle('display', 'none');
			$('contain'+$edit).setStyle('cursor', 'default');
			getDoSize.delay(800);
		}
	}).send();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Function to display the Tip of the Day
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_TipOfTheDay = new Class({
	Implements: [Options, Events],
	Binds: ['buildtip', 'closetip', 'showtab', 'unsubtip'],
	options:
	{
		defaulttip: 'LEGAL',
		tabs: ['LEGAL', 'SELF-PROMOTION', 'RECORDING', 'SONG-WRITING', 'BUSINESS', 'NuMuBu'],
		tabindexs: ['legal', 'selfpromotion', 'recording', 'songwriting', 'business', 'numubu']
	},
	initialize: function(options)
	{
		this.setOptions(options);
		this.countarr = this.options.tabs.length;
		if(!$('totdDIV'))
		{
			this.buildtip();
		}
	},
	buildtip: function()
	{
		var htmlForHeader2 = '';
		var a = new Element('div', {'id':'totdDIV','styles': 
				{
					'position':'absolute', 
					'top':'75px', 
					'left':($('nmi_body').getPosition().x+148).toInt(), 
					'width':'570px', 
					'border':'2px solid #565469',
					'background':'#353535',
					'font-family':'Arial',
					'z-index':'9999999'
				}, 'html':htmlForHeader2
		}).inject(document.body);
		
		var b = new Element('div', {'styles': 
				{
					'width':'570px', 
					'height':'22px', 
					'border-bottom':'2px solid #565469',
					'background':'#333333',
					'position':'relative'
				},
				'html':'<div id="totdhd1" style="margin:0 0 0 10px"></div>'
		}).inject(a);
		
		for(x=0;x<this.countarr;x++)
		{
			var thisnewele = new Element('div', {'id':'totd_'+this.options.tabs[x], 'class':'totdtab', 'style':'font-weight:bold;float:left;font-size:12px;border-right:1px solid #565469;border-left:1px solid #565469;height:22px;cursor:pointer', 'html':'<div style="padding:4px 5px 0 5px;">'+this.options.tabs[x]+'</div>'}).inject('totdhd1');
			
		}
		
		this.totdtabarray = $('totdhd1').getElements('div.totdtab');
		
		this.totdtabarray.each(function(el){ 
			el.addEvent('click', function(){
				this.showtab(el.getProperty('id'));
			}.bind(this));
		}.bind(this));
		
		b.addEvent('mousedown', function(){
			b.setStyle('cursor','move');								 
		});
		b.addEvent('mouseup', function(){
			b.setStyle('cursor','default');								 
		});
		b.addEvent('mouseout', function(){
			b.setStyle('cursor','default');								 
		});
		
		this.totdtabarray[0].setStyle('border-left', '2px solid #565469');
		this.totdtabarray.getLast().setStyle('border-right', '2px solid #565469');
		
		var htmlForHeader3 = '<h3 style="color:#fff;font-size:14px;font-weight:bold;padding:8px 0 0 10px;margin:0;float:left;" id="totdh3header"></h3>';
			htmlForHeader3 += '<div style="float:left;margin-left:60px;font-size:10px;margin-top:12px" id="TipAuthor"></div>';
			htmlForHeader3 += '<div id="unsubtipel" style="width:60px;right:1px;top:0;position:absolute;line-height:10px"><a href="#" style="color:red;font-size:9px;">Unsubscribe from this Tip</a></div><div class="clear"></div>';
		
		var c = new Element('div', {'styles': 
				{
					'width':'570px', 
					'height':'32px', 
					'border-bottom':'2px solid #565469',
					'background':'#0e0e0e',
					'position':'relative'
				},
				'html':htmlForHeader3
		}).inject(a);
		
		$('unsubtipel').addEvent('click', function(e){
			e.stop();
			this.unsubtip();
		}.bind(this));
				
		var b_a = new Element('div', {'styles': 
				{
					'position':'absolute',
					'top':'0px',
					'right':'1px',
					'cursor':'pointer'
				},
				'html':'<img src="assets/closetip.png"/>'
		}).inject(b);
		b_a.addEvent('click', function(e){
			e.stop();
			a.destroy();
		});
		
		new Drag.Move(a, {handle:b});
		
		var d = new Element('div', {'id':'loadtipsinfohere', 'styles': 
				{
					'width':'550px',  
					'padding':'10px 10px 13px 10px',
					'font-size':'11px'
				}
		}).inject(a);
		
		this.tipheaderel = $('totdh3header');
		this.tipauthorel = $('TipAuthor');
		this.loadtpinhereel = d;
		
		this.showtab('totd_'+this.options.defaulttip);
	},
	closetip: function()
	{
		$('totdDIV').destroy();
	},
	showtab: function(which)
	{
		for(x=0;x<this.countarr;x++)
		{
			if('totd_'+this.options.tabs[x] === which)
			{
				var getele = $(which);
				if(getele && (getele.getStyle('background-color') !== '#0E0E0E' && getele.getStyle('background-color') !== '#0e0e0e'))
				{
					this.totdtabarray.each(function(el){
						el.setStyles({
							'background':'#333',
							'height':'22px'
						});
					});
					this.totdtabarray[0].setStyle('border-left', '2px solid #565469');
					this.totdtabarray.getLast().setStyle('border-right', '2px solid #565469');
					getele.setStyles({
						'height':'24px',
						'background':'#0e0e0e'
					});
					
					this.tipheaderel.set('html', this.options.tabs[x]+' TIP OF THE DAY');
					
					var newrwq = new Request.HTML({
						noCache: true,
						evalScripts: true,
						evalResponse: true,
						url: 'php/getTip.php?'+this.options.tabindexs[x],
						onRequest: function() {
							this.loadtpinhereel.set('html', '<img src="assets/loading3.gif"/>');
						}.bind(this),
						onSuccess: function(html) {
							document.cookie = 'seenLegalTip=yes; expires='+new Date().increment().set('hr', 0).set('min', 0).set('sec', 0).toGMTString()+'; path=/';
							var String = newrwq.response.text.split("::");
							this.tipauthorel.set('html', 'by: <a href="'+ROOT_URL+'profile.php?id='+String[1]+'" class="colorLime">'+String[0]+'</a>'); 
							this.loadtpinhereel.set('html', String[2]);
							detectUndesirables();
						}.bind(this),
						onCancel: function() {
							alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
							detectUndesirables();
							this.loadtpinhereel.set('html', '');
						}.bind(this),
						onException: function() {
							alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
							detectUndesirables();
							this.loadtpinhereel.set('html', '');
						}.bind(this),
						onFailure: function() {
							alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
							detectUndesirables();
							this.loadtpinhereel.set('html', '');
						}.bind(this)
					}).post();
				}
				break;
			}
		}
	},
	unsubtip: function()
	{
		for(x=0;x<this.countarr;x++)
		{
			var playel = $('totd_'+this.options.tabs[x]);
			if(playel.getStyle('background-color') === '#0e0e0e' || playel.getStyle('background-color') === '#0E0E0E')
			{
				if(confirm('Do you really want to stop getting "'+this.options.tabs[x]+'" tips?'))
				{
					var newrwq = new Request.HTML({
						noCache: true,
						evalScripts: true,
						evalResponse: true,
						url: 'php/opouttip.php?'+this.options.tabindexs[x],
						onRequest: function() {
						}.bind(this),
						onSuccess: function(html) {
							alert('You have been unsubscribed!');
							detectUndesirables();
						}.bind(this),
						onCancel: function() {
							alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
							detectUndesirables();
						}.bind(this),
						onException: function() {
							alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
							detectUndesirables();
						}.bind(this),
						onFailure: function() {
							alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
							detectUndesirables();
						}.bind(this)
					}).post();
				}
				break;
			}
		}
	}
});
function t_o_t_d(){if(!$("totdDIV")&&Cookie.read("seenLegalTip")===null){var h='<h3 style="color:#fff;font-size:14px;font-weight:bold;padding:8px 0 0 10px;margin:0;float:left;">LEGAL TIP OF THE DAY</h3>';h+='<div style="float:left;margin-left:70px;font-size:10px;margin-top:12px" id="TipAuthor">by: <a href="#" class="colorLime">Numubu</a></div>';h+='<div class="clear"></div>';var g='<div style="font-size:10px;position:absolute;right:3px;bottom:3px"><a href="http://www.numubu.com/profile.php?optout" class="colorRed" class="unsub">unsubscribe</a></div>';var e=new Element("div",{id:"totdDIV",styles:{position:"absolute",top:"75px",left:($("nmi_body").getPosition().x+148).toInt(),width:"570px",border:"2px solid #565469",background:"#353535","font-family":"Arial","z-index":"9999999"},html:g}).inject(document.body);var d=new Element("div",{styles:{width:"570px",height:"32px","border-bottom":"2px solid #565469",background:"#1c1c1c",position:"relative"},html:h}).inject(e);d.addEvent("mousedown",function(){d.setStyle("cursor","move")});d.addEvent("mouseup",function(){d.setStyle("cursor","default")});d.addEvent("mouseout",function(){d.setStyle("cursor","default")});var f=new Element("div",{styles:{position:"absolute",top:"0px",right:"0px",cursor:"pointer"},html:'<img src="assets/closetip.png"/>'}).inject(d);f.addEvent("click",function(a){a.stop();e.destroy()});new Drag.Move(e,{handle:d});var j=new Element("div",{styles:{width:"550px",padding:"10px 10px 13px 10px","font-size":"11px"}}).inject(e);new Request.HTML({noCache:true,evalScripts:true,evalResponse:true,url:"php/getTip.php?legal",onRequest:function(){},onSuccess:function(b){document.cookie="seenLegalTip=yes; expires="+new Date().increment().set("hr",0).set("min",0).set("sec",0).toGMTString()+"; path=/";var a=this.response.text.split("::");$("TipAuthor").set("html",'by: <a href="http://www.numubu.com/profile.php?id='+a[1]+'" class="colorLime">'+a[0]+"</a>");j.set("html",a[2]);detectUndesirables()},onCancel:function(){alert("There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.");detectUndesirables()},onException:function(){alert("There was an error while processing your request. We are working on this issue and it should be resolved soon.");detectUndesirables()},onFailure:function(){alert("There was an error while processing your request. We are working on this issue and it should be resolved soon.");detectUndesirables()}}).post()}}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Send Referal to people
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function sendReferal(){
	$('playercontainer').setStyle('top', '-3000px');
	$('nmi_inner_profilecontent').setStyle('display', 'block');
	if($('inboxcontainer').getStyle('display')=="block"){
		$('inboxcontainer').setStyle('display','none');
		$('nmi_artistinfo').setStyle('display','block');
		$('nmi_profilecontent').setStyle('display','block');
	}
	var getLinkTo = new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		method: 'post',
		url: 'php/edit_profile.php',
		onRequest: function() {
			$('nmi_inner_profilecontent').set('html', '<div style="width:31px;height:31px;margin:15px auto 0px;"><img src="assets/loading.gif"/></div>');
			createFX();
		},
		onSuccess: function(html) {
			$('nmi_inner_profilecontent').set('html', getLinkTo.response.text);
			getDoSize.delay(800);
			detectUndesirables();
		},
		onCancel: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onException: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onFailure: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		}
	}).send('refermForm=SHOW');	
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Function to get the news feed
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function getNewsfeed(){
	$('playercontainer').setStyle('top', '-3000px');
	$('nmi_inner_profilecontent').setStyle('display', 'block');
	if($('inboxcontainer').getStyle('display')=="block"){
		$('inboxcontainer').setStyle('display','none');
		$('nmi_artistinfo').setStyle('display','block');
		$('nmi_profilecontent').setStyle('display','block');
	}
	var getLinkTo = new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		method: 'post',
		url: 'php/edit_profile.php',
		onRequest: function() {
			$('nmi_inner_profilecontent').set('html', '<div style="width:31px;height:31px;margin:15px auto 0px;"><img src="assets/loading.gif"/></div>');
			createFX();
		},
		onSuccess: function(html) {
			$('nmi_inner_profilecontent').set('html', getLinkTo.response.text);
			getDoSize.delay(800);
			detectUndesirables();
		},
		onCancel: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onException: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onFailure: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		}
	}).send('newsfeed=true');	
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Function that executes when inline elements are hovered over or out on the profile
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function showEdit($edit){
	$('top'+$edit).setStyle('display', 'block');
	$('contain'+$edit).setStyle('background-color', '#292929');
	getDoSize();
}
function hideEdit($edit){
	$('top'+$edit).setStyle('display', 'none');
	$('contain'+$edit).setStyle('background-color', 'transparent');
	getDoSize();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Try and find out if Norton Firewall is messing with the sites AJAx functions
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function detectUndesirables(){
	if (typeof SymOnLoad == 'function') {
    	alert('We have detected Norton Personal Firewall. Unfortunately, it may prevent you from viewing this site, and many other modern websites. You may need to turn off Norton Firewall or its Ad Blocking service to view this site properly.');
	}						
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	CDS Function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function informational_CDS()
{
	new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		url: 'CDSinfo.php?status=1'
	}).post();
	var a = new Element('div', {'styles': {'position':'absolute', 'top':'50%', 'left':'50%', 'margin':'-127px 0 0 -107px', 'width':'215px', 'height':'255px'}, 'html':'<img src="assets/info_cds.jpg"/>'}).inject(document.body);
	var b = new Element('div', {'styles':{'cursor':'pointer','position':'absolute','top':'222px','left':'64px'}, 'html':'<img src="assets/newokay.jpg"/>'}).inject(a);
	var c = new Element('div', {'styles':{'cursor':'pointer','position':'absolute','top':'195px','left':'14px', 'width':'185px', 'height':'15px'}, 'html':' '}).inject(a);
		b.addEvent('click', function(e){
			e.stop();
			a.destroy();
		});
		c.addEvent('click', function(e){
			e.stop();
			window.open("http://www.cirquedusoleil.com/jobs");
		});
}
function question_CDS()
{
	var a = new Element('div', {'styles': {'position':'absolute', 'top':'50%', 'left':'50%', 'margin':'-78px 0 0 -134px', 'width':'269px', 'height':'157px'}, 'html':'<img src="assets/cds_yn.jpg"/>'}).inject(document.body);
	var b = new Element('div', {'styles':{'cursor':'pointer','position':'absolute','top':'129px','left':'46px'}, 'html':'<img src="assets/newyes.jpg"/>'}).inject(a);
		//if yes
		b.addEvent('click', function(e){
			e.stop();
			a.destroy();
			informational_CDS();
		});
	var c = new Element('div', {'styles':{'cursor':'pointer','position':'absolute','top':'129px','left':'139px'}, 'html':'<img src="assets/newno.jpg"/>'}).inject(a);
		//if no
		c.addEvent('click', function(e){
			e.stop();
			a.destroy();
			new Request.HTML({
				noCache: true,
				evalScripts: true,
				evalResponse: true,
				url: 'CDSinfo.php?status=2'
			}).post();
		});
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	This function takes 3 arguments, it goes to the specified section of the profile   linkToWhat is the php file, theTitle is the name of the section and whatId is
	the ID of the Anchor tag in the profile menu.
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function goToSectionAjax(linkToWhat, theTitle, whatId){
	$('playercontainer').setStyle('top', '-3000px');
	$('nmi_inner_profilecontent').setStyle('display', 'block');
	var linkTo = linkToWhat;
	var getTitle = theTitle;
	$$('#nmi_checker_id_only_on_profile a').removeClass('act');
	if($(whatId)){$(whatId).addClass('act');}
	$('nmi_body_left_right').removeClass('overflowHidden');
	$('dacontent').removeClass('width530');
	var getLinkTo = new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		url: linkTo,
		onRequest: function() {
			$('nmi_inner_profilecontent').set('html', '<div style="width:31px;height:31px;margin:15px auto 0px;"><img src="assets/loading.gif"/></div>');
			createFX();
		},
		onSuccess: function(html) {
			$('nmi_inner_profilecontent').set('html', getLinkTo.response.text);
			getDoSize.delay(800);
			detectUndesirables();
		},
		onCancel: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onException: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onFailure: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		}
	}).post();	
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	urlEncode and nl2br Functions
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function urlencode(str){var histogram={},histogram_r={},code=0,tmp_arr=[];var ret=str.toString();var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram['!']='%21';histogram['%20']='+';ret=encodeURIComponent(ret);for(search in histogram){replace=histogram[search];ret=replacer(search,replace,ret)}
return ret.replace(/(\%([a-z0-9]{2}))/g,function(full,m1,m2){return"%"+m2.toUpperCase();});return ret;}
function nl2br(text)
{text=escape(text);re_nlchar='';if(text.indexOf('%0D%0A')>-1)
{re_nlchar=/%0D%0A/g;}
else if(text.indexOf('%0A')>-1)
{re_nlchar=/%0A/g;}
else if(text.indexOf('%0D')>-1)
{re_nlchar=/%0D/g;}
return unescape(text.replace(re_nlchar,'<br />'));}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Contact Me and send contact function
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function sendContact($number){
	var bio = $('conMes').value;
	bio = urlencode(bio);
	var myHTMLRequest = new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
			method: 'post',
		url:'php/edit_profile.php', 
		onSuccess: function(a, b, html) {
			$('contactDiv').set('html',html);
		}
	}).send('send=contact&id='+$number+'&sub='+$('conSub').value+'&email='+$('conEm').value+'&msg='+bio);
}
function contactME(linkurl){
	$('playercontainer').setStyle('top', '-3000px');
	$('nmi_inner_profilecontent').setStyle('display', 'block');
	var linkTo = linkurl;
	var getTitle = 'Contact Me';
	$$('#nmi_checker_id_only_on_profile a').removeClass('act');
	var getLinkTo = new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		url: linkTo,
		onRequest: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="loading1"><img src="assets/loading.gif"/></div>');
			createFX();
		},
		onSuccess: function(html) {
			$('nmi_inner_profilecontent').set('html', getLinkTo.response.text);
			detectUndesirables();
			getDoSize.delay(800);
			
		},
		onCancel: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onException: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		},
		onFailure: function() {
			$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
			getDoSize();
			detectUndesirables();
		}
	}).post();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	menu class for search...maybe others in future eh?
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_MenuSubMenu2 = new Class({
	Implements: [Options, Events],
	Binds: ['show', 'hide', 'buildMenu'],
	options:
	{
		id: null,
		topLeft: null,
		mainMenuItems: null,
		subMenuItems: null
	},
	initialize: function(options)
	{
		this.setOptions(options);
		this.buildMenu();
	},
	timer: null,
	buildMenu: function()
	{
		if(!$('menu_outer_cont_search'))
		{
			var a = this.options.mainMenuItems.length;
			var b = '<ul class="aslul2">';
			
			for(x=0;x<a;x++)
			{
				var c = this.options.mainMenuItems[x].split(":");
				b += '<li class="'+c[1]+' '+x+' specarrsear">'+c[0]+'</li>';
			}
			
			b += '</ul>';
			
			this.menucont = new Element('div', {
				'html':b,
				'styles':
						{
						'position':'absolute', 
						'top':'26px', 
						'width':'170px', 
						'z-index':'90000', 
						'left':'600px',
						'color':'#000',
						'display':'block',
						'visibility':'hidden',
						'border':'1px #000 solid',
						'background':'#B7BA9F'
						},
				'id':'menu_outer_cont_search'
			}).inject(this.options.id);
			
			this.menucont.getChildren('ul')[0].getChildren('li')[0].setStyle('border-bottom','4px solid #000');
			this.menucont.getChildren('ul')[0].getChildren('li')[10].setStyle('border-bottom','4px solid #000');
			
			var x = 0;
			this.menucont.getChildren('ul')[0].getChildren('li').each(function(el){
				el.addEvent('click', function(e){
					e.stop();
					if(el.getProperty('class').split(" ")[1] == '0')
					{
						window.location = "search.php";
					}
					else
					{
						window.location = "search.php?ms="+(el.getProperty('class').split(" ")[0]);
					}
				});
				var a = this.options.subMenuItems[x];
				var b = a.split("!");
				var c = b.length;
				var h = el.getPosition();
				var d = '<ul class="aslul2">';
				if(b[0] != "")
				{
					for(y=0;y<c;y++)
					{
						var e = b[y].split(":");
						d += '<li class="'+e[1]+'">'+e[0]+'</li>';
					}
					
					d += '</ul>';
					
					var i = new Element('div', {
						'styles':{
							'position':'absolute',
							'color':'#000',
							'display':'block',
							'z-index':'90000', 
							'visibility':'hidden',
							'border':'1px #000 solid',
							'background':'#B7BA9F',
							'font-size':'12px',
							'font-family':'Arial',
							'cursor':'pointer',
							'width':'170px',
							'left':(h.x+172)+'px',
							'top':(h.y-1)+'px'
						},
						'html':d,
						'id': 'subsearch_'+x
					}).inject("submenitcont");
					
					i.addEvent('mouseleave', function(){
						this.hide(1, i);
						this.timer = (function(){this.hide(0)}.bind(this)).delay(1500);
					}.bind(this));
					
					i.getChildren('ul')[0].getChildren('li').each(function(el){
																		   el.addEvent('click', function(e){
						e.stop();
						window.location = "search.php?ss="+(el.getProperty('class'));
					});
																		   });
				}
				else
				{
					el.removeClass('specarrsear');
				}
				el.addEvent('mouseenter', function(){
						$("submenitcont").getChildren('div').each(function(el){el.setStyle('visibility','hidden');});
						if(i != undefined)
						{
							this.show(1, i);
							i.addEvent('mouseenter', function()
															  {
																 $clear(this.timer); 
															  }.bind(this));
						}
						
					}.bind(this));
					
					x=x+1;
			}.bind(this));
			
			$(this.options.id).addEvent('click', function(e){
				e.stop();
				if($('accntsSBox'))
				{
					$('accntsSBox').fade('out');
					(function(){$('accntsSBox').destroy()}).delay(750);
				}
				this.show(0);
			}.bind(this));
			
			/*$(this.options.id+'_1').addEvent('click', function(e){
				e.stop();
				if($('accntsSBox'))
				{
					$('accntsSBox').fade('out');
					(function(){$('accntsSBox').destroy()}).delay(750);
				}
				this.show(0);
			}.bind(this));*/
			
			this.menucont.addEvent('mouseenter', function(e){
				$clear(this.timer); 
			}.bind(this));
			
			this.menucont.addEvent('mouseleave', function(e){
				this.timer = (function(){this.hide(0)}.bind(this)).delay(1500);
			}.bind(this));
		}
	},
	show: function(a, b)
	{
		if(a === 0)
		{
			$('menu_outer_cont_search').setStyles({'visibility': 'visible', 'opacity':1});
		}
		else if(a === 1)
		{
			b.setStyle('visibility','visible');
		}
	},
	hide: function(a, b)
	{
		if(a === 0)
		{
			$('menu_outer_cont_search').fade('out');
		}
		else if(a === 1)
		{
			b.setStyle('visibility','hidden');
		}
		else if(a === 2)
		{
			$("submenitcont").getChildren('div').each(function(el){el.setStyle('visibility','hidden');});
		}
		else if(a === 3)
		{
			$('menu_outer_cont_search').setStyle('visibility','hidden');
		}
		$clear(this.timer);
	}
});
var NMB_MenuSubMenu = new Class({
	Implements: [Options, Events],
	Binds: ['show', 'hide', 'buildMenu'],
	options:
	{
		id: null,
		topLeft: null,
		mainMenuItems: null,
		subMenuItems: null
	},
	initialize: function(options)
	{
		this.setOptions(options);
		this.buildMenu();
	},
	timer: null,
	buildMenu: function()
	{
		if(!$('menu_outer_cont_search'))
		{
			var a = this.options.mainMenuItems.length;
			var b = '<ul class="aslul2">';
			
			for(x=0;x<a;x++)
			{
				var c = this.options.mainMenuItems[x].split(":");
				b += '<li class="'+c[1]+' '+x+' specarrsear" style="color:#fff">'+c[0]+'</li>';
			}
			
			b += '</ul>';
			
			this.menucont = new Element('div', {
				'html':b,
				'styles':
						{
						'position':'absolute', 
						'top':'20px', 
						'width':'170px', 
						'z-index':'90000', 
						'left':'-80px',
						'color':'#000',
						'display':'block',
						'visibility':'hidden',
						'border':'1px #000 solid',
						'background':'#67694F'
						},
				'id':'menu_outer_cont_search'
			}).inject(this.options.id);
			
			this.menucont.getChildren('ul')[0].getChildren('li')[0].setStyle('border-bottom','4px solid #000');
			this.menucont.getChildren('ul')[0].getChildren('li')[10].setStyle('border-bottom','4px solid #000');
			
			var x = 0;
			this.menucont.getChildren('ul')[0].getChildren('li').each(function(el){
				el.addEvent('click', function(e){
					e.stop();
					if(el.getProperty('class').split(" ")[1] == '0')
					{
						window.location = "search.php";
					}
					else
					{
						window.location = "search.php?ms="+(el.getProperty('class').split(" ")[0]);
					}
				});
				var a = this.options.subMenuItems[x];
				var b = a.split("!");
				var c = b.length;
				var h = el.getPosition();
				var d = '<ul class="aslul2">';
				if(b[0] != "")
				{
					for(y=0;y<c;y++)
					{
						var e = b[y].split(":");
						d += '<li class="'+e[1]+'" style="color:#fff">'+e[0]+'</li>';
					}
					
					d += '</ul>';
					
					var i = new Element('div', {
						'styles':{
							'position':'absolute',
							'color':'#000',
							'display':'block',
							'z-index':'90000', 
							'visibility':'hidden',
							'border':'1px #000 solid',
							'background':'#67694F',
							'font-size':'12px',
							'font-family':'Arial',
							'cursor':'pointer',
							'width':'170px',
							'left':(h.x+172)+'px',
							'top':(h.y-1)+'px'
						},
						'html':d,
						'id': 'subsearch_'+x
					}).inject("submenitcont");
					
					i.addEvent('mouseleave', function(){
						this.hide(1, i);
						this.timer = (function(){this.hide(0)}.bind(this)).delay(1500);
					}.bind(this));
					
					i.getChildren('ul')[0].getChildren('li').each(function(el){
																		   el.addEvent('click', function(e){
						e.stop();
						window.location = "search.php?ss="+(el.getProperty('class'));
					});
																		   });
				}
				else
				{
					el.removeClass('specarrsear');
				}
				el.addEvent('mouseenter', function(){
						$("submenitcont").getChildren('div').each(function(el){el.setStyle('visibility','hidden');});
						if(i != undefined)
						{
							this.show(1, i);
							i.addEvent('mouseenter', function()
															  {
																 $clear(this.timer); 
															  }.bind(this));
						}
						
					}.bind(this));
					
					x=x+1;
			}.bind(this));
			
			$(this.options.id).addEvent('click', function(e){
				e.stop();
				if($('accntsSBox'))
				{
					$('accntsSBox').fade('out');
					(function(){$('accntsSBox').destroy()}).delay(750);
				}
				this.show(0);
			}.bind(this));
			
			$(this.options.id+'_1').addEvent('click', function(e){
				e.stop();
				if($('accntsSBox'))
				{
					$('accntsSBox').fade('out');
					(function(){$('accntsSBox').destroy()}).delay(750);
				}
				this.show(0);
			}.bind(this));
			
			this.menucont.addEvent('mouseenter', function(e){
				$clear(this.timer); 
			}.bind(this));
			
			this.menucont.addEvent('mouseleave', function(e){
				this.timer = (function(){this.hide(0)}.bind(this)).delay(1500);
			}.bind(this));
		}
	},
	show: function(a, b)
	{
		if(a === 0)
		{
			$('menu_outer_cont_search').setStyles({'visibility': 'visible', 'opacity':1});
		}
		else if(a === 1)
		{
			b.setStyle('visibility','visible');
		}
	},
	hide: function(a, b)
	{
		if(a === 0)
		{
			$('menu_outer_cont_search').fade('out');
		}
		else if(a === 1)
		{
			b.setStyle('visibility','hidden');
		}
		else if(a === 2)
		{
			$("submenitcont").getChildren('div').each(function(el){el.setStyle('visibility','hidden');});
		}
		else if(a === 3)
		{
			$('menu_outer_cont_search').setStyle('visibility','hidden');
		}
		$clear(this.timer);
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Localize Confirm functions
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_ConfirmAlert = new Class({
	Implements: [Options, Events],
	Binds: ['doConfirm'],
	options: {
		id: null,
		ifConfirmFunction: $empty,
		arguments: ['myArg1', 'myArg2'],
		text: ''
	},
	initialize: function(options){
		this.setOptions(options);
		this.doConfirm();
	},
	doConfirm: function(){
		if(confirm(this.options.text)){
			this.options.ifConfirmFunction.run(this.options.arguments, this);
		}
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Send Friend Request
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_SendFR = new Class({
	Implements: [Options, Events],
	Binds: ['doConfirm','yea','nah'],
	options: {
		id: '',
		tid: 0,
		tname: ''
	},
	custMsg: '',
	initialize: function(options)
	{
		this.setOptions(options);
		this.doConfirm();
	},
	doConfirm: function()
	{
		var htmlForHeader = '<h3 style="color:#9cb983;font-size:14px;font-weight:bold;padding:9px 0 0 10px;margin:0;">SEND FRIEND REQUEST</h3>';
		this.outerBox	=	new Element('div', {'id':'sfrcontcont', 'styles':{'left':((window.getSize().x).toInt()/2)+'px'}}).inject(document.body);
		this.innerTBox	=	new Element('div', {'id':'sfrcontconttopcont', 'html': htmlForHeader}).inject(this.outerBox);
		this.closeBox	=	new Element('div', {'id':'sfrcontconttopclose', 'html':'<img src="assets/closetip.png"/>'}).inject(this.innerTBox);
		
		this.closeBox.addEvent('click', function(e){e.stop();this.nah();}.bind(this));
		
		var htmlforbox = '<div>';
			htmlforbox += '<div style="float:left;margin-right:10px;"><img src="'+$('Avatar').getElement('img').getProperty('src')+'" width="85"/></div>';
			htmlforbox += '<div style="float:left;position:relative;padding:0 0 30px 0" id="'+this.options.id+'"><p style="width:263px">'+this.options.tname+' will have to confirm you as a friend.</p><p class="" style="margin-top:5px"><a href="#" class="colorLime">Add a message</a><textarea id="personalmessagesfr" style="display:none;width:230px;height:50px;border:1px solid #000000"></textarea><div class="greyed" style="font-size:9px;display:none">Max 200 characters</div></div>';
			htmlforbox += '<div class="clear"></div></div>';
		
		this.innerMBox	=	new Element('div', {'id':'sfrcontcontinnerbox','html':htmlforbox}).inject(this.outerBox);
		//$(this.options.id).setStyle('min-height', ($(this.options.id).getPrevious('div').getElement('img').getSize().y)+'px');
		
		$(this.options.id).getElement('a.colorLime').addEvent('click', function(e){
			e.stop();
			this.getNext('textarea').setStyle('display','block');
			this.getParent('p').getNext('div').setStyle('display','block');
			this.destroy();
		});
		
		this.sendbutton = new Element('img', {'src':ROOT_URL+'assets/newrequest.png', 'styles':{'position':'absolute','bottom':'0','left':'0','cursor':'pointer'}, 'events':{'mousedown':function(e){this.yea();}.bind(this)}}).inject(this.options.id);
		
		this.cancelbutton = new Element('img', {'src':ROOT_URL+'assets/newcancel2.png', 'styles':{'position':'absolute','bottom':'0','left':'88px','cursor':'pointer'}, 'events':{'click':function(e){this.nah();}.bind(this)}}).inject(this.options.id);
		
		new Drag.Move(this.outerBox, {handle:this.innerTBox});
		
		this.innerTBox.addEvent('mousedown', function(){
				this.innerTBox.setStyle('cursor','move');								 
			}.bind(this));
			
			this.innerTBox.addEvent('mouseup', function(){
				this.innerTBox.setStyle('cursor','default');								 
			}.bind(this));
			
			this.innerTBox.addEvent('mouseout', function(){
				this.innerTBox.setStyle('cursor','default');								 
			}.bind(this));
	},
	yea: function()
	{
		var newreq = new Request.HTML({
			evalScripts: true,
			evalResponse: true,
			url: ROOT_URL+'php/addToFriend.php',
			method:'post',
			onSuccess: function(html) {
				alert(newreq.response.text);
				this.nah();
				window.location.reload();
			}.bind(this)
		}).send('id='+this.options.tid+'&msg='+$('personalmessagesfr').getProperty('value').substr(0,200));
	},
	nah: function()
	{
		this.outerBox.destroy();
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Create a Pop-Up
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_PopOut = new Class({
	Implements: [Options, Events],
	Binds: ['createPopUp'],
	options: {
		url: null,
		name: null,
		width: 395,
		height: 520
	},
	initialize: function(options){
		this.setOptions(options);
		this.createPopUp();
	},
	createPopUp: function(){
		this.leftValue=(window.getSize().x/2)-(this.options.width/2);
		this.topValue=(window.getSize().y/2)-(this.options.height/2)+30;
		window.open(this.options.url, this.options.name, 'toolbar=0, scrollbars=1, location=0, statusbar=1, menubar=0, resizable=0, width='+this.options.width+', height='+this.options.height+', left='+this.leftValue+', top='+this.topValue);
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Take Deletetion message, display it, fade it out, then remove the element
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_MessageShowFadeDelete = new Class({
	Implements: [Options, Events],
	Binds: ['showIt','fadeIt','deleteIt'],
	options: {
		getHtml: null,
		getElement: null,
		fadeDelay: 3000,
		deleteDelay: 4000
	},
	initialize: function(options){
		this.setOptions(options);
		this.showIt();
	},
	showIt: function(){
		$(this.options.getElement).set('html',this.options.getHtml);
		this.fadeIt.delay(this.options.fadeDelay);
		this.deleteIt.delay(this.options.deleteDelay);
	},
	fadeIt: function(){
		$(this.options.getElement).fade('out');
	},
	deleteIt: function(){
		$(this.options.getElement).destroy();
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: AddEvents to profile elements for inline edit features
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_AddProfileEditEvents = new Class({
	Implements: [Options, Events],
	Binds: ['addAll','removeAll'],
	options: {
		id: null,
		mouseEnterFunction: $empty,
		mouseLeaveFunction: $empty,
		mouseClickFunction: $empty,
		arguments: ['myArg1', 'myArg2'],
		startState: 0
	},
	initialize: function(options){
		this.setOptions(options);
		if($(this.options.id)){
			this.addAll();
		}
	},
	addAll: function(){
		$(this.options.id).addEvents({
			'mouseenter': function(){
				if(this.options.startState===0){
					this.options.mouseEnterFunction.run(this.options.arguments, this);
					this.setOptions({startState: 1});
				}
			}.bind(this),
			'mouseleave': function(){
				if(this.options.startState===1){
					this.options.mouseLeaveFunction.run(this.options.arguments, this);
					this.setOptions({startState: 0});
				}
			}.bind(this),
			'click': function(){
				if(this.options.startState===1){
					this.options.mouseClickFunction.run(this.options.arguments, this);
					this.setOptions({startState: 2});
				}
			}.bind(this)
		});
	},
	removeAll: function(){
		if($(this.options.id)){
			$(this.options.id).removeEvents();
		}
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Rotate ads on the right side of the page
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_AdRotator = new Class({
	Implements: [Options, Events],
	Binds: ['createAds'],
	options: {
		counter: 0
	},
	initialize: function(options){
		this.setOptions(options);
		if($('nmi_body_right'))
		{
		new Element('div').inject('nmi_body_right');
		this.periCall = this.createAds.periodical(60000);
		this.createAds();
		}
	},
	createAds: function(){
		if(this.options.counter<=10 && $('ADid') && $('nmi_body_right') && $$('#nmi_body_right div').length > 0){
			this.callAds = new Request.HTML({
				evalScripts: true,
				evalResponse: true,
				url: 'getads.php?id='+$('ADid').value,
				onSuccess: function(html) {
					$$('#nmi_body_right div').set('html', this.callAds.response.text);
				}.bind(this)
			}).post();
			this.options.counter++;
		}
		else{
			$clear(this.periCall);
		}
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Send Debug Info
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_SendDebugInfo = new Class({
	Implements: [Options, Events],
	Binds: ['sendInfo'],
	options: {
		debugCode: '0',
		extraComment: ''
	},
	initialize: function(options){
		this.setOptions(options);
		this.sendInfo();
	},
	sendInfo: function(){
		this.sendInfoViaAjax = new Request.HTML({
			method: 'post',
			url: 'debugSender.php'}).send('debugCode='+this.options.debugCode+'&browserName='+Browser.Engine.name+'&browserVersion='+Browser.Engine.version+'&flashVersion='+Browser.Plugins.Flash.version+'.'+Browser.Plugins.Flash.build+'&osName='+Browser.Platform.name+'&extraComment='+this.options.extraComment);
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class reinv
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_NewInvite = new Class({
	Implements: [Options, Events],
	Binds: ['buildWindow'],
	options:
	{
		
	},
	initialize: function(options)
	{
		this.setOptions(options);
		if(!$('outertint'))
		{
			this.buildWindow();
		}
	},
	buildWindow: function()
	{
		var a = new Element('div', {'id':'outertint', 'styles':{
			'position':'absolute',
			'background':'#000',
			'opacity':0.7,
			'width':'100%',
			'height':'100%',
			'top':0,
			'left':0,
			'z-index':99999999
		}}).inject(document.getElement('body'));
		
		var b = new Element('div', {'id':'referfriendouter','styles':{
			'width':'600px',
			'position':'absolute',
			'left':'50%',
			'top':'50px',
			'margin':'0 0 0 -300px',
			'background':'#353535',
			'border':'2px solid #565469',
			'font-family':'Arial',
			'z-index':999999999
		}}).inject(document.getElement('body'));

		var c = new Element('div', {'id':'headerforclassherereff','styles':{
			'position':'relative',
			'width':'600px',
			'background':'#0E0E0E',
			'height':'32px',
			'border-bottom':'2px solid #565469',
			'color':'#fff'
		}, 'html':'<h3 style="padding:0 0 0 10px;margin:0;float:left;font-size:14px;font-weight:bold">INVITE YOUR FRIENDS TO JOIN YOU ON <img src="assets/numubusmall.png" style="position:relative;left:2px;top:4px"/></h3><div class="clear"></div>'}).inject(b);
		
		var d = new Element('div', {'id':'toloaditallhere', 'styles':{
			'position':'relative',
			'width':'600px',
			'background':'#353535',
			'color':'#fff'
		}, 'html':'<img src="http://www.numubu.com/assets/loading3.gif" style="display:block;text-align:center;margin:0 auto;width:31px"/>'}).inject(c, 'after');
		
		var e = new Element('div', {'styles':{
			'position':'absolute',
			'right':0,
			'top':'0',
			'width':'18px',
			'height':'17px',
			'cursor':'pointer'
		}, 'html':'<img src="http://www.numubu.com/assets/closetip.png" style="display:block;text-align:center;margin:0 auto;width:18px"/>', 'events':{
			'click': function(){
				a.destroy();
				b.destroy();
			}
		}}).inject(c, 'bottom');
		
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: false,
			url: 'referfriends_new.php',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				d.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	}
});

var NMB_NewWindow = new Class({
	Implements: [Options, Events],
	Binds: ['buildWindow'],
	options:
	{
		headertext: 'IMPORTANT MESSAGE FROM NuMuBu',
		bodytext: '<p>As a full member on NuMuBu, you are entitled to appear in the artist display ads below. However, you will need to upload a profile picture before we begin circulating your ads.</p>'
	},
	initialize: function(options)
	{
		this.setOptions(options);
		if(!$('outertint'))
		{
			this.buildWindow();
		}
	},
	buildWindow: function()
	{
		if(!$('outertint'))
		{
			var a = new Element('div', {'id':'outertint', 'styles':{
				'position':'absolute',
				'background':'#000',
				'opacity':0.7,
				'width':'100%',
				'height':'100%',
				'top':0,
				'left':0,
				'z-index':99999999
			}}).inject(document.getElement('body'));
		}
		else
		{
			var a = $('outertint');
		}
		
		var b = new Element('div', {'id':'referfriendouter','styles':{
			'width':'600px',
			'position':'absolute',
			'left':'50%',
			'top':'50px',
			'margin':'0 0 0 -300px',
			'background':'#353535',
			'border':'2px solid #565469',
			'font-family':'Arial',
			'z-index':999999999
		}}).inject(document.getElement('body'));

		var c = new Element('div', {'id':'headerforclassherereff','styles':{
			'position':'relative',
			'width':'600px',
			'background':'#0E0E0E',
			'height':'32px',
			'border-bottom':'2px solid #565469',
			'color':'#fff'
		}, 'html':'<h3 style="padding:8px 0 0 10px;margin:0;float:left;font-size:14px;font-weight:bold">'+this.options.headertext+'</h3><div class="clear"></div>'}).inject(b);
		
		var d = new Element('div', {'id':'toloaditallhere', 'styles':{
			'position':'relative',
			'width':'600px',
			'background':'#353535',
			'color':'#fff',
			'font-size':'12px'
		}, 'html':'<div style="padding:5px">'+this.options.bodytext+'</div>'}).inject(c, 'after');
		
		var e = new Element('div', {'styles':{
			'position':'absolute',
			'right':0,
			'top':'0',
			'width':'18px',
			'height':'17px',
			'cursor':'pointer'
		}, 'html':'<img src="http://www.numubu.com/assets/closetip.png" style="display:block;text-align:center;margin:0 auto;width:18px"/>', 'events':{
			'click': function(){
				a.destroy();
				b.destroy();
			}
		}}).inject(c, 'bottom');
	}
});

var NMB_ConfirmNew = new Class({
	Implements: [Options, Events],
	Binds: ['buildWindow'],
	options:
	{
		url: '',
		headertext: '',
		texttoshow: ''
	},
	initialize: function(options)
	{
		this.setOptions(options);
		if(!$('confirmboxout'))
		{
			this.buildWindow();
		}
	},
	buildWindow: function()
	{
		var a = new Element('div', {'id':'confirmboxout', 'styles':{
			'position':'absolute',
			'background':'#000',
			'opacity':0.7,
			'width':'100%',
			'height':'100%',
			'top':0,
			'left':0,
			'z-index':99999999
		}}).inject(document.getElement('body'));
		
		var b = new Element('div', {'id':'confirmboxoutouter','styles':{
			'width':'600px',
			'position':'absolute',
			'left':'50%',
			'top':'50px',
			'margin':'0 0 0 -300px',
			'background':'#353535',
			'border':'2px solid #565469',
			'font-family':'Arial',
			'z-index':999999999
		}}).inject(document.getElement('body'));

		var c = new Element('div', {'id':'confirmboxoutouter2','styles':{
			'position':'relative',
			'width':'600px',
			'background':'#0E0E0E',
			'height':'32px',
			'border-bottom':'2px solid #565469',
			'color':'#fff'
		}, 'html':'<h3 style="padding:10px 0 0 10px;margin:0;float:left;font-size:14px;font-weight:bold">'+this.options.headertext+'</h3><div class="clear"></div>'}).inject(b);
		
		var d = new Element('div', {'id':'toloaditallhere', 'styles':{
			'position':'relative',
			'width':'600px',
			'background':'#353535',
			'color':'#fff'
		}, 'html':'<p style="padding:10px">'+this.options.texttoshow+'</p><div style="text-align:center;background:#0E0E0E;border-top:2px solid #565469;padding:10px 0 6px"> <img src="assets/newyes.jpg" style="cursor:pointer;border:0;margin:0 15px 0 0" width="84" height="18" onclick="if($(\'sttus\')){Cookie.write(\'savedstatus\', $(\'sttus\').getProperty(\'value\'));}window.location=\''+this.options.url+'\'"/> <img src="assets/newno.jpg" style="cursor:pointer;border:0;margin:0 15px 0 0" width="84" height="18" onclick="$(\'confirmboxout\').destroy();$(\'confirmboxoutouter\').destroy();"/></div> </div> '}).inject(c, 'after');
		
		var e = new Element('div', {'styles':{
			'position':'absolute',
			'right':0,
			'top':'0',
			'width':'18px',
			'height':'17px',
			'cursor':'pointer'
		}, 'html':'<img src="http://www.numubu.com/assets/closetip.png" style="display:block;text-align:center;margin:0 auto;width:18px"/>', 'events':{
			'click': function(){
				a.destroy();
				b.destroy();
			}
		}}).inject(c, 'bottom');

	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class first login.
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var FirstLogin = new Class({
	Implements: [Options, Events],
	Binds: ['buildWindow'],
	options:
	{
		fb: true,
		ms: true
	},
	initialize: function(options)
	{
		this.setOptions(options);
		if(!$('outertint'))
		{
			this.buildWindow();
		}
	},
	buildWindow: function()
	{
		var a = new Element('div', {'id':'outertint', 'styles':{
			'position':'absolute',
			'background':'#000',
			'opacity':0.7,
			'width':'100%',
			'height':'100%',
			'top':0,
			'left':0,
			'z-index':99999999
		}}).inject(document.getElement('body'));
		
		var b = new Element('div', {'id':'bigboxfbmsimp','styles':{
			'width':'600px',
			'position':'absolute',
			'left':'50%',
			'top':'50px',
			'margin':'0 0 0 -300px',
			'background':'#353535',
			'border':'2px solid #565469',
			'font-family':'Arial',
			'z-index':999999999
		}}).inject(document.getElement('body'));
		
		var extrastr = 'CHOOSE YOUR INFO FROM ';
		var dontcont = false;
		if(this.options.fb === true)
		{
			extrastr += '<img src="assets/facebook2.png" style="position:relative;left:54px;top:4px"/>';
			
			if(this.options.ms === true)
			{
				extrastr += '<span style="position:relative;left:161px;top:4px"><img src="assets/myspace2.png" /></span>';
				dontcont = true;
			}
		}
		
		if(this.options.ms === true && dontcont === false)
		{
			extrastr += '<img src="assets/myspace2.png" style="position:relative;left:54px;top:4px"/>';
		}

		var c = new Element('div', {'styles':{
			'position':'relative',
			'width':'600px',
			'background':'#0E0E0E',
			'height':'32px',
			'border-bottom':'2px solid #565469',
			'color':'#fff'
		}, 'html':'<h3 style="padding:0 0 0 10px;margin:0;float:left;font-size:14px;font-weight:bold">'+extrastr+'</h3><div class="clear"></div>'}).inject(b);
		
		var d = new Element('div', {'styles':{
			'position':'relative',
			'width':'600px',
			'background':'#353535',
			'color':'#fff'
		}, 'html':'<img src="http://www.numubu.com/assets/loading3.gif" style="display:block;text-align:center;margin:0 auto;width:31px"/>'}).inject(c, 'after');
		
		var e = new Element('div', {'styles':{
			'position':'absolute',
			'right':0,
			'top':'0',
			'width':'18px',
			'height':'17px',
			'cursor':'pointer'
		}, 'html':'<img src="http://www.numubu.com/assets/closetip.png" style="display:block;text-align:center;margin:0 auto;width:18px"/>', 'events':{
			'click': function(){
				a.destroy();
				b.destroy();
			}
		}}).inject(c, 'bottom');
		
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: false,
			url: 'getlaststep.php',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				d.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Function: load up an ad info section
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
function goToAddOnLoad(url)
{
	new Request.HTML({
		noCache: true,
		evalScripts: true,
		evalResponse: true,
		url: url,
		onRequest: function() {
			$('loadadshere').set('html', '<img src="assets/loading.gif" id="mainnavloader"/>');
			$('mainnavloader').src='assets/loading.gif';
		},
		onSuccess: function(html) {
			$('loadadshere').set('html', this.response.text);
			detectUndesirables();
		},
		onCancel: function() {
			alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
			detectUndesirables();
		},
		onException: function() {
			alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
			detectUndesirables();
		},
		onFailure: function() {
			alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
			detectUndesirables();
		}
	}).post();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Tuneography
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_TuneSelect = new Class({
	Implements: [Options, Events],
	Binds: ['stopAtFirst', 'advanceToSecond', 'stopAtSecond', 'advanceToThird', 'stopAtThird'],
	options: {
		tuneQContClass: 'tuneQuestionCont',
		tuneQContId: 'tuneQuestion_',
		yesClass: 'yes',
		noClass: 'no',
		disabledColor: '#454545'
	},
	initialize: function(options){
		this.setOptions(options);
		//collect questions and disable second and third only, at the same time apply click events tof irst questions possible repsonses
		$$('.'+ this.options.tuneQContClass).each(function(el){
			var getTO_Num = el.getProperty('id').substring((this.options.tuneQContId.length));
			el.getChildren('div')[1].setStyle('color', this.options.disabledColor);
			el.getChildren('div')[1].getChildren('a').setStyle('display','none');
			el.getChildren('div')[2].setStyle('color', this.options.disabledColor);
			el.getChildren('div')[2].getChildren('a').setStyle('display','none');
			//------------------->
			el.getChildren('div')[0].getChildren('a.yes')[0].addEvent('click', function(e){
				e.stop();
				var a = getTO_Num;

					this.stopAtFirst(a, el);

			}.bind(this));
			el.getChildren('div')[0].getChildren('a.no')[0].addEvent('click', function(e){
				e.stop();
				var a = getTO_Num;
				if(confirm('Are you sure you "don\'t want" this credit to show-up in your tuneography?'))
				{
					this.advanceToSecond(a, el);
				}
				else
				{
					return false;
				}
			}.bind(this));
		}.bind(this));
	},
	stopAtFirst: function(elId, elRef){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&q=1',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	},
	advanceToSecond: function(elId, elRef){
		elRef.getChildren('div')[0].setStyle('color', this.options.disabledColor);
		elRef.getChildren('div')[0].getChildren('a.yes')[0].setStyle('display','none');
		elRef.getChildren('div')[0].getChildren('a.no')[0].removeEvents('click');
		elRef.getChildren('div')[0].getChildren('a.no')[0].addEvent('click', function(e){e.stop()});
		elRef.getChildren('div')[0].getChildren('a.no')[0].setStyles({'text-decoration':'none', 'cursor':'default', 'outline':'none'});
		new Fx.Tween(elRef.getChildren('div')[1]).start('color', '#fff');
		elRef.getChildren('div')[1].getChildren('a').setStyle('display','inline');
		elRef.getChildren('div')[1].getChildren('a.yes')[0].addEvent('click', function(e){
			e.stop();

				this.stopAtSecond(elId, elRef);

		}.bind(this));
		elRef.getChildren('div')[1].getChildren('a.no')[0].addEvent('click', function(e){
			e.stop();
			if(confirm('Are you sure you "don\'t want" this credit to show-up as a link to you in their tuneography?'))
			{
				this.advanceToThird(elId, elRef);
			}
			else
			{
				return false;
			}
		}.bind(this));
	},
	stopAtSecond: function(elId, elRef){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&q=2',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	},
	advanceToThird: function(elId, elRef){
		elRef.getChildren('div')[1].setStyle('color', this.options.disabledColor);
		elRef.getChildren('div')[1].getChildren('a.yes')[0].setStyle('display','none');
		elRef.getChildren('div')[1].getChildren('a.no')[0].removeEvents('click');
		elRef.getChildren('div')[1].getChildren('a.no')[0].addEvent('click', function(e){e.stop()});
		elRef.getChildren('div')[1].getChildren('a.no')[0].setStyles({'text-decoration':'none', 'cursor':'default', 'outline':'none'});
		new Fx.Tween(elRef.getChildren('div')[2]).start('color', '#fff');
		elRef.getChildren('div')[2].getChildren('a').setStyle('display','inline');
		elRef.getChildren('div')[2].getChildren('a.yes')[0].addEvent('click', function(e){
			e.stop();
			
				this.stopAtThird(elId, elRef, true);

		}.bind(this));
		elRef.getChildren('div')[2].getChildren('a.no')[0].addEvent('click', function(e){
			e.stop();
			if(confirm('Are you sure you "don\'t want" this credit to show-up their tuneogrpahy with no link to you?'))
			{
				this.stopAtThird(elId, elRef, false);
			}
			else
			{
				return false;
			}
		}.bind(this));
	},
	stopAtThird: function(elId, elRef, tf){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&q=3&tf='+tf,
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	}
});
/*******************************************************************************************************************************************************/
var NMB_TuneSelectTwo = new Class({
	Implements: [Options, Events],
	Binds: ['stopAtFirst', 'advanceToSecond', 'stopAtSecond', 'advanceToThird', 'stopAtThird'],
	options: {
		tuneQContClass: 'tuneQuestionContTwo',
		tuneQContId: 'tuneQuestionTwo_',
		yesClass: 'yes',
		noClass: 'no',
		disabledColor: '#454545'
	},
	initialize: function(options){
		this.setOptions(options);
		//collect questions and disable second and third only, at the same time apply click events tof irst questions possible repsonses
		$$('.'+ this.options.tuneQContClass).each(function(el){
			var getTO_Num = el.getProperty('id').substring((this.options.tuneQContId.length));
			el.getChildren('div')[1].setStyle('color', this.options.disabledColor);
			el.getChildren('div')[1].getChildren('a').setStyle('display','none');
			el.getChildren('div')[2].setStyle('color', this.options.disabledColor);
			el.getChildren('div')[2].getChildren('a').setStyle('display','none');
			//------------------->
			el.getChildren('div')[0].getChildren('a.yes')[0].addEvent('click', function(e){
				e.stop();
				var a = getTO_Num;
				if(confirm('Are you sure you want to DELETE this credit from showing-up in your tuneography?'))
				{
					this.advanceToSecond(a, el);
				}
				else
				{
					return false;
				}
			}.bind(this));
			el.getChildren('div')[0].getChildren('a.no')[0].addEvent('click', function(e){
				e.stop();
				var a = getTO_Num;

					this.stopAtFirst(a, el);

			}.bind(this));
		}.bind(this));
	},
	stopAtFirst: function(elId, elRef){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&d=1',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	},
	advanceToSecond: function(elId, elRef){
		elRef.getChildren('div')[0].setStyle('color', this.options.disabledColor);
		elRef.getChildren('div')[0].getChildren('a.yes')[0].setStyle('display','none');
		elRef.getChildren('div')[0].getChildren('a.no')[0].removeEvents('click');
		elRef.getChildren('div')[0].getChildren('a.no')[0].addEvent('click', function(e){e.stop()});
		elRef.getChildren('div')[0].getChildren('a.no')[0].setStyles({'text-decoration':'none', 'cursor':'default', 'outline':'none'});
		new Fx.Tween(elRef.getChildren('div')[1]).start('color', '#fff');
		elRef.getChildren('div')[1].getChildren('a').setStyle('display','inline');
		elRef.getChildren('div')[1].getChildren('a.yes')[0].addEvent('click', function(e){
			e.stop();
			if(confirm('Are you sure you want to DELETE this credit from showing-up as a link to you in their tuneography?'))
			{
				this.advanceToThird(elId, elRef);
			}
			else
			{
				return false;
			}
		}.bind(this));
		elRef.getChildren('div')[1].getChildren('a.no')[0].addEvent('click', function(e){
			e.stop();

				this.stopAtSecond(elId, elRef);

		}.bind(this));
	},
	stopAtSecond: function(elId, elRef){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&d=2',
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	},
	advanceToThird: function(elId, elRef){
		elRef.getChildren('div')[1].setStyle('color', this.options.disabledColor);
		elRef.getChildren('div')[1].getChildren('a.yes')[0].setStyle('display','none');
		elRef.getChildren('div')[1].getChildren('a.no')[0].removeEvents('click');
		elRef.getChildren('div')[1].getChildren('a.no')[0].addEvent('click', function(e){e.stop()});
		elRef.getChildren('div')[1].getChildren('a.no')[0].setStyles({'text-decoration':'none', 'cursor':'default', 'outline':'none'});
		new Fx.Tween(elRef.getChildren('div')[2]).start('color', '#fff');
		elRef.getChildren('div')[2].getChildren('a').setStyle('display','inline');
		elRef.getChildren('div')[2].getChildren('a.yes')[0].addEvent('click', function(e){
			e.stop();
			if(confirm('Are you sure you want to DELETE this credit from their tuneography with no link to you?'))
			{
				this.stopAtThird(elId, elRef, false);
			}
			else
			{
				return false;
			}
		}.bind(this));
		elRef.getChildren('div')[2].getChildren('a.no')[0].addEvent('click', function(e){
			e.stop();

				this.stopAtThird(elId, elRef, true);

		}.bind(this));
	},
	stopAtThird: function(elId, elRef, tf){
		new Request.HTML({
			noCache: true,
			evalScripts: true,
			evalResponse: true,
			url: 'php/tune.php',
			data: 'id='+elId+'&d=3&tf='+tf,
			onRequest: function() {
				
			},
			onSuccess: function(html) {
				elRef.set('html', this.response.text);
				detectUndesirables();
			},
			onCancel: function() {
				alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
				detectUndesirables();
			},
			onException: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			},
			onFailure: function() {
				alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
				detectUndesirables();
			}
		}).post();
	}
});
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	Class: Import and invite contacts from hotmail, gmail etc... and also find friends
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var NMB_InviteFriends = new Class({
	Implements: [Options, Events],
	Binds: ['startProcess', 'tryImport', 'trySendInvites', 'trySendFriendRequests'],
	options: {
		thisIs: 0
	},
	atStep: 0,
	initialize: function(options)
	{
		this.setOptions(options);
		this.startProcess();
	},
	startProcess: function()
	{
		if(!$('importContCont'))
		{
			var htmlForHeader = '<h3 style="color:#fff;font-size:14px;font-weight:bold;padding:6px 0 0 10px;margin:0;">INVITE YOUR FRIENDS TO JOIN YOU ON <img src="assets/smallnumubu.png" style="margin-left:1px"/></h3>';
			this.outerBox	=	new Element('div', {'id':'importContCont','styles':{'left':($('nmi_body').getPosition().x+400).toInt()}}).inject(document.body);
			this.innerTBox	=	new Element('div', {'id':'importinnerTopContCont', 'html': htmlForHeader}).inject(this.outerBox);
			this.closeBox	=	new Element('div', {'id':'importinnerTopClose', 'html':'<img src="assets/closetip.png"/>'}).inject(this.innerTBox);
			this.innerMBox	=	new Element('div', {'id':'importinnerMBox','html':'<img src="assets/loading3.gif"/>'}).inject(this.outerBox);

			new Request.HTML({
				noCache: true,
				evalScripts: true,
				evalResponse: true,
				method:'post',
				data: 'step1=1',
				url: 'invitef1.php',
				onRequest: function()
				{
					if($('LOGININVITEFORMLOADING'))
					{
						$('LOGININVITEFORMLOADING').setStyle('display','block');
					}
				},
				onSuccess: function(a,b,html)
				{
					if($('LOGININVITEFORMLOADING'))
					{
						$('LOGININVITEFORMLOADING').setStyle('display','none');
					}
					$('importinnerMBox').set('html', html);
					this.tryImport();
					this.trySendInvites();
					detectUndesirables();
				}.bind(this),
				onCancel: function()
				{
					alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
					detectUndesirables();
				},
				onException: function()
				{
					alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
					detectUndesirables();
				},
				onFailure: function()
				{
					alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
					detectUndesirables();
				}
			}).send();
			
			this.innerTBox.addEvent('mousedown', function(){
				this.innerTBox.setStyle('cursor','move');								 
			}.bind(this));
			
			this.innerTBox.addEvent('mouseup', function(){
				this.innerTBox.setStyle('cursor','default');								 
			}.bind(this));
			
			this.innerTBox.addEvent('mouseout', function(){
				this.innerTBox.setStyle('cursor','default');								 
			}.bind(this));
		
			this.closeBox.addEvent('click', function(e){
				e.stop();
				this.outerBox.destroy();
			}.bind(this));
			
			new Drag.Move(this.outerBox, {handle:this.innerTBox});
		}
	},
	tryImport: function()
	{
		if($('LOGININVITEFORM'))
		{
			$('LOGININVITEFORM').addEvent('submit',function(e){
				e.stop();
				$('LOGININVITEFORM').removeEvents();
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					method:'post',
					data: $('LOGININVITEFORM').toQueryString()+'&step2=1',
					url: 'invitef1.php',
					onRequest: function()
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','block');
						}
					},
					onSuccess: function(a,b,html)
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','none');
						}
						$('importinnerMBox').set('html', html);
						this.tryImport();
						this.trySendInvites();
						detectUndesirables();
					}.bind(this),
					onCancel: function()
					{
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).send();
			}.bind(this));
		}
		if($('PICKUPSECONDSUBMIT'))
		{
			$('PICKUPSECONDSUBMIT').addEvent('click', function(e){
				e.stop();
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					method:'post',
					data: $('LOGININVITEFORM').toQueryString()+'&stepstar=1',
					url: 'invitef1.php',
					onRequest: function()
					{
						if($('LOGININVITEFORMLOADING2'))
						{
							$('LOGININVITEFORMLOADING2').setStyle('display','block');
						}
					},
					onSuccess: function(a,b,html)
					{
						if($('LOGININVITEFORMLOADING2'))
						{
							$('LOGININVITEFORMLOADING2').setStyle('display','none');
						}
						if(html.substr(40) == 'u.')
						{
							alert('Your Invitiations have been sent.');
						}
						else
						{
							alert('You must select members to send friend requests to.');
						}
					}.bind(this),
					onCancel: function()
					{
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).send();
			});
		}
	},
	trySendInvites: function()
	{
		if($('LOGININVITEFORMIMPORTED'))
		{
			$('INVITESKIPONE').addEvent('click', function(e){
				e.stop();
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					method:'post',
					data: 'step3=1',
					url: 'invitef1.php',
					onRequest: function()
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','block');
						}
					},
					onSuccess: function(a,b,html)
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','none');
						}
						$('importinnerMBox').set('html', html);
						this.trySendFriendRequests();
						detectUndesirables();
					}.bind(this),
					onCancel: function()
					{
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).send();
			}.bind(this));
			$('LOGININVITEFORMIMPORTED').addEvent('submit',function(e){
				e.stop();
				$('LOGININVITEFORMIMPORTED').removeEvents();
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					method:'post',
					data: $('LOGININVITEFORMIMPORTED').toQueryString()+'&step3=1',
					url: 'invitef1.php',
					onRequest: function()
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','block');
						}
					},
					onSuccess: function(a,b,html)
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','none');
						}
						$('importinnerMBox').set('html', html);
						this.tryImport();
						this.trySendInvites();
						this.trySendFriendRequests();
						detectUndesirables();
					}.bind(this),
					onCancel: function()
					{
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).send();
			}.bind(this));
		}
	},
	trySendFriendRequests: function()
	{
		if($('LOGININVITEFORMFRIENDRE'))
		{
			$('INVITESKIPTWO').addEvent('click', function(e){
				e.stop();
				$('importContCont').destroy();
			}.bind(this));
			$('LOGININVITEFORMFRIENDRE').addEvent('submit',function(e){
				e.stop();
				
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					method:'post',
					data: $('LOGININVITEFORMFRIENDRE').toQueryString()+'&step4=1',
					url: 'invitef1.php',
					onRequest: function()
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','block');
						}
					},
					onSuccess: function(a,b,html)
					{
						if($('LOGININVITEFORMLOADING'))
						{
							$('LOGININVITEFORMLOADING').setStyle('display','none');
						}
						if(html.length >= 51)
						{
							alert('Your friend requests have been sent!');
							$('LOGININVITEFORMFRIENDRE').removeEvents();
							$('importContCont').destroy();
						}
						else
						{
							alert('You must select members to send friend requests to.');
						}
						
						detectUndesirables();
					}.bind(this),
					onCancel: function()
					{
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function()
					{
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).send();
			}.bind(this));
		}
		if($$('div.possibleFriendRec').length > 0)
		{
			$$('div.possibleFriendRec').each(function(el){
				el.addEvent('click', function(e){
					e.stop();
					if(el.getChildren('div.innerpfr')[0].getChildren('input.checks')[0].getProperty('checked') === true || el.getChildren('div.innerpfr')[0].getChildren('input.checks')[0].getProperty('checked') == "checked")
					{
						el.getChildren('div.innerpfr')[0].getChildren('input.checks')[0].removeProperty('checked');
						el.setStyle('background','#111');
					}
					else
					{
						el.getChildren('div.innerpfr')[0].getChildren('input.checks')[0].setProperty('checked', 'checked');
						el.setStyle('background','#666666');
					}
				});
			});
			$$('div.possibleFriendRec input.checks').setStyles({'position':'absolute','top':'-9999px'});
		}
	}
});
function fbShare()
{
	if (!window.FB) {FB = {};} if(!FB.dynData) { FB.dynData = {"site_vars":{"canvas_client_compute_content_size_method":1,"use_postMessage":0,"use_xdProxy":0,"use_ui_server":1,"monitor_usage_regex":"somethingtoputhere.com|huffingtonpost.com|lala.com","monitor_usage_rate":0.05,"enable_custom_href":1},"ui_server_dialogs":{"bookmark.add":1,"friends.add":1},"resources":{"base_url_format":"http:\/\/{0}.facebook.com\/","base_cdn_url":"http:\/\/static.ak.fbcdn.net\/","api_channel":1271175547,"api_server":1271175547,"www_channel":1271175349,"xd_proxy":1271175062,"xd_comm_swf_url":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z6D2S\/hash\/c729bxo3.swf","share_button":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z1NNP\/hash\/4273uaqa.png","login_img_dark_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zATAA\/hash\/a969rwcd.png","login_img_dark_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zI08N\/hash\/156b4b3s.png","login_img_dark_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zDFXV\/hash\/85b5jlja.png","login_img_dark_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zHW0N\/hash\/a22m3ibb.png","login_img_dark_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zC8F0\/hash\/8mzymam2.png","login_img_light_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z68PZ\/hash\/8t35mjql.png","login_img_light_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zEV10\/hash\/6ad3z8m6.png","login_img_light_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z7T3O\/hash\/4li2k73z.png","login_img_light_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zEYEC\/hash\/7e3mp7ee.png","login_img_light_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z1RA7\/hash\/8rc0izvz.png","login_img_white_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z79GY\/hash\/di0gkqrt.png","login_img_white_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zDTB7\/hash\/cdozw38w.png","login_img_white_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z6AST\/hash\/338d3m67.png","login_img_white_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z6FD4\/hash\/8yzn0wu3.png","login_img_white_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z5V8V\/hash\/5pwowlag.png","logout_img_small":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z68NS\/hash\/cxrz4k7j.png","logout_img_medium":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/zATSY\/hash\/4lsqsd7l.png","logout_img_large":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/z8P0T\/hash\/4515xk7j.png"}};} if (!FB.locale) {FB.locale = "en_US";} if (!FB.localeIsRTL) {FB.localeIsRTL = false;}


window.FB={};if(!window.FB.Share){FB.Share={results:{},resetUrls:function(){this.urls={};this.urlsA=[];},addQS:function(d,c){var a=[];for(var b in c)if(c[b])a.push(b.toString()+'='+encodeURIComponent(c[b]));return d+'?'+a.join('&');},getUrl:function(a){return a.getAttribute('share_url')||window.location.href;},getType:function(a){return a.getAttribute('type')||'button_count';},pretty:function(a){return a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);},updateButton:function(a){var b=this.getUrl(a);if(this.results[b])a.fb_count=this.results[b].total_count;this.displayBox(a,3);},displayBox:function(a,d){if(typeof(a.fb_count)=='number'&&a.fb_count>=d)for(var c=1;c<=2;c++){var b=a.firstChild.childNodes[c];b.className=b.className.replace('fb_share_no_count','');if(c==2)b.lastChild.innerHTML=this.pretty(a.fb_count);}},renderButton:function(c){var j=this.getUrl(c);var g=this.getType(c);var h=c.innerHTML.length>0?c.innerHTML:'Share';c.href=this.addQS('http://www.facebook.com/sharer.php',{u:j,t:j==window.location.href?document.title:null,src:'sp'});c.onclick=function(){if(!c.fb_clicked){c.fb_count+=1;FB.Share.displayBox(this,1);c.fb_clicked=true;}window.open(c.href,'sharer','toolbar=0,status=0,width=626,height=436');return false;},c.style.textDecoration='none';if(!this.results[j]&&(g.indexOf('count')>=0)){this.urls[j]=true;this.urlsA.push(j);}var i='Small';var a='<span class=\'FBConnectButton FBConnectButton_'+i+'\''+' style=\'cursor:pointer;\'>'+'<span class=\'FBConnectButton_Text\'>'+h+'</span></span>';if(g.indexOf('count')>=0){var e=(g=='box_count');var f=(e?'top':'right');var d='<span class=\'fb_share_size_'+i+' '+(e?'fb_share_count_wrapper':'')+'\'>';var b='<span class=\'fb_share_count_nub_'+f+' fb_share_no_count\'></span>';b+='<span class=\'fb_share_count fb_share_no_count'+' fb_share_count_'+f+'\'>'+'<span class=\'fb_share_count_inner\'>&nbsp;</span></span>';d+=(e)?'<span></span>'+b+a:a+b;}else if(g.indexOf('icon')>=0){var d='<span class=\'FBConnectButton_Simple\'>'+'<span class=\'FBConnectButton_Text_Simple\'>'+(g=='icon_link'?h:'&#xFEFF;')+'</span>';}else var d=a;c.innerHTML=d;c.fb_rendered=true;},insert:function(a){(document.getElementsByTagName('HEAD')[0]||document.body).appendChild(a);},renderAll:function(d){var c=document.getElementsByName('fb_share');var a=c.length;for(var b=0;b<a;b++){if(!c[b].fb_rendered)this.renderButton(c[b]);if(this.getType(c[b]).indexOf('count')>=0&&!c[b].fb_count&&this.results[this.getUrl(c[b])])this.updateButton(c[b]);}},fetchData:function(){var a=document.createElement('script');a.src=this.addQS('http://api.ak.facebook.com/restserver.php',{v:'1.0',method:'fql.query',query:"select url, total_count"+" from link_stat where url in ('"+this.urlsA.join("','")+"')",format:'json',callback:'fb_sharepro_render'});this.resetUrls();this.insert(a);},stopScan:function(){clearInterval(FB.Share.scanner);FB.Share.renderPass();},renderPass:function(){FB.Share.renderAll();if(FB.Share.urlsA.length>0)FB.Share.fetchData();},_onFirst:function(){var a=document.createElement('link');a.rel='stylesheet';a.type='text/css';a.href='http://static.ak.fbcdn.net/connect.php/css/share-button-css';this.insert(a);this.resetUrls();window.fb_sharepro_render=function(b){for(var c=0;b&&c<b.length;c++)FB.Share.results[b[c].url]=b[c];FB.Share.renderAll();};this.renderPass();this.scanner=setInterval(FB.Share.renderPass,700);if(window.attachEvent){window.attachEvent("onload",FB.Share.stopScan);}else window.addEventListener("load",FB.Share.stopScan,false);}};FB.Share._onFirst();}

if (FB && FB.Loader) { FB.Loader.onScriptLoaded(["FB.Share","FB.SharePro"]); }
}
/*******************************************************************************************************************************************************/
var NMB_ToolsMenu = new Class({
	Implements: [Options, Events],
	Binds: ['hideallbut','hideallbut2'],
	options: 
	{

	},
	initialize: function(options){
		this.setOptions(options);
		
		this.getMainsections = $$('#nmi_checker_id_only_on_profile_2 div.toolsection');
		this.getSubSections = $$('#nmi_checker_id_only_on_profile_2 div.toolsection div.subsectiontomain');
		
		this.getMainsections.each(function(el){
			var subsec = el.getElement('div.subsectiontomain');
			var mainanch = el.getElement('a.maintitle');
			mainanch.addEvent('click', function(e){
				e.stop();
				var nextsec = mainanch.getNext('div.subsectiontomain');
				if(nextsec.getStyle('display') !== 'block')
				{
					this.hideallbut();
					mainanch.setStyle('background', '#393939');
					mainanch.getElement('img').setProperty('src', 'http://www.numubu.com/assets/whitearrowdown.png');
					nextsec.setStyle('display','block');
				}
				else
				{
					mainanch.setStyle('background', 'transparent');
					mainanch.getElement('img').setProperty('src', 'http://www.numubu.com/assets/whitearrowright.png');
					nextsec.setStyle('display','none');
				}
			}.bind(this));
		}.bind(this));
		
		this.getSubSections.getElements('a.subanchor').each(function(el2){
					el2.addEvent('click', function(e){
						e.stop();
						var el2 = this;
						if(!el2.hasClass('ignore'))
						{
						$$('#nmi_checker_id_only_on_profile_2 div.toolsection div.subsectiontomain').each(function(el){
			el.getElements('a.subanchor').each(function(els){
				els.setStyle('background','transparent');
				els.removeClass('activated');
			});
		});
						el2.setStyle('background', '#7a7a7a');
						}
						
						if(el2.hasClass('nmb') && el2.hasClass('activated') === false)
						{
							el2.addClass('activated');
							
							if($('inboxcontainer').getStyle('display')=="block")
							{
								$('inboxcontainer').setStyle('display','none');
								$('nmi_artistinfo').setStyle('display','block');
								$('nmi_profilecontent').setStyle('display','block');
							}
				
							if(el2.hasClass('music'))
							{
								$('playercontainer').setStyle('top', '0px');
								$('nmi_inner_profilecontent').setStyle('display', 'none');
								createFX();
								getDoSize();
							}
							else
							{
								$('playercontainer').setStyle('top', '-3000px');
								$('nmi_inner_profilecontent').setStyle('display', 'block');
								new Request.HTML({
									noCache: true,
									evalScripts: true,
									evalResponse: true,
									url: el2.getProperty('href'),
									onRequest: function() {
										$('nmi_inner_profilecontent').set('html', '<div class="loading1"><img src="assets/loading.gif"/></div>');
										createFX();
									},
									onSuccess: function(html) {
										$('nmi_inner_profilecontent').set('html', this.response.text);
										detectUndesirables();
										getDoSize.delay(800);
									},
									onCancel: function() {
										$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load this page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
										getDoSize();
										detectUndesirables();
									},
									onException: function() {
										$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the this page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
										getDoSize();
										detectUndesirables();
									},
									onFailure: function() {
										$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the this page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
										getDoSize();
										detectUndesirables();
									}
								}).post();
							}
						}
						else if(el2.hasClass('notnmb'))
						{
							window.location = el2.getProperty('href');
						}
						else
						{
							return false;
						} 
					});
				}.bind(this));
	},
	hideallbut: function()
	{
		this.getSubSections.each(function(el){
			el.setStyle('display','none');
			el.getPrevious('a.maintitle').setStyle('background', 'transparent');
			el.getPrevious('a.maintitle').getElement('img').setProperty('src', 'http://www.numubu.com/assets/whitearrowright.png');
		});
	},
	hideallbut2: function()
	{
		this.getSubSections.each(function(el){
			el.getElements('a.subanchor').each(function(els){
				els.setStyle('background','transparent');
				els.removeClass('activated');
			});
		});
	}
});
var LIVEFXVAR = null;
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	DomReady functions
*/
//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
var newFormCheck = null;
window.addEvent('domready', function(){

	if(!$('myRadioPage')){new NMB_AdRotator()}
	if($('loadadshere')){
		$$('#alltheadslinks a').each(function(el){
			el.addEvent('click', function(e){
				e.stop();
				var linkTo = this.getProperty('href');
				var getTitle = this.getProperty('title');
				new Request.HTML({
					noCache: true,
					evalScripts: true,
					evalResponse: true,
					url: linkTo,
					onRequest: function() {
						$('loadadshere').set('html', '<img src="assets/loading.gif" id="mainnavloader"/>');
						$('mainnavloader').src='assets/loading.gif';
					},
					onSuccess: function(html) {
						$('loadadshere').set('html', this.response.text);
						runNowPlease();
						detectUndesirables();
					},
					onCancel: function() {
						alert('There was an error while processing your request. You, your browser or your ISP cancelled the connection to our server. Try again.');
						detectUndesirables();
					},
					onException: function() {
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					},
					onFailure: function() {
						alert('There was an error while processing your request. We are working on this issue and it should be resolved soon.');
						detectUndesirables();
					}
				}).post();
			});
		});
	}
	//if it is the profile, attach events to navigation
	if($('nmi_checker_id_only_on_profile')) {
		$$('#nmi_checker_id_only_on_profile a').each(function(el){
			if(el.get('rel')!="#ignore"){
			el.addEvent('click', function(e) {
				if(typeof e !== 'undefined')
				{
					e.stop();
				}
				if($('inboxcontainer').getStyle('display')=="block"){
					$('inboxcontainer').setStyle('display','none');
					$('nmi_artistinfo').setStyle('display','block');
					$('nmi_profilecontent').setStyle('display','block');
				}
				var linkTo = this.getProperty('href');
				var getTitle = this.getProperty('title');
				$$('#nmi_checker_id_only_on_profile a').removeClass('act');
				this.addClass('act');
				$('nmi_body_left_right').removeClass('overflowHidden');
				$('nmi_body_left_right').setStyle('overflow-y','scroll');
				$('dacontent').removeClass('width530');
				if(linkTo=="isMusic"){
					$('playercontainer').setStyle('top', '0px');
					$('nmi_inner_profilecontent').setStyle('display', 'none');
					createFX();
					getDoSize();
				}
				else{
					$('playercontainer').setStyle('top', '-3000px');
					$('nmi_inner_profilecontent').setStyle('display', 'block');
					new Request.HTML({
						noCache: true,
						evalScripts: true,
						evalResponse: true,
						url: linkTo,
						onRequest: function() {
							$('nmi_inner_profilecontent').set('html', '<div class="loading1"><img src="assets/loading.gif"/></div>');
							createFX();
						},
						onSuccess: function(html) {
							$('nmi_inner_profilecontent').set('html', this.response.text);
							detectUndesirables();
							getDoSize.delay(800);
						},
						onCancel: function() {
							$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">A cancel error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
							getDoSize();
							detectUndesirables();
						},
						onException: function() {
							$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An exception error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
							getDoSize();
							detectUndesirables();
						},
						onFailure: function() {
							$('nmi_inner_profilecontent').set('html', '<div class="error1"><img src="assets/error.jpg"/></div><div class="error2">An error occured while trying to load the "'+ getTitle +'" page.<br/>We are working on this issue and it should be resolved shortly.<br/>Try again.</div>');
							getDoSize();
							detectUndesirables();
						}
					}).post();
				}
			});
			}
		});
		getDoSize();
	}
	if($('nmi_checker_id_only_on_profile_2')) {
		
			new NMB_ToolsMenu();
		
	}
	if($('sufnmi')){
		newFormCheck = new FormCheck('sufnmi');	
	}
if($('anchor_live'))
{
	LIVEFXVAR = new Fx.Tween('anchor_live');
	livefuncblinker(true);
}	
});

//------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/*
	End of file
*/