// load dependent scripts
loadScript('/Specific/basefcts.js');


function ajaxLoadProductListingCompleted(container, ajaxResponse)
{
	// remove container previous nodes
	clearAllChildren(container);
	
	// create new div element
	var dv = document.createElement('div');
	dv.className = 'center_ajax_wrap';	
	dv.innerHTML = ajaxResponse;

	// append div to container
	container.appendChild(dv);
}

function ajaxLoadProductListing(productTypeId, pageNumber)
{
	// make ajax params
	var ajaxParameters = "listing_" + productTypeId; 
	
	// set to history	
	if (document.ajaxNavFrames)
	{
		// set ajax ifreme
		document.getElementById('ajaxnav').src = 'empty.aspx?ajaxParameters=' + ajaxParameters;
	}
	else
	{
		// update location
		document.location = '#' + ajaxParameters
	}
}

function ajaxLoadProductListing_Auto(productTypeId, pageNumber)
{
    // check container
    var container = document.getElementById('home_content_ajax_container');
    if (null == container) {return; }
    
    // remove container previous nodes
	clearAllChildren(container);
    
    // load image loading
    //loadHomeLoadingImage(container);
    
    // get current date
    var curDate = new Date();
    
    var tempProductTypeId = parseInt(productTypeId, 10);
    if (isNaN(tempProductTypeId))
    {
		tempProductTypeId = 0;
    }
    
    var tempPageNumber = parseInt(pageNumber, 10);
    if (isNaN(tempPageNumber))
    {
		tempPageNumber = 0;
    }

    // set params
    var url = '/home';
    url += '/default.aspx';
    url += '?ajax_root_ctrl_name=ctrl_product_listing_divisions_pagination_ajax';
    url += '&page_number=' + tempPageNumber;
    url += '&producttype_id=' + tempProductTypeId;
    url += '&justToBeDifferent=' + curDate.getTime();
    
    // call ajax
    executeAjaxRequest(url, container, ajaxLoadProductListingCompleted);
}
