String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function check(field,message)
{
    if((document.getElementById(field).value).trim()=='')
	{
		var spanid=field+'1';
		document.getElementById(spanid).innerHTML='<font color=red face=Arial><small><small>*' +message+ '</small></small></font>';
		return false;
		
	}
	else
	{
		var spanid=field+'1';
		document.getElementById(spanid).innerHTML='';
		return true;
	}
}

function checkcheckbox(field,message)
{
    if(document.getElementById(field).checked)
	{
	var spanid=field+'1';
	document.getElementById(spanid).innerHTML='';
	return true;
	}
	else
	{
	var spanid=field+'1';
	document.getElementById(spanid).innerHTML='<font color=red face=Arial><small><small>*' +message+ '</small></small></font>';
	return false;
	}
}

function validate_email(field)
{
	var email=document.getElementById(field).value;
	if(email!='')
	{
		if(window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		else
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		var url="CheckAvailibity.php?emailid="+email;
		var spanid=field+'1';
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(email))
		{
			var tf=false;
		    xmlhttp.open('GET',url,false);
			xmlhttp.send(null);
			var value=xmlhttp.responseText;
			if(value=="vaild")
			{
				tf=true;
			}
			else
			{
			document.getElementById(spanid).innerHTML="&nbsp;&nbsp;<font color='#FF66FF' face='Arial'><small><small><b>" +value+ "</b></small></small>";
			tf=false;
			}
			//alert("value is "+value+tf);
			return tf;
		}
		else
		{
			document.getElementById(spanid).innerHTML="&nbsp;&nbsp;<font color='#FF66FF' face='Arial'><small><small><b>Invalid emailid</b></small></small>";
			return false;
		}
	
	}
	else
	{
		return false;
	}
}

function check_captcha(field)
{
	var captcha=document.getElementById(field).value;
	if(captcha!='')
	{
	    var tf=false;
		if(window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		else
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		var url="checkCaptcha.php?captcha="+captcha;
		xmlhttp.open('GET',url,false);
		xmlhttp.send(null);
		var value=xmlhttp.responseText;
		if(value=="vaild")
		{
			tf=true;
		}
		else
		{
			var spanid=field+'1';
			document.getElementById(spanid).innerHTML="<font color='#FF66FF' face='Arial'><small><small><b>" +xmlhttp.responseText+ "</b></small></small>";
			tf=false;
		}
		return tf;
	}
	else
	{
		return false;
	}
}
