var mapFrame = $('mapFrame');
if (mapFrame) {
    mapFrame.style.backgroundColor = '#f7f7ed';
    mapFrame.style.position = 'absolute';
    mapFrame.style.width = '524px';
    mapFrame.style.height = '610px';
    mapFrame.style.display = 'none';
    mapFrame.style.zIndex = '9940';
}

var coverDiv = $('coverDiv');
if (coverDiv) {
    coverDiv.style.display = 'none';
    coverDiv.style.position = 'absolute';
    coverDiv.style.top = '0';
    coverDiv.style.left = '0';
    coverDiv.style.width = '100%';
    coverDiv.style.height = '100%';
    coverDiv.style.backgroundColor = '#000';
    coverDiv.style.opacity = '0.4';
    coverDiv.style.filter = 'alpha( opacity = 40 )';
    coverDiv.style.zIndex = '9920';
}

function showState() {
    var state = $F('stateAbbreviation');
    if (!state.empty()) {
        document.location.href = '#' + state;
    }
}

function getDirections(dealerId) {
    self.scrollTo(0, 0);
    if ($('div100000621')) {
        $('div100000621').style.display = 'none';
    }
    coverDiv.style.width = document.body.clientWidth + 'px';
    coverDiv.style.height = document.body.clientHeight + 'px';
    coverDiv.style.display = 'block';

    mapFrame.src = 'cabinet-store-map.asp?showroomId=' + dealerId;
    mapFrame.style.display = 'block';

    var viewportSize = getViewportSize();
    mapFrame.style.top = (viewportSize[1] - mapFrame.scrollHeight) / 2 + 'px';
    mapFrame.style.left = (viewportSize[0] - mapFrame.scrollWidth) / 2 + 'px';

    mapFrame.style.display = 'block';
}

function closeMap() {
    mapFrame.style.display = 'none';
    coverDiv.style.display = 'none';
    if ($('div100000621')) {
        $('div100000621').style.display = 'block';
    }
}

function getViewportSize() {
    var size = [0, 0];

    if (typeof window.innerWidth != 'undefined') {
        size = [
                window.innerWidth,
                window.innerHeight
                ];
    }
    else if (typeof document.documentElement != 'undefined'
            && typeof document.documentElement.clientWidth !=
               'undefined' && document.documentElement.clientWidth != 0) {
        size = [
                document.documentElement.clientWidth,
                document.documentElement.clientHeight
                ];
    } else {
        size = [
                document.getElementsByTagName('body')[0].clientWidth,
                document.getElementsByTagName('body')[0].clientHeight
                ];
    }

    return size;
}

function trackCustomLink(linkType, linkName, myEvent){
		s=s_gi(s_account);
		s.linkTrackVars='events';
		if(myEvent!=null && myEvent!=''){
			s.linkTrackEvents=myEvent;
			s.events=myEvent;
		}
     	s.tl(true,'o',linkType + ": " + linkName);
		s.events="";s.linkTrackEvents="";
}

