
function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;

	// trim the extra text
	if (charcnt > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}

	else {
		// progress bar percentage
		var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
		document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
		document.getElementById(counter).innerHTML="&nbsp;&nbsp;"+percentage+"%"
		// color correction on style from CCFFF -> CC0000
		setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

function sendRequestPrice(val) {
	// Open PHP script for requests
	//alert ("Helllllooooooooo");

	var url ="price.php";
	var posData = "?type=" + val;
	//alert (posData);
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	//alert(url + posData);
	http_request.onreadystatechange = function() { sendrequestres(http_request); };
	http_request.open('GET', url + posData, true);
	http_request.send(null);
}



function sendrequestres(http_request){

	if (http_request.readyState == 4) {
		if (http_request.status == 200)
		{
			resText = http_request.responseText;
			//alert(resText);

			document.getElementById("Price").innerHTML = resText;
		} else {
			document.getElementById("Price").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}
}


function checkemail(){
	evalue=document.form1.email.value;
	if(evalue.length &&(evalue.indexOf("@")==0||evalue.indexOf("@")==-1||evalue.indexOf(".")==-1||evalue.indexOf(".")==0))
	{
	alert("Invalid E-Mail address.\n"+"Format is: abc@domainname.com");
    //document.FormName.email.value="";
	 document.form1.email.focus();
	 return false;
	}
	}

function checkValues(theform)
	{
try{
		if(theform.member_type[0].checked==false && theform.member_type[1].checked==false && theform.member_type[2].checked==false &&theform.member_type[3].checked==false && theform.member_type[4].checked==false )
		{
			alert('Please select a profile type');
			return false;
		}
	
		if(document.getElementById('f_name').value=='')
		{
			alert('Enter First Name');
			document.getElementById('f_name').focus();
			return false;
		}
		if(document.getElementById('l_name').value=='')
		{
			alert('Enter Last Name');
			document.getElementById('l_name').focus();
			return false;
		}
		
		if(document.getElementById('address').value=='')
		{
			alert('Enter Address');
			document.getElementById('address').focus();
			return false;
		}
		if(document.getElementById('state').value=='-1')
		{
			alert('Select State');
			document.getElementById('state').focus();
			return false;
		}
		if(document.getElementById('city').value=='-1')
		{
			alert('Select City');
			document.getElementById('city').focus();
			return false;
		}
		
		if(document.getElementById('phone').value=='')
		{
			alert('Enter Phone no.');
			document.getElementById('phone').focus();
			return false;
		}
		if(document.getElementById('mob').value=='')
		{
			alert(document.getElementById('mob').value);
			alert('Enter Mobile no');
			document.getElementById('mob').focus();
			return false;
		}

		if(theform.email.value=='')
		{
			alert('Enter Your Email-Id');
			theform.email.focus();
			return false;
		}
		evalue=theform.email.value;
		if(evalue.length &&(evalue.indexOf("@")==0||evalue.indexOf("@")==-1||evalue.indexOf(".")==-1||evalue.indexOf(".")==0))
		{
			alert("Invalid E-Mail address.\n"+"Format is: abc@domainname.com");
			 theform.email.focus();
			 return false;
		}
		if(theform.pwd.value=='')
		{
			alert('Enter Your Password');
			theform.pwd.focus();
			return false;
		}
		if(theform.pwd.value !=theform.c_pwd.value)
		{
			alert('Please reconfirm Password');
			theform.c_pwd.focus();
			return false;
		}
}catch(e){
alert(e.message);return false;
}
	}
// Set path to PHP script
var phpscript = 'city.php';

function createRequestObject() {
	var req;
	if(window.XMLHttpRequest){
		// Firefox, Safari, Opera...
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		// Internet Explorer 5+
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		// There is an error creating the object,
		// just as an old browser is being used.
		alert('There was a problem creating the XMLHttpRequest object');
	}
	return req;
}

// Make the XMLHttpRequest object
var http = createRequestObject();

function sendRequestGet(act) {
	// Open PHP script for requests
	http.open('get', phpscript+'?act='+act);
	http.onreadystatechange = handleResponseGet;
	http.send(null);
}

function sendRequestPost(state) {
	// Open PHP script for requests
	//alert("state");
	var action=document.getElementById('action').value;
	var url ="city.php";
	var posData = "?state=" + state+"&action="+action;
	//alert (posData);
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	http_request.onreadystatechange = function() { sendrequest(http_request); };
	http_request.open('GET', url + posData, true);
	http_request.send(null);
}



function sendrequest(http_request){

	if (http_request.readyState == 4) {
		if (http_request.status == 200)
		{
			resText = http_request.responseText;
			//alert(resText);
			document.getElementById("ajaxTest2").innerHTML = resText;
		} else {
			document.getElementById("ajaxtest2").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}
}

function handleResponseGet() {
	if(http.readyState == 4 && http.status == 200){
		// Text returned from PHP script
		var response = http.responseText;
		if(response) {
			// Update ajaxTest content
			document.getElementById("ajaxTest").innerHTML = response;
		}
	}
}
function handleResponsePost() {
	if(http.readyState == 4 && http.status == 200){
		// Text returned from PHP script
		var response = http.responseText;
		if(response) {
			// Update ajaxTest2 content
			document.getElementById("ajaxTest2").innerHTML = response;
		}

	}
}


 function textCounter(field,counter,maxlimit,linecounter) {
 	// text width//
 	var fieldWidth =  parseInt(field.offsetWidth);
 	var charcnt = field.value.length;

 	// trim the extra text
 	if (charcnt > maxlimit)
 	{
 		field.value = field.value.substring(0, maxlimit);
 	}

 	else {
 		// progress bar percentage
 		var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
 		document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
 		document.getElementById(counter).innerHTML="&nbsp;&nbsp;"+percentage+"%"
 		// color correction on style from CCFFF -> CC0000
 		setcolor(document.getElementById(counter),percentage,"background-color");
 	}
 }

 function setcolor(obj,percentage,prop){
 	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
 }

 function check()
 {
 	if(document.form2.property_size.value=='')
 	{
 		alert('select the property available for value');
 		return false;
 	}
 }


var IE = (document.all) ? 1 : 0;
var NS = (document.layers) ? 1 : 0;

function popUp( loc, w, h, menubar ) {
	if( w == '' || w == null || w == false) {
		w = 250;
	}
	if( h == '' || h == null || h == false) {
		h = 250;
		//alert(h);
	}
	if( menubar == null || menubar == false ) {
		menubar = "";
	}else {
		menubar = "menubar,";
	}

	if( NS ) { w += 40}

	//alert('w:'+w + 'h:'+ h + 'M:'+menubar);
	// Need the var or else IE4 blows up not recognizing editorWin

	var editorWin = window.open(loc,'editWin', menubar + 'resizable,scrollbars=yes,width=' + w + ',height=' + h);

	//if( !newWin.opener )
	//newWin.opener = window;
	editorWin.focus(); //causing intermittent errors
}


