function loadSection(content, inside){
	if(inside){
		var p = {
			cnt: content
			};
		var h = $H(p);
		var myAjax = new Ajax.Updater({success: 'content'}, 'content.jsp', {evalScripts:true, parameters: h.toQueryString(), onComplete:showResponse});
	}else{
		this.location.href = url + '.html';
	}
}

function loadCatalogo(cdcatalogo){
	var p = {
		cdcatalogo: cdcatalogo
		};
	var h = $H(p);
	var myAjax = new Ajax.Updater({success: 'content'}, 'catalogo.jsp', {evalScripts:true, parameters: h.toQueryString(), onComplete:showResponse, onFailure: reportError});
}


function updateList(type, pars, nextPage, currentPage){

    if(nextPage!=null){
            var tmp = new Object();
            tmp['nextPageRic'] = nextPage;
            h=h.merge(tmp);	
    }	
    if(currentPage!=null){
            var tmp = new Object();
            tmp['current_page'] = currentPage;
            h=h.merge(tmp);	
    }

    var myAjax = new Ajax.Updater({success: 'center'}, 'catalogo_'+type+'.jsp', {evalScripts:true, parameters: pars.toQueryString(), onComplete:showResponse, onFailure: reportError});

}

function updateArt(pars){

    var myAjax = new Ajax.Updater({success: 'center'}, 'scheda.jsp', {evalScripts:true, parameters: pars.toQueryString(), onComplete:showSchedaArt, onFailure: reportError});

}

function updateContent(page, pars){

    var myAjax = new Ajax.Updater({success: 'center'}, page, {evalScripts:true, parameters: pars.toQueryString(), onFailure: reportError});

}

function showResponse(originalRequest){
	if(originalRequest.responseText.length == 0)
		alert("Error getting page!");	
		
	closePrototypeCnt();		
}

function showSchedaArt(originalRequest){
	if(originalRequest.responseText.length == 0)
		alert("Error getting page!");	

	tabberAutomatic(tabberOptions);
	
	closePrototypeCnt();

}

function reportError(request){
	alert('Sorry. There was an error.');
	alert(request.responseText)
}

function updateMenu(idToOn, idToOff){
    if($(idToOff+'-on')){$(idToOff+'-on').id = idToOff;}
    if($(idToOn)){$(idToOn).id = idToOn+'-on'};
}

function loadScheda(cd) {
	//updateArt($H({r_cdtipmc_m: cdtipmc}));
	updateList('lista', $H({r_cdgptipm_m: cd}));
	updateMenu('pr','ar');	
}

var tabberOptions = {

  'manualStartup':true 
  }
