
var ThickBoxGeneric = function() {
    
    this.images = {
                    'Add':'add.png',
                    'Left':'text_left.png',
                    'Indent':'text_indent.png',
                    'Centre':'text_centre.png',
                    'Right':'text_right.png',
                    'Bold':'bold.png',
                    'Delete':'delete.png',
                    'Italic':'italic.png',
                    'Superscript':'superscript.png',
                    'Underline':'underline.png',
                    'Sent':'tick.png',
                    'Is A User':'tick.png',
					'Spelling':'tick.png'
    }
    this.url = new Url()

    this.init = function(reload) {
    
	    // Set reload to reload page if you click on background
		//
        var self = this
        
        self.setCommonImages($('img.commonFurniture'))

        $('.thickBoxCancel').click( function() { tb_remove() })
        $('.mandatory').keyup( function() { self.checkValid($(this)) })
		
		if (reload) {
			$('#TB_overlay').click( function() { location.reload() } )
		}
    }

    this.setCommonImages = function(elems) {

        var self = this

        $(elems).each(
            function() {
                var alt = $(this).attr('alt')
                $(this).attr('src', COMMONROOT + '/images/furniture/' + self.images[alt])
            })
    } 

    this.applyThickBox = function(nodes) {

        var self = this

        $(nodes).unbind('click')
        $(nodes).click(
            function() {
                var login = new Login()
                var href = $(this).attr('href')
                if ($(this).hasClass('needLogin') && ! login.isLoggedIn()) {
                    href = href + '&NotLoggedIn=1'
                }
                if ($(this).hasClass('formLink')) {
                    var id = self.url.urlArg(location.href, 'Id')
                    href   = self.url.addIdToHref(href, id) 
                    $(this).attr('href', href)
                }
                $('#clickedURL').val(href)
            })
        tb_init(nodes)
    }
    
    this.applyThickBoxNoLogin = function(nodes) {

        $(nodes).unbind('click')
        $(nodes).click(
            function() {
                var href = $(this).attr('href')
                $('#clickedURL').val(href)
            })
        tb_init(nodes)
    }

    this.checkValid = function(elem) {

        if ($(elem).val()) {
            $(elem).removeClass('invalid')
        }
    }
}



