//------------------------------------------------------------------------------------
function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//------------------------------------------------------------------------------------
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
//------------------------------------------------------------------------------------
//Function to validate email
//-----------------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}

//Checks URL against pattern
function chkURL(tmpStr)
{
	var url_pat = /^(http|https|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&amp;,=#@\/:]*)?/;
	return(url_pat.test(tmpStr));
}

function refreshCaptcha(imgid)
{
	var img = new Image();
	img.src = 'captcha/show_captcha.php?hash='+parseInt(Math.random() * 10000000000);
	document.getElementById(imgid).src = img.src;
}
function NewWindow(pageName)
{
	window.open(pageName, '', 'width=720,height=630,toolbar=0,menubar=0,location=0,left=25,top=25');
}

function changeTestimonial()
{
	numTestimonials = parseInt(document.getElementById('num_testimonials').value); // Get the total number of testimonials.
	oldTestimonial = parseInt(document.getElementById('old_testimonial').value);
	newTestimonial = (parseInt(oldTestimonial + 1) > numTestimonials)?1:(oldTestimonial + 1); // Get the newTestimonial value by increasing the counter.
	$('.testimony'+oldTestimonial).stop().fadeOut(500, function(){
			$('.testimony'+newTestimonial).fadeIn();
		});
	document.getElementById('old_testimonial').value = newTestimonial;
}

