var home = 
{
    urlIsReady:Boolean(true),
    urlIsNewWindow:Boolean(),
    urlTarget:String(),
    
    openUrl:function(url, isNewWindow) {
        home.urlIsNewWindow = (isNewWindow == "1");
	    home.urlTarget = url;

		//... Check if a home content id is specified
        var idContent = home.getHomeContentId();
        
        if(idContent == "-1")
        {
            //... No home content id specified, just open the url
            home.displayUrl();
            return;
        }
        
        //... Add 1 to clicks
	    if(!home.urlIsReady) return;
	    home.urlIsReady = false;

		//... Add a time parameter to avoid browser's cache
		var myDate = new Date();
		
	    var myAjax = new Ajax("/ajax/HomeClicks.aspx?contentid=" + idContent + "&bidon=" + myDate.getTime(), {onComplete : home.displayUrl, method: 'get'}).request();
	},
	
	displayUrl:function() {
	    if(home.urlIsNewWindow)
	    {
	        window.open(home.urlTarget, "homeTarget");
	    }
	    else
	    {
	        top.document.location.href = home.urlTarget;
	    }
	    
	    home.urlIsReady = true;
	},
	
	getHomeContentId:function() {
	    var input = document.getElementById("hfContentId");
	    if(!input) return "-1";
	    
	    return input.value;
	}
}
