/*
	Copyright (c) 2006-2007, ePages GmbH
	All Rights Reserved.

	epages.cartridges.de_epages.design.widget.Toolfontfamily $Revision: 1.2 $

*/
dojo.provide("epages.cartridges.de_epages.design.widget.Toolfontfamilyheadline");
dojo.require("epages.widget.LocalizedWidget");
dojo.require("epages.widget.Menu");
dojo.require("epages.event");
dojo.require("dijit._Container");
dojo.require("epages.cartridges.de_epages.design.widget.Toolfontfamily");

dojo.declare(
	"epages.cartridges.de_epages.design.widget.Toolfontfamilyheadline",
	epages.cartridges.de_epages.design.widget.Toolfontfamily,
	{
		_templateMapping:{
			'tablerow' : {templatePath: dojo.moduleUrl('epages.cartridges.de_epages.design.widget', 'templates/Toolfontfamily.html')},
			'xlicon'   : {templatePath: dojo.moduleUrl('epages.cartridges.de_epages.design.widget', 'templates/Toolfontfamilyheadlinexlicon.html')}
		},

		_fonts: {
			'Anton'              : { fontfamily : "Anton",                                                webfont : 'Anton' },
			'Arial'              : { fontfamily : "Arial, Verdana, Helvetica",                            webfont : "" },
			'Baumans'            : { fontfamily : "Baumans",                                              webfont : 'Baumans' },
			'BerkshireSwash'     : { fontfamily : "Berkshire Swash",                                      webfont : 'Berkshire+Swash' },
			'CabinSketch'        : { fontfamily : "Cabin Sketch",                                         webfont : 'Cabin+Sketch:400,700' },
			'CaesarDressing'     : { fontfamily : "Caesar Dressing",                                      webfont : 'Caesar+Dressing' },
			'Chewy'              : { fontfamily : "Chewy",                                                webfont : 'Chewy' },
			'ComingSoon'         : { fontfamily : "Coming Soon",                                          webfont : 'Coming+Soon' },
			'CourierNew'         : { fontfamily : "Courier New, Verdana, Helvetica",                      webfont : "" },
			'Creepster'          : { fontfamily : "Creepster",                                            webfont : 'Creepster' },
			'Cutive'             : { fontfamily : "Cutive",                                               webfont : 'Cutive' },
			'DancingScript'      : { fontfamily : "Dancing Script",                                       webfont : 'Dancing+Script:400,700' },
			'DroidSerif'         : { fontfamily : "Droid Serif",                                          webfont : 'Droid+Serif:400,700,400italic,700italic' },
			'Eater'              : { fontfamily : "Eater",                                                webfont : 'Eater' },
			'Esteban'            : { fontfamily : "Esteban",                                              webfont : 'Esteban' },
			'Ewert'              : { fontfamily : "Ewert",                                                webfont : 'Ewert' },
			'ExpletusSans'       : { fontfamily : "Expletus Sans",                                        webfont : 'Expletus+Sans:400,700,400italic,700italic' },
			'Fascinate'          : { fontfamily : "Fascinate",                                            webfont : 'Fascinate' },
			'Federant'           : { fontfamily : "Federant",                                             webfont : 'Federant' },
			'FrancoisOne'        : { fontfamily : "Francois One",                                         webfont : 'Francois+One' },
			'Georgia'            : { fontfamily : "georgia, Times New Roman, arial, sans-serif",          webfont : "" },
			'GermaniaOne'        : { fontfamily : "Germania One",                                         webfont : 'Germania+One' },
			'Gruppo'             : { fontfamily : "Gruppo",                                               webfont : 'Gruppo' },
			'IMFellDWPicaSC'     : { fontfamily : "IM Fell DW Pica SC",                                   webfont : 'IM+Fell+DW+Pica+SC' },
			'Iceberg'            : { fontfamily : "Iceberg",                                              webfont : 'Iceberg' },
			'Inconsolata'        : { fontfamily : "Inconsolata",                                          webfont : 'Inconsolata' },
			'JosefinSans'        : { fontfamily : "Josefin Sans",                                         webfont : 'Josefin+Sans:400,700,400italic,700italic' },
			'Lobster'            : { fontfamily : "Lobster",                                              webfont : 'Lobster' },
			'LucidaSans'         : { fontfamily : "Lucida Sans Unicode, Lucida Sans, Verdana, Helvetica", webfont : "" },
			'MaidenOrange'       : { fontfamily : "Maiden Orange",                                        webfont : 'Maiden+Orange' },
			'MarckScript'        : { fontfamily : "Marck Script",                                         webfont : 'Marck+Script' },
			'Marmelad'           : { fontfamily : "Marmelad",                                             webfont : 'Marmelad' },
			'Metamorphous'       : { fontfamily : "Metamorphous",                                         webfont : 'Metamorphous' },
			'MysteryQuest'       : { fontfamily : "Mystery Quest",                                        webfont : 'Mystery+Quest' },
			'NovaCut'            : { fontfamily : "Nova Cut",                                             webfont : 'Nova+Cut' },
			'OpenSans'           : { fontfamily : "Open Sans",                                            webfont : 'Open+Sans:400,700,400italic,700italic' },
			'Orbitron'           : { fontfamily : "Orbitron",                                             webfont : 'Orbitron:400,700' },
			'PTSerif'            : { fontfamily : "PT Serif",                                             webfont : 'PT+Serif:400,700,400italic,700italic' },
			'Pacifico'           : { fontfamily : "Pacifico",                                             webfont : 'Pacifico' },
			'Playball'           : { fontfamily : "Playball",                                             webfont : 'Playball' },
			'PoiretOne'          : { fontfamily : "Poiret One",                                           webfont : 'Poiret+One' },
			'Raleway'            : { fontfamily : "Raleway",                                              webfont : 'Raleway' },
			'RopaSans'           : { fontfamily : "Ropa Sans",                                            webfont : 'Ropa+Sans:400,400italic' },
			'Tahoma'             : { fontfamily : "Tahoma, Verdana, Helvetica",                           webfont : "" },
			'TimesNewRoman'      : { fontfamily : "Times New Roman, Times",                               webfont : "" },
			'TrebuchetMS'        : { fontfamily : "Trebuchet MS, Verdana, Arial, Helvetica",              webfont : "" },
			'Trochut'            : { fontfamily : "Trochut",                                              webfont : 'Trochut:400,700,400italic' },
			'UncialAntiqua'      : { fontfamily : "Uncial Antiqua",                                       webfont : 'Uncial+Antiqua' },
			'UnifrakturMaguntia' : { fontfamily : "UnifrakturMaguntia",                                   webfont : 'UnifrakturMaguntia' },
			'VastShadow'         : { fontfamily : "Vast Shadow",                                          webfont : 'Vast+Shadow' },
			'Verdana'            : { fontfamily : "Verdana, Arial, Helvetica",                            webfont : "" },
			'Voltaire'           : { fontfamily : "Voltaire",                                             webfont : 'Voltaire' },
			'YanoneKaffeesatz'   : { fontfamily : "Yanone Kaffeesatz",                                    webfont : 'Yanone+Kaffeesatz:400,700' },
			'Yellowtail'         : { fontfamily : "Yellowtail",                                           webfont : 'Yellowtail' },
			'YesevaOne'          : { fontfamily : "Yeseva One",                                           webfont : 'Yeseva+One' }
		},

		/**
		 * widget properties
		 */
		widgetType: 'Toolfontfamilyheadline',

		_addFontRow: function(/*integer*/i) {
		// summary: add menu entry (link)
			var parentWidget=this;
			var entry= new dijit.MenuItem({
				label: i,
				iconClass: 'MinimizeIcon',
				onClick: function() {
					parentWidget.switchFont(i);
					dijit.popup.close(parentWidget._menuWidget);
				},
				id: 'fontheadline'+i
			});

			entry.containerNode.style.fontFamily= this._fonts[i].fontfamily;
			entry.containerNode.style.fontSize= '12px';
			this._menuWidget.addChild(entry);

			if(this.fontFamily == this._fonts[i].fontfamily) {
				this._lastSelected=entry.domNode;
				dojo.addClass(this._lastSelected, "Selected" );
			}

		},

		switchFont: function(/*ObjectIndex*/fontIndex) {
			this.fontSelectNode.value=this._fonts[fontIndex].fontfamily;
			$('HeadlineWebfont').value = this._fonts[fontIndex].webfont;
			epages.event.fire(this.fontSelectNode,"change");
			if(this._lastSelected) {
				dojo.removeClass(this._lastSelected, "Selected" );
			}
			this._lastSelected=$$('fontheadline'+fontIndex).domNode;
			dojo.addClass(this._lastSelected, "Selected" );
		}
	});