function validate_search(frm)
{
	var city = eval('document.'+frm+'.city.value');
	if(city == '')
	{
		alert('Please select the city');
		eval('document.'+frm+'.city.focus();');
		return false;
	}
	return true;
}
function setBudget(chooser,def_sale,def_rent)
{
	var newElem;
	var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
	var cityChooser = chooser.form.elements["budget"];
	while (cityChooser.options.length)
	{
		cityChooser.remove(0);
	}
	var choice = chooser.options[chooser.selectedIndex].value;
	var db = budgetval[choice];
	if (choice != "") 
	{
		for (var i = 0; i < db.length; i++) 
		{
			newElem = document.createElement("option");
			newElem.text = db[i].text;
			newElem.value = db[i].value;
			cityChooser.add(newElem, where);
			if(choice == 1 && db[i].value == def_sale)
			{
				newElem.selected = true;
			}else if(db[i].value == def_rent){
				newElem.selected = true;
			}
		}
	}
}

function setBudget2(chooser,def_sale,def_rent, find, frm_name, price_from, price_to)
{
	//alert(chooser+"="+def_sale+"="+def_rent+"="+find+"="+frm_name+"="+price_from+"="+price_to);	

	if(!price_from) price_from=0;
	if(!price_to) price_to=0;
	//alert(price_from);
	//alert(price_to);

	if(find == 0) {
		chooser = chooser;
	} else {
		if(eval("document." + frm_name + ".property_for.value")=='1')
			chooser='1';
		else if(eval("document." + frm_name + ".property_for.value")=='2')
			chooser='2';
		else
			chooser='1';
	}
	var newElem;
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	var cityChooser = eval("document." + frm_name + ".elements['budget_from']");
	if(find != 1) {
		while (cityChooser.options.length) {
			cityChooser.remove(0);
		}
		var choice = chooser;
		var db = budgetval[choice];
		newElem = document.createElement('option');
		if(chooser == '2') {
			newElem.text = "<5000";
			newElem.value = "4999";
		} else {
			newElem.text = "<10 Lacs";
			newElem.value = "999999";
		}
		cityChooser.add(newElem, where);
		if (choice != '') {
			var selfound = 0;
			for (var i = 0; i < db.length; i++) {
				if(selfound == 0 && chooser == '2' &&  price_from == '4999') {
					newElem.selected = true;
					selfound = 1;
				} else if(selfound == 0 && chooser == '1' &&  price_from == '999999') {
					newElem.selected = true;
					selfound = 1;
				}
				newElem = document.createElement('option');
				newElem.text = db[i].text;
				newElem.value = db[i].value;
				if(i == (db.length-1)) {
					newElem.text = ">" + newElem.text;
				}
				cityChooser.add(newElem, where);
				if(selfound == 0 && db[i].value == price_from) {
					newElem.selected = true;
					selfound = 1;
				} else if(selfound == 0 && chooser == 1 && db[i].value == '3000000') {
					newElem.selected = true;
				}else if(selfound == 0 && chooser == 2 && db[i].value == '15000'){
					newElem.selected = true;
				}
			}
		}
	}

	var cityChooser2 = eval("document." + frm_name + ".elements['budget_to']");
	while (cityChooser2.options.length) {
		cityChooser2.remove(0);
	}
	var choice = chooser;
	var db = budgetval[choice];
	var start = 0;
	if(find == 0) {
		if(chooser == 1) {
			start = 4;
		} else {
			start = 3;
		}
	} else {
		start = cityChooser.selectedIndex;
	}
	var maxoptions=cityChooser.options.length-1;
	//alert(chooser);

	if(start == 0 || start == maxoptions) {
		newElem = document.createElement('option');
		newElem.text = "Max Price";
		newElem.value = "";
		cityChooser2.add(newElem, where);
		cityChooser2.disabled = true;
	}else if (choice != '') {
		var selfound = 0;
		for (var i = start; i < db.length; i++) {
			newElem = document.createElement('option');
			newElem.text = db[i].text;
			newElem.value = db[i].value;
			cityChooser2.add(newElem, where);
			if(db[i].value == price_to) {
					newElem.selected = true;
					selfound = 1;
			} else if(selfound == 0 && choice == 1 && db[i].value == def_sale) {
				newElem.selected = true;
			}else if(selfound == 0 && db[i].value == def_rent){
				newElem.selected = true;
			}
		}
		cityChooser2.disabled = false;
	}
}
function submitonce(theform)
{
	if (document.all||document.getElementById)
	{
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset" ||tempobj.name.toLowerCase()=="submit")
			tempobj.disabled=true
		}
	}
}
function show_ppc_detail(id,page,city)
{
	document.getElementById('ppc_' + id).style.display='';
	document.getElementById('ppc_button_' + id).style.display='none';
	click_counter(id,page,city);
}
function check_block_email(value)
{
	if(value == '')
	{
		return "Please enter your email.";
	}
	else if(value.indexOf('@shaadi.com') != -1 || value.indexOf('@makaan.com') != -1 || value.indexOf('@shadi.com') != -1 
		|| value.indexOf('@peoplegroup.in') != -1 || value.indexOf('@peoplegroup.net') != -1 || value.indexOf('@makan.com') != -1
		|| value.indexOf('@2bhk.com') != -1 ||  value.indexOf('@mauj.com') != -1 ||  value.indexOf('@shaaditimes.com') != -1
		||  value.indexOf('@shaditimes.com') != -1 || value.indexOf('@peopleinteractive.in')!= -1)
	{
		return "This email is not allowed, please enter an alternate email.";
	}
	else
	{
		return "";
	}
}
function clear_div(divname)
{
	var o = document.getElementById(divname)
	if(o)
	{
		o.innerHTML = '';
	}
}
/* ckeck for the leap year */
function isLeapYear(yr) 
{
	return new Date(yr,2-1,29).getDate()==29;
}

/* this function will return true if given value is numeric else it will return false */
function validateNumber(fieldValue){
	if (fieldValue.length<1)
	{
		return false
	}

    chk1="1234567890";

	for(i=0;i!=fieldValue.length;i++)
	{
		ch1=fieldValue.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
		{
			return false;
			break;
		}
	}

return true	
}

/* this function will return true if given value contain any symbol else it will return false */
function validatesymbol(formName,fieldName)
{
	var	doc = "document."
	a=eval(doc+formName+"."+fieldName)
	fieldValue=eval(doc+formName+"."+fieldName + ".value")
	chk1 = "!@# $%^*+=|\~`{}[]:;<>?/\_,()";
	chk3="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
		else if(rtn1!=-1)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;	
		}
	}
	return true;
}

function reg_validatesymbol(formName,fieldName)
{
	var	doc = "document."
	a=eval(doc+formName+"."+fieldName)
	fieldValue=eval(doc+formName+"."+fieldName + ".value")
	chk1 = "!# $%^*+=&|\~`{}[]:;<>?/\,()";
	chk3="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@._-";
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
		else if(rtn1!=-1)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
	}
	return true;
}


/* this function will show image on icon on left and a messages on right of a field when a field is selected on a form*/
function showdiv_temp(desc_div,divimg)
{
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "icon")
		{
			 tmp_arr[i].innerHTML = "&nbsp;&nbsp;&nbsp;";
		}
	}
	if(divimg != "")
	{
		var imgname = '<img src="'+IMG_SERVER+'/images/icon.gif" width="15" height="13" alt="Locator" title="Locator"/>'
		eval("document.getElementById('"+divimg+"').innerHTML='"+imgname+"'");
	}
}

function showleft_icon(divimg)
{
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "icon")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
	if(divimg != "")
	{
		var imgname = '<img src="'+IMG_SERVER+'/images/icon.gif" width="15" height="13" alt="Locator" title="Locator"/>'
		eval("document.getElementById('"+divimg+"').innerHTML='"+imgname+"'");
	}
}

// Clear a field
function clear_checkbox(frm,field,data)
{
	var val = eval("document." + frm + "." + field + ".value");
	if(data == val)
	{
		eval("document." + frm + "." + field + ".value=''"); 
	}
}

/* check values for valid date*/
function is_valid_day(entered_month,entered_day,entered_year)	
{
	if (((entered_year % 400) == 0 || (entered_year % 4) == 0) && (entered_year % 100) != 0)
	{
		var days_in_month = "312931303130313130313031";
	}
	else	
	{
		var days_in_month = "312831303130313130313031";
	}
	if (entered_month != -1)
	{
		if ( parseInt(entered_day) > parseInt(days_in_month.substring(2*entered_month,2*entered_month+2)) )
		{
//alert ("The date field is entered wrongly (the day field value exceeds the number of days for the month entered).");
			return false;
		}
	}
	return true;
}

var i, j, strlen; 
var strchar = new String("");

// This function trims a string from the left edge
function LTrim(StringToTrim)
{
	StringToTrim = new String(StringToTrim);
	for(i = 0 ;i < StringToTrim.length; i++)
	{
		strchar = StringToTrim.charAt(i);
		if ( (strchar == " ") || (strchar == "\t") || (strchar == "\n") || (strchar == "\r") )
		{
		StringToTrim = StringToTrim.substr(i+1);
		i--;
		}
		else
			break;
	}
	return StringToTrim;
}


// This function trims a string from the right edge
function RTrim(StringToTrim)
{
	StringToTrim = new String(StringToTrim);
	for(i = StringToTrim.length - 1 ; i > -1 ; i--)
	{
			strchar = StringToTrim.charAt(i);
			if ( (strchar == " ") || (strchar == "\t") || (strchar == "\n") || (strchar == "\r") )
			{
				StringToTrim = StringToTrim.substr(0,i);
			}
			else
				break;
	}
	return StringToTrim;
}

// This function trims a string
// for triming a string it will call the LTrim and RTrim function
function Trim(StringToTrim)
{
	return LTrim(RTrim(StringToTrim));
}
	
// Validate a string for symbols including space
function validatesymbolwithspace(formName,fieldName)
{
	var	doc = "document."
	a=eval(doc+formName+"."+fieldName)
	fieldValue=eval(doc+formName+"."+fieldName + ".value")
	chk1 = "!@#$%^*+=|\~`{}[]:;<>?/,1234567890";
	chk3="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
		else if(rtn1!=-1)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;	
		}
	}
	return true;
}

function check_name(value)
{
	var fieldValue=value;
	var chk1 = "!@#&$%^*+=|\~`{}[]:;<>?/,";
	var chk3 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var result = true;
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			result = false;
			break;
		}
		else if(rtn1!=-1)
		{
			result = false;
			break;	
		}
	}
	return result;
}
function check_name_num(value)
{
	var fieldValue=value;
	var chk1 = "!@#&$%^*+=|\~`{}[]:;<>?/,1234567890";
	var chk3 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var result = true;
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			result = false;
			break;
		}
		else if(rtn1!=-1)
		{
			result = false;
			break;	
		}
	}
	return result;
}


function validatesymbolalphanumericwithspace(formName,fieldName)
{
	var	doc = "document."
	a=eval(doc+formName+"."+fieldName)
	fieldValue=eval(doc+formName+"."+fieldName + ".value")
	chk1 = "!@#$%^*+=|\~`{}[]:;<>?/,";
	chk3 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
		else if(rtn1!=-1)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;	
		}
	}
	return true;
}


function validatesymbolalcitylocalitycheck(formName,fieldName)
{
	var	doc = "document."
	a=eval(doc+formName+"."+fieldName)
	fieldValue=eval(doc+formName+"."+fieldName + ".value")
	chk1 = "!@#$%^*+=|\~`{}[]:;<>?/,1234567890";
	chk3="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(j=0;j!=fieldValue.length;j++)
	{
		ch1= fieldValue.charAt(j);
		ch2= fieldValue.charAt(0);
		rtn1=chk1.indexOf(ch1);
		rtn3=chk3.indexOf(ch2);
		if(rtn3 < 0)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;
		}
		else if(rtn1!=-1)
		{
			eval(doc+formName+"."+fieldName + ".focus()")
			return false;
			break;	
		}
	}
	return true;
}

	//enable other if other is selected in locality combo
function check_other_city(value,control1,control2)
{
	var obj = document.getElementById(control1);
	var is_other = value.indexOf('other');
	
	if(is_other == 0)
	{
		obj.style.display = '';
	}
	else
	{
		obj.style.display = 'none';
	}
	if(control2 != "")
	{
		var obj2 = document.getElementById(control2);
		obj2.style.display = 'none';
	}
}

function change_other_location(value,field)
{	
	var obj = document.getElementById(field);
	if(value == "other")
	{
		obj.style.display = '';
	}
	else
	{
		obj.style.display = 'none';
	}
}

// function to show message about the remaining character limit on a control
function check_character_limit(frm,field,show_div,maxKeys,break_it)
{
	var str = eval("document." + frm + "." + field + ".value");
	var showstr = "";
	var len = str.length;
	var showstr = len + " characters of " + maxKeys + " entered";
	if(parseInt(len) > parseInt(maxKeys)) 
	{
		str = str.substring(0,maxKeys)
		eval("document." + frm + "." + field + ".value='"+str+"'");
		//alert(eval("document." + frm + "." + field + ".value"));
		showstr = '(Max '+ maxKeys +' Characters)';
		//if(break_it == 'true')
			//return false;
	}
	document.getElementById(show_div).innerHTML = showstr ;
}



function cleardivs() {
	var tmp_arr = document.getElementsByTagName("div");
	 for(var i = 0; i < tmp_arr.length; i++)
			 {
			 	if(tmp_arr[i].className == "texterror")
				{
					 tmp_arr[i].innerHTML = "&nbsp;";
				}
			 }
}
/*
function isValidEmail(str) {
//Email Validator
	alert(str);
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) {
		return true
	} else {
		return false
	}
}
*/
function isValidEmail(str) {
	if(!(/^[^a-zA-Z]/.test(str)) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))) {
		return true
	} else {
		return false
	}
}

function changecountrycode(new_value,form,target_field,target_field2)
{
	
	var myString = "+" + new String(new_value);
	var splitString = myString.split("|");
	eval('document.' + form + "." + target_field + ".value='" + splitString[0] +"'")
	if(target_field2 != "")
	{
		eval('document.' + form + "." + target_field2 + ".value='" + splitString[0] +"'")
	}
}
function ValidateNo( NumStr, String )
{
	for( var Idx = 0; Idx < NumStr.length; Idx ++ )
	{
		var Char = NumStr.charAt( Idx );
		var Match = false;
		for( var Idx1 = 0; Idx1 < String.length; Idx1 ++)
		{
			if( Char == String.charAt( Idx1 ) )
			Match = true;
		}
		if ( !Match )
		return false;
	}
	return true;
}
function chk_isoption_selected(formname,fieldname){
	//alert(eval("document."+formname+"."+fieldname+".length"));
	fieldlength = parseInt(eval("document."+formname+"."+fieldname+".length"));

	for(i=0;i<fieldlength;i++){
		if(eval("document."+formname+"."+fieldname+"["+i+"].checked")){
			return true;
		}
	}
	return false;

}
function hasWhiteSpace12(s) 
{
	reWhiteSpace = new RegExp(/^\s+$/);
	// Check for white space
	alert(reWhiteSpace);
	if (reWhiteSpace.test(s)) {
		return true;
	}
	return false;
}
function hasWhiteSpace(s) 
{
	var str = s.split(" ");
	if(str.length > 1)
		return true;
	else
		return false;
}
function checkselected3(num)
{
	var displaydiv = document.getElementById('div_result');
	var displaydiv2 = document.getElementById('div_result2');
	if(eval(num)== 1)
	{
		channel=0;
		for (var i=0;i < frm_search.length;i++)
		  {
			  fldObj = frm_search.elements[i];
			  if(fldObj.type == 'checkbox')
			  {
				 if(fldObj.checked==true)
				 channel++;
			  }
		  }
		if(channel==0)
		{		
			displaydiv.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;No properties selected! Please select atleast one property.";
			displaydiv2.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;No properties selected! Please select atleast one property.";
			return false;
		}
		else
		{
			return true;
		}
	}
	else if(num == 2)
	{
		channel=0;
		for (var i=0;i < frm_search.length;i++)
		  {
			  fldObj = frm_search.elements[i];
			  if(fldObj.type == 'checkbox')
			  {
				 if(fldObj.checked==true)
				 channel++;
			  }
		  }
		 
		if(channel==0)
		{		
			
			return false;
		}
		else
		{
			return true;
		}
		//val =chk_isoption_selected('frm_search','checkbox');
		//return val;
	}

	else if(num == 3)
	{
		channel=0;
		/*
		for (var i=0;i < frm_search.length;i++)
		  {
			  fldObj = frm_search.elements[i];
			  if (fldObj.type == 'checkbox')
			  {
				 if(fldObj.checked==true)
				 channel++;
			   }
		  }
		  */
		channel = num_selected_ids;

		if(channel<2)
		{
			//alert("Please select two or more properties to compare.");
			displaydiv.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;Please select two or more properties to compare.";
			displaydiv2.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;Please select two or more properties to compare.";
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}

var showsave= function (cmd, sel)
{
	if(!sel) sel=0;

	var displaydiv = document.getElementById('div_result');
	var displaydiv2 = document.getElementById('div_result2');
	if(sel > 0)
	{		
		ajax_showTooltip("<font class='divmsgbold'>Short-list</font><font class='divmsg'><br>Enter a name for this search and save it as your Short-listed makaan.</font><br><br><form name='frmfolder' method='GET' action='/search/save-property.php'><input type='hidden' name='pid' value="+ sel + "><font class='divmsg'>Enter a name : </font><input type='text' maxlength=10 name='title' class='smallesttextbox'><br><br><input type=submit value=go></form><div align='right'><a href=javascript:return false; class='hrefheader' onclick=ajax_hideTooltip();>Close</a></div>",cmd);
	} // EO if(...)
	else if(checkselected(2))
	{
		//alert("abc");
		ajax_showTooltip("<font class=divmsgbold>Short-list</font><font class=divmsg><br>Enter a name for this search and save it as your Short-listed makaan.</font><br><br><form name=frmfolder method=GET action=/search/save-property.php><input type='hidden' name='from' value='<?= $_GET['from'];?>'><font class=divmsg>Enter a name : </font><input type='text' maxlength='10' name='title' class='smallesttextbox' value='<?= $_GET['title'];?>'><br><br><input type=submit value=go></form><div align='right'><a href=javascript:return false; class='hrefheader' onclick=ajax_hideTooltip();>Close</a></div>",cmd);

		//ajax_showTooltip('<font class=divmsgbold>Short-list</font><font class=divmsg><br>Enter a name for this search and save it as your Short-listed makaan.</font><br><br><form name=frmfolder action="/search/save-property.php"><input type=hidden name=from value='+ <?=$_GET['from'];?>+'><font class=divmsg>Enter a name : </font><input type=text name=title class=smallesttextbox><br><br><input type=submit value=go></form><div align=right><a href=javascript:return false; class=hrefheader onclick=ajax_hideTooltip();>Close</a></div>',cmd);
	}
	else
	{
		displaydiv.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;Please select atleast one property to save.";
		displaydiv2.innerHTML = "<img src='"+ALERT_IMG+"' width='10' height='10' align='absmiddle' vspace='3' border=0>&nbsp;Please select atleast one property to save.";
	}

	return true;

} // EO function()

function isLogin()	{
	cleardivs();
	var str = document.frm_login.login.value;
	var tmp_arr = document.getElementsByTagName("div");
	var isok = true;
	var set_focus = "";
	if (str == "")	{	// is not null
			document.frm_login.login.focus();
			tmp_arr['div_login'].innerHTML = "<img src='"+ALERT_IMG+"' width='10' align='absmiddle' height='10' vspace='3' border=0>&nbsp;Please enter an username";
			isok = false;
			if(set_focus == "")
				set_focus = "login";
	}
	var str2 = document.frm_login.password.value;
	if (str2 == "")	{	// is not null
			document.frm_login.password.focus();
			tmp_arr['div_password'].innerHTML = "<img src='"+ALERT_IMG+"' width='10' align='absmiddle' height='10' vspace='3' border=0>&nbsp;Please enter a password";
			isok = false;
			if(set_focus == "")
				set_focus = "password";
	}
	if(isok == false){
		eval("document.frm_login."+set_focus+".focus();")
		return false;
	}else{
		document.getElementById('lsubmit').disabled=true;
		document.getElementById('lsubmit').src=IMG_SERVER + '/images/login-orange-deact.gif';
		return true;
	}
}
function formatNumber(myNum, numOfDec)
{
  var decimal = 1
  for(i=1; i<=numOfDec;i++)
	 decimal = decimal *10

  var myFormattedNum = (Math.round(myNum * decimal)/decimal).toFixed(numOfDec)
  //alert(myNum + "   " +  myFormattedNum)
  return myFormattedNum;
}

function addCommas( strValue ) {
/************************************************
DESCRIPTION: Inserts commas into numeric string.

PARAMETERS:
  strValue - source string containing commas.

RETURNS: String modified with comma grouping if
  source was all numeric, otherwise source is
  returned.

REMARKS: Used with integers or numbers with
  2 or less decimal places.
*************************************************/
strValue = strValue.replace(/,/g,'');
objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }

  var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})');

    //check for match to search criteria
    while(objRegExp.test(strValue)) {
       //replace original string with first group match,
       //a comma, then second group match
       strValue = strValue.replace(objRegExp, '$1,$2');
    }
  return strValue;
}

function removeCharacters( strValue, strMatchPattern ) {
/************************************************
DESCRIPTION: Removes characters from a source string
  based upon matches of the supplied pattern.

PARAMETERS:
  strValue - source string containing number.

RETURNS: String modified with characters
  matching search pattern removed

USAGE:  strNoSpaces = removeCharacters( ' sfdf  dfd',
                                '\s*')
*************************************************/
 var objRegExp =  new RegExp( strMatchPattern, 'gi' );

 //replace passed pattern matches with blanks
 strValue = strValue.replace(/,/g,'');
 //replace passed pattern matches with blanks
  return strValue.replace(objRegExp,'');
}

// Function to disallow alphabets in numeric fields like price, area
// USAGE:  onkeypress="return isNumberKey(event)"
function isNumberKey(evt,enabledot)
{
	if(!enabledot) enabledot=0;
 var charCode = (evt.which) ? evt.which : event.keyCode
	//alert(charCode)
 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=46 && enabledot==1)
	return false;
 else if (charCode > 31 && (charCode < 48 || charCode > 57) && enabledot==0)
	return false;

 return true;
}
function acceptNumber(evt,enabledot)
{
	
	if(!enabledot) enabledot=0;
	var charCode = (evt.which) ? evt.which : event.keyCode
	var ret = '0';
	if(enabledot == '0')
	{
		var allowedValues = ["48", "49", "50", "51","52", "53", "54", "55", "56", "57", "96", "97", "98", "99","100", "101", "102", "103", "104", "105", "8", "46", "13", "9", "116", "37", "38", "39", "40" ];	
	}else{
		var allowedValues = ["48", "49", "50", "51","52", "53", "54", "55", "56", "57", "96", "97", "98", "99","100", "101", "102", "103", "104", "105", "8", "46", "13", "9", "116", "37", "38", "39", "40", "190", "110" ];	
	}
	
	var length = allowedValues.length;
	
	for(var i = 0; i < length; i++)
	{
		if(allowedValues[i] == charCode)
			ret = '1';
	}
	
	if(ret == '1'){
		return true;
	}else{
		return false;
	}
}

function createAjaxObject(id)
{
	var xmlObj = new Array();
	xmlObj[id] = false;
	//Check if we are using IE.
	try {
	//If the Javascript version is greater than 5.
		xmlObj[id] = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	//If not, then use the older active x object.
		try {
		//If we are using Internet Explorer.
			xmlObj[id] = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
		//Else we must be using a non-IE browser.
			xmlObj[id] = false;
		}
	}
	//If we are using a non-IE browser, create a javascript instance of the object.
	if (!xmlObj[id] && typeof XMLHttpRequest != 'undefined') {
		xmlObj[id] = new XMLHttpRequest();
	}
	return xmlObj[id];
}

