// JavaScript Document
//change captcha image
function refreshCaptcha() {
   //Check if our response is ready
   img = document.getElementById('captchaID'); 
   //Change the image
   img.src = 'captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5&' + Math.random();
}
//end change captcha


/*testimonial character cound*/
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

/*counter function*/
maxL=100000000000000000000000;
minL=0;
var bName = navigator.appName;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}

function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if(minL+objVal.length>200){
		document.getElementById("msgid").style.color='#FF0000';
	}else{
		document.getElementById("msgid").style.color='#006600';
	}
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=minL+objVal.length;}
		else{objCnt.innerText=minL+objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}
/*end*/

/*valid testimonail form*/
function validtestmonials()
{
	var obj=document.testimonialForm;
	var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
	if (isEmpty(obj.name, 'Pleaser enter your name!')) {
		return false;
	}if ( (obj.url.value!='') && (!tomatch.test(obj.url.value)) )   //client url validation
	 {
		 alert("Invalid url entered! please full url eg: http://www.inflexi.com");
		 obj.url.focus();
		 return false;
	}if (isEmpty(obj.message, 'Please enter your testimonial!')) {
		return false;
	}if(obj.message.value.length < 200){
		alert("Please enter mininum 200 to 300 characters!");
		obj.message.focus();
		return false;
	}if (isEmpty(obj.code, 'Please enter the string from the displayed image!')) {
		return false;
	}if (obj.active.checked==false)
	{
		alert("Please check below!");
		return false;
	}if (isEmpty(obj.rate, 'Please rate our site!')) {
		return false;
	}else
	{
		
		checkcode(obj.code.value);
        return false;	
	}

	
}
/*end validation*/

/*validation function for admin site

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}


/*
	Set one value in combo box as the selected value
*/