var SURVEY_IS_INTERNAL_LINK_CLICKED = false;
function makeFrame(loc) {
} 

$(document).ready(function() {
   ifrm = $('<iframe>').attr({
	   'src': 'empty.html?1',
	   'name': 'history_track',
	   'style': 'display: none',
   });
   ifrm.appendTo(document.body);
   setTimeout(function () {
	   ifrm.attr('src', 'empty.html?2');
   }, 1000);
	setInterval(function() {
		if (window.frames['history_track'].location.search == '?2') {
			var interval = setInterval(function() {
				if (window.frames['history_track'].location.search == '?1') {
					window.onbeforeunload = function () {};
					history.back();
					clearInterval(interval);
				}
		   }, 100);
		}
	}, 100);
    $("body").append('<div id="survey_dialog" style="display:none; width:100%;"></div>');
    $('a').live('click', function() {
        SURVEY_IS_INTERNAL_LINK_CLICKED = true;
    });
    window.onbeforeunload = function(evt) {
        if (!SURVEY_IS_INTERNAL_LINK_CLICKED) {
            $('#survey_dialog').append('<iframe src="' + SURVEY_URL + '" width="100%" height="100%" style="border:none;"></iframe>');
            var message = SURVEY_MESSAGE_TEXT;
            evt = (typeof evt == 'undefined')?window.event:evt;
            evt ? evt.returnValue = message:null;
            $("#survey_dialog").dialog({modal: true, height: 500, width: 1000, show: 'slide'});
            return message;
        }
    };
});
