﻿/*
 * Opens a popup window without a toolbar.
*/
function richWin( href, width, height ) {

    var left = ( screen.width / 2 ) - ( width / 2 );
    var top = ( screen.height / 2 ) - ( height / 2 ) - 20;
    
    var params = 'toolbar=no';
    params += ',width=' + width;
    params += ',height=' + height;
    params += ',top=' + top;
    params += ',left=' + left;

	window.open( href, "", params );
}

/*
 * Opens a popup window.
 *      returns: true iff the window failed to be opened.
*/
function openPopupWin( href, width, height, toolbar ) {

    try {
        var left = ( screen.width / 2 ) - ( width / 2 );
        var top = ( screen.height / 2 ) - ( height / 2 ) - 20;
        
        var params;
        
        if( toolbar ) {
            params = 'toolbar=1';
        } else {
            params = 'toolbar=0';
        }
        
        params += ',width=' + width;
        params += ',height=' + height;
        params += ',top=' + top;
        params += ',left=' + left;
        params += ',resizable=1';
        params += ',scrollbars=1';

	    window.open( href, "", params );
	    
	    return false;
	    
    } catch( err ) {
        return true;
    }	
}

/* ============================================================= */

/**
 * Class definition for the storefront javascript library.
 */
function _Storefront() {
}

/**
 * Toggles the display of the specified control.
 *      targetId: The target control to toggle the display of.
 */
_Storefront.prototype.toggleDisplay = function( targetId ) {
    
    if( document.getElementById ){

        var target = document.getElementById( targetId );
    
        if( target.style.display == "none" ){
            target.style.display = "";
        } else {
            target.style.display = "none";
        }
    }
}

// initialize the storefront instance
var Storefront = new _Storefront();
