var isOnLoad = true;
isAjaxDellCrossDomain = true;
var strWSRegion = 'ATA';

function initializeWS() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(handleHistoryChange);
	var initialLocation = dhtmlHistory.getCurrentLocation();
		isOnLoad = false;
	if (dhtmlHistory.isFirstLoad() == true) {
		WeeklySpecials.initWeeklySpecials(strWSRegion, 1,  1);	
	} else {
		if (initialLocation == null || initialLocation == '' ) {
			history.forward();
		}
	}		
}

function handleHistoryChange(newLocation, historyData) {
	updateUI(newLocation, historyData);                           
}

function updateUI(newLocation, historyData) {
	var pageValue = 1;
	var pageTitle = 0;
	var pageNum = newLocation.split(":")
	if ( pageNum[pageTitle]== "batch") {
		WeeklySpecials.getWeeklySpecials(strWSRegion, parseInt(pageNum[pageValue]), parseInt(pageNum[pageValue]));
		if (isOnLoad == true) {
			isOnLoad = false;			
		} 
	} else {
			if (isOnLoad == false)	history.back();
	}	
}

window.onload = initializeWS;
