function check_text (c, t, v) {
   if (t == '1') {
      if ($('#' + c).val() == v) {
	     $('#' + c).val('');
	  }
   }
   else {
      if ($('#' + c).val() == '') {
	     $('#' + c).val(v);
	  }
   }
}
function show_hide_div(d, cb) {
   if ($('#' + d).css('display') == "none") {
      $('#' + d).slideDown();
   }
   else {
	  if (cb) {
	     $('.' + cb).each(function(){
		    $(this).prop('checked', false);
		 })
	  }
      $('#' + d).slideUp();
   }
}
function show_hide_warning(d, p) {
   if ($('#' + d).css('display') == "none") {
      $('#' + d).slideDown();
	  $('#img_circle').attr('src', p + '/images/circleminus.png');
   }
   else {
      $('#' + d).slideUp();
	  $('#img_circle').attr('src', p + '/images/circleplus.png');
   }
}

function show_hide_div2(d) {
   if ($('#' + d).css('display') == "none") {
      $('#' + d).fadeIn();
   }
   else {
      $('#' + d).fadeOut();
   }
}

function reset_form (tb, t, d, cb, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();

   if ($('#hsc').val() == '1') {   
      $('#hsc').val('');
	  $('#div_slider').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4){
            $('#div_slider').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
   
}
function reset_form2 (tb, t, d, cb, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();

   if ($('#hsc2').val() == '1') {   
//      $('#hsc2').val('');
	  $('#div_slider2').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4) {
            $('#div_slider2').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
}

function reset_form_comm (tb, t, d, cb, d2, cb2, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();
   $('.' + cb2).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d2).slideUp();

   if ($('#hsc').val() == '1') {   
      $('#hsc').val('');
	  $('#div_slider').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4){
            $('#div_slider').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
   
}
function reset_form_comm2 (tb, t, d, cb, d2, cb2, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();
   $('.' + cb2).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d2).slideUp();

   if ($('#hsc2').val() == '1') {   
//      $('#hsc2').val('');
	  $('#div_slider2').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4) {
            $('#div_slider2').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
}

function reset_form_res (tb, t, d, cb, d2, cb2, d3, cb3, tb2, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();
   $('.' + cb2).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d2).slideUp();
   $('.' + cb3).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d3).slideUp();
   $('#' + tb2).val('');
   
   if ($('#hsc').val() == '1') {   
      $('#hsc').val('');
	  $('#div_slider').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4){
            $('#div_slider').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }   
}

function reset_form_res2 (tb, t, d, cb, d2, cb2, d3, cb3, tb2, f, cr) {
   $('#' + tb).val(t);
   $('.' + cb).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d).slideUp();
   $('.' + cb2).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d2).slideUp();
   $('.' + cb3).each(function(){
      $(this).prop('checked', false);
   })
   $('#' + d3).slideUp();
   $('#' + tb2).val('');
   
   if ($('#hsc2').val() == '1') {   
//      $('#hsc2').val('');
	  $('#div_slider2').html('<div style="height: 75px">Loading...</div>');
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4) {
            $('#div_slider2').html(ajaxRequest.responseText);
         }
      }
   
      var queryString = '?bustcache=' + new Date().getTime() + '&cr=' + cr;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
   
}

function show_profile (f, id, img) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
		 if ($('#div_profile').css('display') == "block") {
	        $('#div_profile').slideUp();
		 }
         $('#div_profile').html(ajaxRequest.responseText);
		 $('#div_profile').slideDown();
		 $('html, body').animate({ scrollTop: $('#div_profile').offset().top - 120}, 500);
      }
   }

   var queryString = '?bustcache=' + new Date().getTime() + "&id=" + id + '&img=' + img;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function show_service_details (f, t, d) {
   if ($(window).width() > 500) {
      var d = "div_service_details";
   }
   else {
      var d = "div_service_details2";
   }
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
		 if ($('#' + d).css('display') == "block") {
	        $('#' + d).slideUp();
		 }
         $('#' + d).html(ajaxRequest.responseText);
		 $('#' + d).slideDown();
		 $('html, body').animate({ scrollTop: $('#' + d).offset().top - 160}, 500);
      }
   }

   var queryString = '?bustcache=' + new Date().getTime() + "&t=" + t + '&d=' + d;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function scroll_to (d, s) {
   var dd = parseInt(s, 10);	
   $('html, body').animate({ scrollTop: $('#' + d).offset().top - dd}, 500);
}
function change_image (e, img, nh, i, ow, oh, r) {
   if (e.className == "img_prop_1") {
	  $('#h_w_first_pic').val(ow);
	  $('#h_h_first_pic').val(oh);
	  $('#first_pic').fadeOut(300, function() {		 
	     var img_c_h = Math.round($('.div_properties_left').width() * oh / ow);
         var limit_h = Math.round($('.div_properties_left').width() * 700 / 898);
         if (img_c_h > limit_h) {
            img_c_h = limit_h;            
//			$('#first_pic').height(img_c_h);
//			$('#first_pic').width(ow * limit_h / oh);
         }
		 else {
//			$('#first_pic').height(oh);
//			$('#first_pic').width(ow);
		 }
         $('#first_pic').height(img_c_h);   
         $('#first_pic').width($('#first_pic').height() * $('#h_w_first_pic').val() / $('#h_h_first_pic').val()); 
		 
         $('#div_first_pic_container').height(img_c_h);
		 $('#div_first_pic_container').width($('.div_properties_left').width());
         $(this).attr('src', img).bind('onreadystatechange load', function(){
            if (this.complete) $(this).fadeIn(300);
         });
      });

	  $('.img_prop_2').each(function() {
	     $('#' + $(this).prop('id')).removeClass('img_prop_2');
		 $('#' + $(this).prop('id')).addClass('img_prop_1');		 
	  })
	  $('#img_prop_' + i).removeClass('img_prop_1');
	  $('#img_prop_' + i).addClass('img_prop_2');
   }
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function check_request_form_popup(f, info, et) {
   var fn = trim($('#req_full_name').val(), " ");
   if (!fn) {
      alert ("Please enter Full Name");
	  $('#req_full_name').focus();
	  return false;
   }
   
   var e = trim($('#req_email').val(), " ");
   if (!e) {
      alert ("Please enter Email");
	  $('#req_email').focus();
	  return false;
   }
   else {
      var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
      if (!e.match(mailformat)) {
         alert ("Please enter a valid Email Address.");
         $('#req_email').focus();
         return false;
      }
   }
   
   /*
   var HasValue = "";
   var arr = $('#req_comments').val().split(/\n/);
   for (i = 0; i < arr.length; i++) {
      var v = trim(arr[i], " ");
	  if (v) {
	     HasValue = "1";
		 break;
	  }
   }

   if (!HasValue) {
      alert ("Please enter Comments");
	  $('#req_comments').focus();
	  return false;
   }
   */
   
   if (!$('#g-recaptcha-response').val()) {
      alert ('Bot-check failed, please try again');
      return false;
   }
   
   fn = encodeURIComponent(fn);
   e = encodeURIComponent(e);
   var ph = trim($('#req_phone').val(), " ");
   if (ph) {
      ph = encodeURIComponent(ph);
   }
   /*
   var pn = trim($('#req_property_name').val(), " ");
   if (pn) {
      pn = encodeURIComponent(pn);
   }         
   var pa = trim($('#req_property_address').val(), " ");
   if (pa) {
      pa = encodeURIComponent(pa);
   }
   var st = encodeURIComponent($('#div_crt_option').html());
   */
   var m = trim($('#req_comments').val(), " ");
   if (m) {
      m = m.replace(/\r\n/g, "<br />");
      m = m.replace(/\n/g, "<br />"); // for Firefox
   }
   
   alert ("Your message has been sent. Thank you.");
   
   info = encodeURIComponent(info);
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
	     $('#req_full_name').val('');
		 $('#req_email').val('');
		 $('#req_phone').val('');
		 $('#req_comments').val('');
      }
   }

   var queryString = '?bustcache=' + new Date().getTime();
   queryString = queryString + '&fn=' + fn + '&e=' + e + '&ph=' + ph + '&m=' + m + '&info=' + info + '&et=' + et;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function check_request_form(f) {
   var fn = trim($('#req_full_name').val(), " ");
   if (!fn) {
      alert ("Please enter Full Name");
	  $('#req_full_name').focus();
	  return false;
   }
   
   var e = trim($('#req_email').val(), " ");
   if (!e) {
      alert ("Please enter Email");
	  $('#req_email').focus();
	  return false;
   }
   else {
      var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
      if (!e.match(mailformat)) {
         alert ("Please enter a valid Email Address.");
         $('#req_email').focus();
         return false;
      }
   }
   
   var pa = trim($('#req_property_address').val(), " ");
   if (!pa) {
      alert ("Please enter Property Address");
	  $('#req_property_address').focus();
	  return false;
   }
   
   /*
   var HasValue = "";
   var arr = $('#req_comments').val().split(/\n/);
   for (i = 0; i < arr.length; i++) {
      var v = trim(arr[i], " ");
	  if (v) {
	     HasValue = "1";
		 break;
	  }
   }
   if (!HasValue) {
      alert ("Please enter Comments");
	  $('#req_comments').focus();
	  return false;
   }      
   */
   
   if (!$('#g-recaptcha-response').val()) {
      alert ('Bot-check failed, please try again');
      return false;
   }

   fn = encodeURIComponent(fn);
   e = encodeURIComponent(e);
   var ph = trim($('#req_phone').val(), " ");
   if (ph) {
      ph = encodeURIComponent(ph);
   }
   var pn = trim($('#req_property_name').val(), " ");
   if (pn) {
      pn = encodeURIComponent(pn);
   }         
   pa = encodeURIComponent(pa);
   var st = encodeURIComponent($('#div_crt_option').html());
   var m = trim($('#req_comments').val(), " ");
   if (m) {
      m = m.replace(/\r\n/g, "<br />");
      m = m.replace(/\n/g, "<br />"); // for Firefox
   }

   alert ("Your message has been sent. Thank you.");

   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
	     $('#req_full_name').val('');
		 $('#req_email').val('');
		 $('#req_phone').val('');
		 $('#req_property_name').val('');
		 $('#req_property_address').val('');
		 $('#div_crt_option').html('Residential Strata Management');
		 $('#req_comments').val('');
      }
   }

   var queryString = '?bustcache=' + new Date().getTime();
   queryString = queryString + '&fn=' + fn + '&e=' + e + '&ph=' + ph + '&pn=' + pn + '&pa=' + pa + '&st=' + st + '&m=' + m;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
  
}

function check_contact_form(f) {
   var fn = trim($('#contact_full_name').val(), " ");
   if (!fn) {
      alert ("Please enter Full Name");
	  $('#contact_full_name').focus();
	  return false;
   }
   
   var e = trim($('#contact_email').val(), " ");
   if (!e) {
      alert ("Please enter Email");
	  $('#contact_email').focus();
	  return false;
   }
   else {
      var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
      if (!e.match(mailformat)) {
         alert ("Please enter a valid Email Address.");
         $('#contact_email').focus();
         return false;
      }
   }
      
   var HasValue = "";
   var arr = $('#contact_comments').val().split(/\n/);
   for (i = 0; i < arr.length; i++) {
      var v = trim(arr[i], " ");
	  if (v) {
	     HasValue = "1";
		 break;
	  }
   }
   if (!HasValue) {
      alert ("Please enter Comments");
	  $('#contact_comments').focus();
	  return false;
   }      
   
   if (!$('#g-recaptcha-response').val()) {
      alert ('Bot-check failed, please try again');
      return false;
   }

   fn = encodeURIComponent(fn);
   e = encodeURIComponent(e);
   var s = trim($('#contact_subject').val(), " ");
   if (s) {
      s = encodeURIComponent(s);
   }         
   var m = trim($('#contact_comments').val(), " ");
   if (m) {
      m = m.replace(/\r\n/g, "<br />");
      m = m.replace(/\n/g, "<br />"); // for Firefox
   }
   var ph = trim($('#contact_phone').val(), " ");
   alert ("Your message has been sent. Thank you.");

   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
	     $('#contact_full_name').val('');
		 $('#contact_phone').val('');
		 $('#contact_email').val('');
		 $('#contact_subject').val('');
		 $('#contact_comments').val('');
      }
   }

   var queryString = '?bustcache=' + new Date().getTime();
   queryString = queryString + '&fn=' + fn + '&ph=' + ph + '&e=' + e + '&s=' + s + '&m=' + m;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
  
}

function change_nr_entries (f, v, d, t, o) {
   $('#h_crt_page').val('1');
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
         $('#' + d).html(ajaxRequest.responseText);
      }
   }
   var o = $('#' + o).val();
   if (!o) {
      o = 'property_id';
   }
   var a = $('#h_dir_' + o).val();
   if (!a) {
      a = 'ASC';
   }
   var queryString = '?bustcache=' + new Date().getTime() + '&v=' + v + '&t=' + t + '&o=' + o + '&a=' + a;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function show_properties (f, i, v, d, t, o) {
   var v = $('#' + v).val();
   $('#h_crt_page').val(i);
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4){
//		 alert (ajaxRequest.responseText);
         $('#' + d).html(ajaxRequest.responseText);
      }
   }
   
   var o = $('#' + o).val();
   if (!o) {
      o = 'property_id';
   }
   var a = $('#h_dir_' + o).val();
   if (!a) {
      a = 'ASC';
   }
   var queryString = '?bustcache=' + new Date().getTime() + '&i=' + i + '&v=' + v + '&t=' + t + '&o=' + o + '&a=' + a;
//   alert (queryString);
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function sort_dir (s) {
   $('#h_sort').val(s);
   if (!$('#h_dir_' + s).val()) {
      $('#h_dir_' + s).val('ASC');
   }
   else {
      if ($('#h_dir_' + s).val() == 'ASC') {
         $('#h_dir_' + s).val('DESC');
      }
	  else {
	     $('#h_dir_' + s).val('ASC');
      }
   }
}

function delete_record (f, id1, id2, t, td, d, o, v) {
   var agree = confirm('Are you sure you want to delete this record?');
   if (agree) {
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4) {
			$('#' + d).html(ajaxRequest.responseText);
         }
      }
      var i = $('#h_crt_page').val();   
      var o = $('#' + o).val();
      if (!o) {
         o = 'property_id';
      }
      var a = $('#h_dir_' + o).val();
      if (!a) {
         a = 'ASC';
      }	  
      var v = $('#' + v).val();
      var queryString = '?bustcache=' + new Date().getTime() + '&id1=' + id1 + '&id2=' + id2 + '&t=' + t + '&td=' + td + '&i=' + i + '&o=' + o + '&a=' + a + '&v=' + v;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null); 
   }
}

function search_properties (f, t, d, o, v) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {
	     $('#' + d).html(ajaxRequest.responseText);
      }
   }
   var o = $('#' + o).val();
   if (!o) {
      o = 'property_id';
   }
   var a = $('#h_dir_' + o).val();
   if (!a) {
      a = 'ASC';
   }	  
   var v = $('#' + v).val();
   var queryString = '?bustcache=' + new Date().getTime() + '&t=' + t + '&o=' + o + '&a=' + a + '&v=' + v + '&st=' + $('#search').val();
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null); 
}

function display_sponsors (f, w, g) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {
		 if (ajaxRequest.responseText) {
			$('#div_carousel').width($(window).width() * 0.95 - 250);
			$('#div_carousel').html(ajaxRequest.responseText);
//			alert (ajaxRequest.responseText);
		 }
      }
   }
   
   var queryString = '?bustcache=' + new Date().getTime() + "&w=" + w + "&g=" + g;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);    
}
function show_w() {
   $('#div_w').html($(window).width());
}
function get_user_info (f, id) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {		 
		 if (ajaxRequest.responseText) {
			var r_arr = ajaxRequest.responseText.split("\r\n");
			$('#assigned_user_email').val(r_arr[0]);
			$('#assigned_user_phone').val(r_arr[1]);
		 }
		 else {
		    $('#assigned_user_email').val('');
			$('#assigned_user_phone').val('');
		 }
      }
   }
   
   var queryString = '?bustcache=' + new Date().getTime() + "&id=" + id;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);    
}

function add_unit (f, t) {
   var n = parseInt($('#hnewunits').val());
   $('#hnewunits').val(n + 1);
   n += 1;
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {		 
	     $('#unit_container').append(ajaxRequest.responseText);
      }
   }
   
//   var queryString = '?bustcache=' + new Date().getTime() + '&n=' + n + '&w1=' + $('#div_unit_cell_1').width() + '&w2=' + $('#div_unit_cell_2').width() + '&w3=' + $('#div_unit_cell_3').width() + '&w4=' + $('#div_unit_cell_4').width() + '&w5=' + $('#div_unit_cell_5').width() + '&w6=' + $('#div_unit_cell_6').width() + '&w7=' + $('#div_unit_cell_7').width();
   var queryString = '?bustcache=' + new Date().getTime() + '&n=' + n + '&t=' + t + '&w1=' + $('#div_unit_cell_1').width() + '&w2=' + $('#div_unit_cell_2').width() + '&w3=' + $('#div_unit_cell_3').width() + '&w4=' + $('#div_unit_cell_4').width() + '&w5=' + $('#div_unit_cell_5').width() + '&w6=' + $('#div_unit_cell_6').width();
   if (t == 'residential') {
      queryString += '&w7=' + $('#div_unit_cell_7').width();
   }	   
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);    
}

function delete_row(n, t) {
   if (t == '2') {
      $('#new_del_' + n).parent().parent().parent().empty();
	  $('#new_table_u_descr_' + n).empty();
      var n = parseInt($('#hnewunits').val());
      $('#hnewunits').val(n - 1);	  
   }
   else {
	  $('#hdel_unit_' + n).val('1');
      $('#del_' + n).parent().parent().empty();
	  $('#table_u_descr_' + n).empty();
   }
}

function image_order (f, id1, id2, pid, t) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {		 
	     $('#div_existing_images').html(ajaxRequest.responseText);
      }
   }
   
   var queryString = '?bustcache=' + new Date().getTime() + '&id1=' + id1 + '&id2=' + id2 + '&pid=' + pid + '&t=' + t;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);    
}

function upload_image (f, fc) {
   
//   alert (fc);
   /*
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {		 
	     $('#div_existing_images').html(ajaxRequest.responseText);
      }
   }
   
   var queryString = '?bustcache=' + new Date().getTime() + '&id1=' + id1 + '&id2=' + id2 + '&pid=' + pid + '&t=' + t;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);    
   */
}

function show_profiles(f, w, g) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {		 
	     $('#div_profiles').html(ajaxRequest.responseText);
      }
   }
   
   var queryString = '?bustcache=' + new Date().getTime() + '&w=' + w + '&g=' + g;
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);       
}

function check_property_form(f) {
   var pid = trim($('#property_id').val(), " ");
   if (!pid) {
//      alert ("Please enter Property ID");
	  $('#property_id').focus();
	  return '1';
   }
   else {
      var ajaxRequest;
      try {
         ajaxRequest = new XMLHttpRequest();
      }
      catch (e){
         try {
            ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
         }
         catch (e) {
            try {
               ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e){
               alert('Do something about it !');
               return false;
            }
         }
      }
      ajaxRequest.onreadystatechange = function() {
         if(ajaxRequest.readyState == 4) {
			var res = ajaxRequest.responseText;
	        if (res == '0') {
//			   alert ('ok');
			   return '2';
			}
			else {
//		       alert ("Property ID must be unique");
			   $('#property_id').focus();
			   return '3';
			}
         }
      }

      var queryString = '?bustcache=' + new Date().getTime() + '&pid=' + pid;
      ajaxRequest.open('GET', f + queryString, true);
      ajaxRequest.send(null);
   }
}

function fix_top_nav() {
   var diff = (-1) * ($('#div_warning').offset().top - $(window).scrollTop()) - $('#div_warning').height();
   if (diff <= 0) {
       $('#top_nav_container').removeClass('div_top_nav_fixed');
//       $('#div_content').css('padding-top', '0px')
   }
   else {
      $('#top_nav_container').addClass('div_top_nav_fixed');
//      $('#div_content').css('padding-top', '50px')
   }
}

function switch_gallery_map (t) {
   if (t == "1") {
	  if ($('#properties-thumbs').css('display') == "none") {
         $('#span_1').css('font-weight', 'bold');
	     $('#span_2').css('font-weight', 'normal'); 
	     $('#div_google_map').slideUp();
	     $('#properties-thumbs').slideDown(); 
	     $('#div_thumbs').slideDown();   
	  }
   }	
   else {
	  if ($('#div_google_map').css('display') == "none") {
         $('#span_1').css('font-weight', 'normal');
	     $('#span_2').css('font-weight', 'bold');
	     $('#properties-thumbs').slideUp(); 
	     $('#div_thumbs').slideUp();   
	     $('#div_google_map').slideDown();
	  }
   }	
}	

function fill_forms_page(f, w, t, fv) {
   var ajaxRequest;
   try {
      ajaxRequest = new XMLHttpRequest();
   }
   catch (e){
      try {
         ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
      }
      catch (e) {
         try {
            ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
         }
         catch (e){
            alert('Do something about it !');
            return false;
         }
      }
   }
   ajaxRequest.onreadystatechange = function() {
      if(ajaxRequest.readyState == 4) {
         var res = ajaxRequest.responseText;
		 if (ajaxRequest.responseText) {
			if (fv == '1') {
		       $('#div_forms').html(ajaxRequest.responseText);
			   fill_forms_page(f, w, t, '2');
			}
			else {
			   $('#div_vendors').html(ajaxRequest.responseText);
			}
         }
      }
   }

   var queryString = '?bustcache=' + new Date().getTime() + '&w=' + w + '&fv=' + fv;
   if (t) {
      queryString += '&t=' + t;
   }
   ajaxRequest.open('GET', f + queryString, true);
   ajaxRequest.send(null);
}

function adjust_home_page() {
   if ($(window).width() < 640) {
      var d = Math.round(($(window).width() * 0.85 - $('#img_award_1').width()) / 2);
	  var d2 = Math.round(($(window).width() * 0.8 - $('#img_award_1').width()) / 2) - 20;
	  $('.img_award_1').css('padding-left', d + 'px');
	  $('.text_award_1').css('padding-left', d2 + 'px');
	  var d = Math.round(($(window).width() * 0.85 - $('#img_award_2').width()) / 2);
	  var d2 = Math.round(($(window).width() * 0.8 - $('#img_award_2').width()) / 2) - 20;
	  $('.img_award_2').css('padding-left', d + 'px');
	  $('.text_award_2').css('padding-left', d2 + 'px');			 
	  var d = Math.round(($(window).width() * 0.85 - $('#img_award_3').width()) / 2);
	  var d2 = Math.round(($(window).width() * 0.8 - $('#img_award_3').width()) / 2);
	  $('.img_award_3').css('padding-left', d + 'px');
	  $('.text_award_3').css('padding-left', d2 + 'px');			 
	  var d = Math.round(($(window).width() * 0.85 - $('#img_award_4').width()) / 2);
	  var d2 = Math.round(($(window).width() * 0.8 - $('#img_award_4').width()) / 2) + 5;
	  $('.img_award_4').css('padding-left', d + 'px');
	  $('.text_award_4').css('padding-left', d2 + 'px');			 
	  var d = Math.round(($(window).width() * 0.85 - $('#img_award_5').width()) / 2);
	  var d2 = Math.round(($(window).width() * 0.8 - $('#img_award_5').width()) / 2) + 20;
	  $('.img_award_5').css('padding-left', d + 'px');
	  $('.text_award_5').css('padding-left', d2 + 'px');			 
   }
   else {
      $('.img_award_1').css('padding-left', '35px');
	  $('.text_award_1').css('padding-left', '0px');		 
	  $('.img_award_2').css('padding-left', '25px');
	  $('.text_award_2').css('padding-left', '0px');
	  $('.img_award_3').css('padding-left', '10px');
	  $('.text_award_3').css('padding-left', '0px');
	  $('.img_award_4').css('padding-left', '10px');
	  $('.text_award_4').css('padding-left', '0px');
	  $('.img_award_5').css('padding-left', '10px');
	  $('.text_award_5').css('padding-left', '0px');
   }
/*
   if ($(window).width() > 640) {
      $('#div_home_banner').height($(window).height() - 227);		    
   }
   else {
      $('#div_home_banner').height($(window).width() * 585 / 640);		    
   }
*/   
   $('#keywords_2').width($('#keywords_1').width());
   if ($(window).width() > 1400) {
      if ($('#div_home_search_1').height() > $('#div_home_search_2').height()) {
         $('#div_home_search_2').height($('#div_home_search_1').height())	
      }
      else {
         $('#div_home_search_1').height($('#div_home_search_2').height());
      }
   }
   else {
      $('#div_home_search_1').css('height','auto'); 	 
      $('#div_home_search_2').css('height','auto'); 	 
   }
   
   if ($(window).width() > 751) {
      $('.div_home_page_service_image').width(($(window).width() - 10) / 5);
      $('.div_home_page_service_image').height($('.div_home_page_service_image').width() * 530 / 578);
   }
   else {
	  if ($(window).width() > 500) {
         $('.div_home_page_service_image').width(378);
         $('.div_home_page_service_image').height(348);
      }
	  else {
         $('.div_home_page_service_image').width($(window).width() - 2);
         $('.div_home_page_service_image').height($('.div_home_page_service_image').width() * 530 / 578);
	  }
   }
   
   $('.div_home_page_service_image').hover(function() {
      var id = $(this).prop('id').replace(/div_home_page_service_image_/, 'div_home_page_service_caption_');
	  $('#' + id).stop().fadeIn();
   },
   function(){
      var id = $(this).prop('id').replace(/div_home_page_service_image_/, 'div_home_page_service_caption_');
	  $('#' + id).stop().fadeOut();
   });
   
}
function adjust_top_footer () {
   var tnl = Math.round($('#top_nav').position().left);
   if (tnl > 100) {
      var npl = Math.round((tnl - 100) / 2);
   }
   else {
      if ($(window).width() > 768) {
         var npl = 0;
		 
	  }
	  else {
	     var npl = 20;
	  }
   }
   var npt = npl + 100;
   var npt = npl;
   //alert (npl + ' - ' + $('#text_1_container').css('padding-left'));
   $('#top_logo').css('padding-left', npl + 'px');
   $('#text_1_container').css('padding-left', npt + 'px');
   //alert ($('#text_1_container').css('padding-left'));
   if ($(window).height() >= 670) {
      $('.div_scroll_3').height(600);
   }
   else {
      $('.div_scroll_3').height($(window).height() - 70);
   }
   if ($(window).width() >= 1169) {
      $('.google_map').width(500);
	  $('.google_map').height(250);
   }
   else {
      if ($(window).width() > 750) {
	     $('.google_map').width(500 * $(window).width() / 1169);
		 $('.google_map').height($('.google_map').width() / 2);
	  }
	  else {
	     $('.google_map').width($(window).width() * 0.8);
		 $('.google_map').height($('.google_map').width() / 2);
	  }
   }
}

function keydown_1 () {
   $('#keywords_1').keydown( function( event ) {
      if ( event.which === 13 ) {
         $('#form1').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('#keywords_2').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_1').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form1').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_2').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_3').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form1').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_4').keydown( function( event ) {
      if ( event.which === 13 ) {
         $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });
   $('.cb_5').keydown( function( event ) {
      if ( event.which === 13 ) {
         $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });		  
}

function keydown_2 () {
   $('#keywords_2').keydown( function( event ) {
      if ( event.which === 13 ) {
         $('#form1').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('#keywords_3').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_5').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form1').submit();
         event.preventDefault();
         return false;
      }
   });		  
   $('.cb_7').keydown( function( event ) {
      if ( event.which === 13 ) {
	     $('#form2').submit();
         event.preventDefault();
         return false;
      }
   });	
}

function adjust_property_page () {
   if ($(window).width() < 820) {
      $('#div_prop_info').width($(window).width() - 240);
   }
   else {
      $('#div_prop_info').width('auto');
   }
   $('#hdpi_w').val($('#div_prop_info').width());
   
   if ($(window).width() >= 960) {
      $('.google_map3').width(667);
	  $('.google_map3').height(500);
   }
   else {
      if ($(window).width() > 900) {
         $('.google_map3').width(667 * $(window).width() / 960);
		 $('.google_map3').height($('.google_map3').width() * 500 / 667);
	  }
	  else {
	     $('.google_map3').width($(window).width() * 0.8);
		 $('.google_map3').height($('.google_map3').width() * 500 / 667);
      }
   }
   
   var l = $(window).width() - $('#div_property_right_container').width() - 50;
   var t = Math.round($('#div_property_pics').position().top) + 30;   
   $('#div_property_right_container').css('top', t + 'px');
   $('#div_property_right_container').css('left', l + 'px');   
}

function scroll_property_page() {
   if ($(window).width() > 820) {
      var scroll = Math.round($(window).scrollTop());
      var property_right_h = Math.round($('#div_prc4').position().top) - 1;
      var diff = property_right_h - scroll;
	  
      if (diff < 200) {
	     var property_left_h = Math.round($('#div_prop_info').position().top) - 1;
	     var diff2 = scroll - $('#div_prop_info').height();		 
         $('#div_property_right_container4').css('position', 'fixed');
         $('#div_prop_info').width($('#hdpi_w').val());
	     if (diff2 < 200) {
            $('#div_property_right_container4').css('top', '200px');	
	     }   	  
	     else {
		    var diff3 = diff2 - 200;
            var diff4 = 200 - diff3;
		    if (diff4 > 0) {
               $('#div_property_right_container4').css('top', diff4 + 'px');	
		    }
		    else {
		       $('#div_property_right_container4').css('top', 0);
		    }
	     }
      }
      else {
         $('#div_property_right_container4').css('position', 'static');	
      }	  
   }
}

function adjust_about_page() {
   $('#div_about_banner').width($(window).width());
   $('#div_about_banner').height($(window).width() * 553 / 1555);
   if (($(window).width() > 1049) && ($(window).width() < 1400)) {
      var pw = Math.round($(window).width() * 273 / 1400);
	  var hw = Math.round(pw * 356 / 273);
	  $('.div_gallery_9').width(pw);
   }
   else {
      $('.div_gallery_9').width(273);
   }
   if ($(window).width() > 640) {
      $('.div_gallery_1').width($(window).width() / 4 - 8);
	  $('.div_gallery_1').height($('.div_gallery_1').width());
	  $('.div_gallery_2').width($('.div_gallery_1').width());
	  $('.div_gallery_2').height($('.div_gallery_1').height());
	  $('.div_gallery_3').width($('.div_gallery_1').width());
	  $('.div_gallery_3').height($('.div_gallery_1').height());
   }
   else {
      $('.div_gallery_1').width($(window).width() / 2 - 4);
	  $('.div_gallery_1').height($('.div_gallery_1').width());
	  $('.div_gallery_2').width($('.div_gallery_1').width());
	  $('.div_gallery_2').height($('.div_gallery_1').height());
	  $('.div_gallery_3').width($('.div_gallery_1').width());
	  $('.div_gallery_3').height($('.div_gallery_1').height());
   }	
}

function adjust_contact_page() {
   if ($(window).width() >= 1175) {
      $('.google_map2').width(500);
	  $('.google_map2').height(375);
   }
   else {
      if ($(window).width() > 790) {
	     $('.google_map2').width(500 * $(window).width() / 1175);
		 $('.google_map2').height($('.google_map2').width() * 375 / 500);
	  }
	  else {
	     $('.google_map2').width($(window).width() * 0.8);
		 $('.google_map2').height($('.google_map2').width() * 375 / 500);
	  }
   }
   if (($(window).width() < 820) && ($(window).width() > 670)) {
	  var mt =1.4 * (450 - parseInt($(window).width() * 45 / 82, 10));
      $('#div_content_contact').css('margin-top', '-' + mt + 'px');
   }
   else {
      if ($(window).width() <= 670) {
	     $('#div_content_contact').css('margin-top', '-117px');
	  }
	  else {
	     $('#div_content_contact').css('margin-top', '0');
	  }
   }   
}	

function adjust_services_page() {
   if ($(window).width() > 500) {
      $('.div_gallery_11').width($(window).width() / 5);
	  $('.div_gallery_11').height($('.div_gallery_11').width());
	  $('.div_gallery_12').width($(window).width() / 5 - 47);
	  $('#div_services_img_1').width($('#div_service_1').width() / 2);
	  $('#div_services_img_1').height($('#div_services_img_1').width() * 488 / 492);
	  $('.div_services_img_i').width($('#div_services_img_1').width());
  	  $('.div_services_img_i').height($('#div_services_img_1').height());
   }
   else {
      $('.div_gallery_11').width($(window).width());
	  $('.div_gallery_11').height($('.div_gallery_11').width());
	  $('.div_gallery_12').width($(window).width() - 47);
	  $('.div_services_img').width($(window).width());
	  $('.div_services_img').height($('.div_services_img').width() * 700 / 979);
      for (i = 1; i <= 5; i++) {
	     $('#div_services_text_' + i).css('padding-top', '30px');
		 $('#div_services_text_' + i).css('padding-bottom', '30px');
	  }
   }
   $('.div_gallery_12').height($('.div_gallery_12').width());
   $('.div_gallery_12').height($('.div_gallery_12').width());
		 
   if ($(window).width() > 620) {
      $('.div_gallery_13').width($(window).width() / 5);
   }
   else {
      $('.div_gallery_13').width($(window).width());
   }
}

function show_hide_dd() {
   if ($('#div_service_options_container').css('visibility') == 'hidden') {
      $('#div_service_options_container').css('visibility','visible');
   }
   else {
      $('#div_service_options_container').css('visibility','hidden');
   }
}

function fill_dd (d) {
   $('#div_crt_option').html($('#' + d).html());
   $('#div_service_options_container').css('visibility','hidden');
}

function delete_user_account (user_id, url) {
   var agree = confirm('Are you sure you want to delete this record?');
   if (agree) {
      window.location.href = url;
   }
}

function adjust_request_page () {
   if (($(window).width() < 1035) && ($(window).width() > 670)) {
	 var mt = 1.5 * (450 - parseInt($(window).width() * 450 / 1035, 10));
     $('#div_content_request').css('margin-top', '-' + mt + 'px');
   }
   else {
      if ($(window).width() <= 670) {
	     $('#div_content_request').css('margin-top', '-239px');
	  }
	  else {
	     $('#div_content_request').css('margin-top', '0');
	  }
   }
}

function check_assigned_user_form() {
   var n = trim($('#name').val(), " ");
   if (!n) {
      alert ("Please enter Name");
	  return false;
   }
   return true;
}
function scroll_listings_page () {
   $('.div_property_2').each(function() {
      var id = $(this).prop('id').replace(/div_property_2_/, 'div_property_3_');
      if ($('#' + id).css('display') == "none") {
         var scr = Math.round($(window).scrollTop());
	     var diff = Math.round($(this).position().top) - scr;
	     if (diff < 595) {
	        $('#' + id).fadeIn();
		 }
      }
   })
}