/*
	Multifaceted Lightbox
	by Greg Neustaetter - http://www.gregphoto.net
	
	INSPIRED BY (AND CODE TAKEN FROM)
	==================================
	The Lightbox Effect without Lightbox
	PJ Hyett
	http://pjhyett.com/articles/2006/02/09/the-lightbox-effect-without-lightbox
	

	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensend under:
	Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
	
*/

var Lightbox = {

	show : function(href) {
		$('#box').css('width','740px');
		$.post(href, {}, function(data){$("#boxcontent").html(data)});
		this.center('box','100');
		$('html,body').animate({scrollTop:0});
		return false;
	},

	div : function(id,width) {
		$('#box').css('width',width+'px');
		$("#boxcontent").html($("#"+id).html());
		this.center('box','100');
		$('html,body').animate({scrollTop:0});
		return false;
	},

	micro : function(href) {
		$('#box').css('width','428px');
		$.post(href, {}, function(data){$("#boxcontent").html(data)});
		this.color('box');
		$('html,body').animate({scrollTop:0});
		return false;
	},

	mini : function(href) {
		$('#box').css('width','600px');
		$.post(href, {}, function(data){$("#boxcontent").html(data)});
		this.center('box','100');
		$('html,body').animate({scrollTop:0});
		return false;
	},

	large : function(href) {
		$('#box').css('width','980px');
		$.post(href, {}, function(data){$("#boxcontent").html(data)});
		this.center('box','100');
		$('html,body').animate({scrollTop:0});
		return false;
	},

	hide : function() {
		$('#xoverlay').hide();
		$('#boxcontent').html('<div class="boxtitle">Loading...</div><div class="boxpad"><center><img src="/images/loading-large.gif"></center></div>');
		$('#box').css('width',null);
		$('#box').css('height',null);
		$('#box').hide();
		return false;
	},

	color : function(element,top) {
		var windowSize = this.getPageDimensions();
		var windowWidth  = windowSize[0];
		var left = (windowWidth - $('#'+element).width()) / 2;
		if (!$.browser.msie) left = left - 9;
		left = ( left < 0 ) ? 0 : left;
		left = left - 154;
		$('#'+element).css('position','absolute');
		$('#'+element).css('z-index','3000');
		$('#'+element).css('left',left+'px');
		$('#'+element).css('top','124px');
		$('#'+element).show();
		$('#xoverlay').css('height',$(document).height()+'px');
		$('#xoverlay').show();
	},

	center : function(element) {
		var windowSize = this.getPageDimensions();
		var windowWidth  = windowSize[0];
		var left = (windowWidth - $('#'+element).width()) / 2;
		if (!$.browser.msie) left = left - 9;
		left = ( left < 0 ) ? 0 : left;
		$('#'+element).css('position','absolute');
		$('#'+element).css('z-index','3000');
		$('#'+element).css('left',left+'px');
		$('#'+element).css('top','124px');
		$('#'+element).show();
		$('#xoverlay').css('height',$(document).height()+'px');
		$('#xoverlay').show();
	},

	getPageDimensions : function() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight) {
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		if (yScroll < windowHeight) {
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		if (xScroll < windowWidth) {
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight);
		return arrayPageSize;
	},

	init : function() {
		var lightboxtext  = '<div id="box" style="display:none;">';
			lightboxtext += '	<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';
			lightboxtext += '	<td background="/images/lightbox/top-left.png" width="10" height="10"></td>';
			lightboxtext += '	<td background="images/lightbox/border.png"></td>';
			lightboxtext += '	<td background="images/lightbox/top-right.png" width="10" height="10"></td>';
			lightboxtext += '	</tr><tr>';
			lightboxtext += '	<td background="/images/lightbox/border.png"></td>';
			lightboxtext += '	<td><div id="boxcontent"><div class="boxtitle">Loading...</div><div class="boxpad"><center><img src="/images/loading-large.gif"></center></div></div></td>';
			lightboxtext += '	<td background="/images/lightbox/border.png"></td>';
			lightboxtext += '	</tr><tr>';
			lightboxtext += '	<td background="/images/lightbox/bottom-left.png" width="10" height="10"></td>';
			lightboxtext += '	<td background="/images/lightbox/border.png"></td>';
			lightboxtext += '	<td background="/images/lightbox/bottom-right.png" width="10" height="10"></td>';
			lightboxtext += '	</tr></table>';
			lightboxtext += '</div>';
		$('body').append(lightboxtext);
	}
}

var History = {

	first : true,
	current : null,
	updater : null,

	init: function() {
		History.current = History.getHash();
		if (navigator.appVersion.indexOf('MSIE 7') != -1) {
			$('body').append('<iframe id="history" src="iframe" class="none">');
			if (History.current == '') {
				History.current = 'home';
			}
			History.makeNewHash(History.current);
		} else {
			if (History.current != '') {
				History.ajax(History.current);
			}
			History.updater = setInterval('History.checkHash()', 100);
		}
		History.createReload('menu');
		History.createReload('xfooter');
	},

	logout: function() {
		if (History.updater != null) {
			clearInterval(History.updater);
		}
		window.location.href = 'logout';
	},

	ajax : function(hash) {
		var a = hash.split(/\//g);
		var temp = hash.split('/');
		var urls = ['home','artists','design','multi','pixelroom','generationreservoir','inbox','notifications','account','sell','credit','news','password','error','charts','store','search','invite'];
		var help = ['about','terms','ads','developers','contact','help-member','help-artist','wall','help'];
		var boxs = ['register','pixelroom-vote'];

		$('#loading').show();
		if (jQuery.inArray(temp[0],urls) > -1) {
			if (a.length == 1) {
				hash = temp[0] + '.php';
			} else if (a.length == 2) {
				hash = temp[0] + '.php?m='+temp[1];
			} else if (a.length == 3) {
				hash = temp[0] + '.php?m='+temp[1]+'&n='+temp[2];
			} else if (a.length == 4) {
				hash = temp[0] + '.php?m='+temp[1]+'&n='+temp[2]+'&v='+temp[3];
			} else if (a.length == 5) {
				hash = temp[0] + '.php?m='+temp[1]+'&n='+temp[2]+'&v='+temp[3]+'&c='+temp[4];
			} else if (a.length == 6) {
				hash = temp[0] + '.php?m='+temp[1]+'&n='+temp[2]+'&v='+temp[3]+'&c='+temp[4]+'&x='+temp[5];
			} else {
				hash = temp[0] + '.php';
			}
			if ($('#box').is(":visible")) Lightbox.hide();
			History.request(hash);
		} else if (jQuery.inArray(temp[0],help) > -1) {
			if (a.length == 1) {
				hash = 'help.php?m='+temp[0];
			} else if (a.length == 2) {
				hash = 'help.php?m='+temp[0]+'&n='+temp[1];
			} else if (a.length == 3) {
				hash = 'help.php?m='+temp[0]+'&n='+temp[1]+'&v='+temp[2];
			} else {
				hash = 'help.php';
			}
			if ($('#box').is(":visible")) Lightbox.hide();
			History.request(hash);
		} else if (jQuery.inArray(temp[0],boxs) > -1) {
			if (temp[0] == 'pixelroom-vote') {
				Lightbox.mini("ajax/lightbox.php?m="+temp[0]+"&n="+temp[1]);
			} else if (a.length == 1) {
				Lightbox.show("ajax/lightbox.php?m="+temp[0]);
			} else if (a.length == 2) {
				Lightbox.show("ajax/lightbox.php?m="+temp[0]+"&n="+temp[1]);
			} else if (a.length == 3) {
				Lightbox.show("ajax/lightbox.php?m="+temp[0]+"&n="+temp[1]+"&v="+temp[2]);
			} else if (a.length == 4) {
				Lightbox.show("ajax/lightbox.php?m="+temp[0]+"&n="+temp[1]+"&v="+temp[2]+"&c="+temp[3]);
			}
			$('#loading').fadeOut("slow");	
		} else {
			var actual = History.getHash();
			var temb = actual.split('/');
			if (a.length > 1 && temp[0] == temb[0]) {
				if (temp[1] != 'feed') {
					if (a.length == 2) {
						Lightbox.show("ajax/profilebox.php?m="+temp[0]+"&type="+temp[1]);
					} else if (a.length == 3) {
						Lightbox.show("ajax/profilebox.php?m="+temp[0]+"&type="+temp[1]+"&id="+temp[2]);
					} else if (a.length == 4) {
						Lightbox.show("ajax/profilebox.php?m="+temp[0]+"&type="+temp[1]+"&id="+temp[2]+"&n="+temp[3]);
					}
				}
				var uname = 'home';
				if ($('#sprofile')) {
					uname = $('#sprofile').attr('uname');
				}
				if (temp[1] == 'feed') {
					hash = 'profile.php?m='+temp[0]+'&feed='+temp[2];
					History.request(hash);
					if ($('#box')) Lightbox.hide();
				} else if (temp[0] != uname) {
					hash = 'profile.php?m='+temp[0];
					History.request(hash);
				} else {
					$('#loading').fadeOut("slow");	
				}
			} else {
				$('html,body').animate({scrollTop:0});
				hash = 'profile.php?m='+temp[0];
				if ($('#box')) Lightbox.hide();
				History.request(hash);
			}
		}
	},

	request : function(hash) {
		$.post('ajax/' + hash, {}, function(data){
			$('#loading').fadeOut("slow");
			$.each(data, function(key,value){
				if (key == 'xtitle') {
					document.title = value;
					if (History.first) {
						History.first = false;
					}
				} else if (key == 'xscript') {
					eval(value);
				} else if (key == 'xhash') {
					location.hash = value;
				} else if (key == 'xinbox') {
					$('#xinbox').html(value);
				} else if (key == 'xrequest') {
					$('#xrequest').html(value);
				} else if (key == 'xalert') {
					$('#xalert').html(value);
				} else if (key == 'xshow') {
					var div = value.split(',');
					jQuery.each(div, function() {
						$('#'+this).show();
					});
				} else if (key == 'xhide') {
					var div = value.split(',');
					jQuery.each(div, function() {
						$('#'+this).hide();
					});
				} else {
					$('#'+key).html(value);
					History.createReload(key);
				}
				if (hash == 'home.php' || hash == 'home.php?m=logout') {
					//$('#xad').show();
					$('body').css('background','url("/images/back.png") repeat-x center -295px #FFFFFF');
				} else if (hash == 'generationreservoir.php') {
					//$('#xad').hide();
				} else if (hash.indexOf('profile.php') != -1) {
					//$('#xad').hide();
					$('body').css('background',$('#sprofile').attr('back'));
				} else {
					//$('#xad').show();
					$('body').css('background','url("/images/back.png") repeat-x center -295px #FFFFFF');
				}
			});
		}, "json");
	},

	checkHash : function() {
		var temp = History.getHash();
		if (temp == '') {
			History.ajax('home');
			History.current = 'home';
			window.location.hash = 'home';
		} else if (History.current != temp) {
			History.ajax(temp);
			History.current = temp;
		}
	},

	getHash : function() {
		return window.location.hash.toString().substr(1);
	},

	createReload : function(div) {
		$('#'+div+' a:not(.noreload)').each(function() {
			if (navigator.appVersion.indexOf('MSIE 7') != -1) {
				this.onclick = function() {
					var hash = this.href.split('#');
					History.makeNewHash(hash[1]);
				}
			} else {
				this.onclick = function() {
					History.current = null;
				}
			}
		});
	},

	onFrameLoaded : function(hash) {
		location.hash = hash;
		History.ajax(hash);
	},
	
	makeNewHash : function(newhash) {
		window.location.hash = newhash;
		var doc = document.getElementById("history").contentWindow.document;
		doc.open("javascript:'<html></html>'");
		doc.write("<html><head><scri" + "pt type=\"text/javascript\">parent.History.onFrameLoaded('" + newhash + "');</scri" + "pt></head><body>" + newhash + "</body></html>");
		doc.close();
	}
}

var Dedicate = {

	init : function() {
		var hiddencountry;
		$('#selectcountry').click(function() {
			$('#menucountry').show(); 
		});
		$('#divcountry').mouseout(function() {
			hiddencountry = setTimeout(function(){$('#menucountry').hide();}, 500);
		});
		$('#divcountry').mouseover(function() {
			clearTimeout(hiddencountry);
		});
		$('#menucountry > li').each(function() {
			$(this).click(function() {
				Dedicate.menu('country',$(this).attr('value'),$(this).text());
			});
		});
	},

	menu : function(type, value, text) {
		$('#menu'+type).hide();
		$('#input'+type).val(value);
		$('#select'+type).html(text);
		Dedicate.update(type);
	},

	update : function(type) {
		History.ajax($('#hiddenpage').val()+'/'+type+'/'+$('#input'+type).val());
	},

	odel : function(id) {
		$('#boxrep_'+id).hide();
		$('#boxdel_'+id).toggle();
	},

	del : function(id) {
		Home.ajax('ajax/minibox.php?m=dedicatedelete&n='+id, null);
	},

	orep : function(id) {
		if ($('#boxdel_'+id)) $('#boxdel_'+id).hide();
		$('#boxrep_'+id).toggle();
	},

	rep : function(id) {
		Home.ajax('ajax/minibox.php?m=dedicatereport&n='+id, null);
	},

	send : function() {
		var params = $('#form').serialize();
		Home.ajax('ajax/dedicate.php?m=send', params);
	}
}

var Message = {

	send : function() {
		if ($('#messagem').val() != '') {
			var params = $('#writeform').serialize();
			Home.ajax('ajax/inbox.php?m=send', params);
			$('#writeform').hide();
			$('#writesent').show();
			setTimeout('Lightbox.hide();',1000);
		}
	},

	unread : function(id) {
		var params = 'id='+id;
		Home.ajax('ajax/inbox.php?m=unread', params);
	},

	odel : function(id) {
		$('#boxrep_'+id).hide();
		$('#boxdel_'+id).toggle();
	},

	del : function(id) {
		var params = 'id='+id;
		Home.ajax('ajax/inbox.php?m=delete', params);
	},

	orep : function(id) {
		if ($('#boxdel_'+id)) $('#boxdel_'+id).hide();
		$('#boxrep_'+id).toggle();
	},

	rep : function(id) {
		Home.ajax('ajax/minibox.php?m=messagereport&n='+id, null);
	},

	reply : function() {
		if ($('#messager').val() != '') {
			var params = $('#replyform').serialize();
			Home.ajax('ajax/inbox.php?m=reply', params);
	
			var uname = $('#messagereply').attr('uname');
			var name = $('#messagereply').attr('name');
			var picture = $('#messagereply').attr('picture');
			var time = $('#messagereply').attr('time');
	
			var mess = '<div style="padding-top:5px;">';
			mess += '<div class="fleft width80 thumbnail">';
			mess += '<a href="#'+uname+'">';
			mess += '<img src="'+picture+'" width="75" height="75">';
			mess += '</a>';
			mess += '</div>';
			mess += '<div class="fleft width100 gpadleft"><div class="gpadtop small-txt bold"><a href="#'+uname+'" class="light">'+name+'</a></div><div class="light tiny-txt">'+time+'</div></div>';
			mess += '<div class="fleft width300 mpadleft"><div class="gpadtop small-txt">'+$('#messager').val().replace(/\n/g,'<br />')+'</div></div>';
			mess += '<div class="clear"></div>';
			mess += '<div style="margin-left:200px;margin-top:5px;border-bottom:1px solid #E0E6ED;"></div>';
			mess += '</div>';
	
			$('#messagereply').append(mess);
			$('#messager').val('');
		}
	}
}

var Profile = {

	gpage : 0,
	drag : 1,
	playlistonair : true,

	init : function(visitor) {

	},

	upload : function(url) {
		if (url.search('/')>-1) {
			var newurl = url.split('/');
			History.request('profile.php?m='+newurl[0]);
		}
		History.ajax(url);
	},

	playlistload : function(id) {
		if (Profile.playlistonair) {
			niftyplayer('playlist').load(id);
			$('#playspan_'+id).addClass('pausetiny');
			Profile.playlistonair = false;
		} else {
			niftyplayer('playlist').stop();
			$('#playspan_'+id).removeClass('pausetiny');
			Profile.playlistonair = true;
		}
	},

	newconcert : function() {
		Home.ajax('ajax/comment.php?m=newconcert', null);
	},

	addconcert : function() {
		if ($('#concerttitle').val() != '') {
			var params = $('#concertform').serialize();
			Home.ajax('ajax/comment.php?m=addconcert', params);
		}
	},

	listconcert : function() {
		Home.ajax('ajax/comment.php?m=listconcert', null);
	},

	editconcert : function(id) {
		Home.ajax('ajax/comment.php?m=editconcert&n='+id, null);
	},

	saveconcert : function() {
		if ($('#concerttitle').val() != '') {
			var params = $('#concertform').serialize();
			Home.ajax('ajax/comment.php?m=saveconcert', params);
		}
	},

	affiche : function(id,image) {
		$('#concertpicture').html('<img src='+image+' width="120">');
		$('#concertid').val(id);
	},

	newdisco : function() {
		Home.ajax('ajax/comment.php?m=newdisco', null);
	},

	adddisco : function() {
		if ($('#discotitle').val() != '') {
			var params = $('#discoform').serialize();
			Home.ajax('ajax/comment.php?m=adddisco', params);
		}
	},

	listdisco : function() {
		Home.ajax('ajax/comment.php?m=listdisco', null);
	},

	editdisco : function(id) {
		Home.ajax('ajax/comment.php?m=editdisco&n='+id, null);
	},

	savedisco : function() {
		if ($('#discotitle').val() != '') {
			var params = $('#discoform').serialize();
			Home.ajax('ajax/comment.php?m=savedisco', params);
		}
	},

	affichedisco : function(id,image) {
		$('#discopicture').html('<img src='+image+' width="80">');
		$('#discoid').val(id);
	},

	status : function() {
		var params = $('#statusform').serialize();
		$.post('ajax/comment.php?m=status', params);
		$('#editstatus').hide();
		$('#mystatus').html($('#newstatus').val()).show();
	},

	bio : function() {
		var params = $('#bioform').serialize();
		Home.ajax('ajax/comment.php?m=bio', params);
		$('#editbio').hide();
		$('#mybio').show();
	},

	origin : function(val) {
		Home.ajax('ajax/comment.php?m=origin', 't='+val);
		$('#editorigins').hide();
	},

	label : function(val) {
		Home.ajax('ajax/comment.php?m=label', 't='+val);
		$('#editlabel').hide();
	},

	influence : function(val) {
		Home.ajax('ajax/comment.php?m=influence', 't='+val);
		$('#editinfluences').hide();
	},

	changealbum : function(token,id) {
		var params = 'token='+token+'&id='+id;
		$.post('ajax/comment.php?m=changealbum', params);
	},

	createalbum : function(input) {
		if ($('#'+input).val() != '') {
			var params = 'title='+$('#'+input).val().replace(/&/g,"-----");
			Home.ajax('ajax/comment.php?m=createalbum', params);
		}
	},

	editalbum : function(id,input) {
		if ($('#'+input).val() != '') {
			var params = 'id='+id+'&title='+$('#'+input).val().replace(/&/g,"-----");
			Home.ajax('ajax/comment.php?m=editalbum', params);
		}
	},

	deletealbum : function(id) {
		var params = 'id='+id;
		Home.ajax('ajax/comment.php?m=deletealbum', params);
	},

	links : function(type,val) {
		Home.ajax('ajax/comment.php?m=links', 'type='+type+'&val='+val);
	},

	members : function(type,val) {
		Home.ajax('ajax/comment.php?m=members', 'type='+type+'&val='+val);
	},

	picture : function(hash) {
		$('#profilepicture').attr({src:'photos/'+hash+'.jpg'});
		Lightbox.hide();
	},

	favorite : function(id) {
		Profile.ajax('admirer','add','id='+id);
	},

	remove : function(id) {
		Profile.ajax('admirer','remove','id='+id);
	},

	reorganize : function(id) {
		if (Profile.drag) {
			$('#reorganizephotos').load('ajax/player.php?action=photos&id='+id,{'reorganize':'1'});
			Profile.drag = 0;
		} else {
			Profile.drag = 1;
		}
	},

	photoslider : function() {
		$("#slider").slider({range:"min",min:80,max:230,value:110,animate:true,slide:function(event,ui){Profile.photoresize(ui.value);}});
	},

	photoresize : function(value) {
		if (value < 90) {
			value = 80;
		} else if (value > 100 && value < 120) {
			value = 110;
		} else if (value > 140 && value < 160) {
			value = 150;
		} else if (value > 220) {
			value = 230;
		}
		var divs = $('#allphotos img');
		var divmax = divs.length;
		for(var i=0; i<divmax; i++){
			var imgsrc = $(divs[i]).attr('src');
			if (value > 80 && value <= 110) {
				imgsrc = imgsrc.replace('-h80','-h110');
				imgsrc = imgsrc.replace('-h150','-h110');
				imgsrc = imgsrc.replace('-h230','-h110');
			} else if (value > 110 && value <= 150) {
				imgsrc = imgsrc.replace('-h80','-h150');
				imgsrc = imgsrc.replace('-h110','-h150');
				imgsrc = imgsrc.replace('-h230','-h150');
			} else if (value > 150) {
				imgsrc = imgsrc.replace('-h80','-h230');
				imgsrc = imgsrc.replace('-h110','-h230');
				imgsrc = imgsrc.replace('-h150','-h230');
			} else {
				imgsrc = imgsrc.replace('-h110','-h80');
				imgsrc = imgsrc.replace('-h150','-h80');
				imgsrc = imgsrc.replace('-h230','-h80');
			}
			$(divs[i]).css('height',value+'px');
			$(divs[i]).attr('src',imgsrc);
		}
	},

	ajax : function(page,type,params) {
		Home.ajax('ajax/'+page+'.php?m='+type, params);
	},

	lightbox : function() {
		if ($('#box').is(":visible")) {
			Lightbox.hide();
		} else {
			uname = $('#sprofile').attr('uname');
			History.ajax(uname+'/photos');
		}
	},

	addvideo : function() {
		var video = $('#videourl').val();
		if(video.indexOf("youtube.com/watch?v=")!=-1){
			var temp = video.split('watch?v=');
			if(temp[1].indexOf("&")!=-1){
				var tmp = temp[1].split('&');
				var url = 'http://www.youtube.com/v/'+tmp[0];
			}else{
				var url = 'http://www.youtube.com/v/'+temp[1];
			}
			$('#videourl').val(url);
		} else if (video.indexOf("youtu.be/")!=-1) {
			var temp = video.split('.be/');
			var url = 'http://www.youtube.com/v/'+temp[1];
			$('#videourl').val(url);
		} else if (video.indexOf("vimeo.com/")!=-1) {
			var temp = video.split('.com/');
			var url = 'http://www.vimeo.com/'+temp[1];
			$('#videourl').val(url);
		} else {
			$('#videourl').val('');
		}
	},

	insertvideo : function() {
		var url = $('#videourl').val();
		if (url!='') {
			Home.ajax('ajax/comment.php?m=addvideo&n='+url, null);
		}
	},

	owalldel : function(id) {
		$('#boxwallrep_'+id).hide();
		$('#boxwalldel_'+id).toggle();
	},

	walldel : function(id) {
		Home.ajax('ajax/minibox.php?m=walldelete&n='+id, null);
	},

	owallrep : function(id) {
		if ($('#boxwalldel_'+id)) $('#boxwalldel_'+id).hide();
		$('#boxwallrep_'+id).toggle();
	},

	wallrep : function(id) {
		Home.ajax('ajax/minibox.php?m=wallreport&n='+id, null);
	},

	wallclick : function(text) {
		if ($('#walltext').val() == '') {
			$('#walltext').val(text);
			$('#wall_button').addClass('none');
		} else if ($('#walltext').val() == text) {
			$('#walltext').val('');
			$('#wall_button').removeClass('none');
		}
	},

	photopro : function(id) {
		Home.ajax('ajax/minibox.php?m=photoprofile&n='+id, null);
	},

	ophotodel : function(id) {
		$('#boxphotodel_'+id).toggle();
	},

	photodel : function(id) {
		Home.ajax('ajax/minibox.php?m=photodelete&n='+id, null);
	},

	oconcertdel : function(id) {
		$('#boxconcertdel_'+id).toggle();
	},

	concertdel : function(id) {
		Home.ajax('ajax/minibox.php?m=concertdelete&n='+id, null);
	},

	odiscodel : function(id) {
		$('#boxdiscodel_'+id).toggle();
	},

	discodel : function(id) {
		Home.ajax('ajax/minibox.php?m=discodelete&n='+id, null);
	},

	videoedit : function() {
		if ($('#videoedittitle').val() != '') {
			var params = $('#videoeditform').serialize();
			Home.ajax('ajax/minibox.php?m=videoedit', params);
		}
	},

	photoedit : function() {
		var params = $('#statustitle').serialize();
		$.post('ajax/comment.php?m=photoedit', params);
		$('#edittitle').hide();
		$('#mytitle').html($('#newtitle').val()).show();
	},

	ovideodel : function(id) {
		$('#boxvideodel_'+id).toggle();
	},

	videodel : function(id) {
		Home.ajax('ajax/minibox.php?m=videodelete&n='+id, null);
	},

	ovideorep : function(id) {
		$('#boxvideorep_'+id).toggle();
	},

	videorep : function(id) {
		Home.ajax('ajax/minibox.php?m=videoreport&n='+id, null);
	},

	ocomdel : function(id) {
		$('#boxcomrep_'+id).hide();
		$('#boxcomdel_'+id).toggle();
	},

	comdel : function(id,type) {
		Home.ajax('ajax/minibox.php?m=commentdelete&n='+id+'&type='+type, null);
	},

	ocomrep : function(id) {
		if ($('#boxcomdel_'+id)) $('#boxcomdel_'+id).hide();
		$('#boxcomrep_'+id).toggle();
	},

	comrep : function(id) {
		Home.ajax('ajax/minibox.php?m=commentreport&n='+id, null);
	},

	videocomclick : function(text) {
		if ($('#videocomtext').val() == '') {
			$('#videocomtext').val(text);
			$('#video_comment_button').addClass('none');
		} else if ($('#videocomtext').val() == text) {
			$('#videocomtext').val('');
			$('#video_comment_button').removeClass('none');
		}
	},

	videocomsend : function() {
		if ($('#videocomtext').val() != '') {
			var params = $('#videocomform').serialize();
			Home.ajax('ajax/comment.php?m=comment&n=video', params);
		}
	},

	photocomclick : function(text) {
		if ($('#photocomtext').val() == '') {
			$('#photocomtext').val(text);
			$('#photo_comment_button').addClass('none');
		} else if ($('#photocomtext').val() == text) {
			$('#photocomtext').val('');
			$('#photo_comment_button').removeClass('none');
		}
	},

	photocomsend : function() {
		if ($('#photocomtext').val() != '') {
			var params = $('#photocomform').serialize();
			Home.ajax('ajax/comment.php?m=comment&n=photo', params);
		}
	}
}

var Setting = {

	notif : function(val) {
		Home.ajax('ajax/account.php?m=notif','v='+val);
	},

	prod : function() {
		Home.ajax('ajax/account.php?m=production',null);
	},

	pass : function() {
		var params = $('#formpassword').serialize();
		Home.ajax('ajax/account.php?m=newpass',params);
	},

	profile : function() {
		var params = $('#formprofile').serialize();
		Home.ajax('ajax/account.php?m=profile',params);
	},

	save : function() {
		var param = $('#formsetting').serialize();
		var z =(new Date().getTimezoneOffset()/60)*(-1);
		var params = param+'&z='+z;
		Home.ajax('ajax/account.php?m=save',params);
	}
}

var Home = {

	posting : true,

	init : function() {
		var hiddenaccount;
		$('#selectaccount').click(function() {
			$('#menuaccount').show(); 
			$('#selectaccount').addClass('backboxwhite'); 
		});
		$('#selectaccount').mouseout(function() {
			hiddenaccount = setTimeout(function(){$('#menuaccount').hide();$('#selectaccount').removeClass('backboxwhite');}, 500);
		});
		$('#selectaccount').mouseover(function() {
			clearTimeout(hiddenaccount);
		});
		var hiddenrequest;
		$('#selectrequest').click(function() {
			Home.ajax('ajax/request.php');
			$('#menurequest').show(); 
			$('#selectrequest').addClass('backboxwhite'); 
		});
		$('#selectrequest').mouseout(function() {
			hiddenrequest = setTimeout(function(){$('#menurequest').hide();$('#selectrequest').removeClass('backboxwhite');}, 500);
		});
		$('#selectrequest').mouseover(function() {
			clearTimeout(hiddenrequest);
		});
		var hiddennotification;
		$('#selectnotification').click(function() {
			Home.ajax('ajax/notification.php');
			$('#menunotification').show(); 
			$('#selectnotification').addClass('backboxwhite'); 
		});
		$('#selectnotification').mouseout(function() {
			hiddennotification = setTimeout(function(){$('#menunotification').hide();$('#selectnotification').removeClass('backboxwhite');}, 500);
		});
		$('#selectnotification').mouseover(function() {
			clearTimeout(hiddennotification);
		});
	},

	menu : function(value) {
		Home.ajax('ajax/'+value+'.php');
	},

	multi : function() {
		var params = $('#formmulti').serialize();
		Home.ajax('ajax/registermulti.php', params);
	},

	register : function() {
		var params = $('#formregister').serialize();
		Home.ajax('ajax/register.php', params);
	},

	generationreservoir : function(limit) {
		var params = $('#formgenerationreservoir').serialize()+'&limit='+limit;
		Home.ajax('ajax/generationreservoir.php?m=listartists', params);
	},
	
	charts : function(limit) {
		var params = $('#formcharts').serialize()+'&limit='+limit;
		Home.ajax('ajax/charts.php?m=listartists', params);
	},
	
	chartsprod : function(limit) {
		var params = $('#formcharts').serialize()+'&limit='+limit;
		Home.ajax('ajax/charts.php?m=listprod', params);
	},

	attachvideo : function() {
		var val = $('#attachvideo').val();
		if (val.indexOf("http://")!=-1){
			Home.ajax('ajax/attach.php?m=home','video&t='+val);
		}
	},
	
	attachlink : function() {
		var val = $('#attachlink').val();
		if (val.indexOf("http://")!=-1){
			Home.ajax('ajax/attach.php?m=home','link&t='+val);
		}
	},

	attachphoto : function(id,image) {
		$('#attachment').html('<div class="fleft"><img src="'+image+'" height="110"><input type="hidden" name="type" value="photo"><input type="hidden" name="val" value="'+id+'"></div><div class="fright delete" onclick="$(\'#attachment\').html(\'\').hide();$(\'#allattachments\').show();"></div><div class="clear"></div>');
		$("#allattachments").hide();
		$("#wallphoto").hide();
		$("#wallvideo").hide();
		$("#walllink").hide();
		$("#attachment").show();
	},
	
	wallposting : function() {
		var text = $('#walltext').val();
		if (text != '' && text.indexOf("http://")!=-1){
			clearTimeout(Home.posting);
			var params = $('#wallform').serialize();
			Home.posting = setTimeout(function(){Home.ajax('ajax/attach.php?m=home',params);}, 1000);
		}
	},
	
	wallsend : function() {
		if ($('#walltext').val() != '') {
			var params = $('#wallform').serialize();
			Home.ajax('ajax/comment.php?m=wall',params);
		}
	},
	
	help : function() {
		if ($('#walltext').val() != '') {
			var params = $('#wallform').serialize();
			Home.ajax('ajax/comment.php?m=help',params);
		}
	},
	
	message : function(uname) {
		Lightbox.mini('ajax/profilebox.php?m='+uname+'&type=message');
	},
	
	friend : function(id) {
		Lightbox.mini('ajax/friend.php?id='+id);
	},
	
	friendrequest : function(id) {
		Lightbox.mini('ajax/friend.php?m=request&id='+id);
	},
	
	friendconfirm : function(id) {
		Home.ajax('ajax/request.php?m=confirm&id='+id);
	},
	
	friendignore : function(id) {
		Home.ajax('ajax/request.php?m=ignore&id='+id);
	},
	
	friendremove : function(id) {
		Home.ajax('ajax/request.php?m=remove&id='+id);
	},

	search : function(c) {
		var text = $('#search').val();
		var label = $('#search').attr('text');
		if (c) {
			if (text==label) $('#search').val('');
		} else {
			if (text=='') $('#search').val(label);
		}
	},

	fb : function(url) {
		var width = 626;
		var height = 436;
		var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));
		var option = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
		window.open("http://www.facebook.com/sharer.php?u="+url, "share", option);
	},

	twit : function(text) {
		var width = 850;
		var height = 600;
		var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));
		var option = "width=" + width + ",height=" + height + ",status,resizable,scrollbars,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
		window.open("http://twitter.com/home?status="+text, "twit", option);
	},

	comclick : function(id,text) {
		if ($('#'+id).val() == '') {
			$('#'+id).val(text);
			$('#'+id+'_button').addClass('none');
		} else if ($('#'+id).val() == text) {
			$('#'+id).val('');
			$('#'+id).focus();
			$('#'+id+'_button').removeClass('none');
		}
	},

	comsend : function(id) {
		if ($('#'+id+'_input').val() != '') {
			var params = $('#'+id+'_form').serialize();
			Home.ajax('ajax/comment.php?m=comment', params);
		}
	},

	ajax : function(url,params) {
		$.post(url, params, function(data){
			$.each(data, function(key,value){
				if (key == 'xscript') {
					eval(value);
				} else if (key == 'xhash') {
					location.hash = value;
				} else if (key == 'xinsert') {
					$('#xcallback').append(value);
				} else if (key == 'xtitle') {
					document.title = value;
				} else {
					$('#'+key).html(value);
					History.createReload(key);
				}
			});
		}, "json");
	}
}

var changecolor = null;

var Edit = {

	init : function() {
		var alldivcontent = $('#sprofile').children();
		alldivcontent.each(function() {
			if ($(this).attr('id').indexOf('box_') != -1) {
				var decoid = $(this).attr('id').split('_');
				var s = $('#box_'+decoid[1]);
				var m = $('#move_'+decoid[1]);
				var e = $('#edit_'+decoid[1]);
				s.addClass('boxout');
				m.mouseover(function(){s.addClass('boxover');});
				m.mouseout(function(){s.removeClass('boxover');});
				e.mouseover(function(){s.addClass('boxover');});
				e.mouseout(function(){s.removeClass('boxover');});
				m.one('mouseover',function(){
					var x1 = $('#content').offset().left - 1;
					var y1 = $('#content').offset().top - 1;
					var x2 = $('#content').offset().left + 980 - s.width();
					var y2 = $('#content').offset().top + 3000 - s.height();
					m.draggable({containment:[x1,y1,x2,y2],
						drag : function() {
							s.css('top',m.css('top'));
							e.css('top',m.css('top'));
							s.css('left',m.css('left'));
							e.css('left',parseInt(m.css('left'))+21+'px');
							m.attr('left',s.offset().left - x1);
							e.attr('left',s.offset().left - x1 + 21);
							s.attr('left',s.offset().left - x1);
						},
						stop : function () {
							sy = s.offset().top - y1 + 29;
							sx = s.offset().left - x1;
							$.post('ajax/save.php',{id:s.attr('id'),sx:sx,sy:sy});
						}
					});
				});
			}
		});
		$('body').css('background',$('#sprofile').attr('color')+' '+$('#sprofile').attr('back'));
		$('#top').css('background',$('#top').attr('profile'));
		$('#content').removeClass('contentlight');
		Edit.calculate();
		flash('sprofile');
		$(window).resize(Edit.calculate);
	},

	reload : function() {
		$('#inprofile').toggle();
	},
	
	calculate : function() {
		var xcontent = parseInt($('#content').offset().left);
		var alldivcontent = $('#sprofile').children();
		alldivcontent.each(function() {
			var newleft = parseInt($(this).attr('left'))+xcontent;
			if(!isNaN(newleft)) $(this).css('left',newleft+'px');
		});
		$('.boxedit').each(function() {
			$(this).click(function(){Edit.menuedit($(this).attr('boxid'))});
		});
		$('#sprofile').addClass('show');
	},
	
	panel : function(box) {
		Lightbox.hide();
		if (box == 'addbox') {
			$('#addwidget').hide();
			$('#adddeco').hide();
			$('#editpage').hide();
		} else if (box == 'addwidget') {
			$('#addbox').hide();
			$('#adddeco').hide();
			$('#editpage').hide();
		} else if (box == 'adddeco') {
			$('#addbox').hide();
			$('#addwidget').hide();
			$('#editpage').hide();
			if($('#adddeco').is(':hidden')) $('#decopage').load('ajax/deco.php?action=view');
		} else if (box == 'editpage') {
			$('#addbox').hide();
			$('#addwidget').hide();
			$('#adddeco').hide();
		}
		if($('#'+box).is(':hidden')) $('#'+box).show(); else $('#'+box).hide();
		$('#nowidget').fadeOut("slow");
	},

	bgcolor : function(element) {
		var color = $('#color_color').val().replace('#','');
		$('#plugin').css('top',($(element).offset().top+30)+'px');
		$('#plugin').css('left',($(element).offset().left-87)+'px');
		$('#plugin').show();
		iupdate('color',color);
	},

	ncolor : function(element) {
		var color = $('#color_ncolor').val().replace('#','');
		$('#plugin').css('top',($(element).offset().top+30)+'px');
		$('#plugin').css('left',($(element).offset().left-87)+'px');
		$('#plugin').show();
		iupdate('ncolor',color);
	},

	mcolor : function(element) {
		var color = $('#color_mcolor').val().replace('#','');
		$('#plugin').css('top',($(element).offset().top-240)+'px');
		$('#plugin').css('left',($(element).offset().left-87)+'px');
		$('#plugin').show();
		iupdate('mcolor',color);
	},

	colorsave : function(type,color) {
		if (type == 'color') {
			$('body').css('background-color','#'+color);
		} else if (type == 'ncolor') {
			$('#ncolor').css('color','#'+color);
		} else if (type == 'mcolor') {
			var divs = $('#sprofile').find('[color="mcolor"]');
			divs.each(function() {
				$(this).css('color','#'+color);
				$(this).css('border-color','#'+color);
			});
		}
		$('#sprofile').attr('color','#'+color);
		changecolor = setTimeout("$.post('ajax/save.php','id=body&"+type+"="+color+"');",500);
	},

	bgbox : function(element) {
		$('#bgbox').css('top',($(element).offset().top+55)+'px');
		$('#bgbox').css('left',($(element).offset().left-87)+'px');
		$('#bgbox').show();
	},

	bgclick : function(bgimage,bgrepeat) {
		$('#panelback').css('background-image','url('+bgimage+'.mini.png)');
		$('body').css('background-image','url('+bgimage+')');
		$('body').css('background-repeat',bgrepeat);
		$('#sprofile').attr('back','url('+bgimage+') '+bgrepeat+' top center');
		$.post('ajax/save.php',{id:'body',back:bgimage,repeat:bgrepeat});
	},

	menuedit : function(boxid) {
		$('#box_edit_'+boxid).attr('src','images/box-edit-on.gif');
		$('#box_menu_'+boxid).removeClass('none');
		$('#box_edit_'+boxid).unbind();
		$('#box_edit_'+boxid).click(function(){
			Edit.menueditclose(boxid);
		});
	},

	menueditclose : function(boxid) {
		$('#box_edit_'+boxid).attr('src','images/box-edit.gif');
		$('#box_menu_'+boxid).addClass('none');
		$('#box_edit_'+boxid).unbind();
		$('#box_edit_'+boxid).click(function(){
			Edit.menuedit(boxid);
		});
	},

	boxcolor : function(boxid,query) {
		var bimage = $('#img_'+boxid);
		var position = bimage.attr('src').lastIndexOf('/')+1;
		var url = bimage.attr('src').substring(0,position);
		var img = bimage.attr('src').substring(position,bimage.attr('src').length);
		var image = img.split('.');
		var keys = image[0];
		var format = image[1];
		var temp = keys.split('-');
		var color = temp[0];
		var size = temp[1];
		var direction = temp[2];
		if (color != query) {
			bimage.attr('src',url+query+'-'+size+'-'+direction+'.'+format);
			$.post('ajax/save.php',{id:'box_'+boxid,color:query});
		}
		Edit.menueditclose(boxid);
	},
	
	boxsize : function(boxid,query) {
		var bimage = $('#img_'+boxid);
		var position = bimage.attr('src').lastIndexOf('/')+1;
		var url = bimage.attr('src').substring(0,position);
		var img = bimage.attr('src').substring(position,bimage.attr('src').length);
		var image = img.split('.');
		var keys = image[0];
		var format = image[1];
		var temp = keys.split('-');
		var color = temp[0];
		var size = temp[1];
		var direction = temp[2];
		if (size != query) {
			bimage.attr('src',url+color+'-'+query+'-'+direction+'.'+format);
			$.post('ajax/save.php',{id:'box_'+boxid,size:query});
		}
		Edit.menueditclose(boxid);
	},
	
	boxreverse : function(boxid) {
		var bimage = $('#img_'+boxid);
		var position = bimage.attr('src').lastIndexOf('/')+1;
		var url = bimage.attr('src').substring(0,position);
		var img = bimage.attr('src').substring(position,bimage.attr('src').length);
		var image = img.split('.');
		var keys = image[0];
		var format = image[1];
		var temp = keys.split('-');
		var color = temp[0];
		var size = temp[1];
		var direction = temp[2];
		if(direction == 'normal') direction = 'reverse'; else direction = 'normal';
		bimage.attr('src',url + color + '-' + size + '-' + direction + '.' + format);
		$.post('ajax/save.php',{id:'box_'+boxid,reverse:direction});
		Edit.menueditclose(boxid);
	},
	
	boxbringtofront : function(boxid) {
		$('#box_'+boxid).css('z-index',500);
		$.post('ajax/save.php',{id:'box_'+boxid,z:'front'});
		Edit.menueditclose(boxid);
	},
	
	boxsendtoback : function(boxid) {
		$('#box_'+boxid).css('z-index',100);
		$.post('ajax/save.php',{id:'box_'+boxid,z:'back'});
		Edit.menueditclose(boxid);
	},
	
	boxremove : function(boxid) {
		$('#move_'+boxid).remove();
		$('#edit_'+boxid).remove();
		$('#box_'+boxid).remove();
		$.post('ajax/remove.php',{id:boxid});
	},
	
	boxedit : function(boxid,type) {
		Lightbox.mini('ajax/lightbox.php?type='+type);
		Edit.menueditclose(boxid);
	},

	boxeditlink : function(name,label) {
		if (name == "facebook") {
			var profile = $('#facebooklink').val();
			if(profile.indexOf("profile.php?id=")!=-1){
				var temp = profile.split('profile.php?id=');
				if(temp[1].indexOf("&")!=-1){
					var tmp = temp[1].split('&');
					var url = 'Facebook ID : '+tmp[0];
				}else{
					var url = 'Facebook ID : '+temp[1];
				}
				$('#facebooklink').val(url);
			} else if(profile.indexOf("facebook.com/")!=-1){
				var temp = profile.split('facebook.com/');
				var url = 'Facebook ID : '+temp[1];
				$('#facebooklink').val(url);
			} else {
				if ($('#facebooklink').val().indexOf("Facebook ID :")==-1) {
					$('#facebooklink').val(label);
				}
			}
		} else if (name == "twitter") {
			var profile = $('#twitterlink').val();
			if(profile.indexOf("twitter.com/")!=-1){
				var temp = profile.split('twitter.com/');
				var url = 'Twitter ID : '+temp[1];
				$('#twitterlink').val(url);
			} else {
				if ($('#twitterlink').val().indexOf("Twitter ID :")==-1) {
					$('#twitterlink').val(label);
				}
			}
		} else {
			var profile = $('#myspacelink').val();
			if(profile.indexOf("myspace.com/")!=-1){
				var temp = profile.split('myspace.com/');
				var url = 'MySpace ID : '+temp[1];
				$('#myspacelink').val(url);
			} else {
				if ($('#myspacelink').val().indexOf("MySpace ID :")==-1) {
					$('#myspacelink').val(label);
				}
			}
		}

	},
	
	boxeditglitter : function() {
		var glow = 0; var shadow = 0;
		if ($('#glitterglow:checked')) glow = 1; 
		if ($('#glittershadow:checked')) shadow = 1; 
		var flashvars = 'shadow:'+shadow+';sc:'+$('#glittershadowcolor').val()+';glow:'+glow+';gc:'+$('#glitterglowcolor').val()+';num:'+$('#glitternum').val()+';font:'+$('#glitterfont').val()+';fontsize:'+$('#glittersize').val()+';message:'+$('#glittertext').val();
		$('#glitterpreview').html('<div id="swf_text_edit" flash="http://www.sofamous.com/flash/glitter.swf" width="435" height="130" vars="'+flashvars+'" style="width:435px;height:130px;"></div>');
		flash('boxcontent');
	},

	boxeditglittersize : function(w,h) {
		if ($('#glitterwidth')) $('#glitterwidth').val(w);
		if ($('#glitterheight')) $('#glitterheight').val(h);
	},

	boxeditdecocolor : function(element) {
		var divs = $('#boxdecocolor').getElementsByClassName('decocolor');
		divs.each(function(s) {
			s.style.borderColor = '#BDC7D8';
		});
		element.style.borderColor = '#FF3399';
		var newval = element.src.split('-');
		newval = newval[1].split('.');
		$('#decocolor').val(newval[0]);
	},

	boxeditphoto : function(element,id) {
		var divs = $('#simplephoto').children();
		divs.each(function() {
			$(this).children().css('border-color','#BDC7D8');
		});
		$(element).css('border-color','#FF3399');
		$('#photoid').val(id);
	},

	boxeditvideo : function(element,id) {
		var divs = $('#simplevideo').children();
		divs.each(function() {
			$(this).children().css('border-color','#BDC7D8');
		});
		$(element).css('border-color','#FF3399');
		$('#videoid').val(id);
	},

	boxeditfacebooklink : function(element,id) {
		var divs = $('#facebooklinkimg').children();
		divs.each(function() {
			$(this).children().css('background','');
		});
		$(element).css('background',"url('/images/gift/back.png')");
		$('#linkid').val(id);
	},

	boxedittwitterlink : function(element,id) {
		var divs = $('#twitterlinkimg').children();
		divs.each(function() {
			$(this).children().css('background','');
		});
		$(element).css('background',"url('/images/gift/back.png')");
		$('#linkid').val(id);
	},

	boxeditmyspacelink : function(element,id) {
		var divs = $('#myspacelinkimg').children();
		divs.each(function() {
			$(this).children().css('background','');
		});
		$(element).css('background',"url('/images/gift/back.png')");
		$('#linkid').val(id);
	},

	boxedittext : function(id) {
		$('#textid').val(id);
	},

	insertfacebooklink : function(label) {
		var linkid = $('#linkid').val();
		var profile = $('#facebooklink').val();
		if (profile!=label && profile!='' && linkid!='') {
			Edit.insertwidget('facebooklink','num='+linkid+'&options='+profile);
		}
	},

	inserttwitterlink : function(label) {
		var linkid = $('#linkid').val();
		var profile = $('#twitterlink').val();
		if (profile!=label && profile!='' && linkid!='') {
			Edit.insertwidget('twitterlink','num='+linkid+'&options='+profile);
		}
	},

	insertmyspacelink : function(label) {
		var linkid = $('#linkid').val();
		var profile = $('#myspacelink').val();
		if (profile!=label && profile!='' && linkid!='') {
			Edit.insertwidget('myspacelink','num='+linkid+'&options='+profile);
		}
	},

	insertglitter : function() {
		var num = $('#glitternum').val();
		var font = $('#glitterfont').val();
		var size = $('#glittersize').val();
		var text = $('#glittertext').val();
		var w = $('#glitterwidth').val();
		var h = $('#glitterheight').val();
		var glow = 0; var shadow = 0;
		if ($('#glitterglow').checked) glow = 1; 
		if ($('#glittershadow').checked) shadow = 1; 
		var sc = $('#glittershadowcolor').val();
		var gc = $('#glitterglowcolor').val();
		if (w!='' && h!='' && sc!='' && gc!='' && num!='' && size!='' && text!='') {
			Edit.insertwidget('glitter','options='+w+'|'+h+'|'+shadow+'|'+sc+'|'+glow+'|'+gc+'|'+num+'|'+font+'|'+size+'&extra='+text);
		}
	},

	insertphoto : function() {
		var id = $('#photoid').val();
		var size = $('#photosize').val();
		var reflect = 0;
		if ($('#photoreflect').checked) reflect = 1;
		if (id!='' && size!='') {
			Edit.insertwidget('simplephoto','num='+id+'&options='+size+'&extra='+reflect);
		}
	},

	insertvideo : function() {
		var id = $('#videoid').val();
		var size = $('#videosize').val();
		if (id!='' && size!='') {
			Edit.insertwidget('simplevideo','num='+id+'&options='+size);
		}
	},

	inserttext : function() {
		var id = $('#textid').val();
		var size = $('#textsize').val();
		if (id!='' && size!='') {
			Edit.insertwidget('simpletext','num='+id+'&options='+size);
		}
	},

	insertfavorites : function() {
		Edit.insertwidget('favorite','toto');
	},

	insertinfos : function() {
		Edit.insertwidget('infos','toto');
	},

	insertmusic : function() {
		Edit.insertwidget('music','toto');
	},

	insertdeco : function(deco) {
		$.post('ajax/deco.php?action=insert',{id:deco},function(data){$('#sprofile').append(data);Lightbox.hide();});
		Edit.panel('adddeco');
	},

	boxoptions : function() {
		if ($('#previewsize').val() == 1) {
			$('#boxpreview').addClass('width200');
		} else {
			$('#boxpreview').removeClass('width200');
		}
		$('#boxpreviews1s1').hide();
		$('#boxpreviews2s1').hide();
		$('#boxpreviews1s2').hide();
		$('#boxpreviews2s2').hide();
		if ($('#previewsize').val() == 1 && $('#previewstyle').val() == 1) {
			$('#boxpreviews1s1').show();
		} else if ($('#previewsize').val() == 2 && $('#previewstyle').val() == 1) {
			$('#boxpreviews2s1').show();
		} else if ($('#previewsize').val() == 1 && $('#previewstyle').val() == 2) {
			$('#boxpreviews1s2').show();
		} else {
			$('#boxpreviews2s2').show();
		}
	},

	editbox : function(box) {
		Lightbox.mini('ajax/box.php?action=edit&name='+box);
	},

	addbox : function(box,id) {
		if (id != 0) {
			$('#move_'+id).remove();
			$('#edit_'+id).remove();
			$('#box_'+id).remove();
		} 
		var params = $('#formaddbox'+box).serialize();
		Edit.savebox(box,params);
	},

	savebox : function(box, params) {
		$.post('ajax/box.php?action=save&name='+box,params,function(data){$('#sprofile').append(data);Lightbox.hide();});
		$('#addbox').hide();
	},

	addwidget : function(widget) {
		Lightbox.mini('ajax/widget.php?action=add&name='+widget);
	},

	insertwidget : function(widget, params) {
		$.post('ajax/widget.php?action=insert&name='+widget,params,function(data){$('#sprofile').append(data);Lightbox.hide();});
		$('#addwidget').hide();
	}
}

var Pick = {

	num : 1,
	s1 : 0,
	s2 : 0,
	s3 : 0,
	s4 : 0,
	s5 : 0,

	init : function() {
		$('#pick').autocomplete({serviceUrl:'ajax/completer.php',width:306,params:{type:'pick'},onSelect:Pick.add});
	},

	add : function(value,title,image) {
		if (Pick.num < 1 || Pick.num > 5) Pick.num = 1; 
		$('#pickimage'+Pick.num).html('<img src="'+image+'" class="pickimg">');
		$('#picktitle'+Pick.num).html(title);
		$('#pickvalue'+Pick.num).val(value);
		if (Pick.num == 1) Pick.s1 = value;
		else if (Pick.num == 2) Pick.s2 = value;
		else if (Pick.num == 3) Pick.s3 = value;
		else if (Pick.num == 4) Pick.s4 = value;
		else if (Pick.num == 5) Pick.s5 = value;
		$('#pick').val('');
		$('#pick').focus();
		Pick.num++;
		Pick.select(Pick.num);
	},

	select : function(num) {
		Pick.num = num;
		$('#pickdiv1').css('border-color','#BDC7D8');
		$('#pickdiv2').css('border-color','#BDC7D8');
		$('#pickdiv3').css('border-color','#BDC7D8');
		$('#pickdiv4').css('border-color','#BDC7D8');
		$('#pickdiv5').css('border-color','#BDC7D8');
		if (Pick.num < 6) {
			$('#pickdiv'+Pick.num).css('border-color','#43609D');
			$('#pickdiv'+Pick.num).css('background','#FFFFFF');
			$('#pickvalid').attr('disabled','disabled');
			$('#pick').val('');
			$('#pick').focus();
		} else {
			if (Pick.s1 != 0 && Pick.s2 != 0 && Pick.s3 != 0 && Pick.s4 != 0 && Pick.s5 != 0) {
				$('#pickvalid').attr('disabled','');
			}
		}
	},

	newpick : function() {
		$('.autocomplete').hide();
		Lightbox.mini('ajax/like.php?pick');
	},

	valid : function(image) {
		$('#pickimage').val(image);
		Lightbox.mini('ajax/like.php?valid');
	},

	newentry : function() {
		var params = $('#picknew').serialize();
		Home.ajax('ajax/pick.php?m=newentry', params);
	},

	entrysave : function(value,title,image) {
		Pick.add(value,title,image);
		Lightbox.hide();
	},

	save : function() {
		Pick.s1+' - '+Pick.s2+' - '+Pick.s3+' - '+Pick.s4+' - '+Pick.s5
		Home.ajax('ajax/pick.php?m=save', {five:$('#pickfive').val(),s1:Pick.s1,s2:Pick.s2,s3:Pick.s3,s4:Pick.s4,s5:Pick.s5});
	},

	del : function(id) {
		Home.ajax('ajax/pick.php?m=delete&id='+id, null);
	},

	send : function() {
		if ($('#pickcreatetitle').val() != '') {
			var params = $('#form').serialize();
			Home.ajax('ajax/pick.php?m=new', params);
		}
	}
}

function ucwords (str) {
    return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
}

var Club = {

	init : function() {
		var hiddencountry;
		$('#selectcountry').click(function() {
			$('#menucountry').show(); 
		});
		$('#divcountry').mouseout(function() {
			hiddencountry = setTimeout(function(){$('#menucountry').hide();}, 500);
		});
		$('#divcountry').mouseover(function() {
			clearTimeout(hiddencountry);
		});
		$('#menucountry > li').each(function() {
			$(this).click(function() {
				Club.menu('country',$(this).attr('value'),$(this).text());
			});
		});
	},

	menu : function(type, value, text) {
		$('#menu'+type).hide();
		$('#input'+type).val(value);
		$('#select'+type).html(text);
		Club.update(type);
	},

	update : function(type) {
		History.ajax($('#hiddenpage').val()+'/'+type+'/'+$('#input'+type).val());
	},

	ihome : function() {
		if ($('#alldesc').height() > 30) {
			$('#shortdesc').hide();
			$('#longdesc').show();
		}
	},

	leave : function(id) {
		Home.ajax('ajax/club.php?m=leave&n='+id, null);
	},

	join : function(id) {
		Home.ajax('ajax/club.php?m=join&n='+id, null);
	},

	edit : function(id) {
		Lightbox.mini('ajax/lightclub.php?m='+id+'&type=edit');
	},

	picture : function(hash) {
		$('#clubpicture').attr({src:'photos/club/'+hash+'-c100.jpg'});
	},

	save : function(id) {
		if ($('#editn').val() != '') {
			var params = $('#editform').serialize();
			Home.ajax('ajax/lightclub.php?m='+id+'&type=save', params);
			Lightbox.hide();
		}
	},

	create : function() {
		if ($('#createn').val() != '') {
			var params = $('#createform').serialize();
			Home.ajax('ajax/lightclub.php?type=create', params);
		}
	},

	talk : function() {
		if ($('#newt').val() != '' && $('#newm').val() != '') {
			var params = $('#newform').serialize();
			Home.ajax('ajax/lightclub.php?type=new', params);
		}
	},

	reply : function() {
		if ($('#replym').val() != '') {
			var params = $('#replyform').serialize();
			Home.ajax('ajax/lightclub.php?type=reply', params);
		}
	},

	odel : function(id) {
		$('#boxrep_'+id).hide();
		$('#boxdel_'+id).toggle();
	},

	del : function(id) {
		Home.ajax('ajax/minibox.php?m=clubdelete&n='+id, null);
	},

	orep : function(id) {
		if ($('#boxdel_'+id)) $('#boxdel_'+id).hide();
		$('#boxrep_'+id).toggle();
	},

	rep : function(id) {
		Home.ajax('ajax/minibox.php?m=clubreport&n='+id, null);
	},

	todel : function(id) {
		$('#tboxrep_'+id).hide();
		$('#tboxdel_'+id).toggle();
	},

	tdel : function(id) {
		Home.ajax('ajax/minibox.php?m=talkdelete&n='+id, null);
	},

	torep : function(id) {
		if ($('#tboxdel_'+id)) $('#tboxdel_'+id).hide();
		$('#tboxrep_'+id).toggle();
	},

	trep : function(id) {
		Home.ajax('ajax/minibox.php?m=talkreport&n='+id, null);
	},

	member : function(id) {
		Lightbox.mini('ajax/lightclub.php?m='+id+'&type=member');
	},

	admin : function(id) {
		Lightbox.mini('ajax/lightclub.php?m='+id+'&type=admin');
	},

	admina : function(id,member) {
		Lightbox.mini('ajax/lightclub.php?m='+id+'&type=admin&n=add&i='+member);
	},

	adminr : function(id,member) {
		Lightbox.mini('ajax/lightclub.php?m='+id+'&type=admin&n=remove&i='+member);
	}
}

function isInteger(s){return parseInt(s,10)===s;}

var Chat = {

	time : 0,
	writing : 0,
	userstab : 0,
	usersleft : 0,
	active : 1,
	statuso : 1,
	ajaxtime : 2,
	chats : {},
	users : {},
	alerts : {},
	online : {},
	status : null,
	typing : null,
	timeout : null,
	chatopen : null,
	chatall : new Array(),
	chattab : new Array(),
	visibles : new Array(),
	invisiblel : new Array(),
	invisibler : new Array(),

	init : function() {
		$('body').append('<div id="chat_bar"></div>');
		$('#chat_bar').append('<span id="chat_userstab" class="chat_tab"><span id="chat_userstab_icon"/><span id="chat_userstab_text" class="fleft">'+$('#chat_translate_loading').html()+'</span></span>');
		//$('#chat_bar').append('<div class="fleft spadtop spadleft"><div class="l1padtop pointer" onclick="openmusic()"><img id="musicopenbtn" width="13" height="13" src="images/open.png"></div></div>');
		//$('#chat_bar').append('<div class="fleft spadtop l3padleft"><div class="l1padtop pointer" onclick="playprevious()"><img width="13" height="13" src="images/previous.png"></div></div>');
		//$('#chat_bar').append('<div class="fleft spadtop l3padleft"><div class="l1padtop pointer"><img id="musicplaybtn" width="13" height="13" src="images/play.png"></div></div>');
		//$('#chat_bar').append('<div class="fleft spadtop l3padleft"><div class="l1padtop pointer" onclick="playnext()"><img width="13" height="13" src="images/next.png"></div></div>');
		//$('#chat_bar').append('<div class="fleft spadtop spadleft" style="width:14px;height:10px;"><div id="equalizer" class="l3padtop" style="display: none;"><img width="14" height="9" src="images/equalizer.gif"></div></div>');
		//$('#chat_bar').append('<div class="fleft spadtop l3padleft tiny-txt"><div id="onair" class="l2padleft l2padtop dark" style="overflow: hidden; width: 140px;"><div class="pointer" onclick="openmusic()"></div></div></div>');
		$('#chat_bar').append('<div id="chat_chatbox_right" class="chat_chatbox_right_last chat_chatbox_lr" onclick="Chat.left();"><div id="chat_nb_left">0</div><div id="chat_alert_left" style="position:absolute;margin-top:-28px;display:none;background:transparent url(/images/alert.png);width:16px;height:16px;font-family:verdana;" class="tiny-txt white bold center"></div></div>');
		$('#chat_bar').append('<div id="chat_chatboxes"></div>');
		$('#chat_bar').append('<div id="chat_chatbox_left" class="chat_chatbox_left_last chat_chatbox_lr" onclick="Chat.right();"><div id="chat_nb_right">0</div><div id="chat_alert_right" style="position:absolute;margin-top:-28px;display:none;background:transparent url(/images/alert.png);width:16px;height:16px;font-family:verdana;" class="tiny-txt white bold center"></div></div>');
		Chat.resize(0);
		$(window).resize(function(){Chat.resize(1);});
		$('.chat_tab').hover(function(){$(this).addClass('chat_tabmouseover');},function(){$(this).removeClass('chat_tabmouseover');});
		$('.chat_chatbox_lr').hover(function(){$(this).addClass('chat_chatbox_lr_mouseover');},function(){$(this).removeClass('chat_chatbox_lr_mouseover');});
		$('#chat_userstab').click(function(){Chat.listusers();});
		setTimeout('Chat.request(1,0)',1000);
        $(document).bind("idle.idleTimer", function(){
            Chat.active = 0;
        });
        $(document).bind("active.idleTimer", function(){
            Chat.active = 1;
        });
        $.idleTimer();
	},

	resize : function(r) {
		var windowSize = Lightbox.getPageDimensions();
		var l = (windowSize[0] - 980)/ 2;
		$('#playeronair').css('left',l+'px');
		var chatWidth = windowSize[0] - 49;
		Chat.usersleft = chatWidth - 185;
		if (Chat.userstab) $('#chat_userstab_popup').css('left',Chat.usersleft+'px');
		var length = Chat.chattab.length;
		var chatBoxes = chatWidth - 500;
		$('#chat_bar').css('width',chatWidth);
		var maxChats = Math.floor(chatBoxes/138);
		if (Chat.chatopen != null) {
			var doSup = 0;
			if (jQuery.inArray(Chat.chatpos,Chat.visibles) == -1 || r) {
				$('.chat_tab_open').addClass('none');
				var visibles = new Array();
				for (i=Chat.chatpos,k=0;k<maxChats;i--,k++) {
					$('#chat_user_'+Chat.chattab[i]).removeClass('none');
					visibles.push(i);
					if (i == 0) {
						doSup = 1;
						break;
					}
				}
				if (doSup) {
					for (i=Chat.chatpos;k<maxChats;i++,k++) {
						if (jQuery.inArray(i,visibles) == -1 && i >= 0) {
							$('#chat_user_'+Chat.chattab[i]).removeClass('none');
							visibles.push(i);
						}
					}
				}
				Chat.visibles = visibles;
				var invisiblel = new Array();
				var invisibler = new Array();
				for (i=0;i<length;i++) {
					if (jQuery.inArray(i,Chat.visibles) == -1) {
						if (i > Chat.chatpos) invisiblel.push(Chat.chattab[i]);
						else invisibler.push(Chat.chattab[i]);
					}
				}
				Chat.invisiblel = invisiblel;
				Chat.invisibler = invisibler;
				Chat.lralerts();
			}
			$('#chat_user_'+Chat.chatopen+'_popup').addClass('chat_tabopen');
			$('#chat_user_'+Chat.chatopen).addClass('chat_tabclick');
		}
		if (length > maxChats) {
			$('#chat_chatbox_right').removeClass('chat_chatbox_lr');
			$('#chat_chatbox_left').removeClass('chat_chatbox_lr');
		} else {
			$('#chat_chatbox_right').addClass('chat_chatbox_lr');
			$('#chat_chatbox_left').addClass('chat_chatbox_lr');
		}
		if (length > 0) {
			var left = $('#chat_user_'+Chat.chattab[Chat.chatpos]).offset().left - 90;
			$('#chat_user_'+Chat.chattab[Chat.chatpos]+'_popup').css('left',left);
		}
	},

	listusers : function() {
		if ($('#chat_userstab_popup')) $('#chat_userstab_popup').remove();
		$('body').append('<div id="chat_userstab_popup" class="chat_tabpopup" style="display:none;left:'+Chat.usersleft+'px;bottom:62px;"></div>');
		$('#chat_userstab_popup').append('<div id="chat_userstabtitle" class="chat_userstabtitle">'+$('#chat_translate_chat').html()+'</div>');
		$('#chat_userstab_popup').append('<div class="chat_tabcontent" style="background-image:url(/images/tabusers.gif);padding-top:1px;padding-bottom:1px;"><div id="chat_users" class="chat_userscontent"></div></div>');
		if (Chat.userstab) {
			$('#chat_userstab_popup').removeClass('chat_tabopen');
			$('#chat_userstab').removeClass('chat_tabclick');
			Chat.userstab = 0;
		} else {
			$('#chat_userstabtitle').click(function(){Chat.listusers();});
			$('#chat_userstab_popup').addClass('chat_tabopen');
			$('#chat_userstab').addClass('chat_tabclick');
			Chat.userstab = 1;
			Chat.request(1,0);
		}
		$('.chat_userstabtitle').hover(function(){$(this).addClass('chat_userstabtitlemouseover');},function(){$(this).removeClass('chat_userstabtitlemouseover');});
	},

	lralerts : function() {
		var left = 0;
		var right = 0;
		var alertleft = 0;
		var alertright = 0;
		jQuery.each(Chat.invisiblel, function(i,s){
			left++;
			alertleft = alertleft + parseInt($('#chat_user_'+s+'_alert').attr('nb'));
		});
		if (alertleft > 0) {
			$('#chat_alert_right').html(alertleft);
			$('#chat_alert_right').show();
		} else {
			$('#chat_alert_right').hide();
		}
		jQuery.each(Chat.invisibler, function(i,s){
			right++;
			alertright = alertright + parseInt($('#chat_user_'+s+'_alert').attr('nb'));
		});
		if (alertright > 0) {
			$('#chat_alert_left').html(alertright);
			$('#chat_alert_left').show();
		} else {
			$('#chat_alert_left').hide();
		}
		$('#chat_nb_left').html(right);
		$('#chat_nb_right').html(left);
	},

	nchat : function() {
		jQuery.each(Chat.chats, function(i,v){
			jQuery.each(v, function(n,m){
				var messages = new Array();
				$('#chat_user_'+i+'_content > *').each(function(){
					messages.push($(this).attr('mid'));
				});
				if (jQuery.inArray(m[1],messages) == -1) {
					if (m[0] != $('#chat_user_'+i+'_content div:last').attr('nid') || m[4] == 1){
						if (m[0]) {
							$('#chat_user_'+i+'_content').append('<div class="chat_message_title">'+$('#chat_translate_me').html()+'<span class="fright">'+m[3]+'</span></div>');
						} else {
							$('#chat_user_'+i+'_content').append('<div class="chat_message_title"><a href="#'+$('#chat_user_'+i+'_name').attr('uname')+'">'+$('#chat_user_'+i+'_name').html()+'</a><span class="fright">'+m[3]+'</span></div>');
						}
					}
					$('#chat_user_'+i+'_content').append('<div class="chat_message" mid="'+m[1]+'" nid="'+m[0]+'">'+m[2]+'</div>');
					$('#chat_user_'+i+'_content').scrollTop($('#chat_user_'+i+'_content')[0].scrollHeight);
					$('#chat_user_'+i+'_status').removeClass('chat_away');
					$('#chat_user_'+i+'_status').addClass('chat_available');
				}
			});
		});
	},

	sound : function() {
		console.log('play sound');
	},

	nalerts : function() {
		var noresize = 0;
		jQuery.each(Chat.alerts, function(i,v){
			Chat.createchat(i,0,1);
			if (v && i != Chat.chatopen) {
				Chat.sound();
				$('#chat_user_'+i+'_alert').html(v);
				$('#chat_user_'+i+'_alert').attr('nb',v);
				$('#chat_user_'+i+'_alert').fadeIn();
			}
			noresize = 1;
		});
		if (noresize) Chat.resize(1);
	},

	createchat : function(id,o,w) {
		if (jQuery.inArray(id,Chat.chattab) == -1) {
			Chat.chattab.push(id);
			var chatarray = Chat.online[id];
			if(typeof(chatarray) == "undefined") var chatarray = Chat.users[id];
			if (chatarray.status == 0) available = 'chat_away'; else available = 'chat_available';
			$('#chat_chatboxes').append('<span id="chat_user_'+chatarray.id+'" class="chat_tab chat_tab_open"><div class="fleft">'+chatarray.name+'</div><div id="chat_user_'+chatarray.id+'_status" class="chat_closebox_bottom_status '+available+'"/><div id="chat_user_'+chatarray.id+'_alert" style="position:absolute;margin-left:90px;margin-top:-3px;display:none;background:transparent url(/images/alert.png);width:16px;height:16px;font-family:verdana;" class="tiny-txt white bold center" nb="0"></div><div class="chat_closebox_bottom" onclick="Chat.removechat(\''+chatarray.id+'\')"/></span>');
			$('body').append('<div id="chat_user_'+chatarray.id+'_popup" class="chat_tabpopup chat_tabpopup_open" style="display:none;bottom:62px;"><div class="chat_tabtitle"><a id="chat_user_'+chatarray.id+'_name" uname="'+chatarray.uname+'" href="#'+chatarray.uname+'" style="float:left;color:white;margin-left:55px;">'+chatarray.name+'</a><div class="chat_closebox" onclick="Chat.removechat(\''+chatarray.id+'\')"/><div class="chat_reducebox" onclick="Chat.openchat(\''+chatarray.id+'\')"/><div class="clear"/></div><div class="chat_tabsubtitle"><div class="fleft" style="width: 50px; height: 28px;"><a href="#'+chatarray.uname+'"><img width="50" height="50" style="position: absolute; margin-top: -21px;" src="http://www.'+$('#chat_url').html()+'.com/photos/'+chatarray.image+'-c50.jpg"/></a></div><div class="fleft spadleft width160">'+chatarray.age+', '+chatarray.city+'</div><div class="clear"/></div><div class="chat_tabcontent"><div  id="chat_user_'+chatarray.id+'_content" class="chat_tabcontenttext"/><div class="chat_tabcontentinput"><textarea id="chat_user_'+chatarray.id+'_input" class="chat_textarea"></textarea></div></div></div>');
			$('#chat_user_'+chatarray.id).click(function(){Chat.openchat(chatarray.id);});
			$('.chat_tab').hover(function(){$(this).addClass('chat_tabmouseover');},function(){$(this).removeClass('chat_tabmouseover');});
			$('.chat_closebox').hover(function(){$(this).addClass('chat_closebox_hover');},function(){$(this).removeClass('chat_closebox_hover');});
			$('.chat_reducebox').hover(function(){$(this).addClass('chat_reducebox_hover');},function(){$(this).removeClass('chat_reducebox_hover');});
			$('.chat_closebox_bottom').hover(function(){$(this).addClass('chat_closebox_bottomhover');},function(){$(this).removeClass('chat_closebox_bottomhover');});
			$('#chat_user_'+chatarray.id+'_input').autoResize({extraSpace:0,limit:300});
			$('#chat_user_'+chatarray.id+'_input').bind('keydown', 'return', function(){
				Chat.send($('#chat_user_'+chatarray.id+'_input').val());
				$('#chat_user_'+chatarray.id+'_input').val('');
				clearTimeout(Chat.typing);
				Chat.writing = 0;
				return false;
			});
			$('#chat_user_'+chatarray.id+'_input').keypress(function(e){
				if (e.which != 13) {
					Chat.writing = 1;
					clearTimeout(Chat.typing);
					Chat.typing = setTimeout("Chat.writing=0;",5000);
				}
			});
			Chat.time = 0;
		}
		if (o) Chat.openchat(id);
	},

	openchat : function(id) {
		$('.chat_tab_open').removeClass('chat_tabclick');
		$('.chat_tabpopup_open').removeClass('chat_tabopen');
		if (id != Chat.chatopen) {
			$.post('ajax/chat.php', {open:id}, function(data){
				if (data != null) {
					Chat.chats = data;
					Chat.nchat();
				}
			}, "json");
			Chat.chatopen = id;
			Chat.chatpos = jQuery.inArray(id,Chat.chattab);
			setTimeout("$('#chat_user_"+id+"_input').focus()",300);
			Chat.resize(0);
		} else {
			Chat.chatopen = 0;
			Chat.chatpos = 0;
		}
		$('#chat_user_'+id+'_alert').attr('nb',0);
		$('#chat_user_'+id+'_alert').fadeOut();
	},

	removechat : function(id) {
		if (jQuery.inArray(id,Chat.chattab) != -1) {
			$('#chat_user_'+id).remove();
			$('#chat_user_'+id+'_popup').remove();
			var length = Chat.chattab.length;
			for (i=0;i<length;i++) {
				if (Chat.chattab[i] == id) break;
			}
			Chat.chattab.splice(i,1);
			var newpos = Chat.chatpos - 1;
			Chat.chatopen = 0;
			if (newpos >= 0) {
				Chat.chatpos = newpos;
				Chat.resize(1);
			}
		}
	},

	right : function() {
		var newpos = Chat.chatpos + 1;
		var length = Chat.chattab.length;
		if (newpos < length) Chat.openchat(Chat.chattab[newpos]);
		$('#chat_user_'+Chat.chatopen+'_alert').attr('nb',0);
		$('#chat_user_'+Chat.chatopen+'_alert').fadeOut();
	},

	left : function() {
		var newpos = Chat.chatpos - 1;
		if (newpos >= 0) Chat.openchat(Chat.chattab[newpos]);
		$('#chat_user_'+Chat.chatopen+'_alert').attr('nb',0);
		$('#chat_user_'+Chat.chatopen+'_alert').fadeOut();
	},

	whosonline : function() {
		Chat.chatall = new Array();
		$('#chat_users').html('<div style="background:url(/images/chat.png) 0px -196px no-repeat;padding:3px 5px 3px 6px;"><span style="background-color:#FFFFFF;color:#888888;padding-right:5px;">'+$('#chat_translate_online').html()+'</span><div id="chat_status_online" class="chat_status_available" title="Go Offline"/></div><div id="chat_online"></div>');
		$.each(Chat.online, function(key,value){
			Chat.chatall.push(value.id);
			if (value.status == 0) available = 'chat_away'; else available = 'chat_available'; 
			if (jQuery.inArray(value.id,Chat.chattab) != -1) {
				$('#chat_user_'+value.id+'_status').removeClass('chat_away');
				$('#chat_user_'+value.id+'_status').removeClass('chat_available');
				$('#chat_user_'+value.id+'_status').addClass(available);
			}
			$('#chat_online').append('<div onclick="Chat.createchat(\''+value.id+'\',1,0)" class="chat_online" style="padding:1px 5px 1px 9px;" title="'+value.age+', '+value.city+'"><div class="fleft"><img src="http://www.'+$('#chat_url').html()+'.com/photos/'+value.image+'-c25.jpg" width="25" height="25"></div><div class="fleft smarg">'+value.name+'</div><div class="chat_online_icon '+available+'"></div><div class="clear"></div></div>');
		});
		if (Chat.statuso == 1) {
			$('#chat_status_online').attr('title',$('#chat_translate_gooffline').html());
			$('#chat_status_online').removeClass('chat_status_invisible'); 
		} else {
			$('#chat_status_online').attr('title',$('#chat_translate_goonline').html());
			$('#chat_status_online').addClass('chat_status_invisible');
		}
		var windowSize = Lightbox.getPageDimensions();
		if ($('#chat_users').height() > windowSize[1]-150) {
			$('#chat_users').css('height',windowSize[1]-150);
		} else {
			var height = $('#chat_online').height() + 20;
			if (height > windowSize[1]-150) $('#chat_users').css('height',windowSize[1]-150); else $('#chat_users').css('height',height);
		}
		if (Chat.statuso == 1) {
			$('#chat_userstab_icon').addClass('chat_user_available');
		} else {
			$('#chat_userstab_icon').removeClass('chat_user_available');
			$('#chat_userstab_text').html($('#chat_translate_chat').html()+' '+$('#chat_translate_offline').html());
		}
		$.each(Chat.chattab, function(key,value){
			if (jQuery.inArray(value,Chat.chatall) == -1) Chat.taboffline(value); else Chat.tabonline(value);
		});
		$('#chat_status_online').click(function(){Chat.changestatus('online');});
		$('.tipsy-east').remove();
		$('#chat_status_online').tipsy({gravity:'e'});
	},

	tabonline : function(id) {
		$('#chat_user_'+id+'_status').removeClass('chat_offline');
	},

	taboffline : function(id) {
		$('#chat_user_'+id+'_status').addClass('chat_offline');
	},

	changestatus : function(type) {
		if (type == 'online') {
			if (Chat.statuso == 1) {
				Chat.statuso = 0;
				$('#chat_status_online').addClass('chat_status_invisible');
			} else {
				Chat.statuso = 1;
				$('#chat_status_online').removeClass('chat_status_invisible');
			}
		}
		Chat.request(1,1);
	},

	send : function(value) {
		$.post('ajax/chat.php', {send:1,chat:Chat.chatopen,message:value}, function(data){
			Chat.chats = data;
			Chat.nchat();
		}, "json");
	},

	request : function(user,status) {
		var whois = 0;
		clearTimeout(Chat.timeout);
		if (Chat.chatopen == null || Chat.chatopen == 0) Chat.ajaxtime = 10; else Chat.ajaxtime = 2;
		if (status == 0) var params = {alerts:1,users:user,chat:Chat.chatopen,time:Chat.time,typing:Chat.writing,active:Chat.active};
		else var params = {alerts:1,users:user,chat:Chat.chatopen,time:Chat.time,typing:Chat.writing,active:Chat.active,online:Chat.statuso};
		$.post('ajax/chat.php', params, function(data){
			if (data.exit == null) {
				if (data.time != null) {
					Chat.time = data.time;
				}
				if (data.chats != null) {
					Chat.chats = data.chats;
					Chat.nchat();
				}
				if (data.online != null) {
					whois = 1;
					Chat.online = data.online;
				}
				if (data.status != null) {
					Chat.statuso = data.status[0];
				}
				if (whois) {
					$('#chat_userstab_text').html($('#chat_translate_chat').html()+' ('+data.nb+')');
					Chat.whosonline();
				}
				if (data.typing == 1) {
					$('#chat_user_'+Chat.chatopen+'_status').addClass('chat_status_typing');
				} else {
					$('#chat_user_'+Chat.chatopen+'_status').removeClass('chat_status_typing');
				}
				if (data.xinbox != null) {
					$('#xinbox').html(data.xinbox);
				}
				if (data.xrequest != null) {
					$('#xrequest').html(data.xrequest);
				}
				if (data.xalert != null) {
					$('#xalert').html(data.xalert);
				}
				Chat.alerts = data.alerts;
				Chat.users = data.users;
				Chat.nalerts();
				Chat.timeout = setTimeout('Chat.request(0,0)',Chat.ajaxtime*1000);
			} else {
				$('#chat_users').html('<div class="mpad">'+$('#chat_translate_exit').html()+'</div>');
				$('#chat_userstab_text').html($('#chat_translate_chat').html());
			}
		}, "json");
	}
}

/* DHTML Color Picker, Programming by Ulyses, ColorJack.com */
/* This version featured on/ available at Dynamic Drive: http://www.dynamicdrive.com */
/*Minor fixes by DD: Disabled text selection during dragging, fixed IE doctype issue with document.body */

var mycolor = null;
function iupdate(i,c){
	mycolor = i;
	updateH(c);
}
function mkColor(v){
	clearTimeout(changecolor);
	Edit.colorsave(mycolor,v);
	$('#color_'+mycolor).value = v;
	$('#colorbox_'+mycolor).css('background-color','#'+v);
}

var standardbody = (document.compatMode=="CSS1Compat") ? document.documentElement : document.body
function browser(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function within(v,a,z) { return((v>=a && v<=z)?true:false); }
function XY(e,v) { var z=browser('msie')?Array(event.clientX+standardbody.scrollLeft,event.clientY+standardbody.scrollTop):Array(e.pageX,e.pageY); return(z[zero(v)]); }
function zero(v) { v=parseInt(v); return(!isNaN(v)?v:0); }
function zindex(d) { $(d).css('z-index',zINDEX++); }

/* PLUGIN */

var maxValue={'h':'359','s':'100','v':'100'},HSV={0:359,1:100,2:100};
var SVHeight=165,wSV=162,wH=162,slideHSV={0:359,1:100,2:100},zINDEX=15,stop=1;

function HSVslide(d,o,e) {
	function tXY(e) { tY=XY(e,1)-top; tX=XY(e)-left; }
	function mkHSV(a,b,c) { return(Math.min(a,Math.max(0,Math.ceil((parseInt(c)/b)*a)))); }
	function ckHSV(a,b) { if(within(a,0,b)) return(a); else if(a>b) return(b); else if(a<0) return('-'+oo); }
	function drag(e) {
		if(!stop) {
			if(d=='SVslide') {
				tXY(e);
				$('#'+d).css('left',ckHSV(tX-oo,wSV)+'px');
				$('#'+d).css('top',ckHSV(tY-oo,wSV)+'px');
				slideHSV[1] = mkHSV(100,wSV,$('#'+d).css('left'));
				slideHSV[2] = 100 - mkHSV(100,wSV,$('#'+d).css('top'));
				HSVupdate();
			} else if(d=='Hslide') {
				tXY(e);
				$('#'+d).css('top',(ckHSV(tY-oo,wH)-5)+'px');
				slideHSV[0] = mkHSV(359,wH,$('#'+d).css('top'));
				function commit() {
					var r='hsv',z={},j='';
					for(var i=0; i<=r.length-1; i++) {
						j=r.substr(i,1);
						z[i]= (j=='h') ? maxValue[j]-mkHSV(maxValue[j],wH,$('#'+d).css('top')) : HSV[i];
					}
					return(HSVupdate(hsv2hex(z)));
				}
				mkColor(commit());
				$('#SV').css('background-color','#'+hsv2hex(Array(HSV[0],100,100)));
			}
		}
		if (e && e.preventDefault) e.preventDefault(); else return false;
	}

	if(stop) {
		stop='';
		var left=($('#'+o).offset().left+10), top=($('#'+o).offset().top+10), tX, tY, oo=(d=='Hslide')?2:4;
		if(d=='SVslide') slideHSV[0] = HSV[0];
		document.onmousemove = drag;
		document.onmouseup = function(){
			stop = 1;
			document.onmousemove = '';
			document.onmouseup= '';
		};
		drag(e);
	}
}

function HSVupdate(v) {
	HSV = v ? hex2hsv(v) : Array(slideHSV[0],slideHSV[1],slideHSV[2]);
	if(!v) v = hsv2hex(Array(slideHSV[0],slideHSV[1],slideHSV[2]));
	mkColor(v);
	$('#plugHEX').html('#'+v);
	return(v);
}

function loadSV() {
	var z = '';
	for(var i=SVHeight; i>=0; i--) {
		var backcolor = hsv2hex(Array(Math.round((359/SVHeight)*i),100,100));
		z += '<div style="background:#'+backcolor+';"><br /></div>';
	}
	$('#Hmodel').html(z);
}

function updateH(v) {
	HSV = hex2hsv(v);
	$('#plugHEX').html('#'+v);
	$('#SV').css('background-color','#'+hsv2hex(Array(HSV[0],100,100))); 
	$('#SVslide').css('top',(parseInt(wSV-wSV*(HSV[2]/100))-4)+'px');
	$('#SVslide').css('left',parseInt(wSV*(HSV[1]/100))+'px');
	$('#Hslide').css('top',(parseInt(wH*((maxValue['h']-HSV[0])/maxValue['h']))-7)+'px');
}

/* CONVERSIONS */

function toHex(v) { v=Math.round(Math.min(Math.max(0,v),255)); return("0123456789ABCDEF".charAt((v-v%16)/16)+"0123456789ABCDEF".charAt(v%16)); }
function hex2rgb(r) { return({0:parseInt(r.substr(0,2),16),1:parseInt(r.substr(2,2),16),2:parseInt(r.substr(4,2),16)}); }
function rgb2hex(r) { return(toHex(r[0])+toHex(r[1])+toHex(r[2])); }
function hsv2hex(h) { return(rgb2hex(hsv2rgb(h))); }	
function hex2hsv(v) { return(rgb2hsv(hex2rgb(v))); }

function rgb2hsv(r) { // easyrgb.com/math.php?MATH=M20#text20

	var max=Math.max(r[0],r[1],r[2]),delta=max-Math.min(r[0],r[1],r[2]),H,S,V;
	
	if(max!=0) { S=Math.round(delta/max*100);

		if(r[0]==max) H=(r[1]-r[2])/delta; else if(r[1]==max) H=2+(r[2]-r[0])/delta; else if(r[2]==max) H=4+(r[0]-r[1])/delta;

		var H=Math.min(Math.round(H*60),360); if(H<0) H+=360;

	}

	return({0:H?H:0,1:S?S:0,2:Math.round((max/255)*100)});
}

function hsv2rgb(r) { // easyrgb.com/math.php?MATH=M21#text21

	var R,B,G,S=r[1]/100,V=r[2]/100,H=r[0]/360;

	if(S>0) { if(H>=1) H=0;

		H=6*H; F=H-Math.floor(H);
		A=Math.round(255*V*(1.0-S));
		B=Math.round(255*V*(1.0-(S*F)));
		C=Math.round(255*V*(1.0-(S*(1.0-F))));
		V=Math.round(255*V); 

		switch(Math.floor(H)) {

			case 0: R=V; G=C; B=A; break;
			case 1: R=B; G=V; B=A; break;
			case 2: R=A; G=V; B=C; break;
			case 3: R=A; G=B; B=V; break;
			case 4: R=C; G=A; B=V; break;
			case 5: R=V; G=A; B=B; break;

		}

		return({0:R?R:0,1:G?G:0,2:B?B:0});

	}
	else return({0:(V=Math.round(V*255)),1:V,2:V});
}

/*
*  Ajax Autocomplete for jQuery, version 1.0.7
*  (c) 2009 Tomas Kirda
*
*  Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
*  For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
*
*  Last Review: 07/27/2009
*/

(function($) {

  $.fn.autocomplete = function(options) {
    return this.each(function() {
      return new Autocomplete(this, options);
    });
  };

  var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g');

  var fnFormatResult = function(value, data, currentValue) {
    var pattern = '(' + currentValue.replace(reEscape, '\\$1') + ')';
    return value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
  };

  var Autocomplete = function(el, options) {
    this.el = $(el);
    this.el.attr('autocomplete', 'off');
    this.suggestions = [];
    this.data = [];
    this.photos = [];
    this.regions = [];
    this.countries = [];
    this.badQueries = [];
    this.selectedIndex = -1;
    this.currentValue = this.el.val();
    this.intervalId = 0;
    this.cachedResponse = [];
    this.onChangeInterval = null;
    this.ignoreValueChange = false;
    this.serviceUrl = options.serviceUrl;
    this.isLocal = false;
    this.options = {
      autoSubmit: false,
      minChars: 1,
      maxHeight: 300,
      deferRequestBy: 0,
      width: 0,
      highlight: true,
      params: {},
      fnFormatResult: fnFormatResult,
      delimiter: null
    };
    if (options) { $.extend(this.options, options); }
    if(this.options.lookup){
      this.isLocal = true;
      if($.isArray(this.options.lookup)){ this.options.lookup = { suggestions:this.options.lookup, data:[] }; }
    }
    this.initialize();
  };

  Autocomplete.prototype = {

    killerFn: null,

    initialize: function() {

      var me, zindex;
      me = this;

      zindex = 80000;

      this.killerFn = function(e) {
        if ($(e.target).parents('.autocomplete').size() === 0) {
          me.killSuggestions();
          me.disableKillerFn();
        }
      };

      var uid = new Date().getTime();
      var autocompleteElId = 'Autocomplete_' + uid;

      if (!this.options.width) { this.options.width = this.el.width(); }
      this.mainContainerId = 'AutocompleteContainter_' + uid;

      $('<div id="' + this.mainContainerId + '" style="position:absolute;z-index:' + zindex + '"><div class="autocomplete" id="' + autocompleteElId + '" style="display:none; width:' + this.options.width + 'px;"></div></div>').appendTo('body');

      this.container = $('#' + autocompleteElId);
      this.fixPosition();
      if (window.opera) {
        this.el.keypress(function(e) { me.onKeyPress(e); });
      } else {
        this.el.keydown(function(e) { me.onKeyPress(e); });
      }
      this.el.keyup(function(e) { me.onKeyUp(e); });
      this.el.blur(function() { me.enableKillerFn(); });
      this.el.focus(function() { me.fixPosition(); });
      this.el.click(function() { me.onValueChange(); });

      this.container.css({ maxHeight: this.options.maxHeight + 'px' });
    },

    fixPosition: function() {
      var offset = this.el.offset();
      $('#' + this.mainContainerId).css({ top: (offset.top + this.el.innerHeight()) + 'px', left: offset.left + 'px' });
    },

    enableKillerFn: function() {
      var me = this;
      $(document).bind('click', me.killerFn);
    },

    disableKillerFn: function() {
      var me = this;
      $(document).unbind('click', me.killerFn);
    },

    killSuggestions: function() {
      var me = this;
      this.stopKillSuggestions();
      this.intervalId = window.setInterval(function() { me.hide(); me.stopKillSuggestions(); }, 300);
    },

    stopKillSuggestions: function() {
      window.clearInterval(this.intervalId);
    },

    onKeyPress: function(e) {

      if (!this.enabled) { return; }
      // return will exit the function
      // and event will not fire
      switch (e.keyCode) {
        case 27: //Event.KEY_ESC:
          this.el.val(this.currentValue);
          this.hide();
          break;
        case 9: //Event.KEY_TAB:
        case 13: //Event.KEY_RETURN:
          if (this.selectedIndex === -1) {
            this.hide();
            return;
          }
          this.select(this.selectedIndex);
          if (e.keyCode === 9/* Event.KEY_TAB */) { return; }
          break;
        case 38: //Event.KEY_UP:
          this.moveUp();
          break;
        case 40: //Event.KEY_DOWN:
          this.moveDown();
          break;
        default:
          return;
      }
      e.stopImmediatePropagation();
      e.preventDefault();
    },

    onKeyUp: function(e) {
      switch (e.keyCode) {
        case 38: //Event.KEY_UP:
        case 40: //Event.KEY_DOWN:
          return;
      }
      clearInterval(this.onChangeInterval);
      if (this.currentValue !== this.el.val()) {
        if (this.options.deferRequestBy > 0) {
          // Defer lookup in case when value changes very quickly:
          var me = this;
          this.onChangeInterval = setInterval(function() { me.onValueChange(); }, this.options.deferRequestBy);
        } else {
          this.onValueChange();
        }
      }
    },

    onValueChange: function() {
      clearInterval(this.onChangeInterval);
      this.currentValue = this.el.val();
      var q = this.getQuery(this.currentValue);
      this.selectedIndex = -1;
      if (this.ignoreValueChange) {
        this.ignoreValueChange = false;
        return;
      }
      if (q === '' || q.length < this.options.minChars) {
        this.hide();
      } else {
        this.getSuggestions(q);
      }
    },

    getQuery: function(val) {
      var d, arr;
      d = this.options.delimiter;
      if (!d) { return $.trim(val); }
      arr = val.split(d);
      return $.trim(arr[arr.length - 1]);
    },

    getSuggestionsLocal: function(q) {
      var ret, arr, len, val;
      arr = this.options.lookup;
      len = arr.suggestions.length;
      ret = { suggestions:[], data:[] };
      for(var i=0; i< len; i++){
        val = arr.suggestions[i];
        if(val.toLowerCase().indexOf(q.toLowerCase()) === 0){
          ret.suggestions.push(val);
          ret.data.push(arr.data[i]);
          if(this.options.params.type == 'city') {
          	ret.regions.push(arr.regions[i]);
          	ret.countries.push(arr.countries[i]);
		  } else {
			ret.photos.push(arr.photos[i]);
		  }
        }
      }
      return ret;
    },
    
    getSuggestions: function(q) {
      var cr, me, ls;
      cr = this.isLocal ? this.getSuggestionsLocal(q) : this.cachedResponse[q];
      if (cr && $.isArray(cr.suggestions)) {
        this.suggestions = cr.suggestions;
        this.data = cr.data;
        if(this.options.params.type == 'city') {
        	this.regions = cr.regions;
        	this.countries = cr.countries;
		} else {
			this.photos = cr.photos;
		}
        this.suggest();
      } else if (!this.isBadQuery(q)) {
        me = this;
        me.options.params.query = q;
        $.get(this.serviceUrl, me.options.params, function(txt) { me.processResponse(txt); }, 'text');
      }
    },

    isBadQuery: function(q) {
      var i = this.badQueries.length;
      while (i--) {
        if (q.indexOf(this.badQueries[i]) === 0) { return true; }
      }
      return false;
    },

    hide: function() {
      this.enabled = false;
      this.selectedIndex = -1;
      this.container.hide();
    },

    suggest: function() {
      if (this.suggestions.length === 0) {
        this.hide();
        return;
      }

      var me, len, div, f;
      me = this;
      len = this.suggestions.length;
      f = this.options.fnFormatResult;
      v = this.getQuery(this.currentValue);
      this.container.hide().empty();
      for (var i = 0; i < len; i++) {
		if(this.options.params.type == 'city') {
        	if (i < (len-1)) div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li borderbottomlight"><div>' + f(this.suggestions[i], this.data[i], v) + '</div><div class="tiny-txt light">'+this.regions[i]+', '+this.countries[i]+'</div></div></div>');
        	else div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li"><div>' + f(this.suggestions[i], this.data[i], v) + '</div><div class="tiny-txt light">'+this.regions[i]+', '+this.countries[i]+'</div></div></div>');
		} else if(this.options.params.type == 'search') {
        	if (i < (len-1)) div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li borderbottomlight"><div class="fleft l1padtop l1padbottom"><img src="http://www.muzicly.com/photos/'+this.photos[i]+'-c25.jpg" width="25" height="25"></div><div class="fleft l4padleft"><div>' + f(this.suggestions[i], this.data[i], v) + '</div><div class="tiny-txt light">'+this.data[i]+'</div></div><div class="clear"></div></div></div>');
        	else div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li"><div class="fleft l1padtop l1padbottom"><img src="http://www.muzicly.com/photos/'+this.photos[i]+'-c25.jpg" width="25" height="25"></div><div class="fleft l4padleft"><div>' + f(this.suggestions[i], this.data[i], v) + '</div><div class="tiny-txt light">'+this.data[i]+'</div></div><div class="clear"></div></div></div>');
		} else {
        	if (i < (len-1)) div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li borderbottomlight"><div class="fleft l1padtop l1padbottom width50 center"><img src="'+this.photos[i]+'" style="max-width:40px;max-height:40px;"></div><div class="fleft"><div class="mpadtop">' + f(this.suggestions[i], this.data[i], v) + '</div></div><div class="clear"></div></div></div>');
        	else div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + '><div class="li"><div class="fleft l1padtop l1padbottom width50 center"><img src="'+this.photos[i]+'" style="max-width:40px;max-height:40px;"></div><div class="fleft"><div class="mpadtop">' + f(this.suggestions[i], this.data[i], v) + '</div></div><div class="clear"></div></div></div>');
		}
		div.mouseover((function(xi) { return function() { me.activate(xi); }; })(i));
        div.click((function(xi) { return function() { me.select(xi); }; })(i));
        this.container.append(div);
      }
      this.enabled = true;
      this.container.show();
    },

    processResponse: function(text) {
      var response;
      try {
        response = eval('(' + text + ')');
      } catch (err) { return; }
	  if(this.options.params.type == 'pick' && response.suggestions.length === 0) {Pick.newpick();}
      if (!$.isArray(response.data)) { response.data = []; }
      this.cachedResponse[response.query] = response;
      if (response.suggestions.length === 0) { this.badQueries.push(response.query); }
      if (response.query === this.getQuery(this.currentValue)) {
        this.suggestions = response.suggestions;
        this.data = response.data;
		if(this.options.params.type == 'city') {
          this.regions = response.regions;
          this.countries = response.countries;
		} else {
		  this.photos = response.photos;
		}
        this.suggest(); 
      }
    },

    activate: function(index) {
      var divs = this.container.children();
      var activeItem;
      // Clear previous selection:
      if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
        $(divs.get(this.selectedIndex)).attr('class', '');
      }
      this.selectedIndex = index;
      if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
        activeItem = divs.get(this.selectedIndex);
        $(activeItem).attr('class', 'selected');
      }
      return activeItem;
    },

    deactivate: function(div, index) {
      div.className = '';
      if (this.selectedIndex === index) { this.selectedIndex = -1; }
    },

    select: function(i) {
      var selectedValue = this.suggestions[i];
      if (selectedValue) {
        this.el.val(selectedValue);
        if (this.options.autoSubmit) {
          var f = this.el.parents('form');
          if (f.length > 0) { f.get(0).submit(); }
        }
        this.ignoreValueChange = true;
        this.hide();
        this.onSelect(i);
      }
    },

    moveUp: function() {
      if (this.selectedIndex === -1) { return; }
      if (this.selectedIndex === 0) {
        this.container.children().get(0).className = '';
        this.selectedIndex = -1;
        this.el.val(this.currentValue);
        return;
      }
      this.adjustScroll(this.selectedIndex - 1);
    },

    moveDown: function() {
      if (this.selectedIndex === (this.suggestions.length - 1)) { return; }
      this.adjustScroll(this.selectedIndex + 1);
    },

    adjustScroll: function(i) {
      var activeItem, offsetTop, upperBound, lowerBound;
      activeItem = this.activate(i);
      offsetTop = activeItem.offsetTop;
      upperBound = this.container.scrollTop();
      lowerBound = upperBound + this.options.maxHeight - 25;
      if (offsetTop < upperBound) {
        this.container.scrollTop(offsetTop);
      } else if (offsetTop > lowerBound) {
        this.container.scrollTop(offsetTop - this.options.maxHeight + 25);
      }
      //this.el.val(this.suggestions[i]);
    },

    onSelect: function(i) {
      var me, onSelect, getValue, s, d;
      me = this;
      onSelect = me.options.onSelect;
      getValue = function(value) {
        var del, currVal;
        del = me.options.delimiter;
        currVal = me.currentValue;
        if (!del) { return value; }
        var arr = currVal.split(del);
        if (arr.length === 1) { return value; }
        return currVal.substr(0, currVal.length - arr[arr.length - 1].length) + value;
      };
      s = me.suggestions[i];
      d = me.data[i];
      me.el.val(getValue(s));
      if ($.isFunction(onSelect)) {
		  if(this.options.params.type == 'city') {
      		  c = me.countries[i];
			  onSelect(s, d, c);
		  } else if(this.options.params.type == 'search') {
			  onSelect(s, d);
		  } else {
      		  c = me.photos[i];
			  onSelect(d, s, c);
		  }
	  }
    }

  };

})(jQuery);


(function (jQuery){
    // keep reference to the original $.fn.bind, $.fn.unbind and $.fn.find
    jQuery.fn.__bind__ = jQuery.fn.bind;
    jQuery.fn.__unbind__ = jQuery.fn.unbind;
    jQuery.fn.__find__ = jQuery.fn.find;
    
    var hotkeys = {
        version: '0.7.9',
        override: /keypress|keydown|keyup/g,
        triggersMap: {},
        
        specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 
            20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',
            35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 
            109: '-', 
            112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 
            120:'f9', 121:'f10', 122:'f11', 123:'f12', 191: '/'},
        
        shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", 
            "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<", 
            ".":">",  "/":"?",  "\\":"|" },
        
        newTrigger: function (type, combi, callback) { 
            // i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}}
            var result = {};
            result[type] = {};
            result[type][combi] = {cb: callback, disableInInput: false};
            return result;
        }
    };
    // add firefox num pad char codes
    //if (jQuery.browser.mozilla){
    // add num pad char codes
    hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99: 
        '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9', 106: '*', 
        107: '+', 109: '-', 110: '.', 111 : '/'
        });
    //}
    
    // a wrapper around of $.fn.find 
    // see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d
    jQuery.fn.find = function( selector ) {
        this.query = selector;
        return jQuery.fn.__find__.apply(this, arguments);
	};
    
    jQuery.fn.unbind = function (type, combi, fn){
        if (jQuery.isFunction(combi)){
            fn = combi;
            combi = null;
        }
        if (combi && typeof combi === 'string'){
            var selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
            var hkTypes = type.split(' ');
            for (var x=0; x<hkTypes.length; x++){
                delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];
            }
        }
        // call jQuery original unbind
        return  this.__unbind__(type, fn);
    };
    
    jQuery.fn.bind = function(type, data, fn){
        // grab keyup,keydown,keypress
        var handle = type.match(hotkeys.override);
        
        if (jQuery.isFunction(data) || !handle){
            // call jQuery.bind only
            return this.__bind__(type, data, fn);
        }
        else{
            // split the job
            var result = null,            
            // pass the rest to the original $.fn.bind
            pass2jq = jQuery.trim(type.replace(hotkeys.override, ''));
            
            // see if there are other types, pass them to the original $.fn.bind
            if (pass2jq){
                result = this.__bind__(pass2jq, data, fn);
            }            
            
            if (typeof data === "string"){
                data = {'combi': data};
            }
            if(data.combi){
                for (var x=0; x < handle.length; x++){
                    var eventType = handle[x];
                    var combi = data.combi.toLowerCase(),
                        trigger = hotkeys.newTrigger(eventType, combi, fn),
                        selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
                        
                    //trigger[eventType][combi].propagate = data.propagate;
                    trigger[eventType][combi].disableInInput = data.disableInInput;
                    
                    // first time selector is bounded
                    if (!hotkeys.triggersMap[selectorId]) {
                        hotkeys.triggersMap[selectorId] = trigger;
                    }
                    // first time selector is bounded with this type
                    else if (!hotkeys.triggersMap[selectorId][eventType]) {
                        hotkeys.triggersMap[selectorId][eventType] = trigger[eventType];
                    }
                    // make trigger point as array so more than one handler can be bound
                    var mapPoint = hotkeys.triggersMap[selectorId][eventType][combi];
                    if (!mapPoint){
                        hotkeys.triggersMap[selectorId][eventType][combi] = [trigger[eventType][combi]];
                    }
                    else if (mapPoint.constructor !== Array){
                        hotkeys.triggersMap[selectorId][eventType][combi] = [mapPoint];
                    }
                    else {
                        hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length] = trigger[eventType][combi];
                    }
                    
                    // add attribute and call $.event.add per matched element
                    this.each(function(){
                        // jQuery wrapper for the current element
                        var jqElem = jQuery(this);
                        
                        // element already associated with another collection
                        if (jqElem.attr('hkId') && jqElem.attr('hkId') !== selectorId){
                            selectorId = jqElem.attr('hkId') + ";" + selectorId;
                        }
                        jqElem.attr('hkId', selectorId);
                    });
                    result = this.__bind__(handle.join(' '), data, hotkeys.handler)
                }
            }
            return result;
        }
    };
    // work-around for opera and safari where (sometimes) the target is the element which was last 
    // clicked with the mouse and not the document event it would make sense to get the document
    hotkeys.findElement = function (elem){
        if (!jQuery(elem).attr('hkId')){
            if (jQuery.browser.opera || jQuery.browser.safari){
                while (!jQuery(elem).attr('hkId') && elem.parentNode){
                    elem = elem.parentNode;
                }
            }
        }
        return elem;
    };
    // the event handler
    hotkeys.handler = function(event) {
        var target = hotkeys.findElement(event.currentTarget), 
            jTarget = jQuery(target),
            ids = jTarget.attr('hkId');
        
        if(ids){
            ids = ids.split(';');
            var code = event.which,
                type = event.type,
                special = hotkeys.specialKeys[code],
                // prevent f5 overlapping with 't' (or f4 with 's', etc.)
                character = !special && String.fromCharCode(code).toLowerCase(),
                shift = event.shiftKey,
                ctrl = event.ctrlKey,            
                // patch for jquery 1.2.5 && 1.2.6 see more at:  
                // http://groups.google.com/group/jquery-en/browse_thread/thread/83e10b3bb1f1c32b
                alt = event.altKey || event.originalEvent.altKey,
                mapPoint = null;

            for (var x=0; x < ids.length; x++){
                if (hotkeys.triggersMap[ids[x]][type]){
                    mapPoint = hotkeys.triggersMap[ids[x]][type];
                    break;
                }
            }
            
            //find by: id.type.combi.options            
            if (mapPoint){ 
                var trigger;
                // event type is associated with the hkId
                if(!shift && !ctrl && !alt) { // No Modifiers
                    trigger = mapPoint[special] ||  (character && mapPoint[character]);
                }
                else{
                    // check combinations (alt|ctrl|shift+anything)
                    var modif = '';
                    if(alt) modif +='alt+';
                    if(ctrl) modif+= 'ctrl+';
                    if(shift) modif += 'shift+';
                    // modifiers + special keys or modifiers + character or modifiers + shift character or just shift character
                    trigger = mapPoint[modif+special];
                    if (!trigger){
                        if (character){
                            trigger = mapPoint[modif+character] 
                                || mapPoint[modif+hotkeys.shiftNums[character]]
                                // '$' can be triggered as 'Shift+4' or 'Shift+$' or just '$'
                                || (modif === 'shift+' && mapPoint[hotkeys.shiftNums[character]]);
                        }
                    }
                }
                if (trigger){
                    var result = false;
                    for (var x=0; x < trigger.length; x++){
                        if(trigger[x].disableInInput){
                            // double check event.currentTarget and event.target
                            var elem = jQuery(event.target);
                            if (jTarget.is("input") || jTarget.is("textarea") || jTarget.is("select") 
                                || elem.is("input") || elem.is("textarea") || elem.is("select")) {
                                return true;
                            }
                        }                       
                        // call the registered callback function
                        result = result || trigger[x].cb.apply(this, [event]);
                    }
                    return result;
                }
            }
        }
    };
    // place it under window so it can be extended and overridden by others
    window.hotkeys = hotkeys;
    return jQuery;
})(jQuery);

(function($){
    
    $.fn.autoResize = function(options) {
        
        // Just some abstracted details,
        // to make plugin users happy:
        var settings = $.extend({
            onResize : function(){},
            animate : true,
            animateDuration : 300,
            animateCallback : function(){},
            extraSpace : 15,
            limit: 500
        }, options);
        
        // Only textarea's auto-resize:
        this.filter('textarea').each(function(){
            
                // Get rid of scrollbars and disable WebKit resizing:
            var textarea = $(this).css({resize:'none','overflow-y':'hidden'}),
            
                // Cache original height, for use later:
                origHeight = textarea.height(),
                
                // Need clone of textarea, hidden off screen:
                clone = (function(){
                    
                    // Properties which may effect space taken up by chracters:
                    var props = ['height','width','lineHeight','textDecoration','letterSpacing'],
                        propOb = {};
                        
                    // Create object of styles to apply:
                    $.each(props, function(i, prop){
                        propOb[prop] = textarea.css(prop);
                    });
                    
                    // Clone the actual textarea removing unique properties
                    // and insert before original textarea:
                    return textarea.clone().removeAttr('id').removeAttr('name').css({
                        position: 'absolute',
                        top: 0,
                        left: -9999
                    }).css(propOb).attr('tabIndex','-1').insertBefore(textarea);
					
                })(),
                lastScrollTop = null,
                updateSize = function() {
					
                    // Prepare the clone:
                    clone.height(0).val($(this).val()).scrollTop(10000);
					
                    // Find the height of text:
                    if (clone.scrollTop() > (origHeight - settings.extraSpace)) {
						var scrollTop = clone.scrollTop() + settings.extraSpace - 1,
                        toChange = $(this).add(clone);
					} else {
						var scrollTop = origHeight,
                        toChange = $(this).add(clone);
					}
						
                    // Don't do anything if scrollTip hasen't changed:
                    if (lastScrollTop === scrollTop) { return; }
                    lastScrollTop = scrollTop;
					
                    // Check for limit:
                    if ( scrollTop >= settings.limit ) {
                        $(this).css('overflow-y','');
                        return;
                    }
                    // Fire off callback:
                    settings.onResize.call(this);
					
                    // Either animate or directly apply height:
                    settings.animate && textarea.css('display') === 'block' ?
                        toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback)
                        : toChange.height(scrollTop);
                };
            
            // Bind namespaced handlers to appropriate events:
            textarea
                .unbind('.dynSiz')
                .bind('click.dynSiz', updateSize)
                .bind('keyup.dynSiz', updateSize)
                .bind('keydown.dynSiz', updateSize)
                .bind('change.dynSiz', updateSize);
        });
        
        // Chain:
        return this;
    };
    
})(jQuery);

(function($) {
    $.fn.tipsy = function(opts) {

        opts = $.extend({fade: false, gravity: 'n'}, opts || {});
        var tip = null, cancelHide = false;

        this.hover(function() {
            
            $.data(this, 'cancel.tipsy', true);

            var tip = $.data(this, 'active.tipsy');
            if (!tip) {
                tip = $('<div class="tipsy"><div class="tipsy-inner">' + $(this).attr('title') + '</div></div>');
                tip.css({position: 'absolute', zIndex: 100000});
                $(this).attr('title', '');
                $.data(this, 'active.tipsy', tip);
            }
            
            var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
            tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
            var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;

            switch (opts.gravity.charAt(0)) {
                case 'n':
                    tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
                    break;
                case 's':
                    tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
                    break;
                case 'e':
                    tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
                    break;
                case 'w':
                    tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
                    break;
                case 'y':
                    tip.css({top: pos.top - actualHeight - 2, left: pos.left + 14 + pos.width / 2 - actualWidth}).addClass('tipsy-se');
                    break;
            }

            if (opts.fade) {
                tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 1});
            } else {
                tip.css({visibility: 'visible'});
            }

        }, function() {
            $.data(this, 'cancel.tipsy', false);
            var self = this;
			if ($.data(this, 'cancel.tipsy')) return;
			var tip = $.data(self, 'active.tipsy');
			if (opts.fade) {
				tip.stop().fadeOut(function() { $(this).remove(); });
			} else {
				tip.remove();
			}
        });

    };
})(jQuery);


(function($){
$.idleTimer = function f(newTimeout){
    var idle    = false,
        enabled = true,
        timeout = 60000,
        events  = 'mousemove keydown DOMMouseScroll mousewheel mousedown',
    toggleIdleState = function(){
        idle = !idle;
        f.olddate = +new Date;
        $(document).trigger(  $.data(document,'idleTimer', idle ? "idle" : "active" )  + '.idleTimer');            
    },
    stop = function(){
        enabled = false;
        clearTimeout($.idleTimer.tId);
        $(document).unbind('.idleTimer');
    },
    handleUserEvent = function(){
        clearTimeout($.idleTimer.tId);
        if (enabled){
            if (idle){
                toggleIdleState();           
            } 
            $.idleTimer.tId = setTimeout(toggleIdleState, timeout);
        }    
     };
    f.olddate = f.olddate || +new Date;
    if (typeof newTimeout == "number"){
        timeout = newTimeout;
    } else if (newTimeout === 'destroy') {
        stop();
        return this;  
    } else if (newTimeout === 'getElapsedTime'){
        return (+new Date) - f.olddate;
    }
    $(document).bind($.trim((events+' ').split(' ').join('.idleTimer ')),handleUserEvent);
    $.idleTimer.tId = setTimeout(toggleIdleState, timeout);
    $.data(document,'idleTimer',"active");
};
})(jQuery);

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
function flash(div){
	if(div) var divs = $('#'+div+' div'); else var divs = $('div');
	var divmax = divs.length;
	for(var i=0; i<divmax; i++){
		if(divs[i].id.indexOf('swf') != -1){
			var f = $('#'+divs[i].id).attr('flash');
			var h = $('#'+divs[i].id).attr('height');
			var w = $('#'+divs[i].id).attr('width');
			var v = $('#'+divs[i].id).attr('vars');
			setFlash(divs[i].id,f,w,h,v);
		}
	}
}

function setFlash(elm,swf,w,h,v){
	var fname = swf.split('/');
	var vars = v.split(';');
	fname = fname[fname.length -1].split('.');
	var fo = new SWFObject(swf,fname[0],w,h,'7','#FFFFFF');
	fo.addParam('allowScriptAccess','always');
	fo.addParam('wmode','transparent');
	fo.addParam('menu','false');
	fo.addParam('quality','high');
	var t = vars.length;
	for(i=0;i<t;i++){
		var a = vars[i].split(':');
		fo.addVariable(''+a[0]+'',''+a[1]+'');
	}
	fo.write(elm);
}

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