var theresultname;

/* VIDEO
-----------------------------------------------------------------------------*/

var lastthumb;
var lastobj;
var isclosing=false;
function putVideo(id,obj) {
	if(!isclosing) {
		if(lastobj) {
			if(lastobj==obj) {
				return;
			}
			lastobj.innerHTML=lastthumb;
			removeClass(lastobj,'playing');
		}
		lastthumb=obj.innerHTML;
		lastobj=obj;
		addClass(lastobj,'playing');
	
		$('.playing').fadeTo(0,0);
		$('.playing').fadeTo(1,750);
	
		width=360;
		height=270;
		
		obj.innerHTML='<div onclick="closeVideo();" class="the-close"></div>';

		if($('#ajaxc').html()=='<div class="loading"><img src="/images/loading.gif">Loading...</div>')
			$('#ajaxc').html('');
		resetAjax();
		obj.id = 'ajaxc';

		sendReq('/php/G.video.php','u',id);
	} else {
		lastobj.innerHTML=lastthumb;
		lastthumb=null;
		removeClass(lastobj,'playing');
		lastobj=null;
		isclosing=false;
	}
}
function closeVideo() {
	isclosing=true;
}

function randomVideos() {
	theRequests=0;
	theSpecial=1;
	$('#vert-bar span').addClass('clicked');
	$('#updatearea').html('');
	loadMore();
	scrollToContent();
}

function loadVideo(url,obj) {	
	clearVideoSelected();
	obj.className='selected';

	resetAjax();
	$('.the-home-video').attr('id','ajaxc');
	$('#ajaxc').show();
	
	sendReq('/php/G.video.php','u',url);
	scrollWin('#home-video');
}


/* HOME - ALBUM
=============================================================================*/

function loadMusic(thequery) {
	resetAjax();
	$('.music-area').attr('id','ajaxc');

	sendReq('/php/G.music.php','g',thequery);
}
function loadMusicPlayer(id,obj) {
//	clearAlbumSelected();
//	obj.className='selected';

	resetAjax();
	$('.float-music').attr('id','ajaxc');
	$('.float-music').removeClass('closed');
	$('#ajaxc').show('slow');
	
	sendReq('/php/G.bandcamp.php','i',id);
}
function closeMusic() {
	$('.float-music').addClass('closed');
	$('.float-music').hide('slow');
}



/* HOME - NEWS
=============================================================================*/

function loadNext(daysback) {
	if(daysback==0) $('#updatearea').html('');
	if(daysback>0) removeElement('show-more');
	
	//document.newstag.reset();
	resetAjax();
	var nextDiv = document.createElement("div");
	nextDiv.id = "ajaxc";
	nextDiv.innerHTML = "<div class='loading'>Loading headlines...</div>";
	nextDiv.style.visibility = "visible";
	
	document.getElementById('updatearea').appendChild(nextDiv);
	$('#ajaxc').fadeIn();
	
	sendReq('/php/G.news.php','d',daysback.toString());
	daysback++;
}


/* HOME - TWITTER
=============================================================================*/

function getTweets(listname) {
	document.getElementById('twitterhome').src = '/php/I.twitter.php?q=burghsounds/pittsburgh-'+listname+'&t=list&h=380&c=20';
}


/* SIDEBAR - QUICKBAR
=============================================================================*/

var lastclicked=false;
var lastname;
var lastoffset;

function getQuickbar(name,theobj) {
	resetAjax();
	lastrandoms=[];
	if(lastclicked) {
		var theclass=lastclicked.className;
		theclass=theclass.replace(/clicked/,"");
		lastclicked.className=theclass;
	}

	theobj.className=theobj.className+" clicked visited";
	lastclicked=theobj;
	if (lastname==name) {
		window.location = "/" + name;
		$('#everything').fadeOut("slow");
	} else {
		$('.sidebar-sidebar').fadeOut("slow");
		lastname=name;
		$('.sidebar-profile').attr('id','ajaxc');
		lastoffset=currentYPosition();
		$('#ajaxc').html('<div class="loading"><img src="/images/loading.gif">Loading quickbar...</div>');
		lastrandoms=[];
		sendReq('/php/G.quickbar.php','n',name);
		$('#ajaxc').hide().delay(250).fadeIn("slow");
		scrollWin('#sidebar');
	}
}


/* SIDEBAR - RELATED
=============================================================================*/

var lasttag='';

function loadHotlistSide(thetag) {
	if(thetag) lasttag=thetag;
	resetAjax();
	$('.the-sidebar-related').attr('id','ajaxc');
	$('#ajaxc').html('<div class="loading"><img src="/images/loading.gif">Loading news...</div>');
	sendReq('/php/G.genre.php','t,a',lasttag+',true');
}
function showSidebar() {
	lastname='';
	if(lastclicked) {
		var theclass=lastclicked.className;
		theclass=theclass.replace(/clicked/,"");
		lastclicked.className=theclass;
		lastclicked=null;
	}
	$('.sidebar-profile').hide();

	if(lastoffset>500)
		scrollY(lastoffset);
	$('.sidebar-sidebar').fadeIn("slow");
}


/* SIDEBAR - VIDEO
=============================================================================*/

var lastrandoms=[];

function nextQuickbarVideo(query,count,first) {	
	resetAjax();
	$('.the-random-video.video-'+query).attr('id','ajaxc');
	if(lastrandoms.length==0)
		lastrandoms.push(first);
	if(lastrandoms.length>=count) {
		lastrandoms.length=0;
		lastrandoms.push(first);
		theindex=first;
	} else {
		do {
			theindex=Math.floor(Math.random()*(count));
		} while (theindex in oc(lastrandoms));
		lastrandoms.push(theindex);
	}
	sendReq('/php/G.video-q.php','q,i',query+','+theindex);
	$('#ajaxc').show();
}
function oc(a) {
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}
function loadSideVideo(request) {
	if(request) {
		resetAjax();
		data=request.split(',');
		$('.the-random-video.video-'+data[0]).attr('id','ajaxc');	
		sendReq('/php/G.video-q.php','q,i',request);
		$('#ajaxc').show();
	}
}


/* PROFILES
=============================================================================*/

var lasttype='';
var lastgenre='';
var lastquery;
var firstflex;

function getFilterClose(thequery) {
	removeElement('filter-head');
	goDefault();
	clearGenre();
	$lasttype=$('.tabs.filter .clicked');
	lasttype='1';
	refreshResults(false);
}
function goDefault() {
	$(".tabs span").removeClass('clicked');
	$("#button-default").addClass('clicked');
	closeFlex();
	$('#the-map').show();
}
function goAll() {
	$(".tabs.filter span").removeClass('clicked');
	$(".button-all").addClass('clicked');
	closeFlex();
}
function clearGenre() {
	lastgenre='';
	$(".filter-tags span").removeClass('clicked');
	closeFlex();
	$('#the-map').show();
}
function closeFilter(thefilter) {
	if(thefilter=='type') {
		lasttype='';
		if(lastgenre)
			goAll();
		else
			goDefault();
		$lasttype=$('.tabs.filter .clicked');
		lasttype='1';
	}
	else if(thefilter=='genre') {
		clearGenre();
	}
	refreshResults(false);
}
function getTypeFilter(thequery,thetype) {
	resetAjax();
	if(thetype==1) {
		clearGenre();
		goDefault();
	}
	$('.the-results').attr('id','ajaxc');
	lastclicked=null;
	lasttype=thetype;
	refreshResults(thequery);
}
function getTagFilter(thequery,thegenre) {
	resetAjax();
	$('.the-results').attr('id','ajaxc');
	lastclicked=null;
	lastgenre=thegenre;
	if(lasttype==''||lasttype=='1') {
		goAll();
		lastclicked=null;
		lasttype='';
	}
	
	putFlex('<a href="/'+URLMake(URLDecode(thegenre))+'/"><h1>All Pittsburgh '+URLDecode(thegenre)+'</h1></a>');
	$('#the-map').hide();

	refreshResults(thequery);
}
function putFlex(thehtml) {
	$('#flex-tab').hide();
	$('#flex-tab').html(thehtml);
	$('#flex-tab').fadeIn('slow');
	$('.right .hide').hide();
}
function closeFlex() {
	$('#flex-tab').html(firstflex);
	$('.right .hide').show();
}
function URLDecode(psEncodeString) {
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
function URLMake(thestring) {
	/* PHP version
	function get_url($name,$nospaces=true) {
		$name = trim(strtolower($name));
		if($nospaces) {
			$name = str_replace(' ','',$name);
			$name = str_replace('-','',$name);
		} else {
			$name = str_replace(' ','-',$name);
		}
		$name = str_replace(',','',$name);
		$name = str_replace('/','',$name);
		$name = str_replace('@','',$name);
		$name = str_replace('"','',$name);
		$name = str_replace(':','',$name);
		$name = str_replace('?','',$name);
		fix_chars($name);
		return $name;
	}
	function fix_chars(&$str) {
		$str = str_replace('#','',str_replace('\'','',str_replace('>','',str_replace('.','',str_replace('&','and',str_replace('+','',$str))))));
	}

	*/
	return String(thestring).replace(' ','').replace('-','').replace(',','')
		.replace('/','').replace('@','').replace('"','').replace(':','')
		.replace('?','').replace('#','').replace('>','').replace('.','')
		.replace('&','and').replace('+','').replace(' ','').toLowerCase();
}
function refreshResults(thequery) {
	if(thequery) lastquery=thequery;
	resetAjax();
	$('.the-results').attr('id','ajaxc');
	$('#ajaxc').show();
//	alert('lastquery:'+lastquery+',lastgenre:'+lastgenre+',lasttype:');
	sendReq('/php/G.results.php','q,g,t',lastquery+','+lastgenre+','+lasttype);
	scrollToContent();
}


/* WRITING
=============================================================================*/

function getWriting (name) {
	if (lastname!=name) {
		lastname=name;
		$('#updatearea').html('');
		if(lastwriting=document.getElementById('ajaxc')) lastwriting.id = "";
	
		var nextDiv = document.createElement("div");
		nextDiv.id = "ajaxc";
		nextDiv.innerHTML = "<div class='loading'>Loading posts...</div>";
		
		document.getElementById('updatearea').appendChild(nextDiv);
		$('#ajaxc').show();
		
		sendReq('/php/G.blog.php','r',name);
	}
}
function showWritingPage(thepage) {
	resetAjax();
	document.getElementById('bs'+(thepage-1)).style.display = 'none';
	
	var nextDiv = document.createElement("div");
	nextDiv.id = "ajaxc";
	nextDiv.innerHTML = "<div class='loading'>Loading posts...</div>";
	
	document.getElementById('updatearea').appendChild(nextDiv);
	$('#ajaxc').fadeIn("slow");
	
	sendReq('/php/G.blog.php','p,r',thepage+','+lastname);
}
function closeWriting() {
	$('.buttons.glow span').removeClass('clicked');
	getWriting('');	
}

/* CONCERTS
=============================================================================*/

var lastmonth;
var the_page;

function getConcerts (month) {
	resetAjax();
	$('.the-concerts').attr('id','ajaxc');	
//	$('#ajaxc').show();
		
	if(month) lastmonth=month;

	refreshConcerts();
	scrollToContent()
}
function getConcertsTag (tag) {
	resetAjax();
	$('.the-concerts').attr('id','ajaxc');
//	$('#ajaxc').show();

	if(the_page)
		sendReq('/php/G.concerts.php','f,t',tag+','+the_page);
	else
		sendReq('/php/G.concerts.php','f',tag);
		
	putFlex('<a href="/concerts/'+URLMake(URLDecode(tag))+'/"><h1>Pittsburgh '+URLDecode(tag)+' concerts only</h1></a>');
	
	scrollToContent()
}
function refreshConcerts() {
	resetAjax();
	$('.the-concerts').attr('id','ajaxc');
	if(lastmonth) sendReq('/php/G.concerts.php','d',lastmonth);
	else {
		if(the_page)
			sendReq('/php/G.concerts.php','t',the_page);
		else
			sendReq('/php/G.concerts.php','','');
	}
}
function closeConcerts() {
	$('.filter-tags span').removeClass('clicked');
	refreshConcerts();
	closeFlex();
	scrollToContent()
}




/* POST - COMMENTS
=============================================================================*/
function showRespond() {
	$('#respond').slideDown("slow");
	document.getElementById('show-more').style.display = 'none';
}

/* PROFILE - HISTORY
=============================================================================*/

function loadRelated() {
	resetAjax();
	$('.the-related-history').attr('id','ajaxc');
	$('#ajaxc').show();
	
	$('#ajaxc').html('<div class="loading"><img src="/images/loading.gif">Looking up history...</div>');
	sendReq('/php/G.related.php','n',theresultname);
}	


/* PROFILE - NEWS
=============================================================================*/

function loadCatchup(thename) {
	theresultname=escape(thename);
	resetAjax();
	$('.the-profile-news').attr('id','ajaxc');
	$('#ajaxc').show();
	
	sendReq('/php/G.news-p.php','n',thename);
}	



function subTwitter() {
	frames['twitterc'].location.href='/php/G.twitter.php?q=burghsounds/pittsburgh-venues&n=Pittsburgh+venues&t=list&c=15';
}


/* addClass, removeClass, hasClass
============================================================================= */

function hasClass(ele,cls) {
	if (ele.className=== undefined) return false;
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
    	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}




/* infcaro
============================================================================= */

var lastpage=1;

$.fn.infcaro = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapp = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapp.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),    
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapp.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapp.scrollLeft(singleWidth * visible);
        $wrapp.css('visibility','visible');
        
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            if($wrapp.filter(':not(:animated)')) {
           	    if (currentPage+dir==1) {
					$('a.back').hide();	
					$('a.forward').show();
				} else if (currentPage+dir==pages) {
					$('a.forward').hide();
					$('a.back').show();
				} else if (currentPage==1&&dir==1) {
					$('a.back').show();
				} else if (currentPage==pages&&dir==-1) {
					$('a.forward').show();
				}
            }
            $wrapp.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapp.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapp.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;

            });                
            
            return false;
        }
        
        function scrollback() {
        	thepage=currentPage-1;
        	lastpage=thepage;
			$("#the-pages span").removeClass('clicked');
			$("#the-pages span:contains('"+thepage+"')").addClass('clicked');
            return gotoPage(thepage);        
        }
        function scrollforward() {
			thepage=currentPage+1;
			lastpage=thepage;
			$("#the-pages span").removeClass('clicked');
			$("#the-pages span:contains('"+thepage+"')").addClass('clicked');
            return gotoPage(thepage);        
        }
        
        $wrapp.after('<a class="arrow back"></a><a class="arrow forward"></a>');
        
        // 5. Bind to the forward and back buttons
		$('a.back', this).click(function () {
			scrollback();
		});
		$('a.forward', this).click(function () {
			scrollforward();
		});
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
        
        
    });  
};

/*
$(document).ready(function () {
  $('.infcaro').infcaro();
});
*/



/* twitterCallback
============================================================================= */

var idnum = 1

function twitterCallback0(twitters) {
  var statusHTML = [];
  for (var i=0; i<twitters.length; i++){
    var username = twitters[i].user.screen_name;
    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
      return '<a href="'+url+'">'+url+'</a>';
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
      return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
    });
    statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>');
  }
  document.getElementById('twitter_update_list').innerHTML = statusHTML.join('');
}


	function twitterCallback(twitters) {
	  var statusHTML = [];
	  for (var i=0; i<twitters.length; i++){
		var username = twitters[i].user.screen_name;
		var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
		  return '<a href="'+url+'">'+url+'</a>';
		}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
		  return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
		});
		statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>');
	  }
	  document.getElementById('twitter_update_list'+idnum).innerHTML = statusHTML.join('');
	  idnum++;
	}
	
	function relative_time(time_value) {
	  var values = time_value.split(" ");
	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
	  var parsed_date = Date.parse(time_value);
	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
	  delta = delta + (relative_to.getTimezoneOffset() * 60);

	  if (delta < 60) {
		return 'less than a minute ago';
	  } else if(delta < 120) {
		return 'about a minute ago';
	  } else if(delta < (60*60)) {
		return (parseInt(delta / 60)).toString() + ' minutes ago';
	  } else if(delta < (120*60)) {
		return 'about an hour ago';
	  } else if(delta < (24*60*60)) {
		return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
	  } else if(delta < (48*60*60)) {
		return '1 day ago';
	  } else {
		return (parseInt(delta / 86400)).toString() + ' days ago';
	  }
	}


	
/* ajax
============================================================================= */
	
var http = createRequestObject();
var objectId = '';
var requestnum = 0;

function createRequestObject(htmlObjectId){
    var obj;
    var browser = navigator.appName;
    
    objectId = htmlObjectId;
    
    if(browser == "Microsoft Internet Explorer"){
        obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        obj = new XMLHttpRequest();
    }
    return obj;    
}

function sendReq(serverFileName, variableNames, variableValues) {
	var paramString = '';
	
	variableNames = variableNames.split(',');
	variableValues = variableValues.split(',');
	
	for(i=0; i<variableNames.length; i++) {
		paramString += variableNames[i]+'='+variableValues[i]+'&';
	}
	paramString = paramString.substring(0, (paramString.length-1));
			
	if (paramString.length == 0) {
	   	http.open('get', serverFileName);
	}
	else {
		http.open('get', serverFileName+'?'+paramString);
	}
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
	if(http.readyState == 4){
//		$('#ajaxc').css('visibility','hidden');
		responseText = http.responseText;	
		document.getElementById(objectId).innerHTML = responseText;
		if(responseText) {
			requestnum++;
			if(responseText.indexOf('<!--endofcontent-->')==-1)
				$('#load-more').show();
			else
				$('#footer.infinite').show();
			if($('.the-sidebar-related').html()=='<div class="loading"><img src="/images/loading.gif">Loading news...</div>') loadHotlistSide(false);
			if($('.the-related-history').html()=='<!--loading-->') loadRelated();
			else if(is_home&&($('#updatearea').html().length<100)) loadNext(0);
			else if(is_home&&($('.hotlists').html().replace(/^\s*/, "").replace(/\s*$/, "")==''||$('.hotlists').html()=='<div class="loading"><img src="/images/loading.gif">Loading hot list...</div>')) getHotlist(false);
		}
//		$('#ajaxc').show('slow');
    }
}






function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function removeElement(childDiv){
     if (document.getElementById(childDiv)) {     
          var child = document.getElementById(childDiv);
          var parent = child.parentNode;
          parent.removeChild(child);
     }
     else {
          alert("Child div has already been removed or does not exist.");
          return false;
     }
}



function resetAjax() {
	if(document.getElementById('ajaxc')) document.getElementById('ajaxc').id = "";
	$('#ajaxc').attr('id','');	
}
function scrollWin(id){
	$('html, body').animate({
		scrollTop: getTop(id)-50
	}, 750);
}
function scrollToContent() {
	if(currentYPosition()>260)
		scrollWin('#content');
}
function scrollToTop() {
	$('html, body').animate({scrollTop: '0px'}, 800);
}
function getTop(id) {
	return $(id).offset().top;
}
function scrollY(ypos){
	$('html, body').animate({
		scrollTop: ypos
	}, 750);
}
function currentYPosition() {
  // Firefox, Chrome, Opera, Safari
  if (self.pageYOffset) return self.pageYOffset;
  // Internet Explorer 6 - standards mode
  if (document.documentElement && document.documentElement.scrollTop)
	  return document.documentElement.scrollTop;
  // Internet Explorer 6, 7 and 8
  if (document.body.scrollTop) return document.body.scrollTop;
  return 0;
}
function navTabTo(url) {
	if(url) newwindow=window.open(url);
}
function showCollapse(idnum) {
	if(idnum=='maintags') {
	$('#show-alltags').fadeIn("slow");
	document.getElementById('mult-alltags').style.display = 'none';
	} else {
	$('#mult-'+idnum).fadeIn("slow");
	document.getElementById('show-'+idnum).style.display = 'none';
	
	}
}


/* ADD
=============================================================================*/

function goToConcertPage() {
	thetag=document.concertjump.concertmenu.options[document.concertjump.concertmenu.selectedIndex].value;
	theurl='/concerts/'+urlencode(thetag)+'/';
	window.location=theurl;
}
function goToTwitterList() {
	thelist=document.twitterjump.twittermenu.options[document.twitterjump.twittermenu.selectedIndex].value;

	resetAjax();
	$('.the-twitter-list').attr('id','ajaxc');
	$('#ajaxc').show();

	sendReq('/php/G.twitterlist.php','l,g,t',thelist+','+thegenre+','+thetypes);
}


function urlencode(str) {
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}

function loadMore() {
	resetAjax();
	theRequests++;
	if($('#load-id').html()) {
		theRequests=$('#load-id').html();
		removeElement('load-id');
	}
	
	var nextDiv = document.createElement("div");
	nextDiv.id = "ajaxc";
	nextDiv.innerHTML = '<div class="loading"><img src="/images/loading.gif">Loading...</div>';
	nextDiv.style.visibility = "visible";
	
	document.getElementById('updatearea').appendChild(nextDiv);
	$('#ajaxc').show();
	$('#load-more').hide();
	
	sendReq('/php/G.more.php','p,q,r,s',thePage+','+theQuery+','+theRequests+','+theSpecial);
}


function loadConcertNews() {
	resetAjax();
	$('.track-in-the-news').attr('id','ajaxc');	
	$('#ajaxc').show();
	
	sendReq('/php/G.news.php','id',concertid);
}

var lastthumb;
function loadThumb(thethumb) {
	$('.highlight').hide();
	$('#highlight-'+thethumb).show();
	$('.thumb').removeClass('hovered');
	$('#thumb-'+thethumb).addClass('hovered');
	lastthumb=thethumb;
}
