widgets = 0;
function typeOf(value) {

    var s = typeof value; if (s === 'object') {

        if (value) {

            if (typeof value.length === 'number' &&

                !(value.propertyIsEnumerable('length')) && typeof value.splice === 'function') {

            s = 'array';

        }

    } else {

        s = 'null';

    }

    } return s;

} 

if (typeof(lookabooka) != "object") {
		var application = null;
		var lookabooka = {};
		var zmax = 100;
	}
var lookabooka = {};

	/**
	 * Returns the namespace specified and creates it if it doesn't exist			
	 * @static zmax
	 * @private {String} 	zmax to store maximum z-index																			
	 * @param	{String}	arguments 1-n namespaces to create, optional
	 * @return	{Object}	reference to the last namespace object created
	 */
	lookabooka.namespace = function () {

		var widgetClass;	
	};
lookabooka.namespace("modules.widget");

(function ($) {

 	/**
	 * @fileoverview	Simple Widget Display
	 * @author			$Author: shrestha $1
	 * @version			$Revision: 1.1.2.6 $
	 * @namespace		lookabooka.modules.widget
	 */	
	
	//var widget;
	
	//----------------------------------------------------------------------
	// Constructor
	//----------------------------------------------------------------------
	
	
	/**
	 * @constructor
	 * @namespace	lookabooka.widget
	 * @param	{Object}	c	HTML element to contain module
	 */	
		$.fn.lookabooka = function () {
			//Initializing the current Widget
			//widget = $('.'+ c);
			widget = this;
		
			
			//Layering the z-Index for each widget according to which widget is active
		  	$( widget ).mousedown( function () {
			 
			      $( this ).siblings( '.draggable' ).each(function() {
			            var cur =  $( this ).css( 'zIndex');
			            zmax = cur > zmax ? $( this ).css( 'zIndex') : zmax;
			    });
			    $( this ).css( 'zIndex', zmax+1 );
			    zmax++;
			});
			
			$( widget ).children('.widget_container').children('.gradient_image').children('jScrollPaneContainer').mousedown( function () {
			  	
			      $( this ).siblings( '.draggable' ).each(function() {
			            var cur =  $( this ).css( 'zIndex');
			            zmax = cur > zmax ? $( this ).css( 'zIndex') : zmax;
			    });
			    $( this ).css( 'zIndex', zmax+1 );
			    zmax++;
			});
			
			
			//making the widgets draggable
			
			$(this).draggable({
					    	handle: (this).children('h2'),
							start:function(){
								$(this).children('.widget_container').children('.gradient_image').css('background', 'none');
							},
							containment: 'body'
		    });
			
    
		    //Collapsing the widget
		    $(widget).children("h2").children('.widget_collapse_up').click(function () {

		      	$(this).parent().siblings(".widget_container").fadeOut("slow");
		      	$(this).hide();
		    	$(this).siblings(".widget_collapse_down").show();
		      	
		    });
		    
		    //Expanding the widget
		    $(widget).children("h2").children('.widget_collapse_down').click(function () {

		      	$(this).parent().siblings(".widget_container").fadeIn("slow");
		      	$(this).hide();
		    	$(this).siblings(".widget_collapse_up").show();
		      	
		    });
			
			$(".close" ).click(function () {
		      	$(this).parent().parent().hide("slow");
		      	
			});

	}
	

})(jQuery);   	
		//Variables for positioning widgets
		screenSize = $(window).width() - 30;
		pageCenter = (screenSize / 2) - 5;
		leftEdge = pageCenter - 486;
		midEdge = leftEdge + 255;
		lastEdge = midEdge + 505;

