///////////////////////////////////////////////////////////////////////////////
//	Site Utils JS Actions
///////////////////////////////////////////////////////////////////////////////

//Site Utils Common


core.action.SiteUtilsCommon = (function() {
    var SiteUtilsCommon = core.action.AbstractAction(/.*/, /.*/);

    SiteUtilsCommon.initialize = function() {

        HtmlTemplate = new core.ui.HtmlTemplate({
            'element': $('#siteutils_authenticate')
        });

        $('body').append(HtmlTemplate.html);

        Overlay = new core.ui.Overlay({
            'height': $(window).height(),
            'width': $(window).width()
        });


        // handle sign-in link
        $('a#siteutils_signin').click(function(event) {
            event.preventDefault();
            var id = $(this).attr('href');

            Overlay.show();

            //Get the window height and width  
            var winH = $(window).height();
            var winW = $(window).width();

            //Set the popup window to location based upon center  
            //$(id).css('top',  60);
            //$(id).css('left', 676);
            //$(id).css('left', $(body).width()-600);
            //console.log($(body).width());
            $(id).css('top', winH / 2 - $('#siteutils_authenticate .window').height() / 2 - 100);
            $(id).css('left', winW / 2 - $('#siteutils_authenticate .window').width() / 2);

            //transition effect  
            $(id).fadeIn(300);
        });


        // handle Close click
        $('.window .close').click(function(e) {
            e.preventDefault();
            $('.window').hide();
            Overlay.hide();
        });


        // handle submit button
        $('#siteutils_dialog .submit_button').click(function(e) {
            // perform authentication ajax

            // on fail

            // on success
            $('.window').hide();
            Overlay.hide();
        });
        // handle search button
        $('button.search_site').click(function(e) {
            e.preventDefault();
            // redirect to search results
            window.location.href = 'http://www.hawkerbeechcraft.com:8765/query.html?col=rac&charset=iso-8859-1&qt=' + $('input#search').val();
        });

    }

    return SiteUtilsCommon;
} ());
	
	
	
