var mT, sifrFont = baseURL+'sifr/avant.swf', inputV = new Array (),galleryPages,galleryCurrentPage=1,working=0,selectedGallery,selectedGalleryItem,pageNum=1, shareThisObject = new Array (), isIE6,vipWork=false,cc=1,vipStore;

if (navigator.userAgent.toLowerCase().indexOf('msie 6') == -1) notIE6 = true; else notIE6 = false;

function messageBox(message,secondsOut) {
	i='messageBox';
	if (mT) clearTimeout(mT);
	mT=null;
	if ($(i) != null) {
		$(i).update(message);
		centreElement (i,1);
		$(i).show();
		mT = setTimeout(function () { $(i).hide(); }, (secondsOut*1000));
	}
	else {
		alert('Message box doesn\'t exist');	
	}
}

function centreElement (e, vert) {
	var theScrolls = document.viewport.getScrollOffsets();
	theLeft = Math.floor(((document.viewport.getWidth())-($(e).getWidth()))/2) + theScrolls[0];
	theTop = Math.floor(((document.viewport.getHeight())-($(e).getHeight()))/2) + theScrolls[1];
	if (theTop < 0) theTop = 0;
	if (vert==1)  {
		$(e).setStyle({ top: '0px' });
		$(e).setStyle({ top: theTop+'px' });
	}
	$(e).setStyle({ left: theLeft+'px' });
	
}

function closeBox(id,overlay) {
	var ov=1;
	if (overlay != null) {
		ov=0;
		$('pageOverlay').setStyle({ zIndex: overlay });
	}
	if (ov==1) $('pageOverlay').hide();
	$(id).hide();
}

function Select_Value_Set(SelectName, Value) {
  eval('SelectObject = document.' + 
    SelectName + ';');
  for(index = 0; 
    index < SelectObject.length; 
    index++) {
   if(SelectObject[index].value == Value)
     SelectObject.selectedIndex = index;
   }
}

function pageOverlay() {
	var theScrolls = document.viewport.getScrollOffsets();
	pageWidth = document.viewport.getWidth() + theScrolls[0]; pageHeight = document.viewport.getHeight() + theScrolls[1];
	if (pageWidth < $('mainContainer').getWidth()) pageWidth = $('mainContainer').getWidth();
	if (pageHeight < ($('mainContainer').getHeight()+127)) pageHeight = ($('mainContainer').getHeight()+127);
	$('pageOverlay').setStyle({ opacity: '0.5', display: 'block', width:pageWidth+'px', height:pageHeight+'px' });
	$('pageOverlay').show();
}

function showBox(id,noDrag) {
	pageOverlay();
	centreElement (id,1);
	$(id).show();
	if (noDrag==null) new Draggable(id, { scroll: window });
}

function readyForPost(t,z) {
	t = t.replace("‘","'");
	t = t.replace("’","'");
	t = t.replace("‘","'");
	t = t.replace("’","'");
	if (z) return encodeURI(escape(t));
	else return escape(t);
}

function encode_utf8(s) {
	return unescape( encodeURIComponent( s ) );
}

function decode_utf8 (s) {
	return decodeURIComponent( escape( s ) );
}

function clearInputBox(i,t,o,c) {
	if (o==1) {
		if ($F(i) == t) $(i).value='';
	}
	else if (o==2) {
		$(i).observe('focus', function () { clearInputBox(i,t,1,c); });
		$(i).observe('blur', function () { clearInputBox(i,t,0,c); });
	}
	else {
		if ($F(i) == '') $(i).value=t;	
	}
	if (c) { $(i).setStyle({ color: c }); }
}

function isValidEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	return true;			
}

function handleEnter (event, func, v) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		event.stop()
		if (func) func (v);
		return false;
	}
	else return true;
}

function adminLogout () {
	var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'adminLogout=1&'+allNodes,onComplete: function() {
		window.location.href = baseURL+'login/logout';
		messageBox('You have been logged out',8);
	}});
}

function showVimeo (vidID, width, height, divID, colour,auto) {
	var flashvars = {clip_id: vidID,server: "vimeo.com",show_title: "0",show_byline: "0",show_portrait: "0",fullscreen: "1",color: colour,autoplay:auto};
	var params = {allowfullscreen: "true",allowscriptaccess: "always",movie: "http://vimeo.com/moogaloop.swf",wmode: "transparent"};
	var attributes = {clip_id: vidID};
	swfobject.embedSWF("http://vimeo.com/moogaloop.swf", divID, width, height, "9.0.0","expressInstall.swf", flashvars, params, attributes);
}

function showYouTube (vidID, width, height, divID, auto) {
	var flashvars = {};
	var params = {allowfullscreen: "true",allowscriptaccess: "always",wmode: "transparent"};
	var attributes = {id: "vid"};
	swfobject.embedSWF("http://www.youtube.com/v/"+vidID+"&hl=en&fs=1&rel=0&color1=0x000000&color2=0x2d2d2d&autoplay="+auto, divID, width, height, "9.0.0","expressInstall.swf", flashvars, params, attributes);
}

function showJWPlayer (id,w,t) {
	var flashvars = {file: baseURL+'tracks/'+t};
	var params = {allowfullscreen: "true",allowscriptaccess: "always",wmode: "transparent"};
	var attributes = {};
	swfobject.embedSWF(baseURL+'jw_player/player2.swf', id, w, 24, "9.0.0","expressInstall.swf", flashvars, params, attributes);
}

function badField (f,t) {
	var b = false;
	if (t==1) {
		f.each(function(n){
			if ($F(n)=='' || $F(n)==inputV[n]) b = true;
		});
	}
	else if ($(f).tagName == 'FORM' || $(f).tagName == 'form') {
		var a=$$('#'+f+' input[type="text"]');
		a.each(function(n){
			if ($F(n.id)=='' || $F(n.id)==inputV[n.id]) b = true;
		});
		var a=$$('#'+f+' textarea');
		a.each(function(n){
			if ($F(n.id)=='' || $F(n.id)==inputV[n.id]) b = true;
		});
	}
	else if ($F(f)=='' || $F(f)==inputV[f]) b = true;
	return b;
}

function doSIFR (s,oL,oT,aL,sC,sBg,sCase) {
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:s, sFlashSrc:sifrFont, sColor:sC, sLinkColor:"#ffffff", sBgColor:sBg, sHoverColor:"#2b2b2b",sCase:sCase,sWmode:"opaque", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign="+aL+"&offsetTop="+oT+"&offsetLeft="+oL+""}));
	};
}

/********************** ALL ************************/

function setUpAll () {
	if ($('signUpEmail') != null) Event.observe('signUpEmail', 'keypress',function (e) { handleEnter (e, submitSignUp) });
	if ($('signUpName') != null) Event.observe('signUpName', 'keypress',function (e) { handleEnter (e, submitSignUp) });
	if ($('searchText') != null) Event.observe('searchText', 'keypress',function (e) { handleEnter (e, searchSite) });
	var a=$$('form');
	a.each(function(n){
		$(n.id).reset();
	});
	var a=$$('input[type="text"]');
	a.each(function(n){
		if ($F(n.id) != null && n.id != null) {
			clearInputBox($(n.id),$F(n.id),2);
			inputV[n.id]=$F(n.id);
		}
   	});
	var a=$$('textarea');
	a.each(function(n){
		if ($F(n.id) != null && n.id != null) {
			clearInputBox($(n.id),$F(n.id),2);
			inputV[n.id]=$F(n.id);
		}
   	});
	if ($('vipLoginButton') != null) {
		Event.observe('vipLoginButton', 'click',function () { 
			if (vipWork == false) {
				vipWork=true;
				$('vipLogin').setStyle({ zIndex:5 });
				$('vipJoin').setStyle({ zIndex:4 });
				if ($('vipLogin').visible()) {
					new Effect.SlideUp('vipLogin', { duration: 0.2, afterFinish: function () { vipWork=false; } });
				}
				else {
					new Effect.SlideDown('vipLogin', { duration: 0.2, afterFinish: function () { vipWork=false; } });
				}
			}
		});
		setUPVIPLogins ()
		Event.observe('vipJoinButton', 'click',function () { 
			if (vipWork == false) {
				vipWork=true;
				$('vipLogin').setStyle({ zIndex:4 });
				$('vipJoin').setStyle({ zIndex:5 });
				if ($('vipJoin').visible()) {
					new Effect.SlideUp('vipJoin', { duration: 0.2, afterFinish: function () { vipWork=false; } });
				}
				else {
					new Effect.SlideDown('vipJoin', { duration: 0.2, afterFinish: function () { vipWork=false; } });
				}
			}
		});
		Event.observe('forgot', 'click',function () { 
			vipStore = $('vipLoginPar').innerHTML;
			$('vipLoginPar').update('Please enter the email address you registered with so we can send you your password,');
			$('vipLoginName').fade({duration: 0.3});
			$('password3').fade({duration: 0.3});
			$('forgot').fade({duration: 0.3});
			$('submit1').stopObserving('click');
			Event.observe('submit1', 'click',function () { 
				if (isValidEmail($F('vipLoginEmail'))) {
					var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'vipForgotPassword='+$F('vipLoginEmail'),onComplete: function(response) {
						var r = response.responseText;
						if (r == 'An email has been sent to you with your password.' || r == 'Our records show that your account has not been activated yet, you have been sent an email with a new activation code.') {
							closeBox('enquiryOverlay');
							setUPVIPLogins ();
						}
						messageBox(r,3);
					}});
				}
				else {
					messageBox('Please enter a valid email address.',3);
				}
			});
		});
	}
	sendAnEmail ()
	var c = 'closeOverlay';
	if ($(c) != null) Event.observe(c, 'click',function () { closeBox('enquiryOverlay') });
	if ($('mainContainer') != null) var v = $('mainContainer').getHeight(),mH = document.viewport.getHeight()+1;
	if (v < mH) {
		var f = mH - v;
		$('filler').setStyle({ height: f+'px' });
	}
	var tt=$$('img[id^=bannerImage]');
	if (tt.length>1) setInterval (scrollBannerImage,10000);
	loadPlayer ();
}

function loadPlayer (l) {
	if (l) {
		window.open( baseURL+"player_new.php", "myWindow", "status = 1, height = 196, width = 1048, resizable = 0" )
	}		
	else {
		var v = 'listenLive';
		if ($(v) != null) Event.observe(v, 'click',function (e) { loadPlayer (1) });
		v = 'listen';
		if ($(v) != null) Event.observe(v, 'click',function (e) { loadPlayer (1) });
	}
}

var bannerImageShowing=1;
function scrollBannerImage () {
	var newImage,a=$$('img[id^=bannerImage]');
	if (bannerImageShowing==a.length) newImage=1;
	else newImage = bannerImageShowing + 1;
	$('bannerImage_'+newImage).setStyle({ zIndex: 2 });
	$('bannerImage_'+bannerImageShowing).setStyle({ zIndex: 1 });
	new Effect.Move('bannerImage_'+newImage, { 
		x: 0, y: 90, mode: 'relative', transition: Effect.Transitions.sinoidal, 
		afterFinish: function(){ 
			$('bannerImage_'+bannerImageShowing).setStyle({ top:'-90px' }); 
			bannerImageShowing = newImage;
		}
	});
}

function setUPVIPLogins () {
	$('submit1').stopObserving('click');
	$('submit2').stopObserving('click');
	$('vipLoginForm').reset();
	$('vipLoginName').show();
	$('password3').show();
	$('forgot').show();
	if (vipStore) $('vipLoginPar').update(vipStore);
	Event.observe('submit1', 'click',function () {
		var allNodes = Form.serialize('vipLoginForm');
		if (isValidEmail($F('vipLoginEmail')) && $F('password3')) {
			var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'vipLogin=1&'+allNodes,onComplete: function(response) {
				var r = response.responseText;
				if (r == 'You have been logged in.') {
					window.location.href = baseURL+'vip';
				}
				messageBox(r,3);
			}});
		}
		else {
			messageBox('Please enter your email address &amp; password.',3);
		}
	});
	Event.observe('submit2', 'click',function () {
		var allNodes = Form.serialize('vipJoinForm');
		if (isValidEmail($F('vipJoinEmail')) && badField('vipJoinForm',2) != true) {
			if ($F('password') == $F('password2')) {
			var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'vipSignUp=1&'+allNodes,onComplete: function(response) {
				var r = response.responseText;
				if (r == 'Your account has been created and activation link has been sent to the e-mail address you entered. Note that you must activate the account by clicking on the activation link when you get the e-mail before you can login.') {
					$('vipJoinForm').reset();
					replaceT('password','text','Password')
					replaceT('password2','text','Confirm Password')
				}
				messageBox(r,8);
			}});
			}
			else messageBox('Your passwords didn\'t match.',3);
		}
		else messageBox('Please enter your name, a valid email address &amp; password.',3);
	});
}



function submitSignUp (c) {
	var f,em;
	if (c=='comp') {
		f = 'compSignupForm';
		em = 'compSignupEmail';
	}
	else if (c) {
		f = 'contactSignupForm';
		em = 'contactSignupEmail';
	}
	else {
		f = 'signUpForm';
		em = 'signUpEmail';
	}
	if (badField(f,2)) messageBox('Please enter all fields',3);
	else {
		var allNodes = Form.serialize(f);
		var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'signUp=1&'+allNodes,onComplete: function(response) {
			messageBox('Thanks, your details have been saved',3);
			$(f).reset();
		}});
	}
}

function createOverlay (i,bg,topP,leftP,z,aH,aW,ov) {
	if (ov==null) ov = 'focusOverlay';
	var w=$(i).getWidth(),h=$(i).getHeight();
	if (aH) h = h + aH;
	if (aW) w = w + aW;
	if (z==null) z=2;
	if (topP==null) topP=0;
	if (leftP==null) leftP=0;
	if ($(ov)==null) $(i).insert('<div id="'+ov+'" class="focusOverlay"><div></div></div>');
	$(ov).hide();
	$(ov).setStyle({width:w+'px',height:h+'px',backgroundColor:bg,zIndex:z,left:leftP+'px',top:topP+'px'});
	new Effect.Appear(ov, { duration: 0.5 });
	return h;
}

function closeContentBox (contentBox,con,ov) {
	if ($(ov) != null) new Effect.Fade(ov, { duration: 0.5, afterFinish: function(){ $(contentBox).writeAttribute('style', ''); }});
	new Effect.Move(con, { x: $(con).getWidth(), y: 0, duration:0.5, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function(){
		$(con).remove();
		if ($(ov) != null) $(ov).remove();
		sendAnEmail()
	}});
}

function splitHeader(container,hTagNum,hClass) {
	if ($(container) != null) {
		var heads = new Array(),hTagNum2 = hTagNum+1,hClass2;
		if (hClass) hClass2 = '.'+hClass;
		var b = $(container).innerHTML.toLowerCase();
		b = b.replace('<h'+hTagNum+'>','')
		b = b.replace('</h'+hTagNum+'>','');
		b = b.replace(/^\s*|\s*$/g,'');
		b = b.split(' ');
		var c = b.length;
		if (c>1) {
			var d = Math.ceil(c/2),i=1,i2=0,head1='',head2='',c;
			while (i<=d) {
				if (head1 != '') head1=head1+' ';
				head1 = head1+b[i2];
				++i2; ++i;
			}
			d = c-d;
			i=1;
			while (i<=d) {
				if (head2 != '') head2=head2+' ';
				head2 = head2+b[i2];
				++i2; ++i;
			}
			c = '<h'+hTagNum+' class="'+hClass+'">'+head1+'</h'+hTagNum+'><h'+hTagNum2+' class="'+hClass+'">'+head2+'</h'+hTagNum2+'>'
		}
		else c = '<h'+hTagNum+' class="'+hClass+'">'+b[0]+'</h'+hTagNum+'>';
		$(container).update(c);
	}
}

function replaceT(i,newType,value){
	++cc;
	var theID = 'inID_'+cc;
	var newO=document.createElement('input');
	newO.setAttribute('type',newType);
	newO.setAttribute('name',$(i).getAttribute('name'));
	//newO.setAttribute('id',theID);
	newO.setAttribute('id',$(i).getAttribute('id'));
	$(i).parentNode.replaceChild(newO,$(i));
	theID = $(i).getAttribute('id')
	setTimeout(function() {
		if (newType=='text') $(theID).value = value;
		else $(theID).activate();
	}, 10);
	if (newType=='password') Event.observe(theID, 'blur',function () { if ($F(theID)=='' || $F(theID)==null) replaceT(theID,'text',value) });
	else Event.observe(theID, 'focus',function () { replaceT(theID,'password',value) });
}

function searchSite () {
	if ($F('searchText')) {
		window.location.href = baseURL+'search/'+$F('searchText');
	}
}

function sendAnEmail() {
	var a=$$('a[id^=contX]'),f='overlayEnquiryForm';
	a.each(function(n){
		var t = n.id.split("_");
		$(n.id).stopObserving('click');
		Event.observe(n.id, 'click',function () { emailSend (t[1],t[2],t[3],f); });
	});
}

function emailSend (a,b,c,f) {
	showBox('enquiryOverlay',1);
	$('submitOverlay').stopObserving('click');
	Event.observe('submitOverlay', 'click',function () {
		if ((badField(f,2)) || isValidEmail($F('overlayEmail')) != true) messageBox('Please enter all fields',3);
		else  {
			var allNodes = Form.serialize(f);
			var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'sendAnEmail='+a+'&column='+b+'&table='+c+'&'+allNodes,onComplete: function(response) {
				messageBox('Thanks, your email has been sent',3);
				closeBox('enquiryOverlay');
				$(f).reset();
			}});
		}
	});
}

/********************** HOME ************************/

function setUpHome () {
	checkNowPlaying ();
	setInterval(checkNowPlaying,90000);
	checkBlog ('beat');
	blogPreviewShare();
	setupBeatBox ();
	var a=$$('li[id^=newsPrevCont]');
	a.each(function(n){
		var b = parseInt(n.id.replace('newsPrevCont_',''));
		createShareThis ($('newsPrevIm_'+b).alt,$('newsPrevP_'+b).innerHTML,$('newsPrevURL_'+b).href,$('newsPrevIm_'+b).src,'newsShare_'+b);
	});
	var tt=$$('img[id^=homeMainImage]');
	if (tt.length>1) setInterval (scrollHomeImage,8000)
}

var homeImageShowing=1;
function scrollHomeImage () {
	var newImage,a=$$('img[id^=homeMainImage]');
	if (homeImageShowing==a.length) newImage=1;
	else newImage = homeImageShowing + 1;
	$('homeMainImage_'+newImage).setStyle({ zIndex: 2 });
	$('homeMainImage_'+homeImageShowing).setStyle({ zIndex: 1 });
	new Effect.Move('homeMainImage_'+newImage, { x: -864, y: 0, mode: 'relative', transition: Effect.Transitions.sinoidal, afterFinish: function(){ $('homeMainImage_'+homeImageShowing).setStyle({ left:'864px' }); homeImageShowing = newImage;}});
}

function blogPreviewShare() {
	var t,t2;
	if ($('blogTitle1') != null) {
		t = $('blogTitle1').innerHTML.split("<img");
		createShareThis (t[0],$('blogText1').innerHTML,$('blogURL1').href,$('blogImage1').src,'blogShare1');
	}
	if ($('blogTitle2') != null) {
		t2 = $('blogTitle2').innerHTML.split("<img");
		createShareThis (t2[0],$('blogText2').innerHTML,$('blogURL2').href,$('blogImage2').src,'blogShare2');
	}
	if ($('blogTitle3') != null) {
		var t = $('blogTitle3').innerHTML.split("<img");
		createShareThis (t[0],$('blogText3').innerHTML,$('blogURL3').href,$('blogImage3').src,'blogShare3');
	}
}

function createShareThis (title,text,url,image,buttonID) {
	var i = shareThisObject.length;
	shareThisObject[i] = SHARETHIS.addEntry({title:encode_utf8(title),summary: encode_utf8(text),url: encode_utf8(url),icon: encode_utf8(image)}, {button:false,embeds:true} );
	shareThisObject[i].attachButton($(buttonID));
}

function checkNowPlaying () {
	var t = $('playing-now-track').innerHTML;
	var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'checkNowPlaying=1',onComplete: function(response) {
		var reply = response.responseText.split("||message||");
		if (reply.length >5) {
			$('playing-now-track').update(reply[0]);
			$('playing-now-artist').update(reply[1]);
			$('playing-now-pic').src = baseURL+'images/now-playing/'+reply[2];
			$('playing-next-track').update(reply[3]);
			$('playing-next-artist').update(reply[4]);
			$('playing-next-pic').src = baseURL+'images/now-playing/'+reply[5];
		}
	}});
}

function checkBlog (type) {
	var t;
	if ($('blogTitle1') != null) t = $('blogTitle1').innerHTML.split("<img"); else t = '||hjb||';
	var aj2 = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'checkBlog=1&type='+type+'&title='+readyForPost(t[0],1),onComplete: function(response) {
		var reply = response.responseText;
		if (reply.length >5) {
			$('blogPosts').update(reply);
			var sT = setTimeout(blogPreviewShare,1000);
		}
	}});
}

function setupBeatBox () {
	Event.observe('t1', 'mouseover',function () { moveTheBox ('beatAtWork',232,46,0); moveTheBox ('irishBeats',278,92,0) });
	Event.observe('t2', 'mouseover',function () { moveTheBox ('beatAtWork',232,46,1); moveTheBox ('irishBeats',278,92,0) });
	Event.observe('t3', 'mouseover',function () { moveTheBox ('beatAtWork',232,46,1); moveTheBox ('irishBeats',278,92,1) });
}

mo = new Array();
function moveTheBox (id,sI,fI,rI) {
	var a1 = parseInt($(id).getStyle('top').replace('px',''));
	if (rI == 1) {
		if (a1 > fI) {
			var d = (a1 - fI - 100)/100;
			if (mo[id]!='w') {
				mo[id]='w';
				new Effect.Tween(id, a1, fI, { duration: d,afterFinish:function(){mo[id]='f';}} , function(p) { this.setStyle({top : p+'px' }) } );
			}
		}
	}
	else {
		if (a1 < sI) {
			var d = (sI - a1 - 100)/100;
			if (mo[id]!='w') {
				mo[id]='w';
				new Effect.Tween(id, a1, sI, { duration: d,afterFinish:function(){mo[id]='f';}} , function(p) { this.setStyle({top : p+'px' }) } );
			}
		}
	}
}


/********************** BREAKFAST ************************/

function setUpBreakfast () {
	Event.observe('t1', 'mouseover',function () { moveTheBox ('breakfastBox2',215,31,0); moveTheBox ('breakfastBox3',246,62,0) });
	Event.observe('t2', 'mouseover',function () { moveTheBox ('breakfastBox2',215,31,1); moveTheBox ('breakfastBox3',246,62,0) });
	Event.observe('t3', 'mouseover',function () { moveTheBox ('breakfastBox2',215,31,1); moveTheBox ('breakfastBox3',246,62,1) });
	checkBlog ('breakfast');
	blogPreviewShare();
	var tt=$$('img[id^=homeMainImage]');
	if (tt.length>1) setInterval (scrollHomeImage,8000)
}


/********************** DJ'S ************************/

function setUpDJs () {
	if (notIE6) {
		var a=$$('.djList li div');
		a.each(function(n){
			splitHeader(n.id,3,'djTitle')
		});
	}
	var a=$$('.showDays ul li a');
	a.each(function(n){
		Event.observe(n.id, 'click',function () {
			hideShowDays (n.id);
		});
	});
	$('mainContainer').observe('mousemove', getcords);
	var m = $('showsContainer').childElements();
	$('showsContainer').setStyle({ width:(m.length*168)+'px'});
	Event.observe('allShows', 'click',function () {
		hideShowDays ();
	});
	var a=$$('a[id^=djContURL]');
	a.each(function(n){
		var b = parseInt(n.id.replace('djContURL_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadDJ(b,'dj') } );
	});
	var a=$$('a[id^=showLink]');
	a.each(function(n){
		var b = parseInt(n.id.replace('showLink_',''));
		$(n.id).stopObserving();
		if (permalink) {
			$(n.id).observe('click', function () { window.location.href = $(n.id).href; } );
		}
		else $(n.id).observe('click', function () { loadDJ(b,'show') } );
	});
	if (permalink && notIE6){
		splitHeader('title',1,'npo1','#6393c1');
		doSIFR ("h2.npo1",0,-4,"left","#FFFFFF",'#6393c1',"upper");
		doSIFR ("h1.npo1",0,1,"left","#FFFFFF",'#6393c1',"upper");
	}
	if (notIE6) {
		doSIFR ("h4.djTitle",7,-2,"left","#FFFFFF",'#6393c1',"upper");
		doSIFR ("h3.djTitle",7,3,"left","#FFFFFF",'#6393c1',"upper");
		doSIFR ("#shows div ul li h3",7,4,"left","#FFFFFF","#6393c1","upper");
	}
}

function hideShowDays (d) {
	var a=$$('#shows div ul li'),i=0;
	new Effect.Move('showsContainer', { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.full});
	var b=$$('.showDays ul li a');
	b.each(function(n){
		$(n.id).removeClassName('active');
	});
	if (d) $(d).addClassName('active');
	a.each(function(n){
		if (d) {
			if (n.id.search(d)>=0) {
				$(n.id).show();
				++i;
			}
			else $(n.id).hide();
		}
		else {
			$(n.id).show();
			++i;
		}
	});
	$('showsContainer').setStyle({ width:(i*168)+'px'});
}

var scrollLeft,scrollRight;
function getcords(e){
	if ($('showsContainer').getWidth()>$('shows').getWidth()) {
		var mouseX=parseInt(Event.pointerX(e)),mouseY=parseInt(Event.pointerY(e)),i=$('shows'),l=$(i).viewportOffset(),w=$(i).getWidth(),h=$(i).getHeight(),d=150,a1,fI,d,s = document.viewport.getScrollOffsets();
		if (mouseX < (l[0]+s[0]+d) && mouseX > (l[0]+s[0]) && mouseY > (l[1]+s[1]) && mouseY < ((l[1]+s[1])+h)) {
			if (working != 1) {
				working=1;
				a1 = parseInt($('showsContainer').getStyle('left').replace('px',''));
				d = (a1-(a1*2))/500;
				scrollRight = new Effect.Tween('showsContainer', a1, 0, { duration: d} , function(p) { this.setStyle({left : p+'px' }) } );
			}
		}
		else if (mouseX > ((l[0]+s[0]+w)-d) && mouseX < (l[0]+s[0]+w) && mouseY > (l[1]+s[1]) && mouseY < ((l[1]+s[1])+h)) {
			if (working != 1) {
				working=1;
				a1 = parseInt($('showsContainer').getStyle('left').replace('px',''));
				fI = $('showsContainer').getWidth() - w;
				d = (fI+a1)/500;
				fI = fI-(fI*2)-8;
				scrollLeft = new Effect.Tween('showsContainer', a1, fI, { duration: d} , function(p) { this.setStyle({left : p+'px' }) } );
			}
		}
		else {
			working = 0;
			if (scrollLeft) scrollLeft.cancel();
			if (scrollRight) scrollRight.cancel();
		}
	}
}

function loadDJ(i,t) {
	var adH = 0,contentBox = 'leftContent',h2,ov = 'focusOverlay',con='djFocus',pars,timed=1;
	if (t=='show') pars = 'getShow='+i; else pars = 'getDJ='+i;
	if ($(con) != null) {
		closeContentBox (contentBox,con,ov);
		timed=550;
	}
	setTimeout(function () {
		var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: pars,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				if (notIE6) {
				splitHeader('title',1,'npo1');
				doSIFR ("h2.npo1",0,-4,"left","#FFFFFF",'#6393c1',"upper");
				doSIFR ("h1.npo1",0,1,"left","#FFFFFF",'#6393c1',"upper");
				}
				sendAnEmail()
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
	},timed);
}


/********************** NEWS ************************/

function setUpNews () {
	if (notIE6) {
		var a=$$('#newsPresenters li ul li div');
		a.each(function(n){
			splitHeader(n.id,3,'np1');
		});
		newsHeaders();
		doSIFR ("h3.np1",7,5,"left","#FFFFFF","#00BF8F","upper");
		doSIFR ("h4.np1",7,-1,"left","#FFFFFF","#00BF8F","upper");
		splitHeader('newsPO1',3,'npo1');
		doSIFR ("h3.npo1",0,0,"left","#FFFFFF","#00BF8F","upper");
		doSIFR ("h4.npo1",0,-4,"left","#FFFFFF","#00BF8F","upper");
	}
	loadNewsClicks ()
	if ($('n1') != null) {
		$('n1').observe('click', function () { loadNewsCat ('news',1) } );
		$('s1').observe('click', function () { loadNewsCat ('sport',1) } );
	}
}

function loadNewsClicks () {
	var a=$$('a[id^=newsPrevURL]');
	a.each(function(n){
		var b = parseInt(n.id.replace('newsPrevURL_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadNewsArticle(b) } );
		createShareThis ($('newsPrevIm_'+b).alt,$('newsPrevP_'+b).innerHTML,$('newsPrevURL_'+b).href,$('newsPrevIm_'+b).src,'newsShare_'+b);
	});
	var a=$$('a[id^=page]');
	a.each(function(n){
		var b = parseInt(n.id.replace('page',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadNewsPage(b) } );
	});
	var a=$$('a[id^=newsPresInfo]');
	a.each(function(n){
		var b = parseInt(n.id.replace('newsPresInfo_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadNewsPresenter(b) } );
	});
	var a=$$('a[id^=newsFocusPrevURL]');
	a.each(function(n){
		var i = parseInt(n.id.replace('newsFocusPrevURL_',''));
		createShareThis ($('newsFocusPrevIm_'+i).alt,$('newsFocusPrevIm_'+i).alt,$('newsFocusPrevURL_'+i).href,$('newsFocusPrevIm_'+i).src,'newsFocusShare_'+i);
	});
}

function newsHeaders () {
	if (notIE6) doSIFR ("h2.newsTitle",7,0,"left","#FFFFFF","#00BF8F","upper");
}

function loadNewsPresenter(i) {
	var adH = 0,contentBox = 'rightContent',h2,ov = 'focusOverlay',con='presenterFocusContainer',pars;
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: ov },baseURL+'ajaxStuff.php', {
			parameters: 'getNewsPresenter='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				if (notIE6) {
					splitHeader('newsPO1',3,'npo1');
					doSIFR ("h3.npo1",0,0,"left","#FFFFFF","#00BF8F","upper");
					doSIFR ("h4.npo1",0,-4,"left","#FFFFFF","#00BF8F","upper");
				}
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				sendAnEmail()
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
}

function loadNewsArticle(i) {
	var adH = 122,ov = 'focusOverlay2';
	var h = createOverlay ('content','#ffffff',-56,0,2,adH,0,ov),h2,con='articleFocusContainer';
	new Ajax.Updater({ success: ov },baseURL+'ajaxStuff.php', {
		parameters: 'getNewsArticle='+i,
		insertion: 'top',
		onComplete:function (response) { 
			$(con).setStyle({left:$(con).getWidth()+'px'});
			$(con).show();
			newsHeaders ();
			h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$('content').setStyle({height:(h2-adH)+'px'});
				}
			new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
				createShareThis ($('newsFocusPrevIm_'+i).alt,$('newsFocusPrevIm_'+i).alt,$('newsFocusPrevURL_'+i).href,$('newsFocusPrevIm_'+i).src,'newsFocusShare_'+i);
				$('closeArticle2').stopObserving();
				$('closeArticle2').observe('click', function () {
					closeContentBox ('content',con,ov)
				});
			}});
		}
	});
}

function loadNewsPage(p) {
	var aj1 = new Ajax.Updater('content',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getNewsPage='+p+'&cat='+newsCat,onComplete:function(response) { loadNewsClicks (); newsHeaders(); }});
}

function loadNewsPages(p) {
	var aj1 = new Ajax.Updater('pages',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getNewsPages='+p+'&cat='+newsCat,onComplete: function(response) { loadNewsClicks () }});
}

function loadNewsCat (c,p) {
	var a;
	if (newsCat) {
		a = newsCat.substring(0, 1)+'1';
		$(a).removeClassName('active');
	}
	newsCat = c;
	a = newsCat.substring(0, 1)+'1';
	$(a).addClassName('active');
	loadNewsPage(p);
	loadNewsPages(p);
	
}


/********************** ELECTION ************************/

function setUpElection () {
	if (notIE6) {
		electionHeaders();
	}
	loadElectionClicks ();
}

function loadElectionClicks () {
	var a=$$('a[id^=newsPrevURL]');
	a.each(function(n){
		var b = parseInt(n.id.replace('newsPrevURL_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadElectionCandidate(b) } );
	});
}

function electionHeaders () {
	if (notIE6) doSIFR ("h2.electionTitle",7,0,"left","#FFFFFF",sifrColour,"upper");
}

function loadElectionCandidate(i) {
	var adH = 122,ov = 'focusOverlay2';
	var h = createOverlay ('content','#ffffff',0,0,2,adH,0,ov),h2,con='articleFocusContainer';
	new Ajax.Updater({ success: ov },baseURL+'ajaxStuff.php', {
		parameters: 'getElectionCandidate='+i,
		insertion: 'top',
		onComplete:function (response) { 
			$(con).setStyle({left:$(con).getWidth()+'px'});
			$(con).show();
			electionHeaders ();
			h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$('content').setStyle({height:(h2-adH)+'px'});
				}
			new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
				$('back').show();
			}});
		}
	});
}

function closeElectionBox () {
	closeContentBox ('content','articleFocusContainer','focusOverlay2');
	$('back').hide();
}

function mapRolls (onOff,t) {
	if (onOff==1) $('imgCont').addClassName(t);
	else $('imgCont').removeClassName(t);
}

/********************** JOBS ************************/

function setUpJobs () {
	setJobButtons (1)
	setJobButtons ()
	setupJobSearch ('jobSearch','jobFieldList')
	setupJobSearch ('areaSearch','areaFieldList')
	var a=$$('img[id^=shareFocusJob]');
	a.each(function(n){
		var b = parseInt(n.id.replace('shareFocusJob_',''));
		createShareThis ($('jobFocusPic_'+b).alt,$('jobFocusPic_'+b).alt,$('jobFocusURL_'+b).href,$('jobFocusPic_'+b).src,'shareFocusJob_'+b);
	});
	splitHeader('title',2,'npo1');
	jobHeaders ()
	Event.observe('jobSearchButton', 'click',setSearchButton);
	setJobOverlay ();
}

function setJobButtons (p) {
	if (p) {
		var a=$$('a[id^=page]');
		a.each(function(n){
			$(n.id).stopObserving();
			Event.observe(n.id, 'click',function (e) { loadJobPage (parseInt(n.id.replace('page_',''))) });
		});
	}
	else {
		var a=$$('img[id^=shareJob]');
		a.each(function(n){
			var b = parseInt(n.id.replace('shareJob_',''));
			createShareThis ($('jobPic_'+b).alt,$('jobPic_'+b).alt,$('jobURL_'+b).href,$('jobPic_'+b).src,'shareJob_'+b);
		});
		var a=$$('a[id^=jobURL]');
		a.each(function(n){
			$(n.id).stopObserving();
			Event.observe(n.id, 'click',function (e) { loadJob (parseInt(n.id.replace('jobURL_',''))) });
		});
	}
}

function setupJobSearch (fieldID,listID) {
	var z=$$('#'+listID+' ul li a');
	z.each(function(n){
		Event.observe(n.id, 'click',function (e) {
			if (listID=='jobFieldList') jobType = parseInt(n.id.replace('jobType_',''));
			if (listID=='areaFieldList') jobArea = parseInt(n.id.replace('jobArea_',''));
			$(fieldID).value = $(n.id).innerHTML;
			new Effect.SlideUp(listID, { duration: 0.3, afterFinish: function () { $(fieldID).enable(); } });
		});
	});
	if (z.length>0) {
		Event.observe(fieldID, 'focus',function (e) { 
			new Effect.SlideDown(listID, { duration: 0.3 });
			$(fieldID).disable();
		});
		Event.observe(fieldID, 'blur',function (e) { 
			new Effect.SlideUp(listID, { duration: 0.3, afterFinish: function () { $(fieldID).enable(); } });
		});
	}
}

function loadJob(i) {
	var adH = 0,contentBox = 'jobContent',h2,ov = 'focusOverlay',con='jobFocusContainer';
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: 'getJob='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				splitHeader('title',2,'npo1');
				jobHeaders ()
				createShareThis ($('jobFocusPic_'+i).alt,$('jobFocusPic_'+i).alt,$('jobFocusURL_'+i).href,$('jobFocusPic_'+i).src,'shareFocusJob_'+i);
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				setJobOverlay ();
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
}

function jobHeaders () {
	doSIFR ("h3.npo1",7,-3,"left","#FFFFFF","#d1267a","upper");
	doSIFR ("h2.npo1",7,2,"left","#FFFFFF","#d1267a","upper");
	doSIFR ("h3.jobTitle",7,3,"left","#FFFFFF","#d1267a","upper");
}

function setupJobsOverlay (id) {
	splitHeader('title',2,'npo1');
	
}

function loadJobPage(p) {
	new Ajax.Updater({ success: 'jobContent' },baseURL+'ajaxStuff.php', {
		parameters: 'getJobs='+p+'&type='+jobType+'&area='+jobArea,
		onComplete:function (response) {
			jobHeaders ()
			setJobButtons ()
		}
	});
}

function setSearchButton () {
	var go4It = false;
	if ($('jobSearchButton').hasClassName('jobHome')) {
		$('jobSearchButton').removeClassName('jobHome');
		$('jobSearchButton').addClassName('jobSearch');
		jobType = null;
		jobArea = null;
		go4It = true;
	}
	else {
		if (jobType || jobArea) {
			$('jobSearchButton').removeClassName('jobSearch');
			$('jobSearchButton').addClassName('jobHome');
			go4It = true;
		}
	}
	if (go4It) {
		loadJobPage(1);
		loadJobPages();
	}
}

function loadJobPages() {
	new Ajax.Updater({ success: 'jobPages' },baseURL+'ajaxStuff.php', {
		parameters: 'getJobPages=1&type='+jobType+'&area='+jobArea+'&salary='+readyForPost($F('salarySearch')),
		onComplete:function (response) { 
			setJobButtons (1)
		}
	});
}

function setJobOverlay () {
	var a=$$('a[id^=jobApply]'),f='overlayEnquiryForm';
	if (a.length>0) {
		var i = a[0]['id'];
		var id = parseInt(i.replace('jobApply_',''));
		$(i).stopObserving('click');
		Event.observe(i, 'click',function () {
			new Ajax.Updater({ success: 'overlayContent' },baseURL+'ajaxStuff.php', {
				parameters: 'getJobOverlayInfo='+id,
				onComplete:function (response) { 
					showBox('enquiryOverlay',1);
				}
			});
			$('submitOverlay').stopObserving('click');
			Event.observe('submitOverlay', 'click',function () {
				if ((badField(f,2)) || isValidEmail($F('overlayEmail')) != true) messageBox('Please enter all fields',3);
				else  {
					var allNodes = Form.serialize(f);
					var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'submitJobEnquiry='+id+'&'+allNodes,onComplete: function(response) {
						messageBox('Thanks, your enquiry has been sent',3);
						closeBox('enquiryOverlay');
						$(f).reset();
					}});
				}
			});
		});
	}
}


/********************** GALLERY ************************/

function setUpGallery () {
	$('searchGallery').stopObserving();
	if ($('searchGallery').present() == true) $('searchGallery').setStyle({backgroundPosition:'9px 50px'});
	Event.observe('searchGallery', 'focus',function () {$('searchGallery').setStyle({backgroundPosition:'9px 50px'})});
	Event.observe('searchGallery', 'blur',function () {
		if ($('searchGallery').present() != true) $('searchGallery').setStyle({backgroundPosition:'9px 8px'});
	});
	$('scrollLeft').observe('click', function () {
		if (working<1 && galleryCurrentPage>1) {
			working=1;
			new Effect.Move('content', { x: 520, y: 0, mode: 'relative', transition: Effect.Transitions.spring, afterFinish: function(){ working=0; --galleryCurrentPage; }});
		}
	});
	$('scrollRight').observe('click', function () {
		if (working<1 && galleryCurrentPage<galleryPages) {
			working=1;
			new Effect.Move('content', { x: -520, y: 0, mode: 'relative', transition: Effect.Transitions.spring, afterFinish: function(){ working=0; ++galleryCurrentPage; }});
		}
	});
	setupGalleryObserves();
	setupGalleryPageObserves ();
	selectPage(pageNum,'galleryPages');
	Event.observe('searchGallery', 'keypress',function (e) { handleEnter (e, gallerySearch) });
}

function setupGalleryObserves () {
	var a=$$('#galleryAlbums li span span img'),i=1;
	if (a.length<1) {
		resetGalleryContent ();
		$('content').update('No Results');
		selectedGallery = null;
	}
	a.each(function(n){
		$(n.id).setOpacity('0.5');
		if (i<2) {
			$(n.id).setOpacity('1.0');
			loadGallery (n.id);
		}
		$(n.id).stopObserving('mouseout');
		$(n.id).stopObserving('mouseover');
		Event.observe(n.id, 'mouseover',function () { $(n.id).setOpacity('1.0'); });
		Event.observe(n.id, 'mouseout',function () { if ('gal_'+selectedGallery != n.id) $(n.id).setOpacity('0.5'); });
		Event.observe(n.id, 'click',function () { loadGallery (n.id); });
		++i;
	});
}

function setupGalleryItemObserves (l) {
	var a=$$('#selectedList .contentCont #content li img'),t,r,i=1;
	galleryPages = Math.ceil(a.length/4);
	$('content').setStyle({ width:(a.length*130)+'px'});
	a.each(function(n){
		$(n.id).setOpacity('0.5');
		if (i<2) loadGalleryItem(n.id);
		$(n.id).stopObserving('mouseout');
		$(n.id).stopObserving('mouseover');
		Event.observe(n.id, 'mouseover',function () { $(n.id).setOpacity('1.0'); });
		Event.observe(n.id, 'mouseout',function () { if (selectedGalleryItem != n.id)  $(n.id).setOpacity('0.5'); });
		Event.observe(n.id, 'click',function () { if (selectedGalleryItem != n.id) loadGalleryItem(n.id,1); });
		++i;
	});
}

function setupGalleryPageObserves () {
	var a=$$('#galleryPages li a'),r;
	a.each(function(n){
		$(n.id).observe('click',function(){showGalleryPage(n.id)});
	});
}

function gallerySearch () {
	pageNum=999999;
	selectedGallery = null;
	var aj1 = new Ajax.Updater('galleryPages',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getGalleryPages=1&search='+readyForPost($F('searchGallery'))+'&type='+type+'&cat='+cat,onComplete: function(response) { showGalleryPage ('page1'); setupGalleryPageObserves (); }});
}

function resetGalleryContent () {
	if (selectedGalleryItem) {
		if ($(selectedGalleryItem) != null) $(selectedGalleryItem).setOpacity('0.5');
		if ((selectedGalleryItem.search('Vimeo')>=0) || (selectedGalleryItem.search('YouTube')>=0)) {
			swfobject.removeSWF('mainContent');
			$('mainContentContainer').update('<div id="mainContent"></div>');
		}
		else $('mainContent').update();
	}
	$('imageTitle').update('');
	$('imageText').update('');
}

function loadGalleryItem(i,a) {
	resetGalleryContent ();
	$(i).setOpacity('1.0');
	selectedGalleryItem = i;
	if (a == null) a=0;
	var v,r;
	$('mainContent').setStyle({paddingLeft: '0px'});
	if (i.search('image')>=0) {
		v = i.split('_');
		var pad = Math.ceil(($('mainContent').getWidth()-v[2])/2);
		$('mainContent').setStyle({paddingLeft: pad+'px'});
		r = $(i).src.replace('thumbnail','main');
		$('mainContent').update('<img src="'+r+'" />');
	}
	if (i.search('Vimeo')>=0) {
		v = i.replace('Vimeo_','').split('||');
		showVimeo (v[0], 551, 309, 'mainContent', 'ff0000',a);
	}
	if (i.search('YouTube')>=0) {
		v = i.replace('YouTube_','').split('||');
		showYouTube (v[0], 551, 309, 'mainContent',a);
	}
	loadGalleryItemText (v[1]);
}

function loadGalleryItemText (i) {
	$('imageTitle').update();
	$('imageText').update();
	var aj1 = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getGalleryItemInfo='+i,onComplete: function(response) {
		var reply = response.responseText.split('||message||');
		$('imageTitle').update(reply[1]+' <span>'+reply[2]+'</span>');
		$('imageText').update(reply[3]);
	}});
}

function loadGallery (i) {
	var galID = i.replace('gal_',''),m=0;
	if (galID != selectedGallery || selectedGallery == null) {
		if (selectedGallery && $('gal_'+selectedGallery) != null) $('gal_'+selectedGallery).setOpacity('0.5');
		selectedGallery = galID;
		$(i).setOpacity('1.0');
		if (galleryCurrentPage>1) {
			--galleryCurrentPage;
			m = galleryCurrentPage * 520;
			galleryCurrentPage=1;
		}
		var aj1 = new Ajax.Updater('content',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getGalleryItems='+galID+'&search='+readyForPost($F('searchGallery'))+'&type='+type+'&cat='+cat,onComplete: function(response) {
			new Effect.Move('content', { x: m, y: 0, mode: 'relative', transition: Effect.Transitions.full});
			setupGalleryItemObserves (1);
		}});
	}
}

function showGalleries (p) {
	var aj1 = new Ajax.Updater('galleryAlbums',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getGalleries='+p+'&search='+readyForPost($F('searchGallery'))+'&type='+type+'&cat='+cat,onComplete: function(response) {
		setupGalleryObserves ();
	}});
}

function selectPage(i,ulID) {
	var a=$$('#'+ulID+' li a');
	a.each(function(n){
		if ($(n.id).hasClassName('active')) $(n.id).removeClassName('active');
	});
	if ($('page'+i)) $('page'+i).addClassName('active');
}

function showGalleryPage (p) {
	p=p.replace('page','');
	if (p != pageNum) {
		pageNum = p;
		selectPage(p,'galleryPages');
		showGalleries (p);
	}
}


/********************** PRIZES ************************/

function setUpPrizes () {
	if (notIE6) {
		var a=$$('.prizeCont li div div');
		a.each(function(n){
			splitHeader(n.id,2,'prizeHead');
		});
		doSIFR ("h2.prizeHead",7,1,"left","#2b2b2b","#0099e6","upper");
		doSIFR ("h3.prizeHead",7,-3,"left","#2b2b2b","#0099e6","upper");
	}
	Event.observe('compSignupName', 'keypress',function (e) { handleEnter (e, submitSignUp,'comp') });
	Event.observe('compSignupEmail', 'keypress',function (e) { handleEnter (e, submitSignUp,'comp') });
	var a=$$('a[id^=compInfo]');
	a.each(function(n){
		var b = parseInt(n.id.replace('compInfo_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadPrize(b,'show') } );
	});
	if ($('title')) {
		if (notIE6) {
			splitHeader('title',2,'npo1');
			doSIFR ("h2.npo1",7,1,"left","#2b2b2b","#0099e6","upper");
			doSIFR ("h3.npo1",7,-3,"left","#2b2b2b","#0099e6","upper");
		}
		createShareThis ($('prizeFocusImage_1').alt,$('prizeFocusImage_1').alt,$('compFocusInfo_1').href,$('prizeFocusImage_1').src,'compFocusShare_1');
	}
	var a=$$('img[id^=shareComp]');
	a.each(function(n){
		var b = parseInt(n.id.replace('shareComp_',''));
		createShareThis ($('prizeImage_'+b).alt,$('prizeImage_'+b).alt,$('compInfo_'+b).href,$('prizeImage_'+b).src,'shareComp_'+b);
	});
	setPrizeOverlay ()
}

function loadPrize (i) {
	var adH = 0,contentBox = 'left',h2,ov = 'focusOverlay',con='prizesFocusContainer',pars;
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: 'getPrize='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				if (notIE6) {
					splitHeader('title',2,'npo1');
					doSIFR ("h2.npo1",7,1,"left","#2b2b2b","#0099e6","upper");
					doSIFR ("h3.npo1",7,-3,"left","#2b2b2b","#0099e6","upper");
				}
				createShareThis ($('prizeFocusImage_'+i).alt,$('prizeFocusImage_'+i).alt,$('compFocusInfo_'+i).href,$('prizeFocusImage_'+i).src,'compFocusShare_'+i);
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				setPrizeOverlay ()
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
}

function setPrizeOverlay () {
	var a=$$('a[id^=prizeEnter]'),f='overlayEnquiryForm';
	if (a.length>0) {
		var i = a[0]['id'];
		var id = parseInt(i.replace('prizeEnter_',''));
		$(i).stopObserving('click');
		Event.observe(i, 'click',function () {
			new Ajax.Updater({ success: 'overlayContent' },baseURL+'ajaxStuff.php', {
				parameters: 'getPrizeOverlayInfo='+id,
				onComplete:function (response) { 
					showBox('enquiryOverlay',1);
				}
			});
			$('submitOverlay').stopObserving('click');
			Event.observe('submitOverlay', 'click',function () {
				if ((badField(f,2)) || isValidEmail($F('overlayEmail')) != true) messageBox('Please enter all fields and ensure your email address is valid',3);
				else  {
					var allNodes = Form.serialize(f);
					var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'submitPrizeEnquiry='+id+'&'+allNodes+'&type='+thisPage,onComplete: function(response) {
						messageBox('Thanks, your entry has been sent',3);
						closeBox('enquiryOverlay');
						$(f).reset();
					}});
				}
			});
		});
	}
}


/********************** SHOWBIZ ************************/

function setUpShowbiz () {
	showBizHeaders ()
	var a=$$('a[id^=page]');
	a.each(function(n){
		$(n.id).stopObserving();
		Event.observe(n.id, 'click',function (e) { loadShowbizPage (parseInt(n.id.replace('page_',''))) });
	});
	var a=$$('img[id^=shareShowbiz]');
	a.each(function(n){
		var b = parseInt(n.id.replace('shareShowbiz_',''));
		createShareThis ($('showbizPic_'+b).alt,$('showbizPic_'+b).alt,$('showbizURL_'+b).href,$('showbizPic_'+b).src,'shareShowbiz_'+b);
	});
	var a=$$('a[id^=showbizURL]');
	a.each(function(n){
		$(n.id).stopObserving();
		Event.observe(n.id, 'click',function (e) { loadShowbiz (parseInt(n.id.replace('showbizURL_',''))) });
	});
	var a=$$('a[id^=featurePic]');
	a.each(function(n){
		$(n.id).stopObserving();
		Event.observe(n.id, 'click',function (e) { loadShowbiz (parseInt(n.id.replace('featurePic_',''))) });
	});
	var a=$$('img[id^=shareFocusShowbiz]');
	a.each(function(n){
		var b = parseInt(n.id.replace('shareFocusShowbiz_',''));
		createShareThis ($('showbizFocusPic_'+b).alt,$('showbizFocusPic_'+b).alt,$('showbizFocusURL_'+b).href,$('showbizFocusPic_'+b).src,'shareFocusShowbiz_'+b);
	});
}

function loadShowbizPage (p) {
	var a=$$('a[id^=page]');
	a.each(function(n){
		$(n.id).removeClassName('active');
	});
	$('page_'+p).addClassName('active');
	var aj1 = new Ajax.Updater('showBizList',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getShowbizPage='+p,onComplete:setUpShowbiz});
}

function showBizHeaders () {
	if (notIE6) {
	doSIFR ("h2.articleTitle",9,1,"left","#FFFFFF","#7e29c6","upper");
	doSIFR ("h2.showbizTitle",7,4,"left","#ffffff","#7e29c6","upper");
	}
}

function loadShowbiz (i) {
	var adH = 0,contentBox = 'right',h2,ov = 'focusOverlay',con='showbizFocus';
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: 'getShowbiz='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				showBizHeaders ()
				createShareThis ($('showbizFocusPic_'+i).alt,$('showbizFocusPic_'+i).alt,$('showbizFocusURL_'+i).href,$('showbizFocusPic_'+i).src,'shareFocusShowbiz_'+i);
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
}


/********************** MUSIC ************************/

var votes = new Array();
function setUpMusic () {
	var a=$$('.songBox .player'); var i=1,w;
	a.each(function(n){
		if (i<2) w=355; else w = 466;
		showJWPlayer (n.id,w,$(n.id).innerHTML);
		++i;
	});
	var a=$$('.songListCont span');
	a.each(function(n){
		var v = n.id.split('_');
		votes[v[1]] = $('votes_all_'+v[1]).innerHTML;
		$(n.id).stopObserving();
		Event.observe(n.id, 'click',function () { if (working!=1) hotNot(v[0],v[1]);  });
		Event.observe(n.id, 'mouseover',function () { $(n.id).setStyle({ backgroundPosition: '0 -60px' }); });
		Event.observe(n.id, 'mouseout',function () { $(n.id).setStyle({ backgroundPosition: '0 0' }); });
	});
	doSIFR (".track h4",10,0,"left","#FFFFFF","#00b1b1","upper");
	doSIFR (".artist h4",10,0,"left","#FFFFFF","#309e9e","upper");
	doSIFR (".votes h4",10,0,"left","#000000","#ffffff","upper");
	loadPodcast ('breakfast');
	var a=$$('#podcastCats li a');
	a.each(function(n){
		$(n.id).observe('click', function () { loadPodcast (n.id) } );
	});
}

function playerReady () {
		
}

function hotNot(t,i) {
	working=1;
	var aj1 = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'musicHotNot='+t+'&i='+i,onComplete: function(response) { 
		var r = response.responseText;
		if (r=='y') {
			if (t=='hot') ++votes[i]; else --votes[i];
			messageBox('Thanks, your vote has been registered.',4);
			window.location.reload();
		}
		else messageBox(r,4);
		working=0;
	}});
}


/********************** BEAT FLEET ************************/

function replaceBeatFleetAboutText () {
	if ($('mainAboutText') != null) $('mainAboutText').update('<img src="'+baseURL+'images/text/about_beat_fleet.png" />');
}

function setUpBeatFleet () {
	var a=$$('#beatFleet li span');
	a.each(function(n){
		splitHeader(n.id,3,'beatFleetTitle');
	});
	if ($('beatFleetFocus') != null) splitHeader('title',2,'npo1');
	beatFleetHeaders ()
	var a=$$('a[id^=readMore]');
	a.each(function(n){
		$(n.id).stopObserving();
		Event.observe(n.id, 'click',function (e) { loadBeatFleet (parseInt(n.id.replace('readMore_',''))) });
	});
var tt=$$('img[id^=homeMainImage]');
	if (tt.length>1) setInterval (scrollBFImage,8000)
}

function scrollBFImage () {
	var newImage,a=$$('img[id^=homeMainImage]');
	if (homeImageShowing==a.length) newImage=1;
	else newImage = homeImageShowing + 1;
	$('homeMainImage_'+newImage).setStyle({ zIndex: 2 });
	$('homeMainImage_'+homeImageShowing).setStyle({ zIndex: 1 });
	new Effect.Move('homeMainImage_'+newImage, { x: -567, y: 0, mode: 'relative', transition: Effect.Transitions.sinoidal, afterFinish: function(){ $('homeMainImage_'+homeImageShowing).setStyle({ left:'567px' }); homeImageShowing = newImage;}});
}

function loadBeatFleet (i) {
	var adH = 0,contentBox = 'left',h2,ov = 'focusOverlay',con='beatFleetFocus';
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: 'getBeatFleet='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				if (notIE6) {
				splitHeader('title',2,'npo1');
				}
				beatFleetHeaders ()
				h2 = $(con).getHeight();
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				sendAnEmail()
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});
				}});
			}
		});
}

function beatFleetHeaders () {
	if (notIE6) {
	doSIFR ("h2.npo1",2,2,"left","#FFFFFF","#fdbb00","upper");
	doSIFR ("h3.npo1",2,-3,"left","#FFFFFF","#fdbb00","upper");
	doSIFR ("h3.beatFleetTitle",7,4,"left","#2b2b2b","#fdbb00","upper");
	doSIFR ("h4.beatFleetTitle",7,-2,"left","#2b2b2b","#fdbb00","upper");
	}
}


/********************** CONTACT ************************/

function setUpContact () {
	Event.observe('contactSignupName', 'keypress',function (e) { handleEnter (e, submitSignUp,'c') });
	Event.observe('contactSignupEmail', 'keypress',function (e) { handleEnter (e, submitSignUp,'c') });
	Event.observe('name', 'keypress',function (e) { handleEnter (e, submitContact) });
	Event.observe('email', 'keypress',function (e) { handleEnter (e) });
	Event.observe('submit', 'click',submitContact);
	var a=$$('[id^=area_]'),b;
	a.each(function(n){
		b = parseInt(n.id.replace('area_',''))
		$('rep_'+b).setStyle({zIndex:2});
		$('rep_6').setStyle({zIndex:3});
		Event.observe(n.id, 'mouseover',function () {
			showRep (n.id)
		});
		Event.observe(n.id, 'click',function (e) {
			Event.stop(e);
			emailSend (b,'reps','email','overlayEnquiryForm');
		});
		
	});
}

var repTimer, r1;
function showRep (i) {
	var b = parseInt(i.replace('area_','')), i=1;
	while (i<7) {
		if (i != b) $('rep_'+i).setStyle({zIndex:2});
		++i;
	}
	$('rep_'+b).setStyle({zIndex:3});
}

function submitContact () {
	var f = 'contactForm';
	if (badField(f,2)) messageBox('Please enter all fields',3);
	else if (isValidEmail($F('email'))) {
		var allNodes = Form.serialize(f);
		var aj = new Ajax.Request(baseURL+'ajaxStuff.php', {method: 'post', parameters: 'submitContact=1&'+allNodes,onComplete: function(response) {
			messageBox('Thanks, your email has been sent',3);
			$(f).reset();
		}});
	}
	else messageBox('Please enter a valid email',3);
}


/********************** VIP ************************/

function setUpVIPHome () {
	if (notIE6) doSIFR ("h3",0,-2,"left","#2b2b2b",'#FFFFFF',"upper");
}

/********************** VIP PRIZES ************************/

function setUpVIPPrizes () {
	var a=$$('.prizeCont li div div');
	a.each(function(n){
		splitHeader(n.id,2,'prizeHead');
	});
	var a=$$('a[id^=compInfo]');
	a.each(function(n){
		var b = parseInt(n.id.replace('compInfo_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadVIPPrize(b) } );
	});
	var a=$$('a[id^=page_]');
	a.each(function(n){
		var b = parseInt(n.id.replace('page_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadVIPPrizesPage(b) } );
	});
	if ($('t1')) {
		splitHeader('t1',2,'npo1');
		createShareThis ($('prizeFocusImage_1').alt,$('prizeFocusImage_1').alt,$('prizeEnter_1').href,$('prizeFocusImage_1').src,'compFocusShare_1');
		loadVIPPrizesHeaders (1)
	}
	else loadVIPPrizesHeaders ()
	var a=$$('img[id^=shareComp]');
	a.each(function(n){
		var b = parseInt(n.id.replace('shareComp_',''));
		createShareThis ($('prizeImage_'+b).alt,$('prizeImage_'+b).alt,$('compInfo_'+b).href,$('prizeImage_'+b).src,'shareComp_'+b);
	});
	setPrizeOverlay()
}

function loadVIPPrizesHeaders (t) {
	if (notIE6) {
		if (t==null) {
		doSIFR ("h2.prizeHead",7,1,"left","#ffffff","#dd2000","upper");
		doSIFR ("h3.prizeHead",7,-3,"left","#ffffff","#dd2000","upper");
		}
		else {
		doSIFR ("h2.npo1",7,1,"left","#ffffff","#dd2000","upper");
		doSIFR ("h3.npo1",7,-3,"left","#ffffff","#dd2000","upper");
		}
	}
}

function loadVIPPrizesPage (p) {
	var aj1 = new Ajax.Updater('prizesCont',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getVIPPrizesPage='+p,onComplete:function(response) { setUpVIPPrizes(); }});
}

function loadVIPPrize (i) {
	var adH = 0,contentBox = 'vipContent',h2,ov = 'focusOverlay',con='prizeFocus';
	var h = createOverlay (contentBox,'#ffffff',0,0,2,adH,0);
		new Ajax.Updater({ success: 'focusOverlay' },baseURL+'ajaxStuff.php', {
			parameters: 'getVIPPrize='+i,
			insertion: 'top',
			onComplete:function (response) { 
				$(con).setStyle({left:$(con).getWidth()+'px'});
				$(con).show();
				if (notIE6) splitHeader('t1',2,'npo1');
				loadVIPPrizesHeaders (1)
				createShareThis ($('prizeFocusImage_'+i).alt,$('prizeFocusImage_'+i).alt,$('prizeEnter_'+i).href,$('prizeFocusImage_'+i).src,'compFocusShare_'+i);
				h2 = $(con).getHeight();
				setPrizeOverlay()
				if (h2 > h) {
					$(ov).setStyle({height:h2+'px'});
					$(contentBox).setStyle({height:(h2-adH)+'px'});
				}
				new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
					/*$('closeArticle').stopObserving();
					$('closeArticle').observe('click', function () {
						closeContentBox (contentBox,con,ov)
					});*/
				}});
			}
		});
}

/********************** VIP BLOG ************************/

function setUpVIPBlog () {
	loadVIPBlogClicks ()
}

function loadVIPBlogClicks () {
	var a=$$('a[id^=blogPrevURL]');
	a.each(function(n){
		var b = parseInt(n.id.replace('blogPrevURL_',''));
		$(n.id).stopObserving();
		$(n.id).observe('click', function () { loadVIPBlogArticle(b) } );
		createShareThis ($('blogPrevIm_'+b).alt,$('blogPrevP_'+b).innerHTML,$('blogPrevURL_'+b).href,$('blogPrevIm_'+b).src,'blogShare_'+b);
	});
	var a=$$('a[id^=blogFocusPrevURL]');
	a.each(function(n){
		var i = parseInt(n.id.replace('blogFocusPrevURL_',''));
		createShareThis ($('blogFocusPrevIm_'+i).alt,$('blogFocusPrevIm_'+i).alt,$('blogFocusPrevURL_'+i).href,$('blogFocusPrevIm_'+i).src,'blogFocusShare_'+i);
	});
}

function loadVIPBlogArticle(i) {
	var adH = 0,ov = 'focusOverlay';
	var h = createOverlay ('vipContent','#ffffff',0,0,2,adH,0,ov),h2,con='blogFocus';
	new Ajax.Updater({ success: ov },baseURL+'ajaxStuff.php', {
		parameters: 'getVIPBlogArticle='+i,
		insertion: 'top',
		onComplete:function (response) { 
			$(con).setStyle({left:$(con).getWidth()+'px'});
			$(con).show();
			h2 = $(con).getHeight();
			if (h2 > h) {
				$(ov).setStyle({height:h2+'px'});
				$('vipContent').setStyle({height:(h2-adH)+'px'});
			}
			new Effect.Move(con, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal,duration:0.7, afterFinish: function(){
				createShareThis ($('blogFocusPrevIm_'+i).alt,$('blogFocusPrevIm_'+i).alt,$('blogFocusPrevURL_'+i).href,$('blogFocusPrevIm_'+i).src,'blogFocusShare_'+i);
				$('closeArticle').stopObserving();
				$('closeArticle').observe('click', function () {
					closeContentBox ('vipContent',con,ov)
				});
			}});
		}
	});
}


/********************** VIP GALLERY ************************/

function setUpVIPGallery () {
	$('scrollLeft').observe('click', function () {
		if (working<1 && galleryCurrentPage>1) {
			working=1;
			new Effect.Move('content', { x: 520, y: 0, mode: 'relative', transition: Effect.Transitions.spring, afterFinish: function(){ working=0; --galleryCurrentPage; }});
		}
	});
	$('scrollRight').observe('click', function () {
		if (working<1 && galleryCurrentPage<galleryPages) {
			working=1;
			new Effect.Move('content', { x: -520, y: 0, mode: 'relative', transition: Effect.Transitions.spring, afterFinish: function(){ working=0; ++galleryCurrentPage; }});
		}
	});
	loadVIPGallery ('gal_1');
}

function setupVIPGalleryItemObserves (l) {
	var a=$$('#selectedList .contentCont #content li img'),t,r,i=1;
	galleryPages = Math.ceil(a.length/4);
	$('content').setStyle({ width:(a.length*130)+'px'});
	a.each(function(n){
		$(n.id).setOpacity('0.5');
		if (i<2) loadVIPGalleryItem(n.id);
		$(n.id).stopObserving('mouseout');
		$(n.id).stopObserving('mouseover');
		Event.observe(n.id, 'mouseover',function () { $(n.id).setOpacity('1.0'); });
		Event.observe(n.id, 'mouseout',function () { if (selectedGalleryItem != n.id)  $(n.id).setOpacity('0.5'); });
		Event.observe(n.id, 'click',function () { if (selectedGalleryItem != n.id) loadVIPGalleryItem(n.id,1); });
		++i;
	});
}

function resetVIPGalleryContent () {
	if (selectedGalleryItem) {
		if ($(selectedGalleryItem) != null) $(selectedGalleryItem).setOpacity('0.5');
		if ((selectedGalleryItem.search('Vimeo')>=0) || (selectedGalleryItem.search('YouTube')>=0)) {
			swfobject.removeSWF('mainContent');
			$('mainContentContainer').update('<div id="mainContent"></div>');
		}
		else $('mainContent').update();
	}
}

function loadVIPGalleryItem(i,a) {
	resetVIPGalleryContent ();
	$(i).setOpacity('1.0');
	selectedGalleryItem = i;
	if (a == null) a=0;
	var v,r;
	$('mainContent').setStyle({paddingLeft: '0px'});
	if (i.search('image')>=0) {
		v = i.split('_');
		var pad = Math.ceil(($('mainContent').getWidth()-v[2])/2);
		$('mainContent').setStyle({paddingLeft: pad+'px'});
		r = $(i).src.replace('thumbnail','main');
		$('mainContent').update('<img src="'+r+'" />');
	}
	if (i.search('Vimeo')>=0) {
		v = i.replace('Vimeo_','').split('||');
		showVimeo (v[0], 551, 309, 'mainContent', 'ff0000',a);
	}
	if (i.search('YouTube')>=0) {
		v = i.replace('YouTube_','').split('||');
		showYouTube (v[0], 551, 309, 'mainContent',a);
	}
}

function loadVIPGallery (i) {
	var galID = i.replace('gal_',''),m=0;
	var aj1 = new Ajax.Updater('content',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getVIPGalleryItems='+galID,onComplete: function(response) {
			new Effect.Move('content', { x: m, y: 0, mode: 'relative', transition: Effect.Transitions.full});
			setupVIPGalleryItemObserves (1);
		}});
}


/********************** PODCASTS ************************/

function loadPodcast (p) {
	var aj2 = new Ajax.Updater('subscribeButtons',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getPodcast='+p+'&type=subscribe'});
	var aj3 = new Ajax.Updater('podcastPics',baseURL+'ajaxStuff.php', {method: 'post', parameters: 'getPodcast='+p+'&type=images'});
	$('download_podcast').href = baseURL+'fileSave.php?p='+p;
	if ($('podcastCats') != null) {
		var a=$$('#podcastCats li a');
		a.each(function(n){
			$(n.id).removeClassName('active');
		});
		$(p).addClassName('active');
	}
}


/********************** BLOGS ************************/

function setUpBlogs () {
	var bg;
	if ($('leftSide').hasClassName('breakfastBlog')) bg = '#f09900'; else bg = '#dd2000';
	doSIFR ("h1.blogTitle",0,0,"left","#FFFFFF",bg,"upper");
	doSIFR ("h2.blogTitle",0,0,"left","#FFFFFF",bg,"upper");
	var a=$$('span[id^=share]');
	a.each(function(n){
		createShareThis ($(n.id).title,$(n.id).title,$(n.id).innerHTML,'',n.id);
	});
	if ($('submitComment') != null) {
		$('submitComment').observe('click', function() {
			if ($F('author') && $F('email') && $F('comment')) {
				$('commentform').action = theBlogURL+'/wp-comments-post.php';
				$('commentform').submit();
			}
			else messageBox('Please enter all fields',3);
		});
	}
}

Event.observe( window, 'load',setUpAll);
if (thisPage == 'home') 
	Event.observe( window, 'load',setUpHome);
if (thisPage == 'news') 
	Event.observe( window, 'load',setUpNews);
if (thisPage == 'election') 
	Event.observe( window, 'load',setUpElection);
if (thisPage == 'breakfast') 
	Event.observe( window, 'load',setUpBreakfast);
if (thisPage == 'music') 
	Event.observe( window, 'load',setUpMusic);
if (thisPage == 'djs') 
	Event.observe( window, 'load',setUpDJs);
if (thisPage == 'jobs') 
	Event.observe( window, 'load',setUpJobs);
if (thisPage == 'gallery') 
	Event.observe( window, 'load',setUpGallery);
if (thisPage == 'prizes') 
	Event.observe( window, 'load',setUpPrizes);
if (thisPage == 'showbiz') 
	Event.observe( window, 'load',setUpShowbiz);
if (thisPage == 'fleet') {
	replaceBeatFleetAboutText ();
	Event.observe( window, 'load',setUpBeatFleet);
}
if (thisPage == 'contact') 
	Event.observe( window, 'load',setUpContact);
if (thisPage == 'vip_home') 
	Event.observe( window, 'load',setUpVIPHome);
if (thisPage == 'vip_prizes') 
	Event.observe( window, 'load',setUpVIPPrizes);
if (thisPage == 'vip_blog') 
	Event.observe( window, 'load',setUpVIPBlog);
if (thisPage == 'vip_gallery') 
	Event.observe( window, 'load',setUpVIPGallery);
if (thisPage == 'blog_page') 
	Event.observe( window, 'load',setUpBlogs);
