/* Obsificate with: http://www.javascriptobfuscator.com/Default.aspx */

var arr = [
['pictures/gb-uacpromo-1.jpg',357,365],
['pictures/gb-uacpromo-2.jpg',552,364],
['pictures/doug-beer.jpg',175,112],
['pictures/doug-sunclub.jpg',87,125],
['pictures/blank.jpg',1,1],
['pictures/dhwga2.jpg',184,151],
['pictures/small/ginblossoms.jpg',305,329],
['pictures/small/psalms-02.jpg',305,295],
['pictures/small/chimeras-1.jpg',305,248],
['pictures/doug-amtshirt.jpg',259,243],
['pictures/doug-front.jpg',259,243],
['pictures/ginblossoms.jpg',1468,1584],
['pictures/logo-new.gif',642,112],
['pictures/doug-beer-1.jpg',224,352],
['pictures/gb-80s.jpg',175,124],
['pictures/psalms-dougandrichard.jpg',432,347],
['pictures/scholars2.jpg',430,391],
['pictures/doug-markzubia.jpg',600,534],
['pictures/psalms-01.jpg',388,330],
['pictures/psalms-02.jpg',384,372],
['pictures/gin-blossoms495.jpg',495,371],
['pictures/dougandrobin-pharoahs_tattoo.jpg',175,113],
['pictures/gbga2.jpg',183,151],
['pictures/gb-87.jpg',274,200],
['pictures/chimeras-1.jpg',375,305],
['pictures/chimeras-2.jpg',375,310],
['pictures/chimeras-3.jpg',541,328],
['pictures/Copy of blossoms_site.jpg',1000,683],
['pictures/riverotis.jpg',200,198],
['pictures/blossoms_site.jpg',700,478],
['pictures/back.jpg',396,329],
['pictures/dougandrobin-1.jpg',414,364],
['pictures/doug-chimeras.jpg',441,896],
['pictures/dougandrobin-2.jpg',266,296],
['pictures/bash-1.gif',175,125],
['pictures/doug-car.jpg',176,152],
['pictures/logo.gif',460,84],
['pictures/gb-qfest89-01.jpg',640,485],
['pictures/gb-qfest89-02.jpg',640,401],
['pictures/gb-qfest89-03.jpg',640,477],
['pictures/gb-qfest89-04.jpg',640,400],
['pictures/gb-qfest89-05.jpg',640,417],
['pictures/gb-qfest89-06.jpg',640,512],
['pictures/gb-qfest89-07.jpg',640,393],
['pictures/doug-nmede.jpg',343,383],
['pictures/gb-uacsleeve.jpg',426,404],
['pictures/algebraranch.gif',175,119],
['pictures/algebraranch.jpg',175,119],
['pictures/gbga.jpg',365,302],
['pictures/dhwga.jpg',368,301],
['pictures/discography/doug-hopkins-back.jpg',200,202],
['pictures/discography/ngc-cover.jpg',120,72],
['pictures/discography/astoryiwastold-front.jpg',120,119],
['pictures/discography/foay-au.jpg',115,113],
['pictures/discography/foay-au-front.jpg',200,204],
['pictures/discography/mga-us-promo-front.jpg',200,204],
['pictures/discography/foay-uk-le-back.jpg',200,172],
['pictures/discography/hj-uk-promo-cd.jpg',200,206],
['pictures/discography/astoryiwastold-back.jpg',120,120],
['pictures/discography/dusted.jpg',122,124],
['pictures/discography/mga-us-promo-back.jpg',200,205],
['pictures/discography/json.jpg',144,196],
['pictures/discography/nme-de.jpg',120,120],
['pictures/discography/hj-uk-promo-back.jpg',200,192],
['pictures/discography/lh-us-promo-back.jpg',200,194],
['pictures/discography/foay-uk-le-front.jpg',200,179],
['pictures/discography/mga-us-promo-cd.jpg',200,200],
['pictures/discography/barsandguitars.jpg',215,215],
['pictures/discography/foay-uk.jpg',122,104],
['pictures/discography/foay-uk-le-cd.jpg',200,204],
['pictures/discography/foay-uk-cd.jpg',200,200],
['pictures/discography/hj-au-cd.jpg',200,198],
['pictures/discography/hj-uk-promo-front.jpg',200,170],
['pictures/discography/foay-au-back.jpg',200,202],
['pictures/discography/foay-uk-back.jpg',200,186],
['pictures/discography/astoryiwastold.jpg',125,125],
['pictures/discography/foay-uk-le.jpg',122,111],
['pictures/discography/hj-ca-cd.jpg',200,204],
['pictures/discography/hj-au-back.jpg',200,202],
['pictures/discography/lh-us-promo-front.jpg',200,198],
['pictures/discography/heyjealousy-us-promo.jpg',117,113],
['pictures/discography/nme.jpg',120,120],
['pictures/discography/foay-uk-front.jpg',200,170],
['pictures/discography/doug-hopkins-front.jpg',200,191],
['pictures/discography/u&c.jpg',120,120],
['pictures/discography/oli.jpg',170,170],
['pictures/discography/heyjealousy-uk-promo.jpg',117,113],
['pictures/discography/lh-us-promo-cd.jpg',200,197],
['pictures/discography/scottistock.jpg',100,89],
['pictures/discography/ngc-inserts.jpg',120,62],
['pictures/discography/hj-au-front.jpg',200,201],
['pictures/discography/foay-au-cd.jpg',120,117],
['pictures/thumbnails/gb-uacpromo-1.jpg',50,50],
['pictures/thumbnails/gb-uacpromo-2.jpg',50,50],
['pictures/thumbnails/doug-beer.jpg',50,50],
['pictures/thumbnails/doug-sunclub.jpg',50,50],
['pictures/thumbnails/blank.jpg',1,1],
['pictures/thumbnails/dhwga2.jpg',184,151],
['pictures/thumbnails/doug-amtshirt.jpg',50,50],
['pictures/thumbnails/ginblossoms.jpg',50,50],
['pictures/thumbnails/doug-beer-1.jpg',50,50],
['pictures/thumbnails/gb-80s.jpg',50,50],
['pictures/thumbnails/psalms-dougandrichard.jpg',50,50],
['pictures/thumbnails/doug-markzubia.jpg',50,50],
['pictures/thumbnails/psalms-01.jpg',50,50],
['pictures/thumbnails/psalms-02.jpg',50,50],
['pictures/thumbnails/gin-blossoms495.jpg',50,50],
['pictures/thumbnails/dougandrobin-pharoahs_tattoo.jpg',50,50],
['pictures/thumbnails/gbga2.jpg',183,151],
['pictures/thumbnails/gb-87.jpg',50,50],
['pictures/thumbnails/chimeras-1.jpg',50,50],
['pictures/thumbnails/chimeras-2.jpg',50,50],
['pictures/thumbnails/chimeras-3.jpg',50,50],
['pictures/thumbnails/riverotis.jpg',50,50],
['pictures/thumbnails/blossoms_site.jpg',50,50],
['pictures/thumbnails/back.jpg',396,329],
['pictures/thumbnails/dougandrobin-1.jpg',50,50],
['pictures/thumbnails/doug-chimeras.jpg',50,50],
['pictures/thumbnails/dougandrobin-2.jpg',50,50],
['pictures/thumbnails/doug-car.jpg',50,50],
['pictures/thumbnails/gb-qfest89-01.jpg',50,50],
['pictures/thumbnails/gb-qfest89-02.jpg',50,50],
['pictures/thumbnails/gb-qfest89-03.jpg',50,50],
['pictures/thumbnails/gb-qfest89-04.jpg',50,50],
['pictures/thumbnails/gb-qfest89-05.jpg',50,50],
['pictures/thumbnails/gb-qfest89-06.jpg',50,50],
['pictures/thumbnails/gb-qfest89-07.jpg',50,50],
['pictures/thumbnails/doug-nmede.jpg',50,50],
['pictures/thumbnails/gb-uacsleeve.jpg',50,50],
['pictures/thumbnails/algebraranch.jpg',50,50],
['pictures/thumbnails/gbga.jpg',365,302],
['pictures/thumbnails/dhwga.jpg',368,301]
];

function getInternetExplorerVersion()
{
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

		if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
	}
	return rv;
}

function getImageSize(image)
{
	var i;
	//alert(Obj.style.backgroundImage);
	for(i=0; i < arr.length; i++)
	{
		//var t = 'url(/' + arr[i][0] + ')';
		//if( t == Obj.style.backgroundImage )
		if( image == arr[i][0] )
		{
			ret = arr[i];
			return(ret);
			//Obj.style.width = arr[i][1] + 'px';
			//Obj.style.height = arr[i][2] + 'px';
			return;
		}
	}
	alert('Didn\'t find ' + image);
		// alert(t + '\n' + Obj.style.background );
}

function setImageSize(Obj)
{
	var f = Obj.style.backgroundImage.substr(5, Obj.style.backgroundImage.length-6);
	var arr = getImageSize( f.replace(/images/g,'pictures') );
	Obj.style.width = arr[1] + 'px';
	Obj.style.height = arr[2] + 'px';
	// alert(t + '\n' + Obj.style.background );
}

function setImage(f)
{
	var arr = getImageSize( f );
	var width = arr[1] + 'px';
	var height = arr[2] + 'px';
	var s = document.styleSheets[0];
	f=f.replace(/pictures/g,'images');
	var selector = 'div#imagediv';
	var rule = ' width: ' + width + '; height: ' + height + ';' +
		' background-image: url(/' + f + ');'

	// IE8 doesn't have {}'s around the rule, everything else does.
	if( getInternetExplorerVersion() < 8.0 )
	{
		rule = '{' + rule + '}';
	}

	// Firefox sends referer when setting background image.
	// IE and Chrome do not. Hence set a cookie with referer information. Include the user agent, to avoid faking
	var cookie = "referer" + "=" + 
		base64_encode(location.protocol + '://' + location.host + '/css/stylesheet.css' + '|' + navigator.userAgent) + 
		"; path=/";

	if( document.all ) // IE
	{
		document.cookie = cookie;
		s.addRule( selector, rule);
	}
	else // Firefox
	{
		// Cookie method required for Chrome.
		if ( ! /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
		{
			document.cookie = cookie;
		}
		s.insertRule( selector + rule, 2);
	}
}

function init()
{
	var e = document.getElementById('imagediv');
	setImageSize(e);
}

function basename(path)
{
	return path.replace(/\\/g,'/').replace( /.*\//, '' );
}

function dirname(path)
{
	return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
}

function setBackground()
{
	// Firefox
	if( true )
	{
		var f = document.location.pathname;
		f=f.substr(1,f.length-6);
		setImage(f);
	}
	// IE (now unused! )
	else
	{
		var imgs = document.getElementsByTagName('img');
		for(i=0;i<imgs.length;i++)
		{
			if ( imgs[i].className == 'band-img' )
			{
				var f = basename(imgs[i].src);
				var e = imgs[i].parentNode;
				e.style.backgroundImage = 'url(/images/' + f + ')';
				setImageSize(e);
				return;
			}
		}
		
	}
}

/* For the discography page. */
function setImages()
{
	var i;
	var imgs = document.getElementsByTagName('img');
	for(i=0;i<imgs.length;i++)
	{
		if ( imgs[i].className == 'band-img' )
		{
			var img = imgs[i];
			// var src = img.src.replace(/images/g,'pictures');
			var src = img.src;


//			alert( src );
			// img.parentNode.style.backgroundImage = 'url('+src+')';
			var src = img.src.replace(/pictures/g,'images');
			if( basename( src ) == 'doug_int.jpg' )
			{
				img.width = 229;
				img.height = 240;			
			}
			else
			{
/*				img.width = 375;
				img.height = 305;
*/
				var f = img.src.replace(/http:\/\/.*?\//g,'');
				var arr = getImageSize( f );

				img.width = arr[1];
				img.height = arr[2];

			}
			//img.style.cssFloat = 'left';
			img.parentNode.style.width = img.width +  'px';
			img.parentNode.style.height = img.height +  'px';
			//alert(src);
			//alert(img.src.replace(/images/g,'pictures'));
			img.parentNode.style.backgroundImage = 'url(' +src + ')';
			img.parentNode.style.backgroundRepeat = 'no-repeat';
			img.parentNode.style.cssFloat = 'left';
		}
	}
}

/* For the discography page. */
function setImagesDisco()
{
	var i;
	var imgs = document.getElementsByTagName('img');
	for(i=0;i<imgs.length;i++)
	{
//alert( imgs.length );
		if ( imgs[i].className == 'band-img' )
		{
			var img = imgs[i];
			// var src = img.src.replace(/images/g,'pictures');
			var src = img.src;


//			alert( src );
			// img.parentNode.style.backgroundImage = 'url('+src+')';
			var src = img.src.replace(/pictures/g,'images');
			if( basename( src ) == 'doug_int.jpg' )
			{
				img.width = 229;
				img.height = 240;			
			}
			else
			{
/*				img.width = 375;
				img.height = 305;
*/
				var f = img.src.replace(/http:\/\/.*?\//g,'');
//				var arr = getImageSize( f );

//				img.width = 298;
//				img.height = 280;

//				img.width = arr[1];
//				img.height = arr[2];

			}
			//img.style.cssFloat = 'left';
//			img.parentNode.style.width = img.width +  'px';
//			img.parentNode.style.height = img.height +  'px';
			//alert(src);
			//alert(img.src.replace(/images/g,'pictures'));
			img.parentNode.style.backgroundImage = 'url(' +src + ')';
			img.parentNode.style.backgroundRepeat = 'no-repeat';
			img.parentNode.style.cssFloat = 'left';
		}
	}
}



if( basename(dirname(document.location.pathname)) == 'pictures' )
{
	window.onload = setBackground;
}
else if( basename(dirname(document.location.pathname)) == 'bands' )
{
	window.onload = setImages;
}
else if( basename(document.location.pathname) == 'discography.html' )
{
	window.onload = setImagesDisco;
}
else if( basename(document.location.pathname) == 'news.html' )
{
	window.onload = setImages;
}


function expandRecordings( e )
{
	if( e.nextSibling.style.display == 'block' )
	{
		e.nextSibling.style.display = 'none';	
	}
	else
	{
		e.nextSibling.style.display = 'block';
	}
}


function base64_encode( data ) {  
    // Encodes string using MIME base64 algorithm    
    //   
    // version: 902.2516  
    // discuss at: http://phpjs.org/functions/base64_encode  
    // +   original by: Tyler Akins (http://rumkin.com)  
    // +   improved by: Bayron Guevara  
    // +   improved by: Thunder.m  
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
    // +   bugfixed by: Pellentesque Malesuada  
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
    // -    depends on: utf8_encode  
    // *     example 1: base64_encode('Kevin van Zonneveld');  
    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='  
    // mozilla has this native  
    // - but breaks in 2.0.0.12!  
    //if (typeof window['atob'] == 'function') {  
    //    return atob(data);  
    //}  
          
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";  
    var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc="", tmp_arr = [];  
  
    if (!data) {  
        return data;  
    }  
  
    data = utf8_encode(data+'');  
      
    do { // pack three octets into four hexets  
        o1 = data.charCodeAt(i++);  
        o2 = data.charCodeAt(i++);  
        o3 = data.charCodeAt(i++);  
  
        bits = o1<<16 | o2<<8 | o3;  
  
        h1 = bits>>18 & 0x3f;  
        h2 = bits>>12 & 0x3f;  
        h3 = bits>>6 & 0x3f;  
        h4 = bits & 0x3f;  
  
        // use hexets to index into b64, and append result to encoded string  
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);  
    } while (i < data.length);  
      
    enc = tmp_arr.join('');  
      
    switch( data.length % 3 ){  
        case 1:  
            enc = enc.slice(0, -2) + '==';  
        break;  
        case 2:  
            enc = enc.slice(0, -1) + '=';  
        break;  
    }  
  
    return enc;  
} 

function utf8_encode ( argString ) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/utf8_encode
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    
    var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
}

