// carousel stuff

	function mycarousel_itemLoadCallback(carousel, state)
	{
		for (var i = carousel.first; i <= carousel.last; i++) {
			if (carousel.has(i)) {
				continue;
			}
	
			if (i > mycarousel_itemList.length) {
				break;
			}
	
			carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
		}
	};
	
	function artist_itemLoadCallback(carousel, state)
	{
		for (var i = carousel.first; i <= carousel.last; i++) {
			if (carousel.has(i)) {
				continue;
			}
	
			if (i > artist_itemList.length) {
				break;
			}
	
			carousel.add(i, mycarousel_getItemHTML(artist_itemList[i-1]));
		}
		
	};
	
	function releases_itemLoadCallback(carousel, state)
	{
		for (var i = carousel.first; i <= carousel.last; i++) {
			if (carousel.has(i)) {
				continue;
			}
	
			if (i > releases_itemList.length) {
				break;
			}
	
			carousel.add(i, mycarousel_getItemHTML(releases_itemList[i-1]));
		}
		
	};
	
	/**
	 * Item html creation helper.
	 */
	function mycarousel_getItemHTML(item)
	{
		return '<a href="' + item.link + '"><img src="' + item.url + '" alt="' + item.title + '" /><span class="iteminfo">' + item.title + '</span></a>';
	};
	
	jQuery(document).ready(function() {
		
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
		   myWidth = window.innerWidth;
		   myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		bigscroll = Math.floor((myWidth/(250+40)));
		littlescroll = Math.floor((myWidth/(100+30)));
		
		jQuery('#carouselfeatures ul').jcarousel({
			size: mycarousel_itemList.length,
			wrap: 'both',
			auto: 200,
			scroll: bigscroll,
			itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
		});
		
		jQuery('#carouselreleases ul').jcarousel({
			size: releases_itemList.length,
			wrap: 'both',
			scroll: littlescroll,
			auto: 200,
			itemLoadCallback: {onBeforeAnimation: releases_itemLoadCallback}
		});
		
		jQuery('#carouselartists ul').jcarousel({
			size: artist_itemList.length,
			wrap: 'both',
			scroll: littlescroll,
			auto: 200,
			itemLoadCallback: {onBeforeAnimation: artist_itemLoadCallback}
		});
		
		window.setTimeout('tweak()', 1000);
	});

function tweak() {
	document.getElementById('carouselartists').style.height = '99px';
}

function artistlistchanged(selectobject) {
    
    artist = selectobject.options[selectobject.selectedIndex].value;
    if(artist != "0") {
		
		temp = artist.split(' ');
		newartist = temp.join("-");
		
		destination = "/" + artist;
		
		if (destination) {
			window.location = destination;
		}
    }
}

function releaseslistchanged(selectobject) {

	artist = selectobject.options[selectobject.selectedIndex].value;
    if(artist != "0") {
		
		temp = artist.split(' ');
		newartist = temp.join("-");
		
		destination = artist;
		
		if (destination) {
			window.location = destination;
		}
    }
}

function featurelistchanged(selectobject) {

	artist = selectobject.options[selectobject.selectedIndex].value;
    if(artist != "0") {
		
		destination = artist;
		
		if (destination) {
			window.location = destination;
		}
    }
}

function setLiveBkgd() {
	
	myHeight = document.getElementById("container").offsetHeight;
	document.getElementById("largemap").style.height = myHeight + 'px';
	document.getElementById("main").style.height = (myHeight - 502 - 200) + 'px';
	map.checkResize();
}

onload = function () {
	if(document.body.getAttribute('class') == 'live') {
		setLiveBkgd();

	}
}

var mapCentred = 0;

function plotAddress(map, geocoder, address, html) {
        
        
        zoom = 7;
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert(address + " not found");
              
            } else {
              
              
              
              if(mapCentred == 0) {
				  map.setCenter(point, zoom);
				  map.panDirection(0, -0.5);
              }
              
              var marker = new GMarker(point);
              map.addOverlay(marker);
              
              
              if(mapCentred == 0) {
				  marker.openInfoWindowHtml(html);
				  mapCentred = 1;
              }
              
              GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(html);
			  });
              
            }
          }
        );
    }

// email stuff

function setConfirm()
{
	document.getElementById("emailconfirm").value = document.getElementById("inputemail").value;
}
function fieldFocus(element, text)
{
	if(text == element.value) {
		element.value = "";
		
	}
}
function fieldBlur(element, text)
{
	if("" == element.value) {
		element.value = text;
	}
}
function submit()
{
	//setConfirm();
	document.getElementById("frmSubscribe").submit();
}	
