function setDancingToday(start)
{
	var count = Dancers.length;
	var max = 6;
	var ticker = 0;

	if( count == 0 )
		return;

	if( start >= count )
		start = 0;

	if( start < 0 )
		start = 0;

	var button_prev = start - max;
	var button_next = start + max;
	
	if( button_prev < 0 )
		button_prev = 0;
 
 	for( i = 0; i < max; i++ )
 	{
 		if ( typeof Dancers[start + i] != 'undefined' )
 		{
 			if( Dancers[start + i][0].length > 1 )
 				document.getElementById('dancing_today_' + i).innerHTML = "<a href='http://www.xoticspot.com/" + Dancers[start + i][0] + "' target='_BLANK'>" + Dancers[start + i][3] + "</a><div style='width: 60px; height: 80px; overflow: hidden;'><a href='http://www.xoticspot.com/" + Dancers[start + i][0] + "' target='_BLANK'>" + Dancers[start + i][1] + "</a></div>" + Dancers[start + i][2];
 			else
 				document.getElementById('dancing_today_' + i).innerHTML = Dancers[start + i][3] + "<div style='width: 60px; height: 80px; overflow: hidden;'>" + Dancers[start + i][1] + "</div>" + Dancers[start + i][2];
 			ticker = ticker + 1;
 		}
 		else
 			document.getElementById('dancing_today_' + i).innerHTML = '';
 	}
 
 	document.getElementById('dancing_today_showing').innerHTML = "Showing " + (start + 1) + " - " + (start + ticker) + " of " + count;
 	document.getElementById('dancing_today_prev').href = "javascript:setDancingToday(" + button_prev + ");";
 	document.getElementById('dancing_today_next').href = "javascript:setDancingToday(" + button_next + ");"; 
}

function photoScrollUp()
{
	currentPhoto = currentPhoto - 1;
	if( currentPhoto < 0 )
		currentPhoto = 0;

	$('#club_photos').scrollTo('#club_photo_' + currentPhoto, 500);
}

function photoScrollDown()
{
	currentPhoto = currentPhoto + 1;
	if( currentPhoto >= countPhotos )
		currentPhoto = countPhotos - 1;

	$('#club_photos').scrollTo('#club_photo_' + currentPhoto, 500);
}

/*
Removed in favor of scroll to
function photoScroll()
{
	var scrollTo = 0;

	for( i = 0; i < currentPhoto; i++ )
	{
		scrollTo = scrollTo + Photos[i] + 2;
	} 

	$('#club_photos').animate({ scrollTop: scrollTo + 'px' });
}
*/

function ajaxFunctionReturn(url)
{
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	if (xmlHttp.status == 200)
		return xmlHttp.responseText;
	else
		return false;
}

function subscribe()
{
	var name = document.getElementById('subscribe_name').value;
	var email = document.getElementById('subscribe_email').value;
	
	var result = ajaxFunctionReturn("ajax.php?r=subscribe&name=" + encodeURIComponent(name) + "&email=" + encodeURIComponent(email));
	
	if( result.length > 0 )
		document.getElementById('subscribe_message').innerHTML = "<span style='color: #ff3300;'>" + result + "</span>";
}

function getBrowserWidth()
{
	if( window.innerWidth != null )
		return window.innerWidth;
	else if( document.documentElement && document.documentElement.clientWidth )
		return document.documentElement.clientWidth;
	else if( document.body != null )
		return document.body.clientWidth;
	else
		return null;
}

function getBrowserHeight()
{
	if( window.innerHeight != null )
		return window.innerHeight;
	else if( document.documentElement && document.documentElement.clientHeight )
		return document.documentElement.clientHeight;
	else if( document.body != null )
		return document.body.clientHeight;
	else
		return null;
}

function popin (url, width, height) {
	var browserWidth = getBrowserWidth();
	var browserHeight = getBrowserHeight();

	var posLeft = (browserWidth - width) / 2;
	var posTop = (browserHeight - height) / 2;

	var ifr = document.getElementById('popin');
	if ( !ifr && document.createElement ) {
		ifr = document.createElement('iframe');
		if ( ifr ) {
			ifr.src = url;
			ifr.id = "popin";
			ifr.frameBorder = "0";
			ifr.style.border = '1px solid black';
			ifr.style.width =  width + 'px';
			ifr.style.height = height + 'px';
			ifr.style.overflow = 'hidden';
			ifr.style.display = 'block';
			ifr.style.position = 'fixed';
			ifr.style.background = 'transparent';
			ifr.style.top = posTop + 'px';
			ifr.style.left = posLeft + 'px';
			document.body.appendChild(ifr);
		}
		var ifr = document.getElementById('popin');
	}
	if ( navigator.appVersion.match('MSIE 6') || !document.createElement )
	{
		if ( ifr ) ifr.style.display = 'none';
		ifr = null;
	}
	if ( ifr ) {
		ifr.style.display = 'block';
		ifr.src = url;
	}
	if ( !ifr ) {
		if ( ! window.open(url + '?popup=1', 'popin', 'width=' + width + ',height=' + height) )
			alert ('Please disable your popup blocker to subscribe');
	}
}

function closePopin()
{
	document.getElementById('popin').src = '';
	document.getElementById('popin').style.display = 'none';
}

function setDancers(start)
{
	var count = Dancers.length;
	var max = 8;
	var ticker = 0;

	if( (count == 0) )
		return;

	if( start >= count )
		start = 0;

	if( start < 0 )
		start = 0;

	var button_prev = start - max;
	var button_next = start + max;
	
	if( button_prev < 0 )
		button_prev = 0;
 
	for( i = 0; i < max; i++ )
	{
		if ( typeof Dancers[start + i] != 'undefined' )
		{
			document.getElementById('dancer_' + i).innerHTML = "<div class='dancer_frame'><div style='position: relative;'><table border='0' cellpadding='0' cellspacing='0' style='margin: auto; height: 208px;'>\n<tr><td height='30px' valign='middle'>" + Dancers[start + i][1] + "</td></tr><tr><td height='178px' valign='middle'><a href='http://www.xoticspot.com/" + Dancers[start + i][0] + "' target='_BLANK'>" + Dancers[start + i][2] + "</a></td></tr></table><div style='margin-top: 15px;'>" + Dancers[start + i][3] + "</div></div></div>\n";
			
			ticker = ticker + 1;
		}
		else
			document.getElementById('dancer_' + i).innerHTML = '';
	}
 
	document.getElementById('dancer_showing').innerHTML = "Showing " + (start + 1) + " - " + (start + ticker) + " of " + count;
	document.getElementById('dancer_prev').href = "javascript:setDancers(" + button_prev + ");";
	document.getElementById('dancer_next').href = "javascript:setDancers(" + button_next + ");"; 
}
