function show_pop(type,isbn)
{
	height = 0;

	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			//Non IE
			height = window.innerHeight;
		}
		else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ))
		{
			//IE 6+ in 'standards compliant mode'
			height = document.documentElement.clientHeight;
	  	}
	  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	  	{
			//IE 4 compatible
			height = document.body.clientHeight;
		}
	}

	document.getElementById('email_div').style.zIndex = 10;
	document.getElementById('email_div').style.position = 'absolute';

	if (parseInt(height)>0)
	{
		y_pos = height / 2;
		y_pos = y_pos - 120;

		document.getElementById('email_div').style.top = y_pos+'px';
	}

	get_email_book_info(isbn);
}
function show_pop2(clubname)
{
	height = 0;

	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			//Non IE
			height = window.innerHeight;
		}
		else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ))
		{
			//IE 6+ in 'standards compliant mode'
			height = document.documentElement.clientHeight;
	  	}
	  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	  	{
			//IE 4 compatible
			height = document.body.clientHeight;
		}
	}

	if (parseInt(height)>0)
	{
		y_pos = height / 2;
		y_pos = y_pos - 120;

		document.getElementById('email_div').style.top = y_pos+'px';
	}

	get_email_club_info(clubname);
}

function get_email_book_info(isbn)
{
	url = "/scripts/email_book_info.php";
	params = 'isbn=' + isbn;
	ajax_call(params, url, 'post', 'get_email_book_info_callback');
}

function get_email_club_info(clubname)
{
	url = "/scripts/email_club_info.php";
	params = 'clubname=' + clubname;
	ajax_call(params, url, 'post', 'get_email_club_info_callback');
}

function get_email_book_info_callback(req)
{
	response = req.responseXML.documentElement;
	data = response.getElementsByTagName('data')[0].firstChild.data;

	document.getElementById('email_message').value = data;
	document.getElementById('email_div').style.display = "";
}

function get_email_club_info_callback(req)
{
	response  = req.responseXML.documentElement;
	data = response.getElementsByTagName('data')[0].firstChild.data;

	document.getElementById('email_body').value = data;
	document.getElementById('email_div').style.display = "";
}

function email_book_to_friend()
{
	if (document.getElementById('email_to').value!='')
	{
		email_book(document.getElementById('email_to').value, document.getElementById('email_message').value);
		document.getElementById('email_message').value = '';
		document.getElementById('email_div').style.display = "none";
	}
	else
	{
		alert("Please provide your friend's email address!");
	}
}

function email_book(email_to, body)
{
	url = "http://www.paperbackswap.com/scripts/email_book.php";
	if (!email_to)
	{
		email_to = document.getElementById('email_to').value;
	}
	if (!body)
	{
		body = document.getElementById('email_body').value;
	}

	url = "/scripts/email_club_info.php";
	params = "email_to=" + email_to + "&email_body="+ url_encode(body);
	ajax_call(params, url, 'post');

	alert("The email has been sent to your friend");
}

function email_club_to_friend()
{
	if (document.getElementById('email_to').value!='')
	{
		email_about_club(document.getElementById('email_to').value, document.getElementById('email_body').value, 'I have found a PBS Book Club that I think you would enjoy');
		document.getElementById('email_body').value = '';
		document.getElementById('email_div').style.display = "none";
	}
	else
	{
		alert("Please provide your friend's email address!");
	}
}

function email_broadcast(clubname)
{
	if (document.getElementById('email_to').value!='')
	{
		email_club(document.getElementById('email_to').value, document.getElementById('email_body').value, document.getElementById('email_subject').value + ' (' + clubname + ')');
		document.getElementById('email_body').value = '';
		document.getElementById('email_subject').value = '';
		document.getElementById('email_div').style.display = "none";
	}
}

function confirm_book_isbn(isbn_13, isbn_10)
{
	answer = confirm('If your book does not have one of these ISBNs, please post your book from the Post Books page.\n\nISBN-13: '+isbn_13+'\nISBN-10: '+isbn_10);
	if (answer)
	{
		self.location.href='/members/book_add.php?isbn='+isbn_13;
	}
}