var link_num=new Array();
var current_link='';
var current_page='view.php';
var totrec = 0;
// Removes leading whitespaces
function LTrim( value ) {
var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim( value ) {
var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim( value ) {
return LTrim(RTrim(value));
}
/// ajax script ////
var xmlhttp = new XMLHttpRequest();
var str='';
function ajaxCall(url) {
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.send(null);
}
}
function closeparent() {
if (window.opener != null && !window.opener.closed) {
window.open('','main','');
window.name="main";
if(document.all) {
window.opener.opener = '';
}
window.opener.close();
}
}
function stateChanged() {
if (xmlhttp.readyState==1){
document.getElementById("output").innerHTML='Processing...';
document.getElementById("output").className='ajax-success';
}
if (xmlhttp.readyState==4){
var str =xmlhttp.responseText;
if (str.match('.php')){
location.href = str;
}
else {
switch (str) {
case '1':
location.href='message.php?page=profile';
break;
case '2':
location.href='message.php?page=editprofile';
break;
case '3':
location.href='view.php';
break;
case '4':
document.getElementById("output").style.display='inline';
break;
default:
document.getElementById("output").innerHTML=str;
document.getElementById("output").className='ajax-failure';
break;
}
}
str='';
}
}
/// add to comparelist
function compare_ajaxCall(url) {
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = compare_stateChanged;
xmlhttp.send(null);
}
}
function compare_stateChanged() {
if (xmlhttp.readyState==4){
var str = xmlhttp.responseText;
var st='';
document.getElementById('im_'+current_link).innerHTML="";
document.getElementById('compare_content').innerHTML = str;
if (str!='') {
alert('Property added successfully to compare list');
Set_Cookie( 'flag_child', '1', '', '/', '', '' );
document.getElementById('link_'+current_link).style.display='none';
showHideLinks(totrec,'');
document.getElementById('sort_order').style.display='';
}
str='';
}
}
/// add to comparelist
function compareSingle_ajaxCall(url) {
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = compareSingle_stateChanged;
xmlhttp.send(null);
}
}
function compareSingle_stateChanged() {
if (xmlhttp.readyState==4){
var str = xmlhttp.responseText;
var st='';
document.getElementById('compare_content').innerHTML = str;
if (str!='') {
alert('Property added successfully to compare list');
document.getElementById('link_compare').style.display='none';
if (window.opener != null && !window.opener.closed) {
if(window.opener.document.URL.match("view.php") != null) {
var sublen = window.opener.document.ff.prp.length;
for (j=0;j"+cb;
document.getElementById('save_search_cntrl').className='button-table';
break;
}
}
else {
document.getElementById(id+'_flag').className='view_content';
document.getElementById(id+'_arrow').className='arrow-changed';
document.getElementById(id+'_val').value=1;
switch (id){
case 'location':
//getState();
//document.getElementById('state_cntrl').className='button-table';
getCities();
document.getElementById('city_cntrl').className='button-table';
break;
case 'price':
getPrice();
break;
case 'lifestyle':
getLifeStyle();
break;
case 'propertytype':
getPropertyType();
break;
case 'bedrooms':
getBedRooms();
break;
case 'bathrooms':
getBathRooms();
break;
case 'amenities':
getAmenities();
break;
case 'propertystyles':
getPropertyStyles();
break;
case 'listingtypes':
getListingTypes();
break;
case 'save_search':
var inputctrl = "Name this search:
";
var cb = "Email new listings that match this search";
document.getElementById('save_search_cntrl').innerHTML=inputctrl+"
"+cb; document.getElementById('save_search_cntrl').className='button-table';
break;
}
}
}
function chkExists(arr, val)
{
flag = 0;
for (i in arr)
{
if (val == arr[i].name)
{
flag = '1'
}
return flag;
}
}
if (window.XMLHttpRequest){
// If IE7, Mozilla, Safari, etc: Use native object
var xmlhttp = new XMLHttpRequest();
}
else
{
if (window.ActiveXObject){
// ...otherwise, use the ActiveX control for IE5.x and IE6
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
//var xmlhttp = new XMLHttpRequest();
var mytext;
function searchByID()
{
textfield = (trim(document.fd.mls_id.value) == 'Search Location Property ID or MLS ID') ? '' : document.fd.mls_id.value;
if(textfield.length>0) {
document.fd.submit();
}
else {
alert("Please enter Location or Property ID or MLS ID");
return false;
}
}
function sortCriteria()
{
document.getElementById('spinner_go').innerHTML="
";
sort_order = document.ff.sort_order.value;
var ssrch = document.getElementById('ssrch_val').value;
srch_id = document.getElementById('srch_id').value;
url = "view_inc.php?pst=1&page=1&sort_order="+sort_order;
if (ssrch >0) {
url +="&ssrch=1&pst=1&search_id="+srch_id;
}
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = httpstatechange;
xmlhttp.send(null);
}
}
function searchCriteria(page_no)
{
document.getElementById('spinner_go').innerHTML="
";
//document.getElementById('spinner_go').style.display = '';
//document.getElementById('spinner_sort').style.display = '';
go_click = document.ff.go_click.value;
var ssrch = document.getElementById('ssrch_val').value;
arrElements = document.ff.elements;
textfield = document.fd.mls_id.value;
if(textfield == 'Search Location, Property ID or MLS ID') {
textfield ='';
}
sort_order = document.ff.sort_order.value;
state = (document.ff.location_val.value == 1) ? document.ff.state.value : '';
rcity = (document.ff.location_val.value == 1 && document.ff.state.value != '') ? document.ff.rcity.value : '';
price = (document.ff.price_val.value == 1) ? document.ff.price.value : '';
lifestyle = (document.ff.lifestyle_val.value == 1) ? document.ff.lifestyle.value : '';
propertytype = (document.ff.propertytype_val.value == 1) ? document.ff.propertytype.value : '';
bedrooms = (document.ff.bedrooms_val.value == 1) ? document.ff.bedrooms.value : '';
bathrooms = (document.ff.bathrooms_val.value == 1) ? document.ff.bathrooms.value : '';
amenities = (document.ff.amenities_val.value == 1) ? document.ff.amenities.value : '';
propertystyles = (document.ff.propertystyles_val.value == 1) ? document.ff.propertystyles.value : '';
searchname = (document.getElementById('save_search_val').value == 1) ? document.getElementById('savedsearch').value : '';
email_flag = (document.getElementById('save_search_val').value == 1) ? document.getElementById('watchlst').checked : '';
if(!isValidSearchName(searchname) && searchname.length>0) {
alert('Invalid search name');
document.getElementById('spinner_go').innerHTML="";
}
else{
srch_id = document.getElementById('srch_id').value;
if(page_no>=1)
url = "view_inc.php?pgn=1&page="+page_no+"&sort_order="+sort_order;
else
url = "view_inc.php?mls_id="+textfield+"&sort_order="+sort_order+"&state="+state+"&rcity="+rcity+"&price="+price+"&lifestyle="+lifestyle+"&propertytype="+propertytype+"&bedrooms="+bedrooms+"&bathrooms="+bathrooms+"&amenities="+amenities+"&propertystyles="+propertystyles+"&searchname="+searchname+"&email_flag="+email_flag;
if (ssrch >0 && go_click!=1) {
url +="&ssrch=1&pst=1&search_id="+srch_id;
}
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = httpstatechange;
xmlhttp.send(null);
}
}
if(page_no<1)
{
return false;
}
}
function httpstatechange(){
if (xmlhttp.readyState==1){
document.getElementById('spinner_go').style.display='inline';
//lgx(1);
}
if (xmlhttp.readyState == 4){
document.getElementById('spinner_go').innerHTML="";
mytext = xmlhttp.responseText;
var msg = mytext.split('~!^zz');
var teststr = msg[0];
var msgstr ='';
var cont ='';
if (teststr.match('
1){
document.getElementById('address_msg').innerHTML='Invalid Address';
document.getElementById('address_msg').style.color='red';
flag=false;
}
if (flag) {
querystring ="username="+username+"&password="+password+"&email="+email+"&country="+country+"&state="+state+"&city="+city+"&address="+address+"&old_password="+old_password;
if (bttn=='Update') {
option='update&';
}
else {
option='adduser&';
}
ajaxCall('profile.php?option='+option+querystring);
return false;
}
else {
return flag;
}
}
// validate uset
function validateUser(){
var email = trim(document.getElementById('emailx').value);
var password = trim(document.getElementById('passwordx').value);
var url = trim(document.getElementById('strurl').value);
var flag=true;
if (!isValidEmail(email) || email.length<5){
flag=false;
}
if (password.length<6){
flag=false;
}
if (flag) {
querystring ="email="+email+"&password="+password+"&strurl="+url;
ajaxCall('login.php?option=validate&'+querystring);
return false;
}
else {
document.getElementById('output').innerHTML='Invalid Login';
document.getElementById('output').className='ajax-failure';
document.getElementById('passwordx').value="";
return false;
}
}
function changePassword(flag){
//document.getElementById('pass_link').style.display='table-row';
if (flag) {
document.getElementById('link_content').innerHTML=" No need to change password ";
document.getElementById('pass_group1').style.display='';
document.getElementById('pass_group2').style.display='';
document.getElementById('pass_group3').style.display='';
}
else {
document.getElementById('link_content').innerHTML=" Click here to change password ";
document.getElementById('pass_group1').style.display='none';
document.getElementById('pass_group2').style.display='none';
document.getElementById('pass_group3').style.display='none';
}
}
function sendPassword(){
var email = document.getElementById('email').value;
document.getElementById('email_msg').innerHTML='';
var flag=true;
if (!isValidEmail(email) || email.length<3) {
document.getElementById('email_msg').innerHTML=' Invalid Email';
document.getElementById('email_msg').style.color='red';
flag=false;
}
if (flag) {
querystring ="email="+email;
ajaxCall('profile.php?option=resetpassword&'+querystring);
email = document.getElementById('email').value='';
}
return false;
}
function showHideCompare(flag){
if (flag==1) {
document.getElementById('compareTool').style.display='inline';
document.getElementById('sort_order').style.display='none';
document.getElementById('compareBtn').innerHTML="
";
}
else {
document.getElementById('compareTool').style.display='none';
document.getElementById('sort_order').style.display='';
document.getElementById('compareBtn').innerHTML="
";
}
}
/*function compareList(prpid,option){
querystring ="prpid="+prpid;
if (option=='add'){
document.getElementById('link'+prpid).style.display='none';
//Element.show('spinner_sort');
}
compare_ajaxCall('comparelist.php?option='+option+'&'+querystring);
}
*/
function showHideLinks(total,display){
for (i=1;i<=total;i++){
document.getElementById('sidx_'+i).style.display=display;
}
}
function compareList(prpid,option,nm,totalrec){
querystring ="prpid="+prpid;
current_link = nm;
totrec= totalrec;
var st='';
if (option=='add'){
//for (i=1;i<=totrec;i++) {
//if(document.getElementById('link_'+i).style.display=='none'){
//link_num[i] = 'none';
//st +=link_num[i]+',';
// }
//else {
//link_num[i] ='';
//st +=link_num[i]+',';
//document.getElementById('link_'+nm).style.display='none';
//}
document.getElementById('link_'+nm).style.display='none';
document.getElementById('im_'+current_link).innerHTML="
";
showHideLinks(totrec,'none');
}
//Element.show('spinner_sort');
compare_ajaxCall('comparelist.php?option='+option+'&'+querystring);
}
function compareSingleList(prpid,nm){
current_link = nm;
querystring ="prpid="+prpid;
compareSingle_ajaxCall('comparelist.php?option=add&'+querystring);
document.getElementById('im_1').innerHTML="
";
}
function removeList(tot){
var str='';
var lnk='';
var count=0;
if (tot>0) {
flag = document.getElementById('cbx1');
if (flag.checked) {
var st = document.getElementById('cbx1').value;
st = st.split('|');
str = st[0];
lnk = st[1];
count++;
}
for (i=2;i<=tot;i++){
flag = document.getElementById('cbx'+i);
if (flag.checked) {
if (str!='') {
str += ',';
lnk += ',';
}
var st = document.getElementById('cbx'+i).value;
st = st.split('|');
str += st[0];
lnk += st[1];
}
}
if (str!='') {
querystring ="prpid="+str;
remove_ajaxCall('comparelist.php?option=delete&'+querystring);
current_link = lnk;
//str.split(',');
}
else {
alert('You must select atleast one property to remove');
}
}
else {
alert('You must select atleast one property to remove');
}
return false;
}
function compareProperties(tot){
var str ='';
var count=0;
if (tot>0) {
flag = document.getElementById('cbx1');
if (flag.checked) {
var st = document.getElementById('cbx1').value;
st = st.split('|');
str = st[0];
count++;
}
for (i=2;i<=tot;i++){
flag = document.getElementById('cbx'+i);
if (flag.checked) {
count++;
if (str!='') {
str += ',';
}
var st = document.getElementById('cbx'+i).value;
st = st.split('|');
str += st[0];
}
}
}
if (count <2 || tot <1 ) {
alert('You must select atleast two properties to compare');
}
else
if (count >4 ) {
alert('Maximum four properties can be compared at a time');
}
else {
var win_url = "compare_details.php?prpid="+str;
newPopUpWindow(win_url,'compare Properties',716,780,'yes');
}
return false;
}
function saveProperty(tot){
var str ='';
var count=0;
if (tot>0) {
flag = document.getElementById('cbx1');
if (flag.checked) {
var st = document.getElementById('cbx1').value;
st = st.split('|');
str = st[1];
count++;
}
for (i=2;i<=tot;i++){
flag = document.getElementById('cbx'+i);
if (flag.checked) {
count++;
if (str!='') {
str += ',';
}
var st = document.getElementById('cbx'+i).value;
st = st.split('|');
str += st[1];
}
}
}
if (count <1 || tot <1 ) {
alert('You must select atleast one property to save');
}
else {
querystring = "property_id="+str;
save_ajaxCall('save_property.php?option=save&'+querystring);
}
return false;
}
function saveSingleProperty(propertyid,nm,page,total){
totrec=total;
current_link = nm;
current_page = page;
querystring = "property_id="+propertyid;
document.getElementById('im_'+current_link).innerHTML="
";
savesingle_ajaxCall('save_property.php?option=save&'+querystring);
showHideLinks(totrec,'none');
}
function isValidUserName(val) {
validRegExp = /^[a-zA-Z. ]+$/i;
// search email text for regular exp matches
val = trim(val);
if (val.search(validRegExp) == -1) {
return false;
}
return true;
}
function isValidName(val) {
validRegExp = /^[a-zA-Z ]+$/i;
// search email text for regular exp matches
val = trim(val);
if (val.search(validRegExp) == -1) {
return false;
}
return true;
}
function newPopUpWindow(page, name, w, h, scroll) {
name = "foo";
page = page.split(" ").join("%20");
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
//var resizable = false;
winprop = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes';
win = window.open(page, name, winprop);
win.focus();
}
function isValidAddress(addr){
//validRegExp = /^[0-9a-zA-Z\s\,./-]+$/;
validRegExp = /^[0-9a-zA-Z \s,.\!\@\#\$\%\^\&\*\(\)\?\_\'\"/-]+$/;
if (addr.match(validRegExp) == null) {
return false;
}
return true;
}
function isValidComment(commt){
validRegExp = /^[0-9a-zA-Z \s,.\!\@\#\$\%\^\&\*\(\)\?\_\'\"/-]+$/;
if (commt.match(validRegExp) == null) {
return false;
}
return true;
}
function isValidPhone(val) {
validRegExp = /^[0-9 -]+$/;
// search email text for regular exp matches
val = trim(val);
if (val.match(validRegExp) == null) {
return false;
}
return true;
}
function validateContact(){
var result_ajax = '';
var email = document.contact.email.value;
var fname = document.contact.fname.value;
var lname = document.contact.lname.value;
var hphone = document.contact.hphone.value;
var comments = escape(document.contact.comments.value);
var flag = true;
document.getElementById('email_err').innerHTML ='';
document.getElementById('fname_err').innerHTML ='';
document.getElementById('lname_err').innerHTML ='';
document.getElementById('hphone_err').innerHTML ='';
document.getElementById('comments_err').innerHTML ='';
if (!isValidEmail(email) || email.length<3) {
document.getElementById('email_err').innerHTML=' Invalid Email';
flag = false;
}
if (!isValidName(fname) && fname.length>0){
document.getElementById('fname_err').innerHTML='Invalid First name';
flag = false;
}
if (!isValidName(lname) && lname.length>0){
document.getElementById('lname_err').innerHTML='Invalid Last name';
flag = false;
}
if (hphone.length>1){
if(hphone.length<6 || !isValidPhone(hphone)) {
document.getElementById('hphone_err').innerHTML='Invalid Phone No.';
flag = false;
}
}
if (!isValidComment(comments) && comments.length>0){
document.getElementById('comments_err').innerHTML='Invalid Comments';
flag = false;
}
if (flag) {
querystring ="email="+email+"&fname="+fname+"&lname"+lname+"&hphone="+hphone+"&comments="+comments;
url= 'contactus.php?option=contactus&'+querystring;
if(xmlhttp){
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = httpcontactchange;
xmlhttp.send(null);
}
return false;
}
return false;
}
function httpcontactchange(){
if (xmlhttp.readyState==1){
document.getElementById('spinner').innerHTML = "
";
}
if (xmlhttp.readyState == 4){
mytext = xmlhttp.responseText;
document.getElementById("contact_us").innerHTML = mytext;
mytext="";
}
}
function lgx(flag){
if (flag){
var fileLoadingImage = "images/loading.gif";
var objBody = document.getElementsByTagName("body").item(0);
var objOverlay = document.createElement("div");
objOverlay.setAttribute('id','overlay');
objBody.appendChild(objOverlay);
var objLoadingImage = document.createElement("img");
objLoadingImage.setAttribute('src', fileLoadingImage);
objLoadingImage.setAttribute('vspace', "278");
objOverlay.appendChild(objLoadingImage);
document.getElementById('overlay').style.top = window.screen.height-500;
document.getElementById('overlay').style.height=window.screen.height;
}
else {
document.getElementById('overlay').style.display='none';
}
}
function idsearch(){
var val = trim(document.getElementById('mls_id').value);
closeparent();
if (val=='' || val=='Search Location Property ID or MLS ID') {
alert('Invalid search parameter');
return false;
}
return true;
}
function deleteSearch(id) {
if(confirm("Are you sure you want to delete?")) {
location.href="mysavedsearches.php?option=delete&id="+id;
}
}
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
function searchCriteria_new(page_no)
{
//alert('ttstt');
//document.getElementById('spinner_go').innerHTML="
";
//document.getElementById('spinner_go').style.display = '';
//document.getElementById('spinner_sort').style.display = '';
/*go_click = document.ff.go_click.value;
var ssrch = document.getElementById('ssrch_val').value;
arrElements = document.ff.elements;
textfield = document.fd.mls_id.value;
if(textfield == 'Search Location, Property ID or MLS ID') {
textfield ='';
}
state = document.ff.state.value;
rcity = document.ff.rcity.value;
price = document.ff.price.value;
lifestyle = document.ff.lifestyle.value;
propertytype = document.ff.propertytype.value;
bedrooms = document.ff.bedrooms.value;
bathrooms = document.ff.bathrooms.value;
amenities = document.ff.amenities.value;
propertystyles = document.ff.propertystyles.value;*/
//sort_order = document.ff.sort_order.value;
searchname = (document.getElementById('save_search_val').value == 1) ? document.getElementById('savedsearch').value : '';
email_flag = (document.getElementById('save_search_val').value == 1) ? document.getElementById('watchlst').checked : '';
if(!isValidSearchName(searchname) && searchname.length>0) {
alert('Invalid search name');
// document.getElementById('spinner_go').innerHTML="";
}
else{
srch_id = document.getElementById('srch_id').value;
if(page_no>=1)
{
url = "view1_inc.php?pgn=1&page="+page_no;
//alert(url);
}
else
url = "view_inc.php?mls_id="+textfield+"&sort_order="+sort_order+"&state="+state+"&rcity="+rcity+"&price="+price+"&lifestyle="+lifestyle+"&propertytype="+propertytype+"&bedrooms="+bedrooms+"&bathrooms="+bathrooms+"&amenities="+amenities+"&propertystyles="+propertystyles+"&searchname="+searchname+"&email_flag="+email_flag;
/*if (ssrch >0 && go_click!=1) {
url +="&ssrch=1&pst=1&search_id="+srch_id;
}*/
if(xmlhttp){
//alert('here too');
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = httpstatechange_new;
xmlhttp.send(null);
}
}
if(page_no<1)
{
return false;
}
}
function httpstatechange_new(){
/*if (xmlhttp.readyState==1){
document.getElementById('spinner_go').style.display='inline';
}*/
if (xmlhttp.readyState == 4){
//document.getElementById('spinner_go').innerHTML="";
mytext = xmlhttp.responseText;
var msg = mytext.split('~!^zz');
var teststr = msg[0];
var msgstr ='';
var cont ='';
if (teststr.match('