//-----------------------------------------------------------------------------------------------------
//gen functions
//-----------------------------------------------------------------------------------------------------
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 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));
}
//=====================================================================
//=========Open a new window pop up with specific height and width=====
//=====================================================================
function showWindow(pageName, intWidth, intHeight)
{
	window.open(pageName, '', 'width='+intWidth+',height='+intWidth+',left=200,scrollbars=1,top=50,toolbar=0,menubar=0,location=0');
}

/* Function to Change Testimonials*/
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.
	document.getElementById('testimonial_blk_'+oldTestimonial).style.display = 'none'; // First hide the 1st Testimonial
	document.getElementById('testimonial_blk_'+newTestimonial).style.display = 'block'; // Then keep on displaying further divs.
	document.getElementById('old_testimonial').value = newTestimonial;
}
//Refresh Captcha
function refreshCaptcha(imgid)
{
	var newimg = new Image();
	newimg.src = 'inc/captcha/captcha.php?hash='+parseInt(Math.random() * 10000000000);
	newimg.onload = function(){document.getElementById(imgid).src = newimg.src;}
}


