function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

var p = getQuerystring('propertyid');

$().ready(function(){   
    setInterval("checkAnchor()", 300);   
});   
  
//References   
var loading = $("#assocproploading");   
var content = $("#assocpropcontent");   
var pageNum;   
var currentAnchor = null;   
  
//show loading bar   
function showLoading(){   
    content.hide();
	loading.show(); 
	
}   
//hide loading bar   
function hideLoading(){   
    loading.hide();
	content.show();
};   
  
function checkAnchor(){   
    //Check if it has changes   
    if(currentAnchor != document.location.hash){   
        currentAnchor = document.location.hash;   
        //if there is not anchor, the loads the default section   
        if(!currentAnchor) {   
            //default - page = 1   
            pageNum = 1;   
        }   
        else {   
            //get the page number after #   
            pageNum = currentAnchor.substring(1);   
        }   
        //Send the request and display the result   
        showLoading();   
        var targetUrl = "ajax/assocprop.php?propertyid="+p+"&page="+pageNum;   
        content.load(targetUrl, hideLoading);   
    }   
} 
