//<script>
$(function(){
    $.preloadImages(
        '/images/icon_close.gif'
      , '/images/box/f_tl.png'
      , '/images/box/f_t.png'
      , '/images/box/f_tr.png'
      , '/images/box/f_l.png'
      , '/images/box/f_r.png'
      , '/images/box/f_bl.png'
      , '/images/box/f_b.png'
      , '/images/box/f_br.png'
      , '/images/ajax-loader.gif'
      , '/images/feedback/feed_-2.gif'
      , '/images/feedback/feed_-1.gif'
      , '/images/feedback/feed_0.gif'
      , '/images/feedback/feed_+1.gif'
      , '/images/feedback/feed_+2.gif'
    );
});

var popup = '' +
            '  <table cellpadding="0" cellspacing="0" border="0" class="iePNG">' +
            '    <tr>' +
            '      <td width="20"><img src="/images/box/f_tl.png" alt="" width="20" height="20" /></td><td height="20" style="background: url(/images/box/f_t.png);" class="iePNG"></td><td width="20"><img src="/images/box/f_tr.png" alt="" width="20" height="20" /></td>' +
            '    </tr>' +
            '    <tr>' +
            '      <td width="20" style="background: url(/images/box/f_l.png); height:100px;" class="iePNG">&nbsp;</td>' +
            '      <td style="background:#fff;" valign="top">' +
            '        <table width="100%" cellspacing="0" cellpadding="0" border="0">' +
            '          <tr>' +
            '            <td valign="top" height="35"><div id="popupTitle"><h2>Feedback</h2></div></td>' +
            '            <td valign="top" width="16" align="right"><img src="/images/icon_close.gif" alt="X" title="Close" style="cursor:pointer;" onclick="feedbackHide();" id="popupClose" /></td>' +
            '          </tr>' +
            '        </table>' +
            '        <div id="popupContent" style="border:1px solid #e0e0e0"></div>' +
            '      </td>' +
            '      <td width="20" style="background: url(/images/box/f_r.png); height:100px;" class="iePNG">&nbsp;</td>' +
            '    </tr>' +
            '    <tr>' +
            '      <td width="20"><img src="/images/box/f_bl.png" width="20" height="20" alt="" /></td><td height="20" style="background: url(/images/box/f_b.png);" class="iePNG">&nbsp;</td><td width="20"><img src="/images/box/f_br.png" alt="" width="20" height="20" /></td>' +
            '    </tr>' +
            '  </table>' +
            '';

function feedbackShow() {
    pScroll = getPageScroll();
    var docWidth = $(document).width();
    var docHeight = $(document).height();
    
    $('<div id="overlay" style="position:absolute; top:0px; left:0px; background-color:#000; z-index:100;"></div>').appendTo('body');
    $('<div id="popup" style="position:absolute; z-index:101;"></div>').appendTo('body');
    $('#overlay')
        .css({'width':docWidth+'px', 'height':docHeight+'px', 'opacity':0})
        .click(function(event){
            feedbackHide();
        })
        .animate({opacity:.7}, 400, function() {
            $('#popup').hide().html(popup);
            $('#popupContent').css({'height':'150px','width':'200px'});
            $('#popup').css({
                'top': (($(window).height()-220) / 2)+pScroll[1] + 'px'
               ,'left': (($(window).width()-240) / 2) + 'px'
            });
            $('#popupContent').html('<div align="center" id="popupLoading"><br /><br /><br /><br /><img src="/images/ajax-loader.gif" alt="Loading" /></div>');
            $('#popup').show();
            
            $.ajax({
                type: "GET",
                url: "/app/ajax/feedback.php",
                dataType: "html",
                success: function(retData) {
                    $('#popupTitle,#popupClose').hide();
                    $('#popupLoading').hide();
                    $('#popupContent').animate({
                        'height': '225px'
                       ,'width': '580px'
                    }, 400);
                    
                    $('#popup').animate({
                        'top': (($(window).height()-300) / 2)+pScroll[1] + 'px'
                       ,'left': (($(window).width()-620) / 2) + 'px'}, 400, function(){
                            $('#popupTitle,#popupClose').show();
                            $('#popupContent').html(retData);
                       });
                }
            });
        });
    
    return false;
}
function feedbackHide() {
    $('#popup').remove();
    
    $('#overlay').animate({opacity:0}, 400, function() {
        $('#overlay').remove();
    });
}

function getPageScroll() {
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array('', yScroll);
    return arrayPageScroll;
}

//</script>
