function doGetDropdown(type, stateid) {
	$('#'+type+'dropdown').load('/?cdnRequest=1&stateid='+stateid).fadeIn('slow');
}
function doSend(cityid) {
	$.ajax({ type: "GET", url: "/?cnameRequest=1", data: "&cityid="+cityid, 
		success: function(cityurl) {
			if(cityurl) { window.location = cityurl; } else { return; }
		}	
	})
}
function showBlogTab() { clearTabs(); $('#pbBlog').fadeIn(); $('#pbBlogLink').addClass('active'); } 
function showRealEstateTab() { clearTabs(); $('#pbRealEstate').fadeIn(); $('#pbRealEstateLink').addClass('active'); } 
function showLuxuryTab() { clearTabs(); $('#pbLuxury').fadeIn(); $('#pbLuxuryLink').addClass('active'); } 
function clearTabs() {
	$('#pbRealEstate').hide();
	$('#pbRealEstateLink').removeClass('active');
	$('#pbLuxury').hide();
	$('#pbLuxuryLink').removeClass('active');
	$('#pbBlog').hide();
	$('#pbBlogLink').removeClass('active');
}
function blowUpImage(spanId) {
	if(document.getElementById("bigImage"+spanId).style.display == "block") {
		$('#bigImage'+spanId).fadeOut('slow');
		document.getElementById("bigImage"+spanId).style.display = "none";
	} else {
		$('#bigImage'+spanId).fadeIn('slow');
		document.getElementById("bigImage"+spanId).style.display = "block";
	}
}
function showAllRemarks(start,end) {
	var curr = start;
	while(curr <= end) {
		if( $('#remark-'+curr).css('display') == 'none' ) {
			$('#remark-'+curr).fadeIn('350').css('display','block');
		} else {
			$('#remark-'+curr).fadeOut('350').css('display','none');
		}
		curr++;
	}
}
function runBlink(where,setfocus) { var blinkCount = 2*3; do { $(where)['fade'+(blinkCount%2==0?'Out':'In')]('fast'); } while (--blinkCount); if(setfocus) setTimeout("setFocus('"+setfocus+"')",2000); }
function setFocus(element) { $(element).focus_first(); }
$.fn.focus_first = function() {
  var elem = $('input:visible', this).get(0);
  var select = $('select:visible', this).get(0);
  if (select && elem) {
    if (select.offsetTop < elem.offsetTop) {
      elem = select;
    }
  }
  var textarea = $('textarea:visible', this).get(0);
  if (textarea && elem) {
    if (textarea.offsetTop < elem.offsetTop) {
      elem = textarea;
    }
  }
  
  if (elem) {
    elem.focus();
  }
  return this;
}
function clickReply() { 
	if($('#postReplyForm').css('display') == 'none') {
		$('#postCommentForm').fadeOut('slow').css('display','none');
		$('#postReplyForm').fadeIn('slow').css('display','block');
		$('#clickReply').removeClass('inactiveFormButton');
		$('#clickReply').addClass('activeFormButton');
		$('#clickNewComment').addClass('inactiveFormButton');
		$('#clickNewComment').removeClass('activeFormButton');
	}
}
function clickNewComment() { 
	if($('#postCommentForm').css('display') == 'none') {
		$('#postReplyForm').fadeOut('slow').css('display','none');
		$('#postCommentForm').fadeIn('slow').css('display','block');
		$('#clickReply').addClass('inactiveFormButton');
		$('#clickReply').removeClass('activeFormButton');
		$('#clickNewComment').removeClass('inactiveFormButton');
		$('#clickNewComment').addClass('activeFormButton');
	}
}