
// (c) 2010 2011 2012
// Band Directory.
// Local bands
// in the UK.


var website = "http://www.banddirectory.co.uk/";

var aa
function cc(theid,tc,nn) {
	clearTimeout(aa)
	var theobj = document.getElementById(theid);
	var c = theobj.style.backgroundColor.substring(1)
	c = a2b(c,tc,nn)
	theobj.style.backgroundColor = c
	if (nn<100) {aa=setTimeout("cc("+theid+",'"+tc+"',"+(nn+5)+")",110) }
}

function a2b(a,b,p) {
var r1=parseInt(a.substring(0,2),16)
var g1=parseInt(a.substring(2,4),16)
var b1=parseInt(a.substring(4,6),16)
var r2=parseInt(b.substring(0,2),16)
var g2=parseInt(b.substring(2,4),16)
var b2=parseInt(b.substring(4,6),16)
var r3=Math.round((r1*(100-p)+r2*p)/100)
var g3=Math.round((g1*(100-p)+g2*p)/100)
var b3=Math.round((b1*(100-p)+b2*p)/100)
return '#'+d2h(r3) + d2h(g3) + d2h(b3)
}
function d2h(d) {return ('0'+d.toString(16)).slice(-2);}
function h2d(h) {return parseInt(h,16);} 


var a=20, s=1, t3, y=100,x=200, c=0, thestar;
var d=new Array(3000,3000,3000,3000,3000,3000,3000);

function st() {
window.clearTimeout(t3)
if (document.star) {
if (star.complete) {
if (!document.thestar) {thestar=star.style}
thestar.opacity = s/100;
thestar.filter = 'alpha(opacity='+s+')';
s=s+a;
if (s>25 && a==3) {a=12}
if (s>70) {a=-15}
d[c]=100
}
}
if (s<15) {
s=15; a=3; y=Math.random()*130; x=Math.random()*850+50; c=parseInt(Math.random()*4);
document.getElementById("music").innerHTML = "<img name=star src='img/s"+c+".gif' style='position:absolute; left:"+x+"px; top:"+y+"px; z-index:2; opacity:"+(s/100)+"; filter:alpha (opacity="+s+");'>";
}
t3=window.setTimeout("st()",d[c]);
}


function send(something)
{
if (t1!==0) {clearTimeout(t1)};
if (window.XMLHttpRequest) areq=new XMLHttpRequest();
else if (window.ActiveXObject) areq=new ActiveXObject("Microsoft.XMLHTTP");

if (typeof(something)=='undefined') something='';
if (something!="") something='?'+something;
areq.open("GET",url +something,true);
//u=setTimeout("retry()",630000);

areq.setRequestHeader("User-Agent","");
areq.setRequestHeader("Accept","");
areq.setRequestHeader("Accept-Language","");
areq.onreadystatechange=retr;
areq.send(null);
}
function retr()
{
	if (areq.readyState!=4) return;
	var c="";
	if (areq.status==200) c=areq.responseText;
	else window.status="Error: "+ areq.statusText;

	if (c!='') eval(c);
	delete areq;
	t1=setTimeout("send()",600000)
}
function retry()
{
	clearTimeout(t1);
	send()
}
var areq,t1=0,t3=0;
var url = website + "keepalive.asp";

//t=setTimeout("location=location",Math.random()*999999+999999)


function winchk() {
var myw=document.body.clientWidth+29;
var myh=document.body.clientHeight+150;
var myr=false;
if (myh<551) {myh=551; myr=true}
if (myw<770) {myw=770; myr=true}
if (myr) {
 if (window.outerWidth) {
  window.outerWidth = myw;
  window.outerHeight = myh;
 }
 else if (window.resizeTo) {
  window.resizeTo(myw,myh);
 }
}
}


var screenW = 0, screenH = 0;
function sendres() {
if (parseInt(navigator.appVersion)>3) {
 if (typeof window.screen.width=="number") { 
 screenW = window.screen.width;
 screenH = window.screen.height;
 }
}
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled() ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
}
send("do=xy&x="+screenW+"&y="+screenH)
}


function findLocation() {
  //document.write("<br>Requesting your location.....");
  //setTimeout('document.write("<br>Please accept the location request..")',1000);
  navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
}


function foundLocation(position)
{
  var lat = position.coords.latitude;
  var long = position.coords.longitude;
  var acc = position.coords.accuracy;
  //document.write("<br>Got location, loading page...");
  var loc = website +"bandsnearme.asp?coords="+lat+","+long;
  var loc = website +"findlocation.asp?lat="+lat+"&lng="+long+"&acc="+acc;
  //alert(loc);
  location=loc;
}

function noLocation()
{
  alert('Could not find your location\nPlease enter your postcode');
}



function e(a) {
var b='',c='', x
for (var x=a.length; x>=0;x--)
{c = (a.charAt(x))
 if (c==':'){c='@'}
 b=b+c}
document.write('<a hr'+'ef="mai'+'lto:'+b+'">'+b+'</a>')
}
function z() {
if (window.getSelection) {
 window.getSelection().removeAllRanges();
 }
else {
 document.selection.empty();
 document.selection.clear();
 }
return false;
}

function em(a) {
var h = '<hr><form method="post" name="mail"><table><tr><td>Your name</td><td><input name=name class=msg value=""></td></tr><tr><td nowrap>Your email address</td><td><input name=email class=msg value=""></td></tr><tr><td>Message to band</td><td><textarea name=msg class=msg style="height:99px"></textarea></td></tr><tr><td></td><td><button onclick="ems()">send message</button></td></tr></table></form>'
emailmsg.innerHTML = h
//send('do=e')
var t7=window.setTimeout("send('do=e')",30)
}

function ems() {
//alert(mail.msg.value)
if (mail.name.value!='' && mail.email.value!='' && mail.msg.value!='') {status="Sending..";mail.submit();status="Message sent"}
}

var playbutton = website +"img/live.gif";
var pausebutton = website +"img/pause-music.png";
function musiconoff() {
	var audio = document.getElementById('audio');
	canPlayMP3 = (typeof audio.canPlayType === "function" && audio.canPlayType("audio/mpeg") !== "");
	if (!canPlayMP3) return true;

	var button = document.getElementById('musicbutton');
	if (button.src==playbutton) {
		audio.play();
		button.src = pausebutton;
	} else {
		audio.pause();
		button.src = playbutton;
	}
	return false;
}

function loadimages(images) {
	var image = new Image();
	for (x in images) image.src = images[x];
}

function start() {
winchk();sendres();
window.status='(c) Band Directory';
}

