function showImageInPopupDialog(_url, _title) {
    var html = '<div style="text-align:center; margin-left:auto; margin-right:auto;padding:4px;"><img align="middle" alt="'+_title+'" src="'+_url+'"/></span>';
    //var popup = new Liferay.Popup( { message:html, header: _title, position:['center', 10], modal:true, width:640, height:550 } );
    AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', function(A) {
        var dialog = new A.Dialog({
            title: _title,
            centered: true,
            modal: true,
            bodyContent: html
        }).render();
    });
}

function showImageInPopupDialog(_url, _title, width, height) {
    var html = '<div style="text-align:center; margin-left:auto; margin-right:auto;padding:4px;"><img align="middle" alt="'+_title+'" src="'+_url+'"/></span>';
    //var popup = new Liferay.Popup( { message:html, header: _title, position:['center', 10], modal:true, width:640, height:550 } );
    AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', function(A) {
        var dialog = new A.Dialog({
            title: _title,
            centered: true,
            modal: true,
            width: width,
            height: height,
            bodyContent: html
        }).render();
    });
}

function showHTMLPagePopup(url, title, width, height) {
    alert('showHTMLPagePopup');
    //var popup = new Liferay.Popup( { url:_url, header: _title, position:['center', 10], modal:true, width:_width, height:_height } );
    AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', function(A) {
        A.io.request('/binferapps/demo/demo.html', {
            on: {
                success: function() {
                    alert("response rcvd");
                    var response = this.get('responseData');
                    
                    var dialog = new A.Dialog({
                        title: title,
                        centered: true,
                        modal: true,
                        width: width,
                        height: height,
                        bodyContent: response
                    }).render();
                },
                failure: function(e){
                    alert("failed:"+e);
                }
            }
        }
        );
    });
}

function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
    // alert("getCookie:"+name);
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
