var voted=false;
var anchorname;
var	AJAX = new lilAJAX('/lib/ajax.php');
function StarsHover(id) {
	if(!voted) {
		document.getElementById('star'+id).style.cursor='hand';
		for(var i=1; i<id+1; i++) {
			document.getElementById('star'+i).src='/images/star-on.gif';
		}
	}
}
function ClearStars() {
	if(!voted) {
		for(var i=1; i<5; i++) {
			document.getElementById('star'+i).src='/images/star-off.gif';
		}
	}
}
function returnVote(result) {
	document.getElementById('newRating').innerHTML=result;
	document.getElementById('rating').innerHTML=result;
	var coordinates = new Object();
	coordinates = getAnchorPosition(anchorname);
	document.getElementById('div_VotedInfo').style.left=coordinates.x;
	document.getElementById('div_VotedInfo').style.top=coordinates.y-90;
	document.getElementById('div_VotedInfo').style.visibility='visible';
	var t=setTimeout("document.getElementById('div_VotedInfo').style.visibility='hidden';",10000);
}

function showSendToFriend() {
	document.SendToFriend.SendButton.style.visibility='visible';
	anchorname = 'a_SendToFriend';
	coordinates = getAnchorPosition(anchorname);
	document.getElementById('div_SendToFriend').style.left=coordinates.x+170;
	document.getElementById('div_SendToFriend').style.top=coordinates.y-143;
	document.getElementById('div_SendToFriend').style.visibility='visible';
}

function closeSendToFriend() {
	document.getElementById('div_SendToFriend').style.visibility='hidden';
	document.SendToFriend.reset();
	document.getElementById('SendError').innerHTML = '';
}



//#############################################################
// Shoutbox
//#############################################################
var shoutRefresh = true;
var	shoutboxAJAX = new lilAJAX('/framework/processShoutbox.php');
function sendComment() {
	if(document.EnterComment.Comment.value!='') {
		shoutboxAJAX.getTextAsync('postComment', setComments, document.EnterComment.Comment.value);
		document.EnterComment.Comment.value='';
	}
	return false;
}
function setComments(result) {
	document.getElementById('shoutText').innerHTML=result;
	getComments();
}

function showUserMenu(UserID, top) {
	shoutboxAJAX.getText('getUserMenu', returnUserMenu, UserID);
	document.getElementById('div_UserMenu').style.visibility='visible';
	document.getElementById('div_UserMenu').style.top=top+'px';
	shoutRefresh = false;
}
function returnUserMenu(result) {
	document.getElementById('div_UserMenu').innerHTML=result;
}

function closeUserMenu() {
	document.getElementById('div_UserMenu').style.visibility='hidden';
	document.getElementById('div_ReplyToMessage').style.visibility='hidden';
	shoutRefresh=true;
	getComments();
}
function returnMessageUser(result) {
	document.getElementById('div_UserMenu').innerHTML=result;
}

function checkSendMessage(UserID) {
	if(document.MessageUser.Message.value!='') {
		shoutboxAJAX.callAsync('SendMessage', UserID, document.MessageUser.Message.value);
		document.getElementById('MessageUserUpdate').innerHTML = '<font color=#005A74>Message Sent</font>';
		var t=setTimeout("closeUserMenu();",3000);
	}
	return false;
}

function getForm() {
	shoutboxAJAX.getTextAsync('getForm', returnForm);
}
function returnForm(result) {
	document.getElementById('shoutboxForm').innerHTML=result;
}



function showContact() {
	var coordinates = new Object();
	coordinates = getAnchorPosition('a_Contact');
	document.getElementById('div_Contact').style.left=coordinates.x-130;
	document.getElementById('div_Contact').style.top=coordinates.y+10;
	document.getElementById('div_Contact').style.visibility='visible';
}
function closeContact() {
	document.Contact.reset();
	document.getElementById('SendError').innerHTML = '';
	document.getElementById('div_Contact').style.visibility='hidden';
}
function checkContact() {
	var err = false;
	var validEmail='FALSE';
	var x = document.Contact.Email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) validEmail='TRUE';
	if(validEmail=='FALSE') {
		document.getElementById('SendError').innerHTML = '<b>Invalid Email Address</b>';
		err = true;
	}
	if(document.Contact.Message.value=='') {
		document.getElementById('SendError').innerHTML = '<b>Type Something!</b>';
		err = true;
	}
	if(err==false) {
		document.getElementById('SendError').innerHTML = '';
		document.Contact.SendButton.style.visibility='hidden';
		AJAX.callAsync('SendToWebmaster', document.Contact.Email.value, document.Contact.Message.value);
		document.getElementById('SendError').innerHTML = '<font color=blue><b>Message Sent!</b></font>';
		var n=setTimeout("closeContact();", 4000);
	}
	return false;
}


