// Refresh the captcha image
function captcha_refresh() {
	document.getElementById('captcha').src = '/images/_global/captcha.php?' + (Math.round(100000*Math.random()));
	document.getElementById('captcha-text').value = "";
	document.getElementById('captcha-text').focus();
}

// Find the left position of an element
function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent) {
		while(1) {
			curleft += obj.offsetLeft;
			if(!obj.offsetParent) {
				break;
			}
			obj = obj.offsetParent;
		}
	} else if(obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

// Find the top position of an element
function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent) {
		while(1) {
			curtop += obj.offsetTop;
			if(!obj.offsetParent) {
				break;
			}
			obj = obj.offsetParent;
		}
	} else if(obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

// Show the comments form
function comments_show() {
	document.getElementById('comments-form-mini').style.display = 'none';
	document.getElementById('comments-form-full').style.display = 'block';
	location.href = '#comments';
}

// Hide the comments form
function comments_hide() {
	document.getElementById('comments-form-full').style.display = 'none';
	document.getElementById('comments-form-mini').style.display = 'block';
}

// Hide the non-JS rating selector
function comments_hide_rating() {
	document.getElementById('comments-form-rating').style.display = 'none';
}

// Highlight the comments form
function comments_hl() {
	document.getElementById('comments-form-mini').style.borderColor = '#777777'; 
}

// Lowlight the comments form
function comments_ll() {
	document.getElementById('comments-form-mini').style.borderColor = '#aaaaaa';
}

// Provider review star functions
function fill_stars(star) {
	var thestar, count, newcount;
	
	for(count = 1; count <= star; count++) {
		thestar = 'formstar'+count;
		document.getElementById(thestar).src = '/images/9c9fed/template/stars/star-2.gif';
	}
	for(newcount = count; newcount <= 5; newcount++) {
		thestar = 'formstar'+newcount;
		document.getElementById(thestar).src = '/images/9c9fed/template/stars/star-0.gif';
	}
}

function unfill_stars() {
	var thestar;
	var count;
	var rating = document.getElementById('rating').value;
	
	for(count = 1; count <= 5; count++) {
		thestar = 'formstar'+count;
		document.getElementById(thestar).src = '/images/9c9fed/template/stars/star-0.gif';
	}
	if(document.getElementById('rating').value != '') {
		for(count = 1; count <= rating; count++) {
			thestar = 'formstar'+count;
			document.getElementById(thestar).src = '/images/9c9fed/template/stars/star-1.gif';
		}
	}
}

function set_stars(star, mouseover) {
	var thestar;
	var count;
	
	document.getElementById('rating').value = star;
	for(count = 1; count <= star; count++) {
		thestar = 'formstar'+count;
		document.getElementById(thestar).src = '/images/9c9fed/template/stars/star-1.gif';
	}
	if(mouseover == 1) fill_stars(star);
}
