function initializeLandingPage() {



        // other browsers just work
		//var ieRedirect = false;
        if( isIE() || isSafariOnWindows() ){
                // read and immediately clear out the cookie
                var currentCID = readCIDCookie();
                clearCIDCookie();
                // make sure there a value
                if( currentCID ){
                         var newURL = window.location.href ;
                         // we need this check - otherwise we might continually loop back to the landing page on setting the location below
                         if( newURL.indexOf( 'cid' ) == -1 ){
                                // need to tack on the cid for seam
                                newURL = newURL +'?cid='+ currentCID ;
								//ieRedirect = true;
                                window.location.replace( newURL );
                         }
                }
        }



	//Initialize the DealerLocater; only present on the Landing Page
	var pageConversationId = getConversationIdForCurrentPage();
	dlctrComponent = new DLCTRComponent();
	dlctrComponent.init(pageConversationId);
	dlctrComponent.synchronize();

    if (document.getElementById('displayIfScript') != null){
            document.getElementById('displayIfScript').style.display='block';
    }




	//be sure that dropdowns are enabled correctly
	ymmoComponent.disableYMMO();
	ymmoComponent.enableYMMO();
	if (ymmoComponent.isOptionSelected()) {
		dlctrComponent.disableSelections();
		dlctrComponent.enableSelections("state/miles");
	}
}

/**
 * Function to validate that both YMMO and DLRLCTR selections are made on the landing page
 * prior to DLR form submission
 */
function validateLandingPageSelections() {
	return (!ymmoComponent.validateFindTireButton() || !dlctrComponent.validateShowLocationsButton());
}

/**
 * Function to display the location search panel
 */
function showLocationSearchPanel(searchType) {
	var locationSearchPanel = document.getElementById("DLR:locationSearch");
	if (locationSearchPanel) {
		//have to show the panel before clearing due to Opera bug - Opera
		//will not reset selectIndex on a hidden select list
		locationSearchPanel.style.display = "block";
		dlctrComponent.reinitializeCityStateDropdowns();
		dlctrComponent.reinitializeZipCodeSearch();
		if ("zipCode" == searchType) {
			dlctrComponent.showZipSearch();
		} else {
			dlctrComponent.showCityStateSearch();
		}
		//reset the state of the components
		dlctrComponent.disableSelections();
		dlctrComponent.enableSelections("state/miles");
	}
}


/**
 * Function to hide the location search panel
 */
function hideLocationSearchPanel() {
	var locationSearchPanel = document.getElementById("DLR:locationSearch");

	//reinitialize city/state & zip code select lists prior to hiding to work around
	//Opera bug
	dlctrComponent.reinitializeCityStateDropdowns();
	dlctrComponent.reinitializeZipCodeSearch();
	//set the state of dropdowns prior to hiding - work around for Opera not
	//initializing the YMMO lists before executing the page onload event change
	if (isOpera()) {
		//reset the state of the components
		dlctrComponent.disableSelections();
		dlctrComponent.enableSelections("state/miles");
	}
	if (locationSearchPanel) {
		locationSearchPanel.style.display = "none";
	}
}

/**
 * Create a cookie
 * @param {Object} name
 * @param {Object} value
 * @param {Object} days
 */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+encodeURIComponent(value)+expires+"; path=/";
}

/**
 * Read a cookie
 * @param {Object} name
 */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return decodeURIComponent(c.substring(nameEQ.length,c.length));
	}
	return null;
}

/**
 * Expire an existing cookie
 * @param {Object} name
 */
function expireCookie(name) {
	createCookie(name,"",-1);
}

/*
 * Add non-function code here so we don't have to pick through the entire file
 */

//special initialization for landing page
addLoadEvent(initializeLandingPage);

//wrap the onclick event for the "Location Search" button to ensure validation is chained into
//the A4J-generated onclick event
addLoadEvent(function(){
	wrapOnClickEvent("DLR:findLocations", validateLandingPageSelections)
});


