﻿YAHOO.namespace("ParkAve");
var $ParkAve = YAHOO.ParkAve;

$ParkAve.Controls = {

    _init : function()
    {
        //load external HTML page
        YAHOO.util.Connect.asyncRequest('GET', 'yuiControls.html', 
        {
            failure: function(o) {
                alert('Could not download control template:  ' + o.statusText);
            },
            success: function(o) { 
                //Set the image content
                $ParkAve.Controls.ImageModal = 
                    new YAHOO.widget.Panel('imageModal',  
                        { width:'660px',
                          height:'480px',
                          fixedcenter: true, 
                          close: true, 
                          draggable: false, 
                          zindex:10000,
                          modal: true,
                          visible: false
                        } 
                    );
            
                $ParkAve.Controls.ImageModal.render(document.body);
            }    
        });
    },
    
    showImageModal : function(title, imageURL)
    {
//        $ParkAve.Controls.ImageModal.setHeader("Loading, please wait..."); 
//        $ParkAve.Controls.ImageModal.setBody('<img src="http://l.yimg.com/a/i/us/per/gr/gp/rel_interstitial_loading.gif" />'); 
//        $ParkAve.Controls.ImageModal.show();
//        
//        YAHOO.util.Connect.asyncRequest('GET', 'yuiControls.html', 
//        {
//            failure: function(o) {
//                alert('Could not download control template:  ' + o.statusText);
//            },
//            success: function(o) { 
                $ParkAve.Controls.ImageModal.setHeader(title);
                $ParkAve.Controls.ImageModal.setBody('<img src="' + imageURL + '" />'); 
                $ParkAve.Controls.ImageModal.show();
//            }
//        });
    },
    
    getURLParameter : function( name )
    {
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
            return "";
        else
            return results[1];
    }
};

YAHOO.util.Event.onDOMReady(function () {
    $ParkAve.Controls._init();
 });
