if (typeof ajaxCall == 'undefined') {
    var ajaxCall = new function() {
    };
}

ajaxCall.GetSiteMapHtml = function(aspPageUrl, topicID, clbk_suss, clbk_fail) {
	var url = window.WebVirtualRoot + 'WcmsLibrary/AspSiteMap.aspx';
	var data = { '__ajaxmethod': 'wcmslibrary_aspsitemap_aspx.GetSiteMapHtml',
		'aspPageUrl': aspPageUrl
	};
	if (topicID != null) {
		data['sitemapTopicID'] = topicID;
	}
	jQuery.ajax({ type: 'POST', url: url, data: data, dataType: 'text', ifModified: false, async: true,
		success: function(res) {
			try {
				var val = eval('(' + res + ')')
			} catch (e) {
				alert('inner error:' + e.message);
			}
			if (val.Error == null) {
				if (typeof clbk_suss == 'function') clbk_suss.call(this, val.Value);
			} else {
				if (typeof clbk_fail == 'function') clbk_fail.call(this, val.Error);
			}
			return val.Value;
		}
	});
};

$.sitemap = function(pathandquery) {
	if (location.href.toLowerCase().indexOf('portaltop.asp') != -1) return;
	try { if ($.isInIframe()) return; } catch (e) { return true; }
	ajaxCall.GetSiteMapHtml(pathandquery, window.SitemapTopicID, function(siteMapElem) {
		if (window.top.frames['topframe'] != null) {
			var sSitemapHtml = $(siteMapElem).clone().show().html();
			if (sSitemapHtml== "") {
				return;
			}
			if ($.browser.msie) {
				$('#mainPart', window.top.frames['topframe'].document)[0].innerHTML = sSitemapHtml ;
				$('#subPart', window.top.frames['topframe'].document)[0].innerHTML = '';
			} else {
				$('#mainPart', window.top.frames['topframe'].document).html(sSitemapHtml);
				$('#subPart', window.top.frames['topframe'].document).html('');
			}
      $('#mainPart', window.top.frames['topframe'].document).find('a')
        .attr('target', 'display');			
		}
	}, function(err) {
		//alert(err.Message);
	})
}

$.sitemap(location.pathname + location.search);