
	MHT.chache = {};
	MHT.chache.fixed = {
		user:      {},
		macropons: {},
		stores:    {}
	};

    /**
     * POP-OUT componenta
     *
     * Metoda skrije trnutno vidni canvas in prikaže črni canvas,
     * kjer je plac za xhtml elemente, ki bi naj bile v popout-u.
     *
     *
     */
    MHT.dialoglogic = {
        DEBUG: false,    // Debug console messages enabled or disabled
        /**
         * Inicijaliziram vse potrebno za delovanje komponente
         */
        init: function(){
            var _DEBUG = this.DEBUG;

            if(_DEBUG) { console.debug('Entering: MHT.dialoglogic.init()'); }

            // Definiram globalen click class, ki sproži to komponento
            $('.a_dialog').live('click', function(){
                if(_DEBUG) { console.debug('Clicked: .a_dialog'); }

                var _$clicked_el = $(this);

                // Predam logiko parsanja in nadaljnega izvajanja
                MHT.dialoglogic.deparam(_$clicked_el);

                // Prevent default click action
                return false;
            });

        },
        /**
         * Ob kliku na gumb z dialogom, tale metoda prevzame
         * odgovornost za nadaljno logiko
         */
        deparam: function($clicked_el){
            if(MHT.dialoglogic.DEBUG) { console.debug('Entering: MHT.dialoglogic.deparam()'); }

            var _params = $.deparam.querystring($clicked_el.attr('href'), true);
            if(MHT.dialoglogic.DEBUG) { console.debug('Parameters: '); console.debug(_params); }

            var _$content_placeholder = '';

            // Logika, ki se odloči kaj prikazat (popout ali dialog)
            switch(_params.mh_showin) {
                case 'popout':
                    _$content_placeholder = MHT.component.POPOUT.init(_params);
                    break;
                case 'dialog':
                    _$content_placeholder = MHT.component.DIALOG.init(_params);
                    break;
                default:
                    // do nothing (unknown command)
                    if(MHT.dialoglogic.DEBUG) { console.error('Error: Command not recognized!'); }
            }

            MHT.fastsolution.forms.init(_$content_placeholder, _params);

            //_$content_placeholder.replaceWith('wacap!');
        }
    };

    /**
     * Komponenta POPOUT - črni canvas
     *
     * API metode:
     *
     */
    MHT.component.POPOUT = {
        DEBUG: false,
        /**
         *
         * @param params
         */
        init: function(params){
            if(MHT.component.POPOUT.DEBUG) { console.debug('Entering: MHT.component.POPOUT.init()'); }

            var _$content_placeholder = $('.pop-out-content').html('<div class="pop-out-content-spinner">Nalagam...</div>');
            MHT.component.POPOUT.show();

            var _$popout = this;

            // Globalen klik class za zaprtje popout-a
            $('.pop-out-close').bind('click', function(){
                if(MHT.component.POPOUT.DEBUG) { console.debug('Clicked: .pop-out-close'); }

                _$popout.hide();     // call internal hide() method
                return false;        // Prevent default click actin
            });

            return _$content_placeholder;
        },
        /**
         * Metoda prikaže črn canvas
         */
        show: function(){
            if(MHT.component.POPOUT.DEBUG) { console.debug('Entering: MHT.component.POPOUT.show()'); }

            $('#main-container').hide();
            $('.pop-out').show();
        },
        hide: function(){
            $('.pop-out').hide();
            $('.pop-out-content').html('');
            $('#main-container').show();
            $.scrollTo(0, 500);
        }
    };

    /**
     * Komponenta DIALOG - črni canvas
     *
     * API metode:
     *
     */
    MHT.component.DIALOG = {
        DEBUG: false,
        _dialog: {},
        /**
         *
         * @param params
         */
        init: function(params){
            if(MHT.component.POPOUT.DEBUG) { console.debug('Entering: MHT.component.DIALOG.init()'); }

            this._dialog = $('<div class="mh_dialog"></div>')
                    .dialog({
                        autoOpen: false,
                        zIndex:   99999,
                        modal:    true,
                        title:    'Izberi produkt in željen čas izvajanja kampanje',
                        width:    712,                     // XXX dinamično jo pridobi!
                        position: ['center',108],
                        //height:    maxPresetHeight,
                        //maxHeight: 600,
//                        width:     'auto'
                        close: function(event, ui) { $(this).remove(); }
                    });

            return this._dialog;
        }
    };

    MHT.form = {};
    MHT.form.fields = {
        DEBUG: false,
        /*
         * MICROPON: ??
         * DONATOR:  Namen Kampanje
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        headlineDescription: {
            FIELD_ID: 'headline_description',
            validator: {
                needsValidation: false
            },
            init: function(){ return this; },
            html: function(arg_params){

                //console.debug('Entering: MHT.form.fields.headlineDescription.html()');

                var disabled = '';
                if(arg_params.mh_isampera && arg_params.mh_product != 'nanopon') {
                    var disabled = 'disabled="disabled"';
                }

                var _text_Ampera   = 'Namen donacij';
                var _text_Merchant = 'Namen donacij';
                if(arg_params.mh_product == 'macropon'){
                    _text_Ampera   = 'Naslov oglasa';
                    _text_Merchant = 'Naslov oglasa';
                }
                else if(arg_params.mh_product == 'nanopon'){
                    _text_Ampera   = 'Naslov ponudbe';
                    _text_Merchant = 'Naslov ponudbe';
                }

                return ''
                      +'<li class="name desc-tip">'
                        // Tooltip
                      +'  <div class="side-box tip-title" style="display:none;">Izberite kategorijo svojega posla</div>'
                      +'	<div class="side-box tip-content" style="display:none;">'
                      +'      <ul class="side-box-toggler">'
                      +'	        <li>'
                      +'		        <h4 class="toggle_handle open">'
                      +'			        <a class="anti_link list_item_toggle desc-title" href="#">Hrana, pijača (gostinstvo)</a>'
                      +'				</h4>'
                      +'				<p class="toggle_content desc-content" style="display:none;">Blabla text... Če se prijatelj odzove tvojemu povabilu, prejmeš 1% od vsakega njegovega kupljenega Micropona.</p>'
                      +'			</li>'
                      +'			<li>'
                      +'				<h4 class="toggle_handle open">'
                      +'					<a class="anti_link list_item_toggle desc-title" href="#">Turizem (bla)</a>'
                      +'				</h4>'
                      +'				<p class="toggle_content desc-content" style="display:none;">Blabla text... Če se prijatelj odzove tvojemu povabilu, prejmeš 1% od vsakega njegovega kupljenega Micropona.</p>'
                      +'			</li>'
                      +'		</ul>'
                      +'	</div>'
                         // Field
                      +'  <label for="'+this.FIELD_ID+'" style="padding-top:0;"><strong class="asteric">*</strong> '+_text_Merchant+'</label>'
                      +'  <input id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" '+disabled+' placeholder="Za kakšen namen se donacije zbirajo?" autocomplete="off" type="text" style="width: 428px;">'
                      +'	<span class="field_desc" style="width: 440px;">Uporabniki morajo vedeti za kaj točno zbirate sredstva</span>'
                      +'</li>';
            },
            setValue: function(arg_value){
                $('#'+this.FIELD_ID).val(arg_value);
            },
            getValue: function(){
                return $('#'+this.FIELD_ID).val();
            },
            disable: function(){
                $('#'+this.FIELD_ID).prop('disabled',true);
            }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Naslov kampanje
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        headline: {
            FIELD_ID: 'headline',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                required  : true,
	        		minlength : 10,
				    maxlength : 100
                },
                message: {
                    required : jQuery.format("Naslov ponudbe je obvezen podatek"),
				    minlength: jQuery.format("Naslov naj vsebuje vsaj {0} znakov"),
				    maxlength: jQuery.format("Naslov naj vsebuje največ {0} znakov")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                if(arg_params.mh_isampera) {
                    // Prikažem samo Amperi
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Naslov kampanje</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Naslov, kot bo prikazan na strani" autocomplete="off" type="text">'
						  +'</li>';
                } else {
                    // Tega polja ne prikažem upravljalcu
                    return '';
                }
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        maxQuantity: {
            FIELD_ID: 'max_quantity',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required:    true,
	        		min: 10,
	        		max: 100
                },
                message: {
                    required:jQuery.format("Največja dovoljena količina nanoponov je obvezen podatek"),
				    min:     jQuery.format("Najmanjša dovoljena količina nanoponov je {0}"),
				    max:     jQuery.format("Največja dovoljena količina nanoponov je {0}")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Količina nanoponov</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Koliko nanoponov želite največ podeliti?" autocomplete="off" type="text" style="width: 44px;">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        discount: {
            FIELD_ID: 'max_discount_percantage',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required:    true,
	        		min: 2,
	        		max: 49
                },
                message: {
                    required:jQuery.format("Popust je obvezen podatek"),
				    min:     jQuery.format("Najmanjši popust je {0}%"),
				    max:     jQuery.format("Največji popust je {0}%")
                }
            },
            init: function(){return this;},
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Popust</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Kolikšen popust želite dati?" autocomplete="off" type="text" style="width: 44px;">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(parseFloat(arg_value*100).toFixed(2));        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _discount        = $('input[name="'+this.FIELD_ID +'"]');
                var _originalPrice   = $('input[name="price_original"]');
                var _discountedPrice = $('input[name="max_discount_min_price"]');

                _discount.bind('keyup', function(){
                    // #max_discount_min_price
                    if(_originalPrice.val() > 0){
                        _discountedPrice.val( parseFloat(_originalPrice.val() - (_originalPrice.val() * _discount.val() / 100)).toFixed(2) );
                    }
                });
            }
        },
        discountedPrice: {
            FIELD_ID: 'max_discount_min_price',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required:    true
                },
                message: {
                    required:jQuery.format("Cena s popustom je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Cena s popustom</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" disabled="disabled" autocomplete="off" type="text" style="width: 44px;">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        originalPrice: {
            FIELD_ID: 'price_original',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required:true,
                    min:     1
                },
                message: {
                    required:jQuery.format("Redna cena je obvezen podatek"),
                    min:     jQuery.format("Najmanjša dovoljena redna cena je {0}EUR")
                }
            },
            init: function(){

                // FIXME ko vnese original cena in popust je različen od 0 preračunam ceno

                return this;
            },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Redna cena</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="redna cena produkta ali storitve" autocomplete="off" type="text" style="width: 44px;">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _discount        = $('input[name="max_discount_percantage"]');
                var _originalPrice   = $('input[name="'+this.FIELD_ID +'"]');
                var _discountedPrice = $('input[name="max_discount_min_price"]');

                _originalPrice.bind('keyup', function(){
                    // #max_discount_min_price
                    if(_originalPrice.val() > 0){
                        _discountedPrice.val( parseFloat(_originalPrice.val() - (_originalPrice.val() * _discount.val() / 100)).toFixed(2) );
                    }
                });
            }
        },
        merchantTerms: {
            FIELD_ID: 'coupon_highlights',
            validator: {
               needsValidation: false
            },
            init: function(){return this;},
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li>'
						  +'    <label for="'+this.FIELD_ID+'">Opombe</label>'
						  +'	<ul class="mht-checkbox vertical">'
						  +'	    <li class="hideField" id="opombe_li">'
						  +'		    <span class="hidden-input">'
						  +'			    <ul id="'+this.FIELD_ID +'_container" class="opombe">'
						  +'                    <li class="'+this.FIELD_ID +'_loading" style="width:436px;"><div class="rounded" style="padding:5px 9px; font-size: 13px; width: 354px; background: url(/public/images/spinner.gif) no-repeat 0 50%; padding-left: 16px; padding-bottom: 6px;">nalagam...</div></li>'
                          +'			    </ul>'
						  +'		        <input type="text" id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" style="width:354px; margin-top:0px;margin-left:0px;"> <a id="'+this.FIELD_ID+'_add" class="nochk positive button rounded" style="font-weight: normal; padding: 7px 6px 7px 6px; font-size: 13px;"><span class="icon plus" style="padding-top: 2px;"></span>dodaj</a>'
//						  +'		        <span class="field_desc hidden-input" style="margin-left:0px;">Če kaj manjka ali vidiš da bo uporabnikom nejasno dodaj (kontraktiraj trgovca če ne veš točnega pogoja)</span>'
						  +'			</span>'
						  +'		</li>'
						  +'	</ul>'
						  +'	<div class="clearfix"></div>'
						  +'</li>'
                        ;
            },
            setValue: function(arg_values){

                var _fieldName      = this.FIELD_ID +'_items';
                var _fieldItem = this.FIELD_ID +'_item';                   // toliko, da ga lahko preštejem pri brisanju
                var _classDELName   = this.FIELD_ID +'_del_item';
                var _fieldContainer = $('ul#'+this.FIELD_ID +'_container');
                var _fieldLoading = $('li.'+this.FIELD_ID +'_loading');
                var _itemsXhtml     = '';

                if(arg_values != '' && arg_values != undefined && arg_values.length > 0) {

				    var _arguments = arg_values.split('|');

                    $(_arguments).each(function(i, v){
                        _itemsXhtml += '<li style="width:436px;"><div class="rounded" style="border: 1px solid #B3B3B3; padding:5px 9px; font-size: 13px; width: 354px;">'+ v +'<input type="hidden" class="'+_fieldItem +'" name="'+_fieldName+'[]" value="'+v+'"></div><a class="nochk negative rounded button '+_classDELName +'" style="margin-left: 3px;"><span class="icon cross" style="padding-bottom: 2px; margin-right: 0; margin-left: 2px; margin-bottom: 1px; margin-top: -1px;"></span></a></li>';
                    });
				}
                else {
                    _itemsXhtml += '<li class="'+this.FIELD_ID +'_empty" style="width:436px;"><div class="rounded" style="padding:5px 9px; font-size: 13px; width: 354px;">(ni posebnih pogojev prevzema/unovčitve)</div></li>';
                }
                _fieldLoading.replaceWith(_itemsXhtml);
            },
            getValue: function()
            {
                var _fieldItem = this.FIELD_ID +'_item';                   // toliko, da ga lahko preštejem pri brisanju

                var _arguments = $('.'+_fieldItem);
                var _tmpArray  = [];

                $.each(_arguments, function(i, v) {
                    _tmpArray[i] = $(v).val();
                });

                /** lepo izoblikovano string za vstavljanje v DB */
                return _tmpArray.join('|');
            },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _FIELD_ID       = this.FIELD_ID;
                var _fieldName      = this.FIELD_ID +'_items';
                var _fieldItem      = this.FIELD_ID +'_item';                   // toliko, da ga lahko preštejem pri brisanju
                var _classDELName   = this.FIELD_ID +'_del_item';
                var _classERRName   = this.FIELD_ID +'_err_item';
                var _fieldContainer = $('ul#'+this.FIELD_ID +'_container');
                var _fieldsEmpty    = $('li.'+this.FIELD_ID +'_empty');

                var _$input  = $('input[name="'+this.FIELD_ID+'"]');
                var _$addbtn = $('#'+this.FIELD_ID+'_add');

                /** DODAJANJE ITEMA */
                _$addbtn.bind('click', function(){
                    if(_$input.val().length > 5 && _$input.val().length < 200) {
                        $('li.'+_FIELD_ID +'_empty').remove();
                        _fieldContainer.append('<li style="width:436px;"><div class="rounded" style="border: 1px solid #B3B3B3; padding:5px 9px; font-size: 13px; width: 354px;">'+ _$input.val() +'<input type="hidden" class="'+_fieldItem +'" name="'+_fieldName+'[]" value="'+_$input.val()+'"></div><a class="nochk negative rounded button '+_classDELName +'" style="margin-left: 3px;"><span class="icon cross" style="padding-bottom: 2px; margin-right: 0; margin-left: 2px; margin-bottom: 1px; margin-top: -1px;"></span></a></li>');
                        _$input.val('');
                    }
                    else { $(this).after('<label class="'+_classERRName+' error" style="margin:0;">Vsaj 5 in ne več kot 200 znakov</label>');}

                    return false;
                });

                _$input.bind('keypress', function(event){ if(event.keyCode == '13'){ _$addbtn.click(); return false;} });

                /** BRISANJE ITEMA */
                $('.'+_classDELName).live('click', function(){
                    $(this).parent().fadeOut('fast', function(){
                        $(this).remove();
                        if(parseInt($('.'+_fieldItem).length) <= 0){
                            _fieldContainer.append('<li class="'+_FIELD_ID +'_empty" style="width:436px;"><div class="rounded" style="padding:5px 9px; font-size: 13px; width: 354px;">(ni posebnih pogojev prevzema/unovčitve)</div></li>');
                        }
                    });
                });

                /** PREVERJANJE ERRORJA */
                _$input.bind('keyup', function(){
                    if(_$input.val().length > 5 && _$input.val().length < 200) {
                        $('.'+ _classERRName).remove();
                    }
                });

            }
        },
        /*
         * MICROPON: ??
         * DONATOR:  PITCH stavek kampanje
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        pitchStatement: {
            FIELD_ID: 'pitch_statement',
            validator: {
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){
                if(arg_params.mh_isampera) {
                    // Prikažem samo Amperi
                    return ''
                            // Field
                            +'<li class="dela_desc" style="margin-top: 8px;">'
						    +'  <label for="pitch_statement"><strong class="asteric" style="font-size: 13px;">*</strong> Pitch stavek</label>'
						    +'  <textarea style="height: 58px;" name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'"></textarea>'
						    +'</li>';
                } else {
                    // Tega polja ne prikažem upravljalcu
                    return '';
                }
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * MICROPON: ??
         * DONATOR:  PITCH stavek kampanje
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        badge: {
            FIELD_ID: 'badge',
            validator: {
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){
                if(arg_params.mh_isampera) {
                    // Prikažem samo Amperi
                    return ''
                            // Field
                            +'<li style="margin-bottom: 8px;">'
                            +'  <label for="'+this.FIELD_ID+'" style="padding-top: 0;"><strong class="asteric">*</strong>Značka kampanje</label>'
                            +'  <select name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'">'
                            +'      <option value="0" selected="selected">-- izberi značko --</option>'
                            +'      <option value="1">Živali</option>'
                            +'      <option value="2">Umetnost</option>'
                            +'      <option value="3">Izobraževanje</option>'
                            +'      <option value="4">Okolje</option>'
                            +'      <option value="5">Zdravje</option>'
                            +'      <option value="6">Človekove pravice</option>'
                            +'  </select>'
                            +'</li>';
                } else {
                    // Tega polja ne prikažem upravljalcu
                    return '';
                }
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Organizacija opiše svojo kampanjo
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        merchantOfferDescription: {
            FIELD_ID: 'description_description',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                // texte in take fore, bo potreno nastavit v vars, ker imam različne produkte in različne info.je rabim
                var _text_Ampera   = 'Opis kampanje';
                var _text_Merchant = 'Opis';
                if(arg_params.mh_product == 'macropon'){
                    _text_Ampera   = 'Vsebina oglasa';
                    _text_Merchant = 'Vsebina oglasa';
                }
                else if(arg_params.mh_product == 'nanopon'){
                    _text_Ampera   = 'Opis ponudbe';
                    _text_Merchant = 'Opis ponudbe';
                }

                // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                if(arg_params.mh_isampera && arg_params.mh_product != 'macropon' && arg_params.mh_product != 'nanopon') {
                    return ''
                            // Field
                          +'<li class="dela_desc" style="margin-top: 8px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> '+_text_Merchant+'</label>'
						  +'  <div id="'+this.FIELD_ID+'" class="writeup" style="border-bottom:1px solid gray; border-top:1px solid gray; font-size: 13px; margin-left:144px; padding:6px;"></div>'
						  //+'    <span class="field_desc">Iz zgornjega trgovčevega opisa, sestavi opis ko ga želiš imeti na javnem utripu ponudbe</span>'
						  +'</li>';
                }
                else {
                    return ''
                            // Field
                          +'<li class="dela_desc" style="margin-top: 8px;">'
                          +'  <label for="'+this.FIELD_ID+'"  style="padding-top:0;"><strong class="asteric">*</strong> '+_text_Ampera+'</label>'
                          +'  <textarea name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'"></textarea>'
                          +'  <span class="field_desc">Opišite produkt ali storitev, ki jo želite ponuditi. Bodite specifični in navedite čimveč detajlov. Iz tega opisa naša ekipa sestavi spremljajoči text k ponudbi.</span>'
                          +'</li>';
                }
            },
            setValue: function(arg_value){
                if(this._params.mh_isampera) {
                    $('#'+this.FIELD_ID).html(arg_value);
                }
                else {
                    $('#'+this.FIELD_ID).val(arg_value);
                }
            },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Samo donator ima tipping points
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        tippingPoints: {
            FIELD_ID: 'tipping_points',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                    // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                if(arg_params.mh_isampera) {
                    return ''
                            // Field
                            +'<div class="group_desc">'
                            +'  <h2>Določi tipping pointe kampanje</h2>'
                            //+'	<p>Več kot damo, več bomo doblili ;)</p>'
                            +'</div>'
                            +'<ol>'
                            +'  <li class="value">'
						    +'      <label for="tipping_point_one">01) Na doniranih</label>'
                            +'      <input name="tipping_point_one" id="tipping_point_one" autocomplete="off" type="text" value=""><strong style="font-size:13px; line-height: 26px; font-weight:normal;"><span style="font-size:14px;">EUR</span>, doda Microhint zraven</strong>  <input name="tipping_point_one_giveaway" id="tipping_point_one_giveaway" autocomplete="off" type="text" value=""><strong style="font-size:13px; font-weight:normal;"><span style="font-size:14px;">EUR</span></strong>'
                            +'  </li>'
                            +'  <li class="value">'
                            +'      <label for="tipping_point_two">02) Na doniranih</label>'
                            +'      <input name="tipping_point_two" id="tipping_point_two" autocomplete="off" type="text" value=""><strong style="font-size:13px; line-height: 26px; font-weight:normal;"><span style="font-size:14px;">EUR</span>, doda Microhint zraven</strong>  <input name="tipping_point_two_giveaway" id="tipping_point_two_giveaway" autocomplete="off" type="text" value=""><strong style="font-size:13px; font-weight:normal;"><span style="font-size:14px;">EUR</span></strong>'
                            +'  </li>'
                            +'      <li class="value">'
                            +'      <label for="tipping_point_three">03) Na doniranih</label>'
                            +'      <input name="tipping_point_three" id="tipping_point_three" autocomplete="off" type="text" value=""><strong style="font-size:13px; line-height: 26px; font-weight:normal;"><span style="font-size:14px;">EUR</span>, doda Microhint zraven</strong>  <input name="tipping_point_three_giveaway" id="tipping_point_three_giveaway" autocomplete="off" type="text" value=""><strong style="font-size:13px; font-weight:normal;"><span style="font-size:14px;">EUR</span></strong>'
                            +'  </li>'
                            +'</ol>'
                            +'<div class="clearfix"></div>';
                }
                else {
                    return ''
                            // Field
                          ;
                }
            },
            /**
             * XXX Tale rabi key/val za nafilat vseh 6 polj
             *      - 'tipping_point_one': micropon.tipping_point_one (20)
             *
             * @param array arg_value
             */
            setValue: function(arg_values){
                //console.log(arg_values);
                $.each(arg_values, function(i,v){
                    $('#'+v.id).val(v.value);
                });
            },
            /**
             * Dobim za vsako polje posebej vrednosti ven
             *  - tipping_point_one
             *  - tipping_point_two
             *  - tipping_point_three
             *  - tipping_point_one_giveaway
             *  - tipping_point_two_giveaway
             *  - tipping_point_three_giveaway
             *
             * @param arg_field
             */
            getValue: function(arg_field) {
                return $('#'+ arg_field).val();
            },
            // XXX enaka struktura kot setValue() varjanta
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Organizacija opiše svojo kampanjo
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        amperaOfferDescription: {
            FIELD_ID: 'description',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                    // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                if(arg_params.mh_isampera)
                {
                    this.validator.needsValidation = false; // spremeni na TRUE (ko napišeš validator)

                    return ''
                            // Field
                          +'<li class="dela_desc" style="margin-top: 8px;">'
                          +'  <label for="'+this.FIELD_ID+'"  style="padding-top:0;"><strong class="asteric">*</strong> Zgodba</label>'
                          +'  <style type="text/css">#'+this.FIELD_ID+'_container {margin-left: 144px;}</style>'    // tole nucam za pravilno pozicijoniranje RTEja
                          +'  <textarea name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'"></textarea>'
                          +'  <span class="field_desc">Spremljajoča zgodba dobrodelne kampanje</span>'
                          +'</li>';
                }
                else {
                    this.validator.needsValidation = false;

                    // nič ne prikažem v primeru, da gre za kreacijo ponudbe
                    return '';
                }
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function() {

                if(MHT.forms.editors.contentEditor != undefined) {
                    MHT.forms.editors.contentEditor.saveHTML();
			        return encodeURIComponent(MHT.forms.editors.contentEditor.get('element').value);
				}
				else {
					return $('#'+this.FIELD_ID).val();
				}
            },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                // XXX Tule bi lahko MHT.forms.editors prenesli v lokalen namespace
                if(this._params.mh_role == 'admin'){
                    MHT.forms.editors.contentEditor = new YAHOO.widget.SimpleEditor(this.FIELD_ID, {
                        height: '50px',
                        width: '440px',
                        dompath: false, 	//Turns on the bar at the bottom
                        animate: false, 	//Animates the opening, closing and moving of Editor windows
                        autoHeight: true,
                        ptags:		true,
                        toolbar: {
                            titlebar: false,
                            buttons: [
                                      { group: 'textstyle', buttons: [{ type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' }] },
                                      { type: 'separator' },
                                      { group: 'insertitem',buttons: [{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink'}]}
                            ]
                        }
                    });
                    MHT.forms.editors.contentEditor.render();
                }
            }
        },
        /*
         * Interval izvajanja kampanje na strani
         *
         * MICROPON: XXX prikažem začetni datum
         * DONATOR:  prikažem interval
         * NANOPON:  XXX prikažem interval
         * ESCAPE:   XXX prikažem interval
         *
         * Parsanje izbrane vrednosti: "SLUGOKRAJA_BRANDID_STARTTIME_ENDTIME"
         *
         */
        offerDistrictIntervalSelect: {
            FIELD_ID: 'interval_',
            brandID: 0,
            _params:  {},
            _valueArray: [],
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(brandID){ this.brandID = brandID; this.FIELD_ID = this.FIELD_ID + Math.floor ( Math.random ( ) * 1000 + 1 ); console.log(this.FIELD_ID); return this; },
            html: function(arg_params){

                this._params = arg_params;

                return ''
                       // Field
                       +'<td>'
                       +'  <span id="spinner_'+this.FIELD_ID+'_d" style="display:block; background:url(/public/images/spinner.gif) no-repeat 0 50%; padding-left:16px;" >Iščem okraje...</span>'
                       +'  <select id="'+this.FIELD_ID+'_d" name="purchase[district]['+this.FIELD_ID+']" style="display:none;">'
                       +'      <option value="0">-- Izberi okraj --</option>'
                       +'   </select>'
                       +'</td>'
                       +'<td>'
                       +'  <span id="placeholder_'+this.FIELD_ID+'_i" style="display:block;" >&laquo; najprej izberi okraj</span>'
                       +'  <span id="spinner_'+this.FIELD_ID+'_i" style="display:none; background:url(/public/images/spinner.gif) no-repeat 0 50%; padding-left:16px;" >Iščem proste datume...</span>'
                       +'  <span id="booked_'+this.FIELD_ID+'_i" style="display:none; color:red;" >Ni prostega datuma</span>'
                       +'  <select id="'+this.FIELD_ID+'_i" name="purchase[interval]['+this.FIELD_ID+']" style="display:none;">'
                       +'      <option value="0">-- Izberi datum --</option>'
                       +'   </select>'
                       +'</td>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            /**
             * Sparsam vlaue <select>-a in vrnem zahtevane dele
             *
             * @param string arg_value_name Ime property-a, ki ga želim
             */
            getValue: function(arg_value_name)
            {
                // XXX optimize with local property
                if(this._valueArray.length == 0) {
                    this._valueArray = $('#'+this.FIELD_ID +'_i option:selected').val().split('_');
                }

                switch(arg_value_name){
                    case 'district_slug':
                        return this._valueArray[0];
                        break;
                    case 'brand_id':
                        return this._valueArray[1];
                        break;
                    case 'date_start':
                        return this._valueArray[2];
                        break;
                    case 'date_end':
                        return this._valueArray[3];
                        break;
                }
            },
            disable:  function()         {
                //$('#'+this.FIELD_ID).prop('disabled',true);
                // XXX TODO
            },
            afterDOMInsertionInit: function(){

                var __brandID  = this.brandID;
                var __FIELD_ID = this.FIELD_ID;

                var _$d_select  = $('select#'+this.FIELD_ID+'_d');
                var _$d_spinner = $('#spinner_'+this.FIELD_ID+'_d');

                var _$i_select      = $('select#'+this.FIELD_ID+'_i');
                var _$i_placeholder = $('#placeholder_'+this.FIELD_ID+'_i');
                var _$i_spinner     = $('#spinner_'+this.FIELD_ID+'_i');
                var _$i_booked      = $('#booked_'+this.FIELD_ID+'_i');

                var _items_d       = '<option value="0" selected="selected">-- Izberi okraj --</option>';
                var __districtSLUG = '';

                var __prevSelectedValue = '';

                $.get('/store/store-data?store_slug='+ this._params.mh_storeslug, function(data, textStatus, XMLHttpRequest)
				{
					var store = data.stores[0].store;
                    var slugs = [];

                    $.each(store.store_locations.locations, function(i,v){
                        if(!MHT.utils.in_array(v.location.district_slug, slugs, false)) {
                            _items_d += '<option value="'+v.location.district_slug+'">'+ v.location.district_name +'</option>';
                            slugs.push(v.location.district_slug);
                        }
                    });

                    _$d_spinner.hide();
                    _$d_select.empty().append(_items_d).show();

                    //** Ko spremenim izbiro okraja, poženem preverjanje zasedenih datumov, da lahko prosti prikažem
                    _$d_select.bind('change', function(){

                        _$i_placeholder.hide();  // skrijem placeholder (če gre za prvo izbiro)
                        _$i_select.show();       // prikažem select (če gre za ponovno izbiro)

                        __districtSLUG = _$d_select.find("option:selected").val(); // SLUG izbranega okraja

                        $.get('/store/get-reserved-offer-dates?store_slug='+store.store_slug+'&districtslug='+ __districtSLUG +'&brandid='+ __brandID , function(data){

                            var __items = '<option value="0" selected="selected">-- Izberi datum --</option>';

                            //** Kolkiko dni traja offer?
                            var __daysIncrement   = 0;
                            var __startIncrement  = 0;

                            /***
                             * Donatorska kampanja
                             *
                             * Dobim zasedene datume
                             ***/
                            if(__brandID == '3')
                            {
                                var __availableIterations = 12; // 4 ponedeljki * 3 meseci


                                __daysIncrement = 7;

                                var dateMonday = Date.next().monday();   // XXX Štartu moram prišteti nekaj dni - koliko?
                                var currIter = 0;

                                var prevIterDays     = 0;
                                var nextIterDays     = 0;

                                __disabledOption     = '';

                                while(currIter <= __availableIterations) {

                                    nextIterDays = (currIter+1)*__daysIncrement;

                                    startDate    = Date.next().monday().add({ days:prevIterDays }).toString("dd.MMM.yyyy");    // 1.jan.2011
                                    startDate_TS = Date.next().monday().add({ days:prevIterDays }).getTime();                  // 9832091802
                                    endDate      = Date.next().monday().add({ days:nextIterDays} ).toString("dd.MMM.yyyy");    // 8.jan.2011
                                    endDate_TS   = Date.next().monday().add({ days:nextIterDays} ).getTime();                  // 9832091802

                                    //if(MHT.utils.in_array(startDate_TS, data, false)) { __disabledOption = 'disabled="disabled"'; }
                                    //else                                              { __disabledOption = '';                    }

                                    //** prikažem samo tiste, ki niso zasedeni (so prosti datumi)
                                    if(!MHT.utils.in_array(startDate_TS, data, false)) {
                                        __items += '<option value="'+__districtSLUG+'_'+__brandID+'_'+startDate_TS+'_'+endDate_TS+'" '+__disabledOption+' >'+startDate+' - '+endDate+'</option>';
                                    }

                                    prevIterDays = nextIterDays;
                                    currIter++;
                                } // end while
                            }
                            /**
                             * Dnevna ponudba
                             *
                             * Dobim zasedene datume
                             */
                            else if(__brandID == '2')
                            {
                                var __availableIterations = 50; // 50 dni / 1 dnevni interval

                                __startIncrement  = 7;  // XXX Štartu moram prišteti nekaj dni - koliko?
                                __daysIncrement   = 1;

                                var currIter     = 0;
                                var prevIterDays = 0;
                                var nextIterDays = 0;

                                __disabledOption = '';

                                while(currIter <= __availableIterations) {

                                    nextIterDays += __daysIncrement;

                                    startDate    = Date.today().add({ days:__startIncrement }).add({ days:prevIterDays }).toString("dd.MMMM.yyyy");   // 1.januar.2011
                                    startDate_TS = Date.today().add({ days:__startIncrement }).add({ days:prevIterDays }).getTime();                  // 9832091802
                                    endDate      = Date.today().add({ days:__startIncrement }).add({ days:nextIterDays} ).toString("dd.MMMM.yyyy");   // 8.januar.2011
                                    endDate_TS   = Date.today().add({ days:__startIncrement }).add({ days:nextIterDays} ).getTime();                  // 9832091802

                                    //if(MHT.utils.in_array(startDate_TS, data, false)) { __disabledOption = 'disabled="disabled"'; }
                                    //else                                              { __disabledOption = '';                    }

                                    //** prikažem samo tiste, ki niso zasedeni (so prosti datumi)
                                    if(!MHT.utils.in_array(startDate_TS, data, false)) {
                                        __items += '<option value="'+__districtSLUG+'_'+__brandID+'_'+startDate_TS+'_'+endDate_TS+'" '+__disabledOption+' >'+startDate+'</option>';
                                    }

                                    prevIterDays = nextIterDays;
                                    currIter++;
                                } // end while

                            }
                            /**
                             * Escape
                             *
                             * Dobim proste datume
                             */
                            else if(__brandID == '1' || __brandID == '4' || __brandID == '5')
                            {
                                __startIncrement  = 7;  // XXX Štartu moram prišteti nekaj dni - koliko?
                                var __lastingDays = 0;

                                __disabledOption = '';

                                if(__brandID == '1') { __lastingDays = 7; }
                                else if(__brandID == '4') { __lastingDays = 4; }
                                else if(__brandID == '5') { __lastingDays = 30; }

                                $.each(data, function(i, ts){

                                    //** pazim da je datum večji od potrebnega števila dni za pregled nanopona
                                    if(ts > Date.today().add({days:__startIncrement}).getTime())
                                    {
                                        startDate    = (new Date(ts)).toString('dd.MMM.yyyy');                 // 1.januar.2011
                                        startDate_TS = ts;                                                      // 9832091802
                                        endDate      = (new Date(ts)).add({days:__lastingDays}).toString('dd.MMM.yyyy');   // 8.januar.2011
                                        endDate_TS   = (new Date(ts)).add({days:__lastingDays}).getTime();                  // 9832091802

                                        //** prikažem samo tiste, ki niso zasedeni (so prosti datumi)
                                        __items += '<option value="'+__districtSLUG+'_'+__brandID+'_'+startDate_TS+'_'+endDate_TS+'" '+__disabledOption+' >'+startDate+' - '+endDate+'</option>';
                                    }

                                });
                            }

                            _$i_select.hide();       // skrijem select (če gre za ponovno izbiro)
                            _$i_placeholder.hide();  // skrijem placeholder (če gre za prvo izbiro)
                            _$i_spinner.show();      // prikažem spinner (v vsakem primeru)

                            _$i_spinner.hide();                         // skrijem spinner
                            _$i_select.empty().append(__items).show();  // prikažem <SELECT> z prostimi intervali

                            //** tiste datume v obrazcu, ki so že izbrani (in niso zabeleženi v DB) tule dizejblam
                            $.each($('select').find('option:selected'), function(){
                                _$i_select.find('option[value='+$(this).val()+']').prop('disabled', true);
                            });

                        });

                    });

                    //** dizejblam tale datum pri ostalih <select>-ih
                    _$i_select.bind('change', function(){
                        $('select').not(this).find('option[value='+__prevSelectedValue+']').prop('disabled', false);
                        $('select').not(this).find('option[value='+_$i_select.find('option:selected').val()+']').prop('disabled', true);
                        __prevSelectedValue = _$i_select.find('option:selected').val();

                        //** naredim še skupni poračun
                        var __total = 0;
                        $.each($('.pi_number'), function(){
                            __total += parseInt($(this).text());
                        });
                        $('#grand_total').text('€'+Globalize.format(__total,'n2'));
                    });
                });
            }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Organizacija - slike za kampanjo
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        merchantOfferPictures: {
            FIELD_ID: 'files',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                var _text_Ampera   = 'Slike kampanje';
                var _text_Merchant = 'Slike kampanje';
                if(arg_params.mh_product == 'macropon'){
                    _text_Ampera   = 'Slika oglasa';
                    _text_Merchant = 'Slika oglasa';
                }
                else if(arg_params.mh_product == 'nanopon'){
                    _text_Ampera   = 'Slika ponudbe';
                    _text_Merchant = 'Slika ponudbe';
                }

                    // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                if(arg_params.mh_isampera && arg_params.mh_product != 'nanopon') {
                    return ''
                            // Field
                            +'<li class="name" style="margin-bottom:20px;">'
                            +'  <label for="merchant_pics">Slikovni materjal</label>'
                            +'  <ul id="userFiles" style="margin-left: 144px; padding:6px 20px 6px 20px; border-top: 1px solid gray; border-bottom: 1px solid gray;"><li style="font-size: 13px; margin-bottom:0;">(Organizacija ni priložila nobene slike)</li></ul>'
                            +'</li>'
                           ;
                }
                else {
                    return ''
                        +'<li>'
                        +'  <label for="avatar"><strong class="asteric" style="font-size: 13px;">*</strong> '+_text_Merchant+'</label>'
                        +'	  <div id="fileupload" style="width: 444px; margin-left: 144px;">'
                     // +'	    <form action="/account/dealpic-upload?store_slug='+ storeSlug+'" method="POST" enctype="multipart/form-data"> '
                        +'	      <div class="fileupload-buttonbar"> '
                        +' 	        <label class="fileinput-button"> '
                        +'		      <span>Dodaj slike...</span> '
                        +' 			    <input type="file" name="'+this.FIELD_ID+'[]" multiple> '
                                +'						</label>'
                                // +'					<button type="submit" class="start">Start upload</button> '
                                // +'					<button type="reset" class="cancel">Cancel upload</button> '
                                // +'					<button type="button" class="delete">Izbriši vse datoteke</button> '
                                +'						<div class="clearfix"></div>'
                                +'					</div> '
                                // +'				</form>'
                                +'					<div class="fileupload-content">'
                                +' 						<table class="'+this.FIELD_ID+'"></table> '
                                +' 						<div class="fileupload-progressbar"></div> '
                                +' 					</div> '
                                +'				</div> '
                                +'				<script id="template-upload" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-upload{{if error}} ui-state-error{{/if}}">'
                                +'						<td class="preview"></td>'
                                +'						<td class="name">${name}</td>'
                                +' 						<td class="size">${sizef}</td>'
                                +' 						{{if error}}'
                                +'						<td class="error" colspan="2">Napaka:'
                                +'							{{if error === \'maxFileSize\'}}Prevelika datoteka'
                                +'							{{else error === \'minFileSize\'}}Premajhna datoteka'
                                +'							{{else error === \'acceptFileTypes\'}}Dovoljene so samo slike'
                                +'							{{else error === \'maxNumberOfFiles\'}}Preveč datotek'
                                +'							{{else}}${error}'
                                +' 						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                +'						<td class="progress"><div></div></td>'
                                +'						<td class="start"><button>Start</button></td>'
                                +'						{{/if}}'
                                +'						<td class="cancel"><button>Cancel</button></td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<script id="template-download" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-download{{if error}} ui-state-error{{/if}}">'
                                +'						{{if error}}'
                                +'						<td></td>'
                                +'	 					<td class="name">${name}</td>'
                                +'						<td class="size">${sizef}</td>'
                                +' 						<td class="error" colspan="2">Napaka:'
                                +' 							{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)'
                                +'							{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)'
                                +'							{{else error === 3}}File was only partially uploaded'
                                +'							{{else error === 4}}No File was uploaded'
                                +'							{{else error === 5}}Missing a temporary folder'
                                +' 							{{else error === 6}}Failed to write file to disk'
                                +'							{{else error === 7}}File upload stopped by extension'
                                +' 							{{else error === \'maxFileSize\'}}File is too big'
                                +' 							{{else error === \'minFileSize\'}}File is too small'
                                +' 							{{else error === \'acceptFileTypes\'}}Filetype not allowed'
                                +' 							{{else error === \'maxNumberOfFiles\'}}Max number of files exceeded'
                                +'  						{{else error === \'uploadedBytes\'}}Uploaded bytes exceed file size'
                                +'  						{{else error === \'emptyResult\'}}Empty file upload result'
                                +' 							{{else}}${error}'
                                +'  						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                 +' 						<td class="preview">'
                                +' 							{{if thumbnail_url}}'
                                +'							<a href="${url}" target="_blank"><img src="${thumbnail_url}" width="40" height="40"></a>'
                                +' 							{{/if}}'
                                +'						</td>'
                                +' 						<td class="name" style="width: 300px;">'
                                +'							<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>'
                                +' 						</td>'
                                +'						<td class="size">${sizef}</td>'
                                +'						<td colspan="2"></td>'
                                +'						{{/if}}'
                                +' 						<td class="delete">'
                                +'							<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>'
                                +' 						</td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<span class="field_desc">Slika naj čimbolje zajame vaše podjejte oz. produkt, ki ga ponujate</span>'
                                +'  		</li>';
                }
            },
            /**
             *
             * @param arg_value --> micropon.multimedia
             */
            setValue: function(arg_value){
                //$('#'+this.FIELD_ID).val(arg_value);

                _params = this._params;

                if(null !== arg_value) {
                    var files = [];
                    var fileName = '';
                    var hostName = window.location.host;

                    var userFilesXhtml = '';

                    $.each(arg_value, function(i, v){

                        fileName = v['file_name'];

                        if(v['uploader'] == '1') { userFilesXhtml += '<li><a href="/tmp/mppics/'+fileName+'" target="_blank">'+fileName+' (download)</a></li>'; }
                        else {

                            if(v['usefor'] == 'offer-merchant' || v['usefor'] == 'inadd') {
                                files.push({
                                    "name"			:fileName,
                                    //"size"			:902604,
                                    "url"			:'\/tmp\/mppics\/'+fileName,
                                    "thumbnail_url"	:'http://'+ hostName +'\/tmp\/mppics\/'+fileName,
                                    "delete_url"	:'\/account\/dealpic-upload?store_slug='+_params.mh_storeslug+'&file='+fileName,
                                    "delete_type"	:'DELETE'
                                });
                            }
                        }
                    });

                    if(this._params.mh_isampera && this._params.mh_product != 'nanopon') {
                        if(userFilesXhtml != '') { $('#userFiles').html(userFilesXhtml); }
                    }
                    else {
                        // Fizično jih vstavim v file uploader
                        var fu = $('#fileupload').data('fileupload');
                            fu._adjustMaxNumberOfFiles(-files.length);
                            fu._renderDownload(files)
                                .appendTo($('#fileupload .files'))
                                .fadeIn(function () {
                                    // Fix for IE7 and lower:
                                    $(this).show();
                                });
                    }

                }
            },
            getValue: function() {

                var data = {};

                /* sestavim še slike */
                $.each($('#fileupload td.name a'), function(i, v) {
                    data['multimedia['+i+']'] = $(v).text();
                });
                return data;
            },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _params = this._params;

                // Initialize the jQuery File Upload widget:
                $('#fileupload').fileupload({
                            autoUpload: true,
                            url: '/account/dealpic-upload?store_slug='+ _params.mh_storeslug,
                }).bind('fileuploaddestroy', function (e, data) { return false; })
                    .bind('fileuploadfail', function (e, data) { console.log('error'); return false; });

                // Open download dialogs via iframes,
                // to prevent aborting current uploads:
                $('#fileupload .'+this.FIELD_ID+' a:not([target^=_blank])').live('click', function (e) {
                    e.preventDefault();
                    $('<iframe style="display:none;"></iframe>').prop('src', this.href).appendTo('body');
                });
            }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Organizacija - slike za kampanjo
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        merchantLogoPicture: {
            FIELD_ID: 'logos',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                var _text_Ampera   = 'Logotip';
                var _text_Merchant = 'Logotip';
                if(arg_params.mh_product == 'macropon'){
                    _text_Ampera   = 'Logotip';
                    _text_Merchant = 'Logotip';
                }

                    // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                    return ''
                        +'<li>'
                        +'  <label for="avatar"><strong class="asteric" style="font-size: 13px;">*</strong> '+_text_Merchant+'</label>'
                        +'	  <div id="fileupload_'+this.FIELD_ID+'" style="width: 444px; margin-left: 144px;">'
                     // +'	    <form action="/account/dealpic-upload?store_slug='+ storeSlug+'" method="POST" enctype="multipart/form-data"> '
                        +'	      <div class="fileupload-buttonbar"> '
                        +' 	        <label class="fileinput-button"> '
                        +'		      <span>Dodaj slike...</span> '
                        +' 			    <input type="file" name="files[]" multiple> '
                                +'						</label>'
                                // +'					<button type="submit" class="start">Start upload</button> '
                                // +'					<button type="reset" class="cancel">Cancel upload</button> '
                                // +'					<button type="button" class="delete">Izbriši vse datoteke</button> '
                                +'						<div class="clearfix"></div>'
                                +'					</div> '
                                // +'				</form>'
                                +'					<div class="fileupload-content">'
                                +' 						<table class="files"></table> '
                                +' 						<div class="fileupload-progressbar"></div> '
                                +' 					</div> '
                                +'				</div> '
                                +'				<script id="template-upload" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-upload{{if error}} ui-state-error{{/if}}">'
                                +'						<td class="preview"></td>'
                                +'						<td class="name">${name}</td>'
                                +' 						<td class="size">${sizef}</td>'
                                +' 						{{if error}}'
                                +'						<td class="error" colspan="2">Napaka:'
                                +'							{{if error === \'maxFileSize\'}}Prevelika datoteka'
                                +'							{{else error === \'minFileSize\'}}Premajhna datoteka'
                                +'							{{else error === \'acceptFileTypes\'}}Dovoljene so samo slike'
                                +'							{{else error === \'maxNumberOfFiles\'}}Preveč datotek'
                                +'							{{else}}${error}'
                                +' 						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                +'						<td class="progress"><div></div></td>'
                                +'						<td class="start"><button>Start</button></td>'
                                +'						{{/if}}'
                                +'						<td class="cancel"><button>Cancel</button></td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<script id="template-download" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-download{{if error}} ui-state-error{{/if}}">'
                                +'						{{if error}}'
                                +'						<td></td>'
                                +'	 					<td class="name">${name}</td>'
                                +'						<td class="size">${sizef}</td>'
                                +' 						<td class="error" colspan="2">Napaka:'
                                +' 							{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)'
                                +'							{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)'
                                +'							{{else error === 3}}File was only partially uploaded'
                                +'							{{else error === 4}}No File was uploaded'
                                +'							{{else error === 5}}Missing a temporary folder'
                                +' 							{{else error === 6}}Failed to write file to disk'
                                +'							{{else error === 7}}File upload stopped by extension'
                                +' 							{{else error === \'maxFileSize\'}}File is too big'
                                +' 							{{else error === \'minFileSize\'}}File is too small'
                                +' 							{{else error === \'acceptFileTypes\'}}Filetype not allowed'
                                +' 							{{else error === \'maxNumberOfFiles\'}}Max number of files exceeded'
                                +'  						{{else error === \'uploadedBytes\'}}Uploaded bytes exceed file size'
                                +'  						{{else error === \'emptyResult\'}}Empty file upload result'
                                +' 							{{else}}${error}'
                                +'  						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                 +' 						<td class="preview">'
                                +' 							{{if thumbnail_url}}'
                                +'							<a href="${url}" target="_blank"><img src="${thumbnail_url}" width="40" height="40"></a>'
                                +' 							{{/if}}'
                                +'						</td>'
                                +' 						<td class="name" style="width: 300px;">'
                                +'							<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>'
                                +' 						</td>'
                                +'						<td class="size">${sizef}</td>'
                                +'						<td colspan="2"></td>'
                                +'						{{/if}}'
                                +' 						<td class="delete">'
                                +'							<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>'
                                +' 						</td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<span class="field_desc">Slika naj čimbolje zajame vaše podjejte oz. produkt, ki ga ponujate</span>'
                                +'  		</li>';
            },
            /**
             *
             * @param arg_value --> micropon.multimedia
             */
            setValue: function(arg_value){
                //$('#'+this.FIELD_ID).val(arg_value);

                _params = this._params;

                if(null !== arg_value) {
                    var files = [];
                    var fileName = '';
                    var hostName = window.location.host;

                    var userFilesXhtml = '';

                    $.each(arg_value, function(i, v){

                        fileName = v['file_name'];

                        if(v['usefor'] == 'logo') {
                            files.push({
                                "name"			:fileName,
                            //  "size"			:902604,
                                "url"			:'\/tmp\/mppics\/'+fileName,
                                "thumbnail_url"	:'http://'+ hostName +'\/tmp\/mppics\/'+fileName,
                                "delete_url"	:'\/account\/dealpic-upload?store_slug='+_params.mh_storeslug+'&file='+fileName,
                                "delete_type"	:'DELETE'
                            });
                        }
                    });

                     // Fizično jih vstavim v file uploader
                     var fu = $('#fileupload_'+this.FIELD_ID).data('fileupload');
                     fu._adjustMaxNumberOfFiles(-files.length);
                     fu._renderDownload(files)
                                .appendTo($('#fileupload_'+this.FIELD_ID+' .files'))
                                    .fadeIn(function () {
                                        // Fix for IE7 and lower:
                                        $(this).show();
                                    });

                }
            },
            getValue: function() {

                var data = {};

                /* sestavim še slike */
                $.each($('#fileupload_'+this.FIELD_ID+' td.name a'), function(i, v) {
                    data['multimedia['+i+']'] = $(v).text();
                });
                return data;
            },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _params = this._params;

                // Initialize the jQuery File Upload widget:
                $('#fileupload_'+this.FIELD_ID).fileupload({
                            autoUpload: true,
                            url: '/account/dealpic-upload?store_slug='+ _params.mh_storeslug,
                }).bind('fileuploaddestroy', function (e, data) { return false; })
                    .bind('fileuploadfail', function (e, data) { console.log('error'); return false; });

                // Open download dialogs via iframes,
                // to prevent aborting current uploads:
                $('#fileupload_'+this.FIELD_ID+' .files a:not([target^=_blank])').live('click', function (e) {
                    e.preventDefault();
                    $('<iframe style="display:none;"></iframe>').prop('src', this.href).appendTo('body');
                });
            }
        },
        /*
         * MICROPON: ??
         * DONATOR:  Skrbnik - slike za kampanjo
         * NANOPON:  ??
         * ESCAPE:   ??
         */
        amperaOfferPictures: {
            FIELD_ID: 'files',
            _params:  {},
            validator:{
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){

                this._params = arg_params;

                // XXX Pravila za prikazovanje (Ampera, Upravljalec, ipd.)
                if(!arg_params.mh_isampera && arg_params.mh_product != 'macropon') {
                    return ''
                            // Field
                           ;
                }
                else {
                    return ''
                        +'<li>'
                        +'  <label for="avatar"><strong class="asteric" style="font-size: 13px;">*</strong> Slike kampanje</label>'
                        +'	  <div id="fileupload" style="width: 444px; margin-left: 144px;">'
                     // +'	    <form action="/account/dealpic-upload?store_slug='+ storeSlug+'" method="POST" enctype="multipart/form-data"> '
                        +'	      <div class="fileupload-buttonbar"> '
                        +' 	        <label class="fileinput-button"> '
                        +'		      <span>Dodaj slike...</span> '
                        +' 			    <input type="file" name="'+this.FIELD_ID+'[]" multiple> '
                                +'						</label>'
                                // +'					<button type="submit" class="start">Start upload</button> '
                                // +'					<button type="reset" class="cancel">Cancel upload</button> '
                                // +'					<button type="button" class="delete">Izbriši vse datoteke</button> '
                                +'						<div class="clearfix"></div>'
                                +'					</div> '
                                // +'				</form>'
                                +'					<div class="fileupload-content">'
                                +' 						<table class="'+this.FIELD_ID+'"></table> '
                                +' 						<div class="fileupload-progressbar"></div> '
                                +' 					</div> '
                                +'				</div> '
                                +'				<script id="template-upload" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-upload{{if error}} ui-state-error{{/if}}">'
                                +'						<td class="preview"></td>'
                                +'						<td class="name">${name}</td>'
                                +' 						<td class="size">${sizef}</td>'
                                +' 						{{if error}}'
                                +'						<td class="error" colspan="2">Napaka:'
                                +'							{{if error === \'maxFileSize\'}}Prevelika datoteka'
                                +'							{{else error === \'minFileSize\'}}Premajhna datoteka'
                                +'							{{else error === \'acceptFileTypes\'}}Dovoljene so samo slike'
                                +'							{{else error === \'maxNumberOfFiles\'}}Preveč datotek'
                                +'							{{else}}${error}'
                                +' 						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                +'						<td class="progress"><div></div></td>'
                                +'						<td class="start"><button>Start</button></td>'
                                +'						{{/if}}'
                                +'						<td class="cancel"><button>Cancel</button></td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<script id="template-download" type="text/x-jquery-tmpl"> '
                                +'					<tr class="template-download{{if error}} ui-state-error{{/if}}">'
                                +'						{{if error}}'
                                +'						<td></td>'
                                +'	 					<td class="name">${name}</td>'
                                +'						<td class="size">${sizef}</td>'
                                +' 						<td class="error" colspan="2">Napaka:'
                                +' 							{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)'
                                +'							{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)'
                                +'							{{else error === 3}}File was only partially uploaded'
                                +'							{{else error === 4}}No File was uploaded'
                                +'							{{else error === 5}}Missing a temporary folder'
                                +' 							{{else error === 6}}Failed to write file to disk'
                                +'							{{else error === 7}}File upload stopped by extension'
                                +' 							{{else error === \'maxFileSize\'}}File is too big'
                                +' 							{{else error === \'minFileSize\'}}File is too small'
                                +' 							{{else error === \'acceptFileTypes\'}}Filetype not allowed'
                                +' 							{{else error === \'maxNumberOfFiles\'}}Max number of files exceeded'
                                +'  						{{else error === \'uploadedBytes\'}}Uploaded bytes exceed file size'
                                +'  						{{else error === \'emptyResult\'}}Empty file upload result'
                                +' 							{{else}}${error}'
                                +'  						{{/if}}'
                                +'						</td>'
                                +'						{{else}}'
                                +' 						<td class="preview">'
                                +' 							{{if thumbnail_url}}'
                                +'							<a href="${url}" target="_blank"><img src="${thumbnail_url}" width="40" height="40"></a>'
                                +' 							{{/if}}'
                                +'						</td>'
                                +' 						<td class="name" style="width: 300px;">'
                                +'							<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>'
                                +' 						</td>'
                                +'						<td class="size">${sizef}</td>'
                                +'						<td colspan="2"></td>'
                                +'						{{/if}}'
                                +' 						<td class="delete">'
                                +'							<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>'
                                +' 						</td>'
                                +' 					</tr>'
                                +'				</script> '
                                +'				<span class="field_desc">Slika naj čimbolje zajame vaše podjejte oz. produkt, ki ga ponujate</span>'
                                +'  		</li>';
                }
            },
            /**
             *
             * @param arg_value --> micropon.multimedia
             */
            setValue: function(arg_value){
                //$('#'+this.FIELD_ID).val(arg_value);

                if(null !== arg_value) {
                    var files = [];
                    var fileName = '';
                    var hostName = window.location.host;

                    var _params = this._params;

                    var userFilesXhtml = '';

                    $.each(arg_value, function(i, v){

                        fileName = v['file_name'];

                        if(v['uploader'] == '1') { userFilesXhtml += '<li><a href="/tmp/mppics/'+fileName+'" target="_blank">'+fileName+' (download)</a></li>'; }
                        else {
                            files.push({
                                "name"			:fileName,
                            //  "size"			:902604,
                                "url"			:'\/tmp\/mppics\/'+fileName,
                                "thumbnail_url"	:'http://'+ hostName +'\/tmp\/mppics\/'+fileName,
                                "delete_url"	:'\/account\/dealpic-upload?store_slug='+_params.mh_storeslug+'&file='+fileName,
                                "delete_type"	:'DELETE'
                            });
                        }
                    });

                    if(!this._params.mh_isampera) {
                        //if(userFilesXhtml != '') { $('#userFiles').html(userFilesXhtml); }
                    }
                    else {
//                        console.log($('#fileupload').data('fileupload'));
                        //Fizično jih vstavim v file uploader
                        var fu = $('#fileupload').data('fileupload');
                            fu._adjustMaxNumberOfFiles(-files.length);
                            fu._renderDownload(files)
                                .appendTo($('#fileupload .'+this.FIELD_ID))
                                .fadeIn(function () {
                                    // Fix for IE7 and lower:
                                    $(this).show();
                                });
                    }
                }//fi
            },
            /**
             *
             * @param arg_query QUERY za na server, ki ga modificiram
             */
            getValue: function() {

                // XXXX NE DELA!!

                var data = {};

                /* sestavim še slike */
                $.each($('#fileupload td.name a'), function(i, v) {
                    data[i] = $(v).text();
                });
                return data;
            },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){

                var _params = this._params;

                // Initialize the jQuery File Upload widget:
                $('#fileupload').fileupload({
                            autoUpload: true,
                            url: '/account/dealpic-upload?store_slug='+ _params.mh_storeslug,
                }).bind('fileuploaddestroy', function (e, data) { return false; })
                    .bind('fileuploadfail', function (e, data) { console.log('error'); return false; });

                // Open download dialogs via iframes,
                // to prevent aborting current uploads:
                $('#fileupload .'+this.FIELD_ID+' a:not([target^=_blank])').live('click', function (e) {
                    e.preventDefault();
                    $('<iframe style="display:none;"></iframe>').prop('src', this.href).appendTo('body');
                });
            }
        },
        /*
         * Search podjetja po DDV
         */
        searchCompany: {
            FIELD_ID: 'search_company_by_ddv',
            validator: {
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){
                    // Prikažem samo Amperi
                    return ''
                            // Field
                            +'<input type="text" id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" class="mh_input" placeholder="Davčna številka" style="width: 400px;">'
                            +'<a href="#" class="button ajaxsubmit" style="padding-top: 7px; padding-bottom: 8px;"><span class="icon magnifier"></span>Poišči</a>'
                            ;
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){
            }
        },
        /*
         * Search userjev po email-u
         */
        searchUser: {
            FIELD_ID: 'search_user_by_email',
            validator: {
               needsValidation: false     // explicitno določim ali ima ali nima element validacijo
            },
            init: function(){ return this; },
            html: function(arg_params){
                    // Prikažem samo Amperi
                    return ''
                            // Field
                            +'<input type="text" id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" class="mh_input" placeholder="Email" style="width: 400px;">'
                            +'<a href="#" class="button ajaxsubmit" style="padding-top: 7px; padding-bottom: 8px;"><span class="icon magnifier"></span>Poišči</a>'
                            ;
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); },
            afterDOMInsertionInit: function(){
            }
        },
        /*
         * COMPANY - ime podjetja
         */
        companyName: {
            FIELD_ID: 'company_name',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                required  : true,
	        		minlength : 10,
				    maxlength : 100
                },
                message: {
                    required : jQuery.format("Ime podjetja je obvezen podatek"),
				    minlength: jQuery.format("Ime podjetja naj vsebuje vsaj {0} znakov"),
				    maxlength: jQuery.format("Ime podjetja naj vsebuje največ {0} znakov")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Ime podjetja</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Polno ime podjetja" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * COMPANY - ime podjetja
         */
        companyDDV: {
            FIELD_ID: 'davcna',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" >'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Davčna</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Davčna številka podjejta" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * FIELD WIDGET - Lokacija
         */
        geoLocations: {
            FIELD_ID: 'geo_locations',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li style="margin-bottom: 0px;">'
                          +'    <label>Lokacije trgovin</label>'
                          +'    <ol id="selected-addresses" style="margin-top: 8px">'
        				  //+'	    <li class="pin pin_location" data-item-address="Tovarniška cesta 7" data-item-storelocation-phone="" data-item-storelocation-name="Pod taborom" data-item-city="Ajdovscina" data-item-googleaddress="7 Tovarniška cesta, Ajdovscina 5270, Slovenia" data-item-lat="13.903203964233" data-item-long="45.882476806641" data-item-postalcode="5270" data-item-street="Tovarniška cesta" data-item-streetnumber="7" style="text-align:left;">Tovarniška cesta 7, 5270 Ajdovscina <a class="xc_remove_item remove_item">odstrani x</a></li>'
        				  //+'	    <li class="pin pin_location" data-item-address="Tovarniška cesta 7" data-item-storelocation-phone="" data-item-storelocation-name="Pod taborom" data-item-city="Ajdovscina" data-item-googleaddress="7 Tovarniška cesta, Ajdovscina 5270, Slovenia" data-item-lat="13.903203964233" data-item-long="45.882476806641" data-item-postalcode="5270" data-item-street="Tovarniška cesta" data-item-streetnumber="7" style="text-align:left;">Tovarniška cesta 7, 5270 Ajdovscina <a class="xc_remove_item remove_item">odstrani x</a></li>'
        				  //+'	    <li class="pin pin_location" data-item-address="jožeta jame 14" data-item-city="Ljubljana" data-item-googleaddress="Ulica Jožeta Jame 14, 1210 Ljubljana, Slovenia" data-item-lat="46.0903548" data-item-long="14.478364000000056" data-item-postalcode="1210" data-item-street="Ulica Jožeta Jame" data-item-streetnumber="14" data-item-storelocation-phone="(01) 42345 239" data-item-storelocation-name="" style="text-align:left;">Ulica Jožeta Jame 14, 1210 Ljubljana <a class="xc_remove_item remove_item">odstrani x</a></li>'
        				  +'	    <li id="add-new-location" style="text-align:left; margin-bottom:10px;"><a class="a_dialog" href="http://microhint.com/?mh_showin=dialog&mh_form=create-location&mh_action=insert&mh_startedfrom=location-field&mh_isampera=false&mh_role=marketer" style="color: #0981BE; text-decoration: underline;">+ dodaj podružnico</a> <a id="sedez-podjetja" class="a_dialog" href="http://microhint.com/?mh_showin=dialog&mh_form=create-location&mh_action=primary&mh_startedfrom=location-field&mh_isampera=false&mh_role=marketer" style="color: #0981BE; text-decoration: underline;">+ dodaj sedež</a></li>'
                          +'    </ol>'
                          +'	<div class="clearfix"></div>'
                          +'</li>';
            },
            setValue: function(arg_value){
                // XXX TODO
                $('#'+this.FIELD_ID).val(arg_value);
            },
            getValue: function(){
                var locationLIs = $('#selected-addresses li').not('#add-new-location');
			    var _query      = [];

                $.each(locationLIs, function(i, v)
			    {
                    _query.push({
                        'address':              encodeURIComponent($(v).attr('data-item-address')),
                        'is_primary':           encodeURIComponent($(v).attr('is_primary')),
                        'city':                 encodeURIComponent($(v).attr('data-item-city')),
                        'google_address':       encodeURIComponent($(v).attr('data-item-googleaddress')),
                        'lat':                  encodeURIComponent($(v).attr('data-item-lat')),
                        'long':                 encodeURIComponent($(v).attr('data-item-long')),
                        'postal_code':          encodeURIComponent($(v).attr('data-item-postalcode')),
                        'street':               encodeURIComponent($(v).attr('data-item-street')),
                        'street_number':        encodeURIComponent($(v).attr('data-item-streetnumber')),
                        'storelocation_name':   encodeURIComponent($(v).attr('data-item-storelocation-name')),
                        'storelocation_phone':  encodeURIComponent($(v).attr('data-item-storelocation-phone'))
                    });
				});
                return _query;
            },
            disable:  function(){}
        },
        /*
         * Ulica in št.
         */
        geoPrimary: {
            FIELD_ID: 'is_primary',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_primary){
                    return ''
                            // Field
					      +'	<input id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" type="hidden" value="'+arg_primary+'">';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);},
            getValue: function(){ return $('#form_location').find('input#'+this.FIELD_ID).val();},  // XXX tule je hack in je potrebno poporavit
            disable:  function(){}
        },
        /*
         * Ulica in št.
         */
        geoStreet: {
            FIELD_ID: 'street_name',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(){
                    return ''
                            // Field
                          +'<li>'
						  +'    <label for="'+this.FIELD_ID+'"><strong class="asteric">*</strong> Ulica</label>'
					      +'	<input id="'+this.FIELD_ID+'" name="'+this.FIELD_ID+'" placeholder="Ulica in hišna številka" type="text" value="">'
						  //+'    <span class="field_desc">Primer: <i>"Jožeta Jame 14"</i></span>'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);},
            getValue: function(){ return $('#form_location').find('input#'+this.FIELD_ID).val();},  // XXX tule je hack in je potrebno poporavit
            disable:  function(){}
        },
        /*
         * Mesto/Vas
         */
        geoCity: {
            FIELD_ID: 'city_name',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li>'
						  +'    <label for="'+this.FIELD_ID+'"><strong class="asteric">*</strong> Kraj</label>'
					      +'	<input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Ime kraja" type="text">'
						  //+'    <span class="field_desc">Primer: <i>"Jožeta Jame 14"</i></span>'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);},
            getValue: function(){return $('#form_location').find('input#'+this.FIELD_ID).val();},
            disable:  function(){}
        },
        /*
         * Mesto/Vas
         */
        geoPostalCode: {
            FIELD_ID: 'postalcode_number',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li>'
						  +'    <label for="'+this.FIELD_ID+'"><strong class="asteric">*</strong> Poštna št.</label>'
					      +'	<input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Poštna številka" type="text">'
						  //+'    <span class="field_desc">Primer: <i>"Jožeta Jame 14"</i></span>'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);},
            getValue: function(){ return $('#form_location').find('input#'+this.FIELD_ID).val();},
            disable:  function(){}
        },
        /*
         * Tel. št. poslovalnice
         */
        geoPhone: {
            FIELD_ID: 'store_phone',
            validator: {
               needsValidation: false,
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li>'
						  +'    <label for="'+this.FIELD_ID+'"><strong class="asteric">*</strong> Telefonska št.</label>'
					      +'	<input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Telefonska številka poslovalnice" type="text">'
						  //+'    <span class="field_desc">Primer: <i>"Jožeta Jame 14"</i></span>'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);},
            getValue: function(){return $('#form_location').find('input#'+this.FIELD_ID).val();},
            disable:  function(){}
        },
        /*
         * COMPANY - ime podjetja
         */
        userName: {
            FIELD_ID: 'user_name',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true,
                },
                message: {
                    required : jQuery.format("Ime in priimek uporabnika je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Ime upravljalca</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Ime in priimek upravljalca" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - ime podjetja
         */
        userName: {
            FIELD_ID: 'user_name',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true,
                },
                message: {
                    required : jQuery.format("Ime in priimek uporabnika je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Ime in priimek</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Ime in priimek uporabnika" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - email
         */
        userEmail: {
            FIELD_ID: 'user_email',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true,
                },
                message: {
                    required : jQuery.format("Email uporabnika je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Email</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Email uporabnika" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - nickname
         */
        userNickname: {
            FIELD_ID: 'user_nickname',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true,
                },
                message: {
                    required : jQuery.format("Nickname uporabnika je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Uporabniško ime</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Nickname uporabnika" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - phone
         */
        userPhone: {
            FIELD_ID: 'user_phone',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true,
                },
                message: {
                    required : jQuery.format("Telefonska št. uporabnika je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:20px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Telefonska št.</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Nickname uporabnika" autocomplete="off" type="text">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - novo geslo
         */
        userPasswordNew: {
            FIELD_ID: 'user_password',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required  : true
                },
                message: {
                    required : jQuery.format("Novo geslo je obvezen podatek")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:10px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Novo geslo</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Vnesi novo geslo" autocomplete="off" type="password">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - novo geslo
         */
        userPasswordNewRepeat: {
            FIELD_ID: 'user_password_repeat',
            validator: {
               needsValidation: true,     // explicitno določim ali ima ali nima element validacijo
               rule: {
                    required: true,
                    equalTo:  "#user_password"
                },
                message: {
                    required:   jQuery.format("Ponovljeno geslo je obvezen podatek"),
                    equalTo:    jQuery.format("Gesli se ne ujemata. Morata se ujemati")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:10px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Ponovi geslo</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Ponovi vnos gesla" autocomplete="off" type="password">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        },
        /*
         * USER - izbira okraja
         */
        userDistrictsSelect: {
            FIELD_ID: 'user_district_select',
            validator: {
               needsValidation: false,
               rule: {
                    required: true
                },
                message: {
                    required:   jQuery.format("Vsaj en okraj mora biti izbran")
                }
            },
            init: function(){ return this; },
            html: function(arg_params){
                    return ''
                            // Field
                          +'<li class="name" style="margin-bottom:10px;">'
						  +'  <label for="'+this.FIELD_ID+'"><strong class="asteric" style="font-size: 13px;">*</strong> Ponovi geslo</label>'
			              +'  <input name="'+this.FIELD_ID+'" id="'+this.FIELD_ID+'" placeholder="Ponovi vnos gesla" autocomplete="off" type="password">'
						  +'</li>';
            },
            setValue: function(arg_value){ $('#'+this.FIELD_ID).val(arg_value);        },
            getValue: function()         { return $('#'+this.FIELD_ID).val();          },
            disable:  function()         { $('#'+this.FIELD_ID).prop('disabled',true); }
        }
    };

    /**
     * FORMS componenta
     *
     * Metoda APPENDa xhtml zahtevanega obrazca, skupaj z validatorjem
     * in submit eventom
     *
     * Terminologija:
     *  - insert[ime obrazca]Form()
     *  - update[ime obrazca]Form()
     *
     *
     * Obrazci:
     *  1.  insertUserAndCompanyForm()
     *      ------------------------------------------------------------
     *      Obrazec je primarno namenjen za tržnike. Vstavi v DB
     *      novega userja (z random geslom) in mu pripopa novo trgovino.
     *      ------------------------------------------------------------
     *
     *  2.  insertDailyOfferForm()
     *      ------------------------------------------------------------
     *      Obrazec za kreacijo nove "dnevne ponudbe"
     *      ------------------------------------------------------------
     *
     *  3.  insertDonateOfferForm()
     *      ------------------------------------------------------------
     *      Obrazec za kreacijo nove "dobrodelne kampanje"
     *      ------------------------------------------------------------
     */
    MHT.fastsolution.forms = {
        DEBUG: false,
        _params: {},
        _displayComponent: {},
        /**
         * Metoda požreba pravilen obrazec glede na vhodna parametre (params) in se odloči
         * ali naredi GET klic na server (update) ali naloži prazen obrazec (insert)
         *
         * @param $content_placeholder  (jQuery Object)     Element kamor pirpopam vsebino obrazca
         * @param params                (JavaScript Object) Sparsani parametri iz URLja (IDji,SLUGi in ostali podakti)
         */
        init: function($content_placeholder, params){
            if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.init()'); }

            var _$form = '';

            this._displayComponent = $content_placeholder;
            this._params = params;

            switch(params.mh_form)
            {
                case 'micronator-offer':
                    _$form = MHT.fastsolution.forms.micronator_OfferForm.init(params);                          // inicializiram xhtml obrazca
                    $content_placeholder.append(_$form.html());                                                 // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.micronator_OfferForm.setup(_$form, params, $content_placeholder);    // Dodam Validator in Submit Event Handler
                    break;
//                case 'dailydeal-offer':
//                    if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.init()'); }
//                    break;
                /***********************************************
                 * obazec update MACROPONa
                 ***********************************************/
                case 'macropon-offer':
                    _$form = MHT.fastsolution.forms.macropon_OfferForm.init(params);                          // inicializiram xhtml obrazca
                    $content_placeholder.append(_$form.html());                                                 // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.macropon_OfferForm.setup(_$form, params, $content_placeholder);    // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * obazec update NANOPONa
                 ***********************************************/
                case 'nanopon-offer':
                    _$form = MHT.fastsolution.forms.nanopon_OfferForm.init(params);                          // inicializiram xhtml obrazca
                    $content_placeholder.append(_$form.html());                                                 // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.nanopon_OfferForm.setup(_$form, params, $content_placeholder);    // Dodam Validator in Submit Event Handler
                    break;
                case 'micronator-basket':
                    this._displayComponent.dialog('option','title','Izberi okraj in željen čas izvajanja kampanje');
                    _$form = MHT.fastsolution.forms.micronator_OfferBuyForm.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());                                                   // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.micronator_OfferBuyForm.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * obazec za CELOTNO KOŠARICO
                 *  - XXX prednastavi jo z izbiro userja
                 *        (itaq zmeraj lahko vse izbere)
                 ***********************************************/
                case 'products-basket':
                    this._displayComponent.dialog('option','title','Izberi produkte, okraje in željen čas izvajanja kampanj');
                    _$form = MHT.fastsolution.forms.merchant_productBuyForm.init(params);                         // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());                                                       // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.merchant_productBuyForm.setup(_$form, params, $content_placeholder);   // Dodam Validator in Submit Event Handler
                    break;
                case 'marketer-wizard':
                    this._displayComponent.dialog('option','title','Poglej, če podjetje obstaja');
                    _$form = MHT.fastsolution.forms.matketer_form_searchddv.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+15) );               // Vstavim obrazec v DOM
                    MHT.fastsolution.forms.matketer_form_searchddv.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * obazec NOVA TRGOVINA (na obstoječega userja)
                 ***********************************************/
                case 'create-store':
                    this._displayComponent.dialog('option','title','Vpiši podatke za novo trgovino');
                    _$form = MHT.fastsolution.forms.form_store.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+30) );
                    MHT.fastsolution.forms.form_store.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * obazec NOV USER + TRGOVINA
                 ***********************************************/
                case 'create-user-store':
                    this._displayComponent.dialog('option','title','Vpiši podatke za novega uporabnika & trgovino');
                    _$form = MHT.fastsolution.forms.marketer_form_user_store.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+30) );
                    MHT.fastsolution.forms.marketer_form_user_store.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * obazec DODAJ LOKACIJO
                 ***********************************************/
                case 'create-location':
                    this._displayComponent.dialog('option','title','Vpiši podatke za novo lokacijo');
                    _$form = MHT.fastsolution.forms.form_location.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+30) );
                    MHT.fastsolution.forms.form_location.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * zamenjaj geslo z novim (brez starega)
                 ***********************************************/
                case 'pwd-change':
                    this._displayComponent.dialog('option','title','Vpis novega gesla');
                    _$form = MHT.fastsolution.forms.user_form_change_pwd.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+30) );
                    MHT.fastsolution.forms.user_form_change_pwd.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
                /***********************************************
                 * naroči se na newsletter (user)
                 ***********************************************/
                case 'newsletter-subscribe':
//                    $('.call-to-action fieldset').css('height', '210');
                    $('#top-msg').show().find('fieldset').css('height', '210');
                    this._displayComponent.bind("dialogclose", function(event, ui) {
                        $('.call-to-action fieldset').css('height', '83');
                        $.cookie('_mh_topnewlsub_close', '1', {path:'/', domain: '.microhint.com', expires: 1});
                    });
                    this._displayComponent.dialog("option", "title",'');
                    this._displayComponent.dialog("option", "dialogClass", 'no-title' );
                    _$form = MHT.fastsolution.forms.user_form_newsletter.init(params);                       // inicializiram xhtml obrazca
                    $content_placeholder.html(_$form.html());
                    this._displayComponent.dialog('option','width', (_$form.html().width()+30) );
                    this._displayComponent.dialog("option", "position", 'top');
                    MHT.fastsolution.forms.user_form_newsletter.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
                    break;
//                case 'merchant-basket':
//
//                    this._displayComponent.dialog('option','title','Izberi okraj in željen čas izvajanja kampanje');
//
//                    _$form = MHT.fastsolution.forms.micronator_OfferBuyForm.init(params);                       // inicializiram xhtml obrazca
//                    $content_placeholder.html(_$form.html());                                               // Vstavim obrazec v DOM
//                    MHT.fastsolution.forms.micronator_OfferBuyForm.setup(_$form, params, $content_placeholder); // Dodam Validator in Submit Event Handler
//
//                    // XXX prestavi v odgovoren widget
//                    $( "#payment-accordion" ).accordion({
//                        autoHeight: false,
//                        navigation: true,
//                        //active:     0,
//                        active:     false,
//                        collapsible:true
//                    });
//                    break;
            }


            // XXX gas dalje!
        },
        show: function($content_placeholder, FORM_DOM_ID){

            if(this._params.mh_showin == 'popout') {
                this._displayComponent.find('.pop-out-content-spinner').hide();
            }
            else if(this._params.mh_showin == 'dialog'){
                this._displayComponent.dialog('open');
                $('#'+FORM_DOM_ID).show();
            }
            $('#'+FORM_DOM_ID).show();
        },
        close: function($content_placeholder, FORM_DOM_ID){

            if(this._params.mh_showin == 'popout') {
                // XXX akcija za "popup"
                $('.pop-out').hide();
                $('.pop-out-content').html('');
                $('#main-container').show();
                $.scrollTo(0, 500);
                //this._displayComponent.hide();
            }
            else if(this._params.mh_showin == 'dialog'){
                this._displayComponent.dialog('close');
            }
            $('#'+FORM_DOM_ID).parent().parent().remove();
        },
        micronator_OfferForm: {
            FORM_DOM_ID: 'micronator_OfferForm',     // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferForm.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                if(arg_params.mh_action == 'update')      { this.setUrl('ampera/update-micropon-status'); title = 'Uredi dobrodelno kampanjo'; }
                else if(arg_params.mh_action == 'insert') { this.setUrl('store/add-micropon'); title = 'Kreiraj dobrodelno kampanjo'; }

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['namenKampanje']              = MHT.form.fields.headlineDescription.init();
                this.fields['naslovKampanje']             = MHT.form.fields.headline.init();
                this.fields['badgeKampanje']              = MHT.form.fields.badge.init();
                this.fields['organizacija_opisKampanje']  = MHT.form.fields.merchantOfferDescription.init();
                this.fields['ampera_opisKampanje']        = MHT.form.fields.amperaOfferDescription.init();
                this.fields['organizacija_slikaKampanje'] = MHT.form.fields.merchantOfferPictures.init();
                this.fields['ampera_slikaKampanje']       = MHT.form.fields.amperaOfferPictures.init();
                this.fields['ampera_tippingPoints']       = MHT.form.fields.tippingPoints.init();
                this.fields['ampera_pitchStatement']       = MHT.form.fields.pitchStatement.init();


                this._$form = $(
                         '<div id="'+this.FORM_DOM_ID+'" style="display:none;">'
                            +'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff; font-weight:normal;">'+title+'</h1>'
                            +'</div>'
                            +'<div style="margin:0 auto; padding:14px 14px 14px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'<form action="#" method="post" id="newOfferRequest_dailydeal">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder"></div>'

                            +'		<div class="group_desc" style="margin-top: 8px;">'
                            +'			<h2>Povzetek datuma izvajanja kampanje in njen namen</h2>'
                            +'		</div>'
                            +'		<ol>'
                                        // XXX Okraji
                            +           this.fields.districts.html()

                            +'  		<li class="value" style="margin-top:14px;">'
                            +'  			<label for="date_start" style="padding-top: 0;"><strong class="asteric">*</strong>Izvajanje</label>'
                            +'				<div class="date_wrap">'
                            +'					<span style="margin:7px 4px 0 0; font-size:13px; font-weight:normal;">začetek:</span> <span id="dk_start_date"  style="margin:7px 4px 0 0; font-size:13px; text-decoration:underline;"></span> <span  style="margin:6px 4px 0 0; font-size:13px;  font-weight:normal;">zaključek: </span> <span id="dk_end_date"  style="margin:6px 4px 0 0; font-size:13px; text-decoration:underline;"></span>'
                            +'				</div>'
                            +'				<span class="field_desc clearfix" style="width:auto;"></span>'
                            +'  		</li>'

                            +           this.fields.namenKampanje.html(arg_params)
                            +           this.fields.naslovKampanje.html(arg_params)
                            +           this.fields.badgeKampanje.html(arg_params)

//                            +'          <li>'
//                            +'  			<label for="badge" style="padding-top: 0;"><strong class="asteric">*</strong>Značka kampanje</label>'
//                            +'              <select name="badge" id="badge">'
//                            +'                  <option value="1">Živali</option>'
//                            +'                  <option value="2">Umetnost</option>'
//                            +'                  <option value="3">Izobraževanje</option>'
//                            +'                  <option value="4">Okolje</option>'
//                            +'                  <option value="5">Zdravje</option>'
//                            +'                  <option value="6">Človekove pravice</option>'
//                            +'              </select>'
//                            +'          </li>'

                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'

                            +           this.fields.ampera_tippingPoints.html(arg_params)

                            +'		<div class="group_desc" style="margin-top: 18px;">'
                            +'			<h2>Slikovni in textovni materijal za izvajanje kamanje na strani</h2>'
                            +'			<p>Bodite specifični in navedite kar največ podatkov, dejstev in zgodb. Tako bo naša ekipa lažje sestavila super textovno predstavitev kampanje.</p>'
                            +'		</div>'
                            +'		<ol>'
                            +           this.fields.organizacija_slikaKampanje.html(arg_params)
                            +           this.fields.ampera_slikaKampanje.html(arg_params)
                            +           this.fields.organizacija_opisKampanje.html(arg_params)
                            +           this.fields.ampera_pitchStatement.html(arg_params)
                            +           this.fields.ampera_opisKampanje.html(arg_params)
                            +'		</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'  <div class="box store-profile-settings button_wrap" style="padding:14px 0 14px 10px; margin-bottom:14px;">'
                            +'	    <div id="error-placeholder" class="error" style="font-size:1.2em; text-align:center; margin:0 0 8px 0px; display:none;"></div>'
                            +       this.fields.button.toactionNew.html(arg_params)
                            +       this.fields.button.toactionEditedMarketer.html(arg_params)
                            +       this.fields.button.toactionReview.html(arg_params)
                            +       this.fields.button.toactionDraft.html(arg_params)
                            +       this.fields.button.toactionRuntimeUpdate.html(arg_params)
                            +       this.fields.button.toactionReject.html(arg_params)
                            +'  </div>'
                            +'</form>'
                            +'</div>'
                            +'<div style="padding-top:28px;"></div>'
                        +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        _toStatus: 'new',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'marketer' || arg_params.mh_role == 'admin') {
                                return '';
                            }
                            else {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                                    ;
                            }
                        }
                    },
                    toactionEditedMarketer: {
                        FIELD_ID: 'btn_action_editedmarketer',
                        _toStatus: 'edited-marketer',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'user') {
                                return '';
                            }
                            else if(arg_params.mh_role == 'marketer') {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji trgovcu povzetek ponudbe</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }
                        }
                    },
                    toactionRuntimeUpdate: {
                        FIELD_ID: 'btn_action_runtimeupdate',
                        _toStatus: 'runtime-update',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon reload"></span>Runtime update</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReview: {
                        FIELD_ID: 'btn_action_review',
                        _toStatus: 'review',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:114px;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="positive button ajaxsubmit" style="text-align: center;"><span class="icon check"></span>Pošlji v predogled</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionDraft: {
                        FIELD_ID: 'btn_action_draft',
                        _toStatus: 'draft',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon clock"></span>Shrani osnutek</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReject: {
                        FIELD_ID: 'btn_action_reject',
                        _toStatus: 'reject',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="negative button ajaxsubmit" style="text-align: center;"><span class="icon cross"></span>Zavrni</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    }
                },
                districts: {
                    validator: {
                        needsValidation: false
                    },
                    html: function(){
                        return ''
                            +'  		<li>'
                            +'  			<label for="district-selector"  style="padding-top:0px;">Okraj akcije</label>'
                            +'				<ul class="mht-districts" id="district-selector" style="margin-top:8px; margin-left: 144px; list-style:none; ">'
                            +'					<li id="district_loading" class="data district" style="text-align:left; float:none;">'
                            +'						<span style="font: normal 13px arial, sans-serif; background: url(/public/images/spinner.gif) no-repeat 0 50%; padding-left: 16px; color: #333;">Nalagam...</span>'
                            +'					</li>'
                            +'					<li id="district_8" class="data district" style="display:none; text-align:left; float:none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="8" data-item-slug="koprski-okraj"><span style="margin-bottom:0px;"></span>Koprski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_7" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="7" data-item-slug="novogoriski-okraj"><span style="margin-bottom:0px;"></span>Novogoriški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_3" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="3" data-item-slug="ljubljanski-okraj"><span style="margin-bottom:0px;"></span>Ljubljanski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_6" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="6" data-item-slug="kranjski-okraj"><span style="margin-bottom:0px;"></span>Kranjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_5" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="5" data-item-slug="celjski-okraj"><span style="margin-bottom:0px;"></span>Celjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_9" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="9" data-item-slug="novomeski-okraj"><span style="margin-bottom:0px;"></span>Novomeški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_4" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="4" data-item-slug="mariborski-okraj"><span style="margin-bottom:0px;"></span>Mariborski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_10" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="10" data-item-slug="murskosoboski-okraj"><span style="margin-bottom:0px;"></span>Murskosoboški okraj</a></strong>'
                            +'					</li>'
                            +'				</ul>'
                            +'				<input type="hidden" name="districtslug" id="districtslug">'
                            +'				<div class="clearfix"></div>'
                            +'				<span style="display:block; color:red; float:none; margin-left:0; font-weight:bold;" class="err-district"></span>'
                            +'  		</li>'
                        ;
                    },
                    load: function(){

                    },
                    setValues: function(arg_values){

                    },
                    getValues: function(){

                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferForm.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert
                //console.log(arg_$form);

                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

					var micropon = data.micropons[0].micropon;

                    // XXX na malo lepše mesto je potrebno tole postavit
                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">'+micropon.district_name+'</div>');

                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));

                    // Nastavim polja iz DB
                    arg_$form.fields.namenKampanje.setValue(micropon.description_headline);                 // namen donacij - organizacija
                    arg_$form.fields.naslovKampanje.setValue(micropon.headline);                            // namen donacij - ampera
                    arg_$form.fields.badgeKampanje.setValue(micropon.badge_id);                             // značka        - ampera
                    arg_$form.fields.organizacija_opisKampanje.setValue(micropon.description_description);  // opis kampanje - organizacija
                    arg_$form.fields.ampera_pitchStatement.setValue(micropon.pitch_statement);              // pitch state,  - ampera
                    arg_$form.fields.ampera_opisKampanje.setValue(micropon.description);                    // opis kampanje - ampera

                    arg_$form.fields.ampera_tippingPoints.setValue([
                        {'id':'tipping_point_one','value':micropon.tipping_point_one},
                        {'id':'tipping_point_two','value':micropon.tipping_point_two},
                        {'id':'tipping_point_three','value':micropon.tipping_point_three},
                        {'id':'tipping_point_one_giveaway','value':micropon.tipping_point_one_giveaway},
                        {'id':'tipping_point_two_giveaway','value':micropon.tipping_point_two_giveaway},
                        {'id':'tipping_point_three_giveaway','value':micropon.tipping_point_three_giveaway},
                    ]);
//
//                    arg_$form.field.namenDonacije.setValue(micropon.description_headline);  // XXX FIX opis pitch stavek Skrbnika

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

                    //** OBVEZNO ZA init()
                    arg_$form.fields.organizacija_slikaKampanje.setValue(micropon.multimedia);        // slike kampanje - organizacija
                    arg_$form.fields.ampera_slikaKampanje.setValue(micropon.multimedia);              // slike kampanje - ampera

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'store_slug': 			   arg_params.mh_storeslug,
                        'mp_id': 			       arg_params.mh_microponid,

                        //'files':                   arg_$form.fields.organizacija_slikaKampanje.getValue(),
                        'status': 				   $(this).attr('data-item-tostatus'),
                        'headline_description':    arg_$form.fields.namenKampanje.getValue(),
                        'headline':                arg_$form.fields.naslovKampanje.getValue(),
                        'badge_id':                arg_$form.fields.badgeKampanje.getValue(),
                        'description_description': arg_$form.fields.organizacija_opisKampanje.getValue(),
                        'description':             arg_$form.fields.ampera_opisKampanje.getValue(),
                        'pitch_statement':         arg_$form.fields.ampera_pitchStatement.getValue(),

                        'tipping_point_one':       arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_one'),
                        'tipping_point_two':       arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_two'),
                        'tipping_point_three':     arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_three'),
                        'tipping_point_one_giveaway':     arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_one_giveaway'),
                        'tipping_point_two_giveaway':     arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_two_giveaway'),
                        'tipping_point_three_giveaway':   arg_$form.fields.ampera_tippingPoints.getValue('tipping_point_three_giveaway')
                    };

                    /* sestavim še FB ADD slike */
					var pics = _$form.find('#fileupload td.name a');
                    var i = 0;
					$.each(pics, function(i, v) {
						query['multimedia['+i+']'] = {
                            'name':   $(v).text(),
                            'usefor': 'offer-merchant'
                        };
					});

                    console.log(query);
                    //return false;

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'micropon_marketers-wizard':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                      // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);                                     // flash
                                    $('#actions_'+arg_params.mh_storeslug).html(MHT.status.interpret('3_marketer-added', arg_params));  // replace actions
                                    break;
                                case 'micronator_wall-item':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);
                                    // XXX neka akcija na view-u
                                    //$('#actions_paket_reserve_dk_date').replaceWith('<span style="font-size:12px; color:#999; font-style:italic;">Naslednjo dobrodelno kampanjo lahko kreirate čez cca. 60dni.</span>');  // replace actions

                                    // XXX spremeni akcijski gumb!
                                    $('#product_'+data.micropons[0].micropon.id).replaceWith(MHT.list.product.generateItem(data.micropons[0].micropon, arg_params.mh_role));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);

                                    break;
                                default:
                                    //# Privzeto (če nimam flag-a) reloadam page
                                    window.location = '/redirect-to?url='+window.location.href;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        macropon_OfferForm: {
            FORM_DOM_ID: 'macropon_OfferForm',     // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.macropon_OfferForm.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('ampera/update-micropon-status'); title = 'Uredi Macropon';

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['namenMacropona']        = MHT.form.fields.headlineDescription.init();         // naslov oglasa
                this.fields['podjetjeMacroponText']  = MHT.form.fields.merchantOfferDescription.init();    // text oglasa
                this.fields['podjetjeMacroponSlika'] = MHT.form.fields.merchantOfferPictures.init();       // FB slika
                this.fields['podjetjeLogo']          = MHT.form.fields.merchantLogoPicture.init();         // logotip


                this._$form = $(
                         '<div id="'+this.FORM_DOM_ID+'" style="display:none;">'
                            +'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff; font-weight:normal;">'+title+'</h1>'
                            +'</div>'
                            +'<div style="margin:0 auto; padding:14px 14px 14px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'<form action="#" method="post" id="newOfferRequest_dailydeal">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder"></div>'

                            +'		<div class="group_desc" style="margin-top: 8px;">'
                            +'			<h2>Povzetek datuma izvajanja kampanje in njen namen</h2>'
                            +'		</div>'
                            +'		<ol>'
                                        // XXX Okraji
                            +           this.fields.districts.html()

                            +'  		<li class="value" style="margin-top:14px;">'
                            +'  			<label for="date_start" style="padding-top: 0;"><strong class="asteric">*</strong>Izvajanje</label>'
                            +'				<div class="date_wrap">'
                            +'					<span style="margin:7px 4px 0 0; font-size:13px; font-weight:normal;">začetek:</span> <span id="dk_start_date"  style="margin:7px 4px 0 0; font-size:13px; text-decoration:underline;"></span> <span  style="margin:6px 4px 0 0; font-size:13px;  font-weight:normal;">zaključek: </span> <span id="dk_end_date"  style="margin:6px 4px 0 0; font-size:13px; text-decoration:underline;"></span>'
                            +'				</div>'
                            +'				<span class="field_desc clearfix" style="width:auto;"></span>'
                            +'  		</li>'

                            +           this.fields.namenMacropona.html(arg_params)
                            +           this.fields.podjetjeMacroponText.html(arg_params)
                            +           this.fields.podjetjeMacroponSlika.html(arg_params)
                            +           this.fields.podjetjeLogo.html(arg_params)

                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'  <div class="box store-profile-settings button_wrap" style="padding:14px 0 14px 10px; margin-bottom:14px;">'
                            +'	    <div id="error-placeholder" class="error" style="font-size:1.2em; text-align:center; margin:0 0 8px 0px; display:none;"></div>'
                            +       this.fields.button.toactionRuntimeUpdate.html(arg_params)
                            +'  </div>'
                            +'</form>'
                            +'</div>'
                            +'<div style="padding-top:28px;"></div>'
                        +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        _toStatus: 'new',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'marketer' || arg_params.mh_role == 'admin') {
                                return '';
                            }
                            else {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                                    ;
                            }
                        }
                    },
                    toactionEditedMarketer: {
                        FIELD_ID: 'btn_action_editedmarketer',
                        _toStatus: 'edited-marketer',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'user') {
                                return '';
                            }
                            else if(arg_params.mh_role == 'marketer') {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji trgovcu povzetek ponudbe</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }
                        }
                    },
                    toactionRuntimeUpdate: {
                        FIELD_ID: 'btn_action_runtimeupdate',
                        _toStatus: 'runtime-update',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon reload"></span>Runtime update</a></span>'
                                    ;
                            }
                            else if(arg_params.mh_product == 'macropon'){
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon reload"></span>Posodobi macropon</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReview: {
                        FIELD_ID: 'btn_action_review',
                        _toStatus: 'review',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:114px;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="positive button ajaxsubmit" style="text-align: center;"><span class="icon check"></span>Pošlji v predogled</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionDraft: {
                        FIELD_ID: 'btn_action_draft',
                        _toStatus: 'draft',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon clock"></span>Shrani osnutek</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReject: {
                        FIELD_ID: 'btn_action_reject',
                        _toStatus: 'reject',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="negative button ajaxsubmit" style="text-align: center;"><span class="icon cross"></span>Zavrni</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    }
                },
                districts: {
                    validator: {
                        needsValidation: false
                    },
                    html: function(){
                        return ''
                            +'  		<li>'
                            +'  			<label for="district-selector"  style="padding-top:0px;">Okraj akcije</label>'
                            +'				<ul class="mht-districts" id="district-selector" style="margin-top:8px; margin-left: 144px; list-style:none; ">'
                            +'					<li id="district_loading" class="data district" style="text-align:left; float:none;">'
                            +'						<span style="font: normal 13px arial, sans-serif; background: url(/public/images/spinner.gif) no-repeat 0 50%; padding-left: 16px; color: #333;">Nalagam...</span>'
                            +'					</li>'
                            +'					<li id="district_8" class="data district" style="display:none; text-align:left; float:none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="8" data-item-slug="koprski-okraj"><span style="margin-bottom:0px;"></span>Koprski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_7" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="7" data-item-slug="novogoriski-okraj"><span style="margin-bottom:0px;"></span>Novogoriški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_3" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="3" data-item-slug="ljubljanski-okraj"><span style="margin-bottom:0px;"></span>Ljubljanski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_6" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="6" data-item-slug="kranjski-okraj"><span style="margin-bottom:0px;"></span>Kranjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_5" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="5" data-item-slug="celjski-okraj"><span style="margin-bottom:0px;"></span>Celjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_9" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="9" data-item-slug="novomeski-okraj"><span style="margin-bottom:0px;"></span>Novomeški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_4" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="4" data-item-slug="mariborski-okraj"><span style="margin-bottom:0px;"></span>Mariborski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_10" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="10" data-item-slug="murskosoboski-okraj"><span style="margin-bottom:0px;"></span>Murskosoboški okraj</a></strong>'
                            +'					</li>'
                            +'				</ul>'
                            +'				<input type="hidden" name="districtslug" id="districtslug">'
                            +'				<div class="clearfix"></div>'
                            +'				<span style="display:block; color:red; float:none; margin-left:0; font-weight:bold;" class="err-district"></span>'
                            +'  		</li>'
                        ;
                    },
                    load: function(){

                    },
                    setValues: function(arg_values){

                    },
                    getValues: function(){

                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferForm.setup()'); }

                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

					var micropon = data.micropons[0].micropon;

                    // XXX na malo lepše mesto je potrebno tole postavit
                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">'+micropon.district_name+'</div>');

                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));

                    // Nastavim polja iz DB
                    arg_$form.fields.namenMacropona.setValue(micropon.description_headline);           // naslov oglasa - podjetje
                    arg_$form.fields.podjetjeMacroponText.setValue(micropon.description_description);  // text oglasa   - podjetje

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

                    //** OBVEZNO ZA init()
                    arg_$form.fields.podjetjeMacroponSlika.setValue(micropon.multimedia);     // slike kampanje - FB slika
                    arg_$form.fields.podjetjeLogo.setValue(micropon.multimedia);              // slike kampanje - logotip

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'store_slug': 			   arg_params.mh_storeslug,
                        'mp_id': 			       arg_params.mh_microponid,
                        'status': 				   $(this).attr('data-item-tostatus'),
                        'headline_description':    arg_$form.fields.namenMacropona.getValue(),
                        'description_description': arg_$form.fields.podjetjeMacroponText.getValue()
                    };

                    /* sestavim še FB ADD slike */
					var pics = _$form.find('#fileupload td.name a');
                    var i = 0;
					$.each(pics, function(i, v) {
						query['multimedia['+i+']'] = {
                            'name':   $(v).text(),
                            'usefor': 'inadd'
                        };
					});

                    /* sestavim še LOGOTIB slike */
					var logos = _$form.find('#fileupload_logos td.name a');
					$.each(logos, function(j, v) {
						query['multimedia['+(i+(j+1))+']'] = {
                            'name':   $(v).text(),
                            'usefor': 'logo'
                        };
					});

                    console.log(query);
                    //return false;

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'micropon_marketers-wizard':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                      // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);                                     // flash
                                    $('#actions_'+arg_params.mh_storeslug).html(MHT.status.interpret('5_marketer-added', arg_params));  // replace actions
                                    break;
                                case 'macropon_wall-item':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);
                                    // XXX neka akcija na view-u
                                    //$('#actions_paket_reserve_dk_date').replaceWith('<span style="font-size:12px; color:#999; font-style:italic;">Naslednjo dobrodelno kampanjo lahko kreirate čez cca. 60dni.</span>');  // replace actions

                                    // XXX spremeni akcijski gumb!
                                    $('#product_'+data.micropons[0].micropon.id).replaceWith(MHT.list.product.generateItem(data.micropons[0].micropon, arg_params.mh_role));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);

                                    break;
                                default:
                                    //# Privzeto (če nimam flag-a) reloadam page
                                    window.location = '/redirect-to?url='+window.location.href;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        nanopon_OfferForm: {
            FORM_DOM_ID: 'nanopon_OfferForm',     // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.nanopon_OfferForm.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('ampera/update-micropon-status'); title = 'Uredi Nanopon';

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['naslovNanopon']        = MHT.form.fields.headlineDescription.init();       // naslov nanopona
                this.fields['maxKolicinaNanopon']   = MHT.form.fields.maxQuantity.init();               // max količina nanoponov
                this.fields['cenaOriginal']         = MHT.form.fields.originalPrice.init();             // cena brez popusta
                this.fields['popustVProcentih']     = MHT.form.fields.discount.init();                  // popust
                this.fields['cenaSPopustom']        = MHT.form.fields.discountedPrice.init();           // cena z pospustom
                this.fields['pogoji']               = MHT.form.fields.merchantTerms.init();             // pogoji
                // TODO pogoji (lahko je textarea, če ne gre z dinamiko)
                this.fields['podjetjeNanoponText']  = MHT.form.fields.merchantOfferDescription.init();    // text oglasa
                this.fields['podjetjeNanoponSlika'] = MHT.form.fields.merchantOfferPictures.init();       // FB slika


                this._$form = $(
                         '<div id="'+this.FORM_DOM_ID+'" style="display:none;">'
                            +'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff; font-weight:normal;">'+title+'</h1>'
                            +'</div>'
                            +'<div style="margin:0 auto; padding:14px 14px 14px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'<form action="#" method="post" id="newOfferRequest_dailydeal">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder"></div>'

                            +'		<div class="group_desc" style="margin-top: 8px;">'
                            +'			<h2>Povzetek datuma izvajanja kampanje in njen namen</h2>'
                            +'		</div>'
                            +'		<ol>'
                                        // XXX Okraji
                            +           this.fields.districts.html()

                            +'  		<li class="value" style="margin-top:14px;">'
                            +'  			<label for="date_start" style="padding-top: 0;"><strong class="asteric">*</strong>Izvajanje</label>'
                            +'				<div class="date_wrap">'
                            +'					<span style="margin:7px 4px 0 0; font-size:13px; font-weight:normal;">začetek:</span> <span id="dk_start_date"  style="margin:7px 4px 0 0; font-size:13px; text-decoration:underline;"></span> <span  style="margin:6px 4px 0 0; font-size:13px;  font-weight:normal;">zaključek: </span> <span id="dk_end_date"  style="margin:6px 4px 0 0; font-size:13px; text-decoration:underline;"></span>'
                            +'				</div>'
                            +'				<span class="field_desc clearfix" style="width:auto;"></span>'
                            +'  		</li>'

                            +           this.fields.naslovNanopon.html(arg_params)
                            +           this.fields.maxKolicinaNanopon.html(arg_params)
                            +           this.fields.cenaOriginal.html(arg_params)
                            +           this.fields.popustVProcentih.html(arg_params)
                            +           this.fields.cenaSPopustom.html(arg_params)
                            +           this.fields.pogoji.html(arg_params)
                            +           this.fields.podjetjeNanoponText.html(arg_params)
                            +           this.fields.podjetjeNanoponSlika.html(arg_params)

                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'  <div class="box store-profile-settings button_wrap" style="padding:14px 0 14px 10px; margin-bottom:14px;">'
                            +'	    <div id="error-placeholder" class="error" style="font-size:1.2em; text-align:center; margin:0 0 8px 0px; display:none;"></div>'
                            +       this.fields.button.toactionNew.html(arg_params)
                            +       this.fields.button.toactionEditedMarketer.html(arg_params)
                            +       this.fields.button.toactionReview.html(arg_params)
                            +       this.fields.button.toactionDraft.html(arg_params)
                            +       this.fields.button.toactionRuntimeUpdate.html(arg_params)
                            +       this.fields.button.toactionReject.html(arg_params)
                            +'  </div>'
                            +'</form>'
                            +'</div>'
                            +'<div style="padding-top:28px;"></div>'
                        +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        _toStatus: 'new',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'marketer' || arg_params.mh_role == 'admin') {
                                return '';
                            }
                            else {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                                    ;
                            }
                        }
                    },
                    toactionEditedMarketer: {
                        FIELD_ID: 'btn_action_editedmarketer',
                        _toStatus: 'edited-marketer',
                        html: function(arg_params){

                            if(arg_params.mh_role == 'user') {
                                return '';
                            }
                            else if(arg_params.mh_role == 'marketer') {
                                return ''
                                    +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji trgovcu povzetek ponudbe</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }
                        }
                    },
                    toactionRuntimeUpdate: {
                        FIELD_ID: 'btn_action_runtimeupdate',
                        _toStatus: 'runtime-update',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon reload"></span>Runtime update</a></span>'
                                    ;
                            }
                            else if(arg_params.mh_product == 'macropon'){
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon reload"></span>Posodobi macropon</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReview: {
                        FIELD_ID: 'btn_action_review',
                        _toStatus: 'review',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:114px;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="positive button ajaxsubmit" style="text-align: center;"><span class="icon check"></span>Pošlji v predogled</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionDraft: {
                        FIELD_ID: 'btn_action_draft',
                        _toStatus: 'draft',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="button ajaxsubmit" style="text-align: center;"><span class="icon clock"></span>Shrani osnutek</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    },
                    toactionReject: {
                        FIELD_ID: 'btn_action_reject',
                        _toStatus: 'reject',
                        html: function(arg_params){

                            if(arg_params.mh_isampera) {
                                return ''
                                    +'<span class="store_finish" style="padding: 14px 5px 10px 5px !important; margin-left:0;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="negative button ajaxsubmit" style="text-align: center;"><span class="icon cross"></span>Zavrni</a></span>'
                                    ;
                            }
                            else {
                                return '';
                            }

                        }
                    }
                },
                districts: {
                    validator: {
                        needsValidation: false
                    },
                    html: function(){
                        return ''
                            +'  		<li>'
                            +'  			<label for="district-selector"  style="padding-top:0px;">Okraj akcije</label>'
                            +'				<ul class="mht-districts" id="district-selector" style="margin-top:8px; margin-left: 144px; list-style:none; ">'
                            +'					<li id="district_loading" class="data district" style="text-align:left; float:none;">'
                            +'						<span style="font: normal 13px arial, sans-serif; background: url(/public/images/spinner.gif) no-repeat 0 50%; padding-left: 16px; color: #333;">Nalagam...</span>'
                            +'					</li>'
                            +'					<li id="district_8" class="data district" style="display:none; text-align:left; float:none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="8" data-item-slug="koprski-okraj"><span style="margin-bottom:0px;"></span>Koprski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_7" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="7" data-item-slug="novogoriski-okraj"><span style="margin-bottom:0px;"></span>Novogoriški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_3" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="3" data-item-slug="ljubljanski-okraj"><span style="margin-bottom:0px;"></span>Ljubljanski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_6" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="6" data-item-slug="kranjski-okraj"><span style="margin-bottom:0px;"></span>Kranjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_5" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="5" data-item-slug="celjski-okraj"><span style="margin-bottom:0px;"></span>Celjski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_9" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="9" data-item-slug="novomeski-okraj"><span style="margin-bottom:0px;"></span>Novomeški okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_4" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="4" data-item-slug="mariborski-okraj"><span style="margin-bottom:0px;"></span>Mariborski okraj</a></strong>'
                            +'					</li>'
                            +'					<li id="district_10" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
                            +'						<strong><a style="font-size:12px;" data-item-id="10" data-item-slug="murskosoboski-okraj"><span style="margin-bottom:0px;"></span>Murskosoboški okraj</a></strong>'
                            +'					</li>'
                            +'				</ul>'
                            +'				<input type="hidden" name="districtslug" id="districtslug">'
                            +'				<div class="clearfix"></div>'
                            +'				<span style="display:block; color:red; float:none; margin-left:0; font-weight:bold;" class="err-district"></span>'
                            +'  		</li>'
                        ;
                    },
                    load: function(){

                    },
                    setValues: function(arg_values){

                    },
                    getValues: function(){

                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferForm.setup()'); }

                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

					var micropon = data.micropons[0].micropon;

                    // XXX na malo lepše mesto je potrebno tole postavit
                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">'+micropon.district_name+'</div>');

                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));

                    // Nastavim polja iz DB
                    arg_$form.fields.naslovNanopon.setValue(micropon.description_headline);           // naslov oglasa - podjetje
                    arg_$form.fields.maxKolicinaNanopon.setValue(micropon.max_quantity);              // naslov oglasa - podjetje
                    arg_$form.fields.cenaOriginal.setValue(micropon.original_price);                  // naslov oglasa - podjetje
                    arg_$form.fields.popustVProcentih.setValue(micropon.max_discount_percentage);     // naslov oglasa - podjetje
                    arg_$form.fields.cenaSPopustom.setValue(micropon.max_discount_min_price);         // naslov oglasa - podjetje
                    arg_$form.fields.pogoji.setValue(micropon.coupon_highlights);                     // naslov oglasa - podjetje
                    arg_$form.fields.podjetjeNanoponText.setValue(micropon.description_description);  // text oglasa   - podjetje

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

                    //** OBVEZNO ZA init()
                    arg_$form.fields.podjetjeNanoponSlika.setValue(micropon.multimedia);     // slike kampanje - FB slika

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'store_slug': 			   arg_params.mh_storeslug,
                        'mp_id': 			       arg_params.mh_microponid,
                        'status': 				   $(this).attr('data-item-tostatus'),
                        'headline_description':    arg_$form.fields.naslovNanopon.getValue(),
                        'max_quantity':            arg_$form.fields.maxKolicinaNanopon.getValue(),
                        'price_original':          arg_$form.fields.cenaOriginal.getValue(),
                        'discount':                arg_$form.fields.popustVProcentih.getValue(),
                        'max_discount_min_price':  arg_$form.fields.cenaSPopustom.getValue(),
                        'coupon_highlights':       arg_$form.fields.pogoji.getValue(),
                        'description_description': arg_$form.fields.podjetjeNanoponText.getValue()
                    };

                    /* sestavim še FB ADD slike */
					var pics = _$form.find('#fileupload td.name a');
                    var i = 0;
					$.each(pics, function(i, v) {
						query['multimedia['+i+']'] = {
                            'name':   $(v).text(),
                            'usefor': 'offer-merchant'
                        };
					});

//                    console.log(query);
                    //return false;

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'micropon_marketers-wizard':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                      // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);                                     // flash
                                    $('#actions_'+arg_params.mh_storeslug).html(MHT.status.interpret('5_marketer-added', arg_params));  // replace actions
                                    break;
                                case 'nanopon_wall-item':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);
                                    // XXX neka akcija na view-u
                                    //$('#actions_paket_reserve_dk_date').replaceWith('<span style="font-size:12px; color:#999; font-style:italic;">Naslednjo dobrodelno kampanjo lahko kreirate čez cca. 60dni.</span>');  // replace actions

                                    // XXX spremeni akcijski gumb!
                                    $('#product_'+data.micropons[0].micropon.id).replaceWith(MHT.list.product.generateItem(data.micropons[0].micropon, arg_params.mh_role));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);

                                    break;
                                default:
                                    //# Privzeto (če nimam flag-a) reloadam page
                                    window.location = '/redirect-to?url='+window.location.href;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        form_store: {
            FORM_DOM_ID: 'form_store',             // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.form_store.init()'); }

                /**
                 * Nastavim submit URLje
                 */
                if(arg_params.mh_action == 'update')      { this.setUrl('ampera/update-micropon-status'); title = 'Uredi dobrodelno kampanjo'; }    // XXX FIXME
                else if(arg_params.mh_action == 'insert') { this.setUrl('/new-store-signup'); title = 'Kreiraj podjetje/trgovino'; }

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['imePodjetja'] = MHT.form.fields.companyName.init();
                this.fields['ddvPodjetja'] = MHT.form.fields.companyDDV.init();
                this.fields['geoLocations'] = MHT.form.fields.geoLocations.init();


                this._$form = $(
                             '<div id="'+this.FORM_DOM_ID+'" style="display:none; width:486px;">'
                            +'<form method="post">'
                            +'<div style="margin:0 auto; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder"></div>'
                            +'		<ol>'
                            +           this.fields.imePodjetja.html()
                            +           this.fields.ddvPodjetja.html()
                            +           this.fields.geoLocations.html()
                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'</div>'
                            +'<ol style="list-style-type: none;">'
                            +'  <li style="float:left; margin-top:-2px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span></li>'
                            +   this.fields.button.toactionNew.html()
                            +'</ol>'
                            +'<div class="clearfix"></div>'
                            +'</form>'
                            +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        _toStatus: 'marketer_new',
                        html: function(arg_params){

                                return ''
                                    +'<li style="text-align:right;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="positive button ajaxsubmit">Dodaj podjetje</a></li>'
                                    ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferForm.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert
//                console.log('sem not');
//                return false;

//                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

//					var micropon = data.micropons[0].micropon;
//
//                    // XXX na malo lepše mesto je potrebno tole postavit
//                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
//                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">Koprski okraj</div>');
//
//                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
//                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));
//
//                    // Nastavim polja iz DB
//                    arg_$form.fields.namenKampanje.setValue(micropon.description_headline);                 // namen donacij - organizacija
//                    arg_$form.fields.naslovKampanje.setValue(micropon.headline);                            // namen donacij - ampera
//                    arg_$form.fields.organizacija_opisKampanje.setValue(micropon.description_description);  // opis kampanje - organizacija
//                    arg_$form.fields.ampera_pitchStatement.setValue(micropon.pitch_statement);              // pitch state,  - ampera
//                    arg_$form.fields.ampera_opisKampanje.setValue(micropon.description);                    // opis kampanje - ampera
//
//                    arg_$form.fields.ampera_tippingPoints.setValue([
//                        {'id':'tipping_point_one','value':micropon.tipping_point_one},
//                        {'id':'tipping_point_two','value':micropon.tipping_point_two},
//                        {'id':'tipping_point_three','value':micropon.tipping_point_three},
//                        {'id':'tipping_point_one_giveaway','value':micropon.tipping_point_one_giveaway},
//                        {'id':'tipping_point_two_giveaway','value':micropon.tipping_point_two_giveaway},
//                        {'id':'tipping_point_three_giveaway','value':micropon.tipping_point_three_giveaway},
//                    ]);
//
//                    arg_$form.field.namenDonacije.setValue(micropon.description_headline);  // XXX FIX opis pitch stavek Skrbnika

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

//                    //** OBVEZNO ZA init()
//                    arg_$form.fields.organizacija_slikaKampanje.setValue(micropon.multimedia);        // slike kampanje - organizacija
//                    arg_$form.fields.ampera_slikaKampanje.setValue(micropon.multimedia);              // slike kampanje - ampera

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
//                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'user_id': 	     arg_params.mh_userid,
                        'status': 	     $(this).attr('data-item-tostatus'),
                        'company_name':  arg_$form.fields.imePodjetja.getValue(),
                        'davcna':        arg_$form.fields.ddvPodjetja.getValue(),
                        'locations':     arg_$form.fields.geoLocations.getValue()
                    };

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'marketer-wizard':
                                    console.log(arg_$form.FORM_DOM_ID);
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    $('#store-not-found').fadeOut('fast', function(){
                                        $('#store-found ul').html(MHT.list.store.generateItem(data.stores[0].store, arg_params.mh_role));
                                    });
                                    $('#store_'+data.stores[0].store.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        /**
         * Obrazec za zamenjavo gesla (vpis novega)
         */
        user_form_change_pwd: {
            FORM_DOM_ID: 'user_form_change_pwd',   // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.user_form_change_pwd.init()'); }

                /**
                 * Nastavim submit URLje
                 */
                if(arg_params.mh_action == 'update')      { this.setUrl('account/reset-pwd'); title = 'Zamenjaj obstoječe geslo'; }    // XXX FIXME

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['gesloNovo']   = MHT.form.fields.userPasswordNew.init();
                this.fields['gesloPonovi'] = MHT.form.fields.userPasswordNewRepeat.init();

                this._$form = $(
                             '<div id="'+this.FORM_DOM_ID+'" style="display:none; width:486px;">'
                            +'<form method="post">'
                            +'<div style="margin:0 auto; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder" style="text-align: left;"></div>'
                            +'		<ol>'
                            +           this.fields.gesloNovo.html()
                            +           this.fields.gesloPonovi.html()
                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'</div>'
                            +'<ol style="list-style-type: none;">'
                            +'  <li style="float:left; margin-top:-2px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span></li>'
                            +   this.fields.button.toactionNew.html()
                            +'</ol>'
                            +'<div class="clearfix"></div>'
                            +'</form>'
                            +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_submit',
                        html: function(arg_params){

                                return ''
                                    +'<li style="text-align:right;"><a id="'+this.FIELD_ID+'" class="positive button ajaxsubmit">Zamenjaj geslo</a></li>'
                                    ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.user_form_change_pwd.setup()'); }

                arg_$form.afterDOMInsertionInit();
                MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    var query = {
                        'e':           arg_params.mh_useremail,
                        'k':           arg_params.mh_key,
                        'newpassword': arg_$form.fields.gesloNovo.getValue()
                    };

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.success == true)
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'alert':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger('success', 'Geslo sem uspešno zamenjal z novim. Naslednjič se lahko z njim prijaviš');
                                    break;
                            }
						}
						else if(data.notice != undefined && data.success == false){
							_$form.find('#error-placeholder').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
						}
						else if( data.notice == undefined ){
							_$form.find('#error-placeholder').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
						}
					}).error(function() {
						_$form.find('#error-placeholder').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
					}).complete(function() {});
					return false;
				});
            }
        },
        /**
         * Obrazec za naročilo na newsletter (uporabnik)
         */
        user_form_newsletter: {
            FORM_DOM_ID: 'user_form_newsletter',   // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.user_form_newsletter.init()'); }

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('/newsletter/subscribe');    // XXX FIXME

                var _email    = '';
                var _disabled = '';
                if(undefined != document.email){_email = document.email; _disabled = 'disabled="disabled"'; }

                this._$form = $(
                             '<div id="'+this.FORM_DOM_ID+'" style="display:none; width:898px; margin-top: -60px;">'
                            +'  <form accept-charset="UTF-8" action="/subscribers" class="call-to-action" method="post"> '
                           +'       <fieldset>'
                           +'           <h2>Pomagaj okraju v kateremu živiš. Kako?</h2>'
                           +'           <h3>Tako, da prejemaš zgodbe nevladnih lokalnih organizacij na svoj em@il naslov. Če želiš, lahko zgodbo posreduješ svojim prijateljem ali doniraš od 1¢ do 1€. Vsako dejanje šteje.</h3>'
                           +'	        <div id="newsletter-error-notice" style="color:red; font-size:1.2em; text-align: center;"></div>'
                            +'		    <ul id="districts" class="mht-checkbox" style="margin-left: 43px;">'
                            +'			    <li><a data-item-id="8" id="okraj_8" style="line-height:12px; color: #51AB0C;"><span></span>Koprski okraj</a></li>'
                            +'			    <li><a data-item-id="7" id="okraj_7" style="line-height:12px; color: #51AB0C;"><span></span>Novogoriški okraj</a></li>'
                            +'			    <li><a data-item-id="3" id="okraj_3" style="line-height:12px; color: #51AB0C;"><span></span>Ljubljanski okraj</a></li>'
                            +'			    <li><a data-item-id="6" id="okraj_6" style="line-height:12px; color: #51AB0C;"><span></span>Kranjski okraj</a></li>'
                            +'			    <li><a data-item-id="5" id="okraj_5" style="line-height:12px; color: #51AB0C;"><span></span>Celjski okraj</a></li>'
                            +'			    <li><a data-item-id="9" id="okraj_9" style="line-height:12px; color: #51AB0C;"><span></span>Novomeški okraj</a></li>'
                            +'			    <li><a data-item-id="4" id="okraj_4" style="line-height:12px; color: #51AB0C;"><span></span>Mariborski okraj</a></li>'
                            +'			    <li><a data-item-id="10" id="okraj_10" style="line-height:12px; color: #51AB0C;"><span></span>Murskosoboški okraj</a></li>'
                            +'		    </ul>'
                            +'		    <div class="clearfix"></div>'
                            +'          <ol style="list-style-type: none; margin-bottom: -10px; margin-top: 16px;">'
							//+'	        <li style="float:left; margin-top:-2px; margin-bottom: 0;"><span class="small gray logo-font" style="margin-left: 14px;">Microhint<sup style="font-size: 8px;">™</sup></span></li>'
							+'	            <li class="rounded" style="text-align: right; margin: 0 auto 6px auto; background: #BDDA9B; width: 442px; padding: 8px 0 8px 0;"><input id="email" name="email" class="mh_input rounded" style="vertical-align: top; font-family: Arial,sans-serif; font-size: 14px; padding: 4px 9px 5px 9px;" type="text" value="'+_email+'" '+_disabled+' placeholder="tedensko ti na ema@il pošljem zgodbo okraja"><a id="btn_login" class="big positive activated button rounded ajaxsubmit" style="height: auto; float:none; font-weight: normal; margin: 0 8px 0px 0;"><span class="icon plus"></span>prijava</a></li>'
                            +'          </ol>'
                           +'       </fieldset>'
                           +'   </form>'
                           +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_submit',
                        html: function(arg_params){

                                return ''
                                    +'<li style="text-align:right;"><a id="'+this.FIELD_ID+'" class="positive button ajaxsubmit">Zamenjaj geslo</a></li>'
                                    ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.user_form_newsletter.setup()'); }

                _$form = arg_$form.html().find('form');

                if(document.username != undefined)
                {
                    $.get('user/newsletter-subscriptions?user_nick='+ document.username, function(data, textStatus, XMLHttpRequest)
                    {
                        if(data.subs != undefined)
                        {
                            $(data.subs).each(function(i, v){
                                _$form.find('#okraj_'+ v.district_id).addClass('checked');
                            });
                        }
                        // prikažem obrazec
                        arg_$form.afterDOMInsertionInit();
                        MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                    });
                }
                else {
                    // prikažem obrazec
                    arg_$form.afterDOMInsertionInit();
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                }

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() || (_$form.find('input[name="email"]').prop('disabled')==true && document.username == undefined) ) {
                        return false;
                    }

                    var $click_el = $(this);
                    var _text = $click_el.html();
                    $click_el.text("trenutek");
                    _$form.find('input[name="email"]').prop('disabled',true);

                    var selection = _$form.find('#districts').find('a.checked');
                    var districts = [];
                    $(selection).each(function(i, v){
                        districts.push($(v).attr('data-item-id'));
                    });

                    var data = {
                        'districts[]': districts,
                        'email'      : _$form.find('input[name="email"]').val()
                    };

                    var jqxhr = $.ajax({ type:'POST', url:'/newsletter/subscribe', data:data, dataType: "json" });

					jqxhr.success(function(data)
					{
						if(data.success == true)
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'top-widget':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    $('#top-msg').hide();
                                    MHT.utils.flashMessanger('success', 'Uspešno si se naročil na prejemanje obvestil za izbrane okraje. V imenu sodelujočih organizacij in microhinta, hvala :)');
                                    break;
                            }
						}
						else if(data.notice != undefined && data.success == false){
							_$form.find('#newsletter-error-notice').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
						}
						else if( data.notice == undefined ){
							_$form.find('#newsletter-error-notice').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
						}
					}).error(function() {
						_$form.find('#newsletter-error-notice').html('Opala, tehničen škrat - očitno :S Refresh(osvežtev) strani je obvezna za pravilno delovnaje').fadeIn('fast');
					}).complete(function() {$click_el.html(_text); _$form.find('input[name="email"]').prop('disabled',false);});
					return false;
				});
            }
        },
        marketer_form_user_store: {
            FORM_DOM_ID: 'marketer_form_user_store',             // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.marketer_form_user_store.init()'); }

                /**
                 * Nastavim submit URLje
                 */
                if(arg_params.mh_action == 'insert') { this.setUrl('/new-user-store-signup'); title = 'Kreiraj uporabnika & trgovino'; }

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['imeUporabnika']     = MHT.form.fields.userName.init();
                this.fields['emailUporabnika']   = MHT.form.fields.userEmail.init();
                this.fields['nicknameUporabnika']= MHT.form.fields.userNickname.init();
                this.fields['telefonUporabnika'] = MHT.form.fields.userPhone.init();

                this.fields['imePodjetja'] = MHT.form.fields.companyName.init();
                this.fields['ddvPodjetja'] = MHT.form.fields.companyDDV.init();
                this.fields['geoLocations'] = MHT.form.fields.geoLocations.init();


                this._$form = $(
                             '<div id="'+this.FORM_DOM_ID+'" style="display:none; width:486px;">'
                            +'<form method="post">'
                            +'<div style="margin:0 auto; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<ol>'
                            +           this.fields.imeUporabnika.html()
                            +           this.fields.emailUporabnika.html()
                            +           this.fields.nicknameUporabnika.html()
                            +           this.fields.telefonUporabnika.html()
                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'</div>'
                            +'<div style="margin:0 auto; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<ol>'
                            +           this.fields.imePodjetja.html()
                            +           this.fields.ddvPodjetja.html()
                            +           this.fields.geoLocations.html()
                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'</div>'
                            +'<ol style="list-style-type: none;">'
                            +'  <li style="float:left; margin-top:-2px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span></li>'
                            +   this.fields.button.toactionNew.html()
                            +'</ol>'
                            +'<div class="clearfix"></div>'
                            +'</form>'
                            +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        _toStatus: 'marketer_new',  // pomeni, da jo je tržnik naredil
                        html: function(arg_params){

                                return ''
                                    +'<li style="text-align:right;"><a id="'+this.FIELD_ID+'" data-item-tostatus="'+this._toStatus+'" class="positive button ajaxsubmit">Dodaj uporabnika & podjetje</a></li>'
                                    ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.marketer_form_user_store.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert
//                console.log('sem not');
//                return false;

//                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

//					var micropon = data.micropons[0].micropon;
//
//                    // XXX na malo lepše mesto je potrebno tole postavit
//                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
//                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">Koprski okraj</div>');
//
//                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
//                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));
//
//                    // Nastavim polja iz DB
//                    arg_$form.fields.namenKampanje.setValue(micropon.description_headline);                 // namen donacij - organizacija
//                    arg_$form.fields.naslovKampanje.setValue(micropon.headline);                            // namen donacij - ampera
//                    arg_$form.fields.organizacija_opisKampanje.setValue(micropon.description_description);  // opis kampanje - organizacija
//                    arg_$form.fields.ampera_pitchStatement.setValue(micropon.pitch_statement);              // pitch state,  - ampera
//                    arg_$form.fields.ampera_opisKampanje.setValue(micropon.description);                    // opis kampanje - ampera
//
//                    arg_$form.fields.ampera_tippingPoints.setValue([
//                        {'id':'tipping_point_one','value':micropon.tipping_point_one},
//                        {'id':'tipping_point_two','value':micropon.tipping_point_two},
//                        {'id':'tipping_point_three','value':micropon.tipping_point_three},
//                        {'id':'tipping_point_one_giveaway','value':micropon.tipping_point_one_giveaway},
//                        {'id':'tipping_point_two_giveaway','value':micropon.tipping_point_two_giveaway},
//                        {'id':'tipping_point_three_giveaway','value':micropon.tipping_point_three_giveaway},
//                    ]);
//
//                    arg_$form.field.namenDonacije.setValue(micropon.description_headline);  // XXX FIX opis pitch stavek Skrbnika

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

//                    //** OBVEZNO ZA init()
//                    arg_$form.fields.organizacija_slikaKampanje.setValue(micropon.multimedia);        // slike kampanje - organizacija
//                    arg_$form.fields.ampera_slikaKampanje.setValue(micropon.multimedia);              // slike kampanje - ampera

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
//                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'user_id': 	     arg_params.mh_userid,
                        'status': 	     $(this).attr('data-item-tostatus'),
                         // user data
                        'user_name':     arg_$form.fields.imeUporabnika.getValue(),
                        'user_email':    arg_$form.fields.emailUporabnika.getValue(),
                        'user_nickname': arg_$form.fields.nicknameUporabnika.getValue(),
                        'user_phone':    arg_$form.fields.telefonUporabnika.getValue(),
                         // company data
                        'company_name':  arg_$form.fields.imePodjetja.getValue(),
                        'davcna':        arg_$form.fields.ddvPodjetja.getValue(),
                        'locations':     arg_$form.fields.geoLocations.getValue()
                    };

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'marketer-wizard':
                                    console.log(arg_$form.FORM_DOM_ID);
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    $('#store-not-found').fadeOut('fast', function(){
                                        $('#store-found ul').html(MHT.list.store.generateItem(data.stores[0].store, arg_params.mh_role));
                                    });
                                    $('#store_'+data.stores[0].store.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        form_location: {
            FORM_DOM_ID: 'form_location',          // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.form_location.init()'); }

                /**
                 * Nastavim submit URLje
                 */
                var _isPrimary = 0;
                if(arg_params.mh_action == 'primary') { _isPrimary = 1; }

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['geoStreet']     = MHT.form.fields.geoStreet.init();
                this.fields['geoPrimary']    = MHT.form.fields.geoPrimary.init();
                this.fields['geoCity']       = MHT.form.fields.geoCity.init();
                this.fields['geoPostalCode'] = MHT.form.fields.geoPostalCode.init();
                this.fields['geoPhone']      = MHT.form.fields.geoPhone.init();


                this._$form = $(
                             '<div id="'+this.FORM_DOM_ID+'" style="display:none; width:486px;">'
                            +'<form method="post">'
                            +'<div style="margin:0 auto; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
                            +'		<div id="profile-error-placeholder"></div>'
                            +'		<ol>'
                            +           this.fields.geoPrimary.html(_isPrimary)
                            +           this.fields.geoStreet.html()
                            +           this.fields.geoCity.html()
                            +           this.fields.geoPostalCode.html()
                            +           this.fields.geoPhone.html()
                            +'  	</ol>'
                            +'		<div class="clearfix"></div>'
                            +'	</div>'
                            +'</div>'
                            +'<ol style="list-style-type: none;">'
                            +'  <li style="float:left; margin-top:-2px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span></li>'
                            +   this.fields.button.toactionNew.html()
                            +'</ol>'
                            +'<div class="clearfix"></div>'
                            +'</form>'
                            +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        html: function(arg_params){

                                return ''
                                    +'<li style="text-align:right;"><a id="'+this.FIELD_ID+'" class="positive button ajaxsubmit">dodaj lokacijo</a></li>'
                                    ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.form_location.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert
//                console.log('sem not');
//                return false;

//                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

//					var micropon = data.micropons[0].micropon;
//
//                    // XXX na malo lepše mesto je potrebno tole postavit
//                    arg_$form.html().find('#date_start_spinner').fadeIn('fast');
//                    arg_$form.html().find('#district_loading').html('<div style="font-weight:bold; font-size:13px; text-decoration:underline;">Koprski okraj</div>');
//
//                    arg_$form.html().find('#dk_start_date').html((new Date(1000*micropon.date_start)).toString('dd MMMM yyyy'));
//                    arg_$form.html().find('#dk_end_date').html((new Date(1000*micropon.date_end)).toString('dd MMMM yyyy'));
//
//                    // Nastavim polja iz DB
//                    arg_$form.fields.namenKampanje.setValue(micropon.description_headline);                 // namen donacij - organizacija
//                    arg_$form.fields.naslovKampanje.setValue(micropon.headline);                            // namen donacij - ampera
//                    arg_$form.fields.organizacija_opisKampanje.setValue(micropon.description_description);  // opis kampanje - organizacija
//                    arg_$form.fields.ampera_pitchStatement.setValue(micropon.pitch_statement);              // pitch state,  - ampera
//                    arg_$form.fields.ampera_opisKampanje.setValue(micropon.description);                    // opis kampanje - ampera
//
//                    arg_$form.fields.ampera_tippingPoints.setValue([
//                        {'id':'tipping_point_one','value':micropon.tipping_point_one},
//                        {'id':'tipping_point_two','value':micropon.tipping_point_two},
//                        {'id':'tipping_point_three','value':micropon.tipping_point_three},
//                        {'id':'tipping_point_one_giveaway','value':micropon.tipping_point_one_giveaway},
//                        {'id':'tipping_point_two_giveaway','value':micropon.tipping_point_two_giveaway},
//                        {'id':'tipping_point_three_giveaway','value':micropon.tipping_point_three_giveaway},
//                    ]);
//
//                    arg_$form.field.namenDonacije.setValue(micropon.description_headline);  // XXX FIX opis pitch stavek Skrbnika

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();

//                    //** OBVEZNO ZA init()
//                    arg_$form.fields.organizacija_slikaKampanje.setValue(micropon.multimedia);        // slike kampanje - organizacija
//                    arg_$form.fields.ampera_slikaKampanje.setValue(micropon.multimedia);              // slike kampanje - ampera

                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
//                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                // XXX TODO

                _$form.find('.ajaxsubmit').bind('click', function()
				{
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // Try to pinpoint store address
                    var location = MHT.utils.geocodeLocation( arg_$form.fields.geoStreet.getValue(), arg_$form.fields.geoPostalCode.getValue() );

			        var locationCustomName  = '';
			        var locationCustomPhone = arg_$form.fields.geoPhone.getValue();
                    var city                = arg_$form.fields.geoCity.getValue();
                    var isPrimary                = arg_$form.fields.geoPrimary.getValue();

			        setTimeout(function() {
				        $('#add-new-location').before(''
					        +'<li  class="pin pin_location" data-item-address="'+ location.address +'" data-item-city="'+ location.city +'" data-item-googleaddress="'+ location.google_address +'" data-item-lat="'+ location.lat +'" data-item-long="'+ location.long +'" data-item-postalCode="'+ location.postalCode +'" data-item-street="'+ location.street +'" data-item-streetnumber="'+ location.streetNumber +'" data-item-storelocation-phone="'+ locationCustomPhone +'" data-item-storelocation-name="'+ locationCustomName +'" is_primary="'+isPrimary+'" style="text-align:left;">'
							+'	'+ location.address +', '+ location.postalCode +' '+ city +' <a class="xc_remove_item remove_item">odstrani x</a>'
							+'</li>'
					    );
					}, 1000);   // 1s

                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
					return false;
				});
            }
        },
        micronator_OfferBuyForm: {
            FORM_DOM_ID: 'micronator_OfferBuyForm',     // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferBuyForm.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                if(arg_params.mh_action == 'update')      { this.setUrl('ampera/update-micropon-status'); title = 'Uredi dobrodelno kampanjo'; }
                else if(arg_params.mh_action == 'insert') { this.setUrl('store/add-micropon'); title = 'Kreiraj dobrodelno kampanjo'; }

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['intervalSelect'] = MHT.form.fields.offerDistrictIntervalSelect.init(3);

                this._$form = $(
                         '<div id="'+this.FORM_DOM_ID+'" style="display:none;">'
                            +'<div style="padding:0; width:681px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'<form action="#" method="post" id="newOfferBuyRequest_dailydeal">'

                            +' <div class="new_purchase">'

                            +'  <table id="purchase" class="chalkboard">'
                            +'    <tbody>'
                            // GLAVA
                            +'      <tr>'
                            +'          <th class="left"><div style="width:150px;">Produkt</div></th>'
                            +'          <th>Okraj</th>'
                            +'          <th>Datum izvajanja kampanje</th>'
                            +'          <th class="rowTotal">Cena v EUR</th>'
                            +'      </tr>'
                            // VSEBINA
                            +'      <tr class="item donator">'
                            +'          <td>Dobrodelna kampanja</td>'
                            +           this.fields.intervalSelect.html(arg_params)
                            +'          <td class="rowTotal">Brezplačno</td>'
                            +'      </tr>'
                            // TOTAL
                            +'      <tr class="grand_total">'
                            +'          <td colspan="4">'
                            +'              <div style="margin-top:4px;"><div style="float:left; width:200px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span></div> <div style="float:right; width:200px; text-align: right;"><a class="positive button activated ajaxsubmit">Rezerviraj datum</a></div></div>'
                            +'          </td>'
                            +'      </tr>'
                            +'    </tbody>'
                            +'  </table>'

                            +' </div>'
                            +'</form>'
                            +'</div>'
                        +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        html: function(arg_params){
                            return ''
                                +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-goto="/#!/manage-store/'+ arg_params.mh_storeslug +'/micropons" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                            ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferBuyForm.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert

                // XXX tega načeloma ne rabim, ne? Saj nimam obrazca drugega razen datuma?
                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

                    // XXX tule naredim dodatna preverjanja, ki so pomembna za tale obrazec!!

                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();
                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
                    // XXX validator daj na <select> elemente
                    // XXX validator daj na <form> element - nucam vsaj en produkt izbran! (custom)
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // Pohendlam status
                    var status = 'new';
                    if(arg_params.mh_startedfrom === 'marketer-wizard'){ status = 'started-marketer'; }
                    else if(arg_params.mh_startedfrom === 'micronator_store-package'){ status = 'started-merchant'; }

                    //console.log(arg_params.mh_startedfrom);


//                    var paymentType = $('ul#mht-radios_payingoption-selection').find('a.checked').attr('data-pg-type');

//                    var query = {};
//                    query['uaf']              = '';
//                    query['order[0][amount]'] = '1';
//                    query['order[0][donation]'] = $click_el.attr('data-item-value');
//                    query['order[0][mp_id]']  = micropon.id;
//                    query['order[0][type]']   = 'personal';
//                    query['pg_id']            = $click_el.attr('data-pg-type');



                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = {
                        'store_slug': 			   arg_params.mh_storeslug,							         // NOT NULL
                        'status': 				   status,
				    	'brand_id': 			   arg_$form.fields.intervalSelect.getValue('brand_id'),
				    	'date_start': 			   arg_$form.fields.intervalSelect.getValue('date_start'),	 // NOT NULL
				    	'date_end': 			   arg_$form.fields.intervalSelect.getValue('date_end'),     // NOT NULL
                        'district_slug':           arg_$form.fields.intervalSelect.getValue('district_slug'),
				    	'headline': 			   '(skrbnik izpolni)',								         // NOT NULL
				    	'description': 			   '(skrbnik izpolni)'
                    };

					var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'micronator_store-package':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, 'Datum na okraju je bil uspešno rezerviran. Dobrodelno kampanjo lahko takoj kreirate.');

                                    $('#products-wall #wall-title').after(MHT.list.product.generateItem(data.micropons[0].micropon, 'merchant'));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                                case 'marketer-wizard':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, 'Datum na okraju je bil uspešno rezerviran. Dobrodelno kampanjo lahko takoj kreiraš.');
                                    // XXX moram zapreti še prejšnji dialog
                                    $('#search-results').parents('.ui-dialog, .mh_dialog').remove();
                                    $('#products-wall #wall-title').after(MHT.list.product.generateItem(data.micropons[0].micropon, 'marketer'));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                            }

							//window.location = gotoURL;
							//arg_$form.html().find('#success-placeholder').html(data.notice.msg).fadeIn('fast');

							// Ugasnem popin in sfejdam element v tabeli
							//arg_$form.html().parent().parent().find('a.xc_popnormal').click();
                            //MHT.component.POPOUT.hide();

							// TODO: Tule je posebna akcija, ker je MP nov - posebej obdelaj, samo stanje spremeni!
							//$('#intable_micropon_'+ query['mp_id']).css({'background':'#89B556', 'color':'#fff'}).fadeOut('slow');
                            //window.location = '/redirect-to?url='+window.location.href;
							//MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);

						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        matketer_form_searchddv: {
            FORM_DOM_ID: 'matketer_form_searchddv',// FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.matketer_form_searchddv.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('ampera/company-by-item'); title = 'Poišči podjetje';

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['searchCompany'] = MHT.form.fields.searchCompany.init();

                this._$form = $(
                         '<div style="width:500px;">'
                        +'  <form id="form_'+this.FORM_DOM_ID+'" method="GET">'
                        +'  <div style="width:468px; padding:10px; background:#F8F8F8;">'
                        +'      <strong>1. korak</strong>'
                        +'      <div>'
                        +'          Poišči podjetje prek <span style="text-decoration:underline;">davčne številke</span>'
                        +'      </div>'
                        +'  </div>'
                        +   this.fields.searchCompany.html(arg_params)
                        +'  </form>'
                        +'</div>'


                        +'<ul id="search-results" style="list-style-type:none; margin-top:10px; width:487px;">'

                        +'  <div id="text-default" style="text-align: center; color: gray; font-style:italic;">Iskalni rezultati</div>'
                        +'  <div id="text-default" class="nodisplay" style="text-align: center; color: gray; font-style:italic;"><span class="spinner_small">Počakaj trenutek...</span></div>'
                        // NE najdem podjetja - Iščem userja
                        +'  <div id="store-not-found" class="nodisplay" style="text-align: center; color: gray; font-style:italic;">'
                        +'      Prikažem FORM za iskanje userja (še ne dela)'
//                            + '<div style="width:500px; text-align:left; font-style:normal;">'
//                            +'  <form method="GET">'
//                            +'  <div style="width:468px; padding:10px; background:#F8F8F8;">'
//                            +'      <strong>1. korak</strong>'
//                            +'      <div>'
//                            +'          Poišči podjetje prek <span style="text-decoration:underline;">davčne številke</span>'
//                            +'      </div>'
//                            +'  </div>'
//                            +   this.fields.searchCompany.html(arg_params)
//                            +'  </form>'
//                            +'</div>'
                        +'  </div>'
                        // Najdem userja
                        +'  <div id="user-found" class="nodisplay">'
                        +'      Prikažem userja, ki sem ga našel (še ne dela)'
                        +'  </div>'
                        // NE najdem userja - kreiram USER+STORE
                        +'  <div id="user-not-found" class="nodisplay">'
                        +'      Gumb za kreacijo USERJA + TRGOVINE (še ne dela)'
                        +'  </div>'

                        // Najdem store - dodam Produkt
                        +'  <div id="store-found">'
                        //  DOBIL PODJETJE (naslednji korak je košarica)
                        +'    <ul style="list-style-type:none;">'
//                        +'      <li id="product_324" class="gradient rounded content" style="font-family: Arial,sans-serif;">'
//                        +'          <div style="padding-top: 4px;">'
//                        +'              <div style="float:left; font-size:13px;">Alan Ristić, alan.ristic@gmail.com</div><div style="float:right; width:100px; font-size: 11px; padding-top: 2px;"></div>'
//                        +'              <div class="clearfix"></div>'
//                        +'          </div>'
//                        +'          <div style="padding: 6px 2px 6px 2px;">'
//                        +'              <div style="float:left;"><a href="#" style="color:#0981BE; font-weight: normal; font-size:15px;">Fructal d.o.o.</a></div><div style="float:right; width:200px; text-align:right;"><a href="http://microhint.com/?mh_showin=dialog&mh_form=micronator-basket&mh_action=insert&mh_storeslug=j-rupert&mh_startedfrom=marketer-wizard&mh_isampera=false&mh_role=marketer" class="button a_dialog"><span class="icon plus"></span>dodaj produkte</a></div>'
//                        +'              <div class="clearfix"></div>'
//                        +'          </div>'
//                        +'      </li>'
                        +'     </ul>'
                        +'  </div>'

                        +'</ul>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        html: function(arg_params){
                            return ''
                                +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-goto="/#!/manage-store/'+ arg_params.mh_storeslug +'/micropons" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                            ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.marketer_searchddv.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert
                console.log(arg_$form);

                // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                arg_$form.afterDOMInsertionInit();
                // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);

                arg_$form.validate();

                arg_$form.html().find('form#form_'+ arg_$form.FORM_DOM_ID).find('.ajaxsubmit').bind('click', function()
				{
                    // XXX dodaj
                    console.log(arg_$form.html().find('form#form_'+ arg_$form.FORM_DOM_ID));

                    var _$form = arg_$form.html().find('form#form_'+ arg_$form.FORM_DOM_ID);

                    // XXX validator daj na <select> elemente
                    // XXX validator daj na <form> element - nucam vsaj en produkt izbran! (custom)
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = { 'q':arg_$form.fields.searchCompany.getValue() };

                    console.log(arg_$form.getUrl());
                    console.log(query);

					var jqxhr = $.ajax({
							type: 	'GET',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
                        if(data.length < 1){
                            $('#search-results #store-found ul').html('');  // spraznim prejšnji rezultat
                            $('#store-not-found').html('');  // spraznim prejšnji rezultat

                            // XXX prikaži obrazec za kreacijo novega userja in podjetja
                            $('#search-results #text-default').fadeOut('fast');
                            $('#search-results #store-not-found').fadeIn('fast');

                            // logika za dodajanje userja - inline view
                            var $content_placeholder = $('#store-not-found');
                            _$form = MHT.fastsolution.forms.matketer_form_searchuser.init(arg_params);                       // inicializiram xhtml obrazca
                            $content_placeholder.html(_$form.html());                                                        // Vstavim obrazec v DOM
                            MHT.fastsolution.forms.matketer_form_searchuser.setup(_$form, arg_params, $content_placeholder); // Dodam Validator in Submit Event Handler
                        } else {
                            var _store = data.stores[0].store;

                            $('#store-not-found').html('');  // spraznim prejšnji rezultat

                            $('#search-results #store-found ul').html(MHT.list.store.generateItem(_store, arg_params.mh_role));
                            $('#search-results #text-default').fadeOut('fast', function(){ $('#search-results #store-found').fadeIn('fast') });
                        }
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        matketer_form_searchuser: {
            FORM_DOM_ID: 'matketer_form_searchuser',// FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.matketer_form_searchuser.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('ampera/user-by-item'); title = 'Poišči uporabnika';

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['uporabnik'] = MHT.form.fields.searchUser.init();

                this._$form = $(
                         '<div style="width:490px;">'
                        +'  <form id="form_'+this.FORM_DOM_ID+'" method="GET">'
                        +'  <div style="width:468px; padding:10px; background:#F8F8F8; text-align: left; font-style: normal; color:#333;">'
                        +'      <strong>2. korak</strong> - Poišči uporabnika preko <span style="text-decoration:underline;">email-a</span>'
                        +'  </div>'
                        +   this.fields.uporabnik.html(arg_params)
                        +'  </form>'
                        +'</div>'


                        +'<ul id="user_search-results" style="list-style-type:none; margin-top:10px; width:487px;">'

                        +'  <div id="text-default" style="text-align: center; color: gray; font-style:italic;">Iskalni rezultati</div>'
                        +'  <div id="text-default" class="nodisplay" style="text-align: center; color: gray; font-style:italic;"><span class="spinner_small">Iščem uporabnike, počakaj trenutek...</span></div>'
                        // NE najdem userja - kreiram oboje
                        +'  <div id="user-not-found" class="nodisplay" style="text-align: center; color: gray; font-style:italic;">'
                        +'      Uporabnika nisem našel: <a href="http://microhint.com/?mh_showin=dialog&amp;mh_form=create-user-store&amp;mh_action=insert&amp;&amp;mh_startedfrom=marketer-wizard&amp;mh_isampera=false&amp;mh_role=marketer" class="button a_dialog"><span class="icon plus"></span>dodaj uporabnika & trgovino</a>'
                        +'  </div>'

                        // Najdem store - dodam Produkt
                        +'  <div id="user-found">'
                        //  DOBIL PODJETJE (naslednji korak je košarica)
                        +'    <ul style="list-style-type:none;">'
//                        +'      <li id="product_324" class="gradient rounded content" style="font-family: Arial,sans-serif;">'
//                        +'          <div style="padding-top: 4px;">'
//                        +'              <div style="float:left; font-size:13px; font-style: normal;">Alan Ristić, alan.ristic@gmail.com</div><div style="float:right; width:100px; font-size: 11px; padding-top: 2px;"></div>'
//                        +'              <div class="clearfix"></div>'
//                        +'          </div>'
//                        +'          <div style="padding: 6px 2px 6px 2px;">'
//                        +'              <div style="float:left; font-size:13px; font-style: normal;">040 423 688, Pod Taborom 9, 6210 Sežana</div><div style="float:right; width:200px; text-align:right;"><a href="http://microhint.com/?mh_showin=dialog&mh_form=create-store&mh_action=insert&mh_userid=19&mh_startedfrom=marketer-wizard&mh_isampera=false&mh_role=marketer" class="button a_dialog"><span class="icon plus"></span>dodaj trgovino</a></div>'
//                        +'              <div class="clearfix"></div>'
//                        +'          </div>'
//                        +'      </li>'
                        +'     </ul>'
                        +'  </div>'

                        +'</ul>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {}
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.marketer_searchddv.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert

                // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                arg_$form.afterDOMInsertionInit();
                // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);

                arg_$form.validate();

                var _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
                    // XXX dodaj

                    // XXX validator daj na <select> elemente
                    // XXX validator daj na <form> element - nucam vsaj en produkt izbran! (custom)
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // NOTE: Tule je predpostavka, da imam SAMO 1 datum, ne več njih!!
                    var query = { 'q':arg_$form.fields.uporabnik.getValue() };

					var jqxhr = $.ajax({
							type: 	'GET',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
                        if(data.length < 1){
                            // XXX prikaži obrazec za kreacijo novega userja + podjetja
                            $('#user_search-results #user-found ul').html('');
                            $('#user_search-results #text-default').fadeOut('fast');
                            $('#user_search-results #user-not-found').fadeIn('fast');
                        } else {
                            var _user = data.users[0].user;
                            $('#user-not-found').fadeOut('fast');
                            $('#user_search-results #user-found ul').html(MHT.list.user.generateItem(_user, arg_params.mh_role));
                            $('#user_search-results #text-default').fadeOut('fast', function(){ $('#user_search-results #user-found').fadeIn('fast') });
                        }
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        },
        /**
         *  Košarica za dodajanje produktov (trnutno Macropona)
         */
        merchant_productBuyForm: {
            FORM_DOM_ID: 'micronator_OfferForm',     // FORM ID
            _$form: '',                            // FORM xhtml
            _submitUrl: '',                        // FORM SUBMIT url
            init: function(arg_params){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferBuyForm.init()'); }

                var title = '';

                /**
                 * Nastavim submit URLje
                 */
                this.setUrl('store/buy-product'); title = 'Kreiraj dobrodelno kampanjo';

                // Nastavim in poimenujem si tista polja, ki jih nucam
                this.fields['intervalSelect'] = MHT.form.fields.offerDistrictIntervalSelect.init(5);    // nastaviš začetni BRAND_ID

                this._$form = $(
                         '<div id="'+this.FORM_DOM_ID+'" style="display:none;">'
                            +'<div style="padding:0; width:681px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
                            +'<form action="#" method="post" id="newOfferBuyRequest_dailydeal">'

                             // GUMBI
                            +'  <div style="margin-bottom:12px;">'
                            +'      <span>Dodaj: </span>'
                            //+'      <a class="button buy_extra donator"><span class="icon plus"></span>Dobrodelna kampanja</a>'
                            //+'      <a class="button buy_extra micropon"><span class="icon plus"></span>Dnevna ponudba</a>'
                            +'      <a class="button buy_extra nanopon logo-font"><span class="icon plus"></span>Nanopon</a>'
                            +'      <a class="button buy_extra banner logo-font"><span class="icon plus"></span>Macropon</a>'
                            +'  </div>'

                            +' <div class="new_purchase">'

                            +'  <table id="purchase" class="chalkboard">'
                            +'    <tbody>'
                            // GLAVA
                            +'      <tr>'
                            +'          <th class="left"><div style="width:150px;">Produkt</div></th>'
                            +'          <th>Okraj</th>'
                            +'          <th>Datum izvajanja kampanje</th>'
                            +'          <th class="rowTotal">Cena v EUR</th>'
                            +'      </tr>'
                            // VSEBINA
//                            +'      <tr class="item donator">'
//                            +'          <td>Dobrodelna kampanja <a class="remove_buy_extra" style="font-size: 8px; display:block;"><strong>x</strong> odstrani</a></td>'
//                            +           this.fields.intervalSelect.html(arg_params)
//                            +'          <td class="rowTotal">Brezplačno</td>'
//                            +'      </tr>'
                            +'      <tr class="item banner">'
                            +'          <td><span class="logo-font">Macropon</span> <a class="remove_buy_extra" style="font-size: 8px; display:block;"><strong>x</strong> odstrani</a></td>'
                            +           this.fields.intervalSelect.html(arg_params)
                            +'          <td class="rowTotal pi_number">'+Globalize.format(350,'n2')+'</td>'
                            +'      </tr>'
                            // TOTAL
                            +'      <tr class="grand_total">'
                            +'          <td colspan="3">'
                            +'              <div style="margin-top:4px;"><label style="font-size: 15px;">Total v EUR</label></div>'
                            +'          </td>'
                            +'          <td class="total">'
                            +'              <span id="grand_total">€0,00</span>'
                            +'          </td>'
                            +'      </tr>'
                            +'    </tbody>'
                            +'  </table>'

                            +' </div>'

                            // IZBIRA PLAČILA
                            +' <h2 style="font: normal 16px arial,sans-serif; margin: 14px 0 8px 0;">Izberi način plačila</h2>'
                            +' <div id="payment-accordion">'
//	                        +'  <h3><a href="#">Plačilo s kartico na strani Activa Gateway Payment System <sup>&#xae;</sup> (Maestro, MC/EC, Activa...)</a></h3>'
//	                        +'  <div>'
//		                    +'      <p> '
//							+'			<div class="payment-option-description">'
//							+'				<table cellspacing="0" class="supported-cards">'
//						    +'					<tbody>'
//					        +'						<tr>'
//					        +'    						<td style="padding-left: 0;"><img src="/public/images/mp/ac.jpg" alt="Activa Card" height="30" width="51"></td>'
//					        +'   					 	<td><img src="/public/images/logotipi/MasterCardMaestro/mc_accpt_034_gif.gif" alt="MasterCard" height="30" width="51"></td>'
//					        +'    						<td><img src="/public/images/logotipi/MasterCardMaestro/ms_accpt_034_gif.gif" alt="Mastro" height="30" width="51"></td>'
//					        +'    						<td><img src="/public/images/mp/visa.jpg" alt="Visa" height="30" width="51"></td>'
//					        +'    						<td><img src="/public/images/mp/visa-ele.jpg" alt="Visa Electron" height="30" width="51"></td>'
//					        +'    						<td><img src="/public/images/mp/diners-club.jpg" alt="Diners Club" height="30" width="51"></td>'
//					        +'						</tr>'
//					        +'					</tbody>'
//					        +'				</table>'
//							+'				<p>Nakup je možen s plačilnimi karticami: <strong>MasterCard</strong>, <strong>Maestro</strong> <sup>(1)</sup>, <strong>Visa</strong> in <strong>Visa Electron</strong>.</p>'
//							+'				<p>Vse transakcije potekajo preko Activa Payment Gateway (varni spletni plačilni sistem Banke Koper), ki omogoča varno komunikacijo prek svetovnega spleta. Preusmerjeni boste na spletno stran, ki jo upravlja procesni center Activa in banka s katero imamo sklenjeno pogodbo o sprejemu kartic.</p>'
//							+'				<p>Sistem vas preusmeri na spletno stran Activa Payment Gateway, kjer zaključite nakup. Ko končate, vas bo stran Activa Payment Gateway avtomatično preusmerila nazaj na našo stran, kjer bo viden rezultat nakupa.</p>'
//
//							+'				<p><sup><strong>(1)</strong></sup><strong> E-nakupovanje z <strong style="text-decoration: underline;">Maestro</strong> kartico je možno le pod pogojem, da je kartica registrirana na sistemu za avtentikacijo »MasterCard SecureCode«.</strong></p>'
//
//							+'				<table cellspacing="0" class="supported-cards">'
//						    +'					<tbody>'
//					        +'						<tr>'
//					        +'    						<td style="padding-left: 0;"><img src="/public/images/mp/visa-ver.jpg" alt="Verified by Visa" height="30" width="58"></td>'
//					        +'    						<td><img src="/public/images/logotipi/SecureCode/sclogo_62x34.gif" height="30" width="58" alt="MasterCard SecureCode"></td>'
//					        +'						</tr>'
//					        +'					</tbody>'
//					        +'				</table>'
//							+'			</div>'
//                            +'      </p> '
//
//                            +'      <div style="margin-top:10px;"><div style="float:left; width:200px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span> <a style="margin-left:4px; color:#0981BE;">Varnost</a></div> <div style="float:right; width:200px; text-align: right;"><a class="positive button activated ajaxsubmit" data-item-pgid="3">Zaključi nakup &raquo;</a></div></div>'
//                            +'  </div>'

	                        +'  <h3><a href="#">Plačilo z Univerzalnim plačilnim nalogom UPN</a></h3>  '
	                        +'  <div>   '
		                    +'      <p>  '
							+'			<div class="payment-option-description">'
							+'				<p><img width="200" height="115" alt="placilni_nalog_bn02.jpg" src="/public/images/mp/placilni_nalog_bn02.jpg" style="float:right; margin-left:10px;">Plačilo lahko izvedete s univerzalnim plačilnim nalogom UPN. Gre za klasično plačilo s položnico, ki ga opravite prek svoje elektronske banke ali fizično na pošti (oziroma banki).</p>'
							+'			<div class="clearfix"></div>'
							+'			</div>'
                            +'      </p>   '
                            +'      <div style="margin-top:10px;"><div style="float:left; width:200px;"><span class="small gray logo-font">Microhint<sup style="font-size: 8px;">&#x2122;</sup></span> <a style="margin-left:4px; color:#0981BE;">Varnost</a></div> <div style="float:right; width:200px; text-align: right;"><a class="positive button activated ajaxsubmit" data-item-pgid="2">Zaključi nakup &raquo;</a></div></div>'
                            +'  </div>'
                            +' </div>'


                            +'</form>'
                            +'</div>'
                        +'</div>'
                );
                return this;
            },
            html: function(){
                return this._$form;
            },
            setUrl: function(arg_value){
                this._submitUrl = arg_value;
            },
            getUrl: function(){
                return this._submitUrl;
            },
            validate: function() {

                var rules    = {rules:{},messages:{}};

                $.each(this.fields, function(i, o){
                    if(o.validator.needsValidation) {
                        rules.rules[o.FIELD_ID]     = o.validator.rule;
                        rules.messages[o.FIELD_ID]  = o.validator.message;
                    }
                });

                return this._$form.find('form').validate(rules);
            },
            afterDOMInsertionInit: function() {

                $.each(this.fields, function(i, field){
                    if(undefined != field.afterDOMInsertionInit){
                        field.afterDOMInsertionInit();
                    }
                });
            },
            /**
             * Polja v obrazcu
             * NOTE: polja so različne glede na to, ali so prikazana "iz ampre" ali od drugod na strani.
             *       Tista iz Ampere imajo dodatna/različna polja
             */
            fields: {
                button: {
                    validator: {
                        needsValidation: false
                    },
                    /**
                     * Gumb za spremembo statusa Micropona na "new"
                     */
                    toactionNew: {
                        FIELD_ID: 'btn_action_new',
                        html: function(arg_params){
                            return ''
                                +'<span class="store_finish"><a id="'+this.FIELD_ID+'" data-item-goto="/#!/manage-store/'+ arg_params.mh_storeslug +'/micropons" class="primary positive big button activated ajaxsubmit" style="width: 396px; text-align: center;">Pošlji povpraševanje</a></span>'
                            ;
                        }
                    }
                }
            },
            setup: function(arg_$form, arg_params, arg_$content_placeholder){
                if(MHT.fastsolution.forms.DEBUG) { console.debug('Entering: MHT.fastsolution.forms.micronator_OfferBuyForm.setup()'); }

                // XXX Logika, ki se odloča ali gre za update ali insert

                // XXX - PRESELI TOLE KAMOR SODI!!

                //** OMOGOČIM GUMB ZA ODSTRANJEVANJE
                $('.remove_buy_extra').live('click', function(){

                    // sprostim <option> v vseh <select>-ih za tiste, ki so bili tule izbrani
                    $.each($(this).parents('tr').find('select > option:selected'), function(){
                        $('select').find('option[value='+$(this).val()+']').prop('disabled', false);
                    });

                    // izbris elementa
                    $(this).parents('tr').remove();

                    //** naredim še skupni poračun (ponovno)
                    var __total = 0;
                    $.each($('.pi_number'), function(){
                        __total += parseInt($(this).text());
                    });
                    $('#grand_total').text('€'+Globalize.format(__total,'n2'));

                    return false;
                });


                //** OMOGOČIM GUMBE ZA DODAJANJE
                arg_$form.html().find('.buy_extra').click(function(){

                    var xhtml = '';

                    var randID = Math.floor ( Math.random ( ) * 1000 + 1 );
                    var fieldID = 'intervalSelect_'+randID;

                    var _text           = '';   // text, ki je prikazan v <TR> kot ime produkta
                    var _item           = '';   // class, ki določa produkt [donator|micropon|banner|nanopon]
                    var _brandID        = 0;    // ID branda, da znam pravi <SELECT> inicializirat
                    var _price          = '';   // cena za 1 kos produkta [20€|"Brezplačno"|"20% provizija"]
                    var _priceIndicator = '';   // flag, za SUM kalkulator - [pi_number|pi_text]

                    //** dodam nov DONATOR ITEM
                    if($(this).hasClass('donator')) {
                        _text           = 'Dobrodelna kampanja';
                        _item           = 'donator';
                        _brandID        = 3;
                        _price          = 'Brezplačno';
                        _priceIndicator = 'pi_text';
                    }
                    else if($(this).hasClass('micropon')) {
                        _text           = 'Micropon';
                        _item           = 'micropon';
                        _brandID        = 2;
                        _price          = 100;
                        _priceIndicator = 'pi_number';
                    }
                    else if($(this).hasClass('nanopon')) {
                        _text           = 'Nanopon';
                        _item           = 'nanopon';
                        _brandID        = 4;
                        _price          = 60;
                        _priceIndicator = 'pi_number';
                    }
                    else if($(this).hasClass('banner')) {
                        _text           = 'Macropon';
                        _item           = 'banner';
                        _brandID        = 5;
                        _price          = 350;
                        _priceIndicator = 'pi_number';
                    }

                    //** Vstavim nov field v obrazec
                    arg_$form.fields[fieldID] = MHT.form.fields.offerDistrictIntervalSelect.init(_brandID);

                    xhtml = ''
                        +'      <tr class="item '+_item+'">'
                        +'          <td><span class="logo-font">'+_text+'</span> <a class="remove_buy_extra" style="font-size: 8px; display:block;"><strong>x</strong> odstrani</a></td>'
                        +           arg_$form.fields[fieldID].html(arg_params)
                        +'          <td class="rowTotal '+_priceIndicator+'">'+Globalize.format(_price,'n2')+'</td>'
                        +'      </tr>';

                    // Vstavim v DOM
                    arg_$form.html().find('tr.grand_total').before(xhtml);

                    // dodam JS na selectorje
                    arg_$form.fields[fieldID].afterDOMInsertionInit();

                    return false;
                });

                // END XXX

                $.get('store/micropon?store_slug='+arg_params.mh_storeslug+'&micropon_id='+arg_params.mh_microponid, function(data, textStatus, XMLHttpRequest){

                    // XXX tule naredim dodatna preverjanja, ki so pomembna za tale obrazec!!

                    // XXX prestavi v odgovoren widget
                    $( "#payment-accordion" ).accordion({
                        autoHeight: false,
                        navigation: true,
                        //active:     0,
                        active:     0,      // false
                        collapsible:true
                    });


                    // Štartam še JS komponente, ki so odvisne od vstavitve elementov v DOm strukturo
                    arg_$form.afterDOMInsertionInit();
                    // NOTE: To je odgovornost od komponente kjer se prikazuje (raje MHT.component.getComponent()->show())!!
                    MHT.fastsolution.forms.show(arg_$content_placeholder, arg_$form.FORM_DOM_ID);
                });

                arg_$form.validate();

                _$form = arg_$form.html().find('form');

                _$form.find('.ajaxsubmit').bind('click', function()
				{
                    // XXX validator daj na <select> elemente
                    // XXX validator daj na <form> element - nucam vsaj en produkt izbran! (custom)
					if( !_$form.valid() ) return false;

					var $click_el = $(this);

                    // Pohendlam status
                    var status = 'new';
                    if(arg_params.mh_startedfrom === 'marketer-wizard'){ status = 'started-marketer'; }
                    else if(arg_params.mh_startedfrom === 'store-package'){ status = 'started-merchant'; }

                    // Na kup spravim vse izbrane produkte
                    var _$items = _$form.find('.item');

                    var query = {
                        'order': {}
                    };

                    $.each(_$items, function(i,v){
                        query['order'][i] = {
                            'brand_id': 			   arg_$form.fields.intervalSelect.getValue('brand_id'),
                            'status': 			       status,
                            'date_start': 			   arg_$form.fields.intervalSelect.getValue('date_start'),	 // NOT NULL
                            'date_end': 			   arg_$form.fields.intervalSelect.getValue('date_end'),     // NOT NULL
                            'district_slug':           arg_$form.fields.intervalSelect.getValue('district_slug'),
                            'headline': 			   '(skrbnik izpolni)',								         // NOT NULL
                            'description': 			   '(skrbcnik izpolni)'
                        };
                    });

                    // nastavim še variabile, ki so enotne na naročilo
                    query['store_slug']         = 	   arg_params.mh_storeslug,							         // NOT NULL
                    query['payment_gateway_id'] =      $click_el.attr('data-item-pgid')

                    var jqxhr = $.ajax({
							type: 	'POST',
                            dataType: 'json',
							url: 	arg_$form.getUrl(),
							data:  	query
					});

					jqxhr.success(function(data)
					{
						if(data.notice != undefined && data.notice.msgType == 'success')
						{
                            switch(arg_params.mh_startedfrom)
                            {
                                case 'store-package':
                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
                                    MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);
                                    $('#products-wall #wall-title').after(MHT.list.product.generateItem(data.micropons[0].micropon, 'merchant'));
                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                                case 'marketer-wizard':
                                    // XXX implement me!!
//                                    MHT.fastsolution.forms.close(arg_$content_placeholder, arg_$form.FORM_DOM_ID);                       // zapri canvas
//                                    MHT.utils.flashMessanger(data.notice.msgType, 'Datum na okraju je bil uspešno rezerviran. Dobrodelno kampanjo lahko takoj kreiraš.');
//                                    // XXX moram zapreti še prejšnji dialog
//                                    $('#search-results').parents('.ui-dialog, .mh_dialog').remove();
//                                    $('#products-wall #wall-title').after(MHT.list.product.generateItem(data.micropons[0].micropon, 'marketer'));
//                                    $('#product_'+data.micropons[0].micropon.id).effect("pulsate", { times:4 }, 1000);
                                    break;
                            }
						}
						else if(data.notice != undefined && data.notice.msgType == 'error')
						{
							arg_$form.html().find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
						}
						else if( data.notice == undefined )
						{
							arg_$form.html().find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
						}
					}).error(function() {
                        // TODO (donator) tule nek smiselen error vreči, ne tole!
						alert("error");
					}).complete(function() {});
					return false;
				});
            }
        }
    };

    /**
     * Nastavi UI text glede na stanje Ponudbe
     * NOTE: Centralizacija vseh sporočil v sistemu, tako bodo povsod enaki
     *       in enostavno spremenljivi
     */
    MHT.status = {
        /**
         * Metoda dobi status in vrne spremljajoč UI text
         *
         * BrandID:
         *  - 2: Dnevna ponudba
         *  - 3: Dobrodelna kampanja
         *
         * @param string arg_status Status akterja (user,store,DD-dnevne ponudbe,DK-dobr.kamp.)
         * @param array arg_params  Dodatni parametri za "rekreacijo" gumbov, linkov ipd. (IDji,SLUGi itn.)
         */
        interpret:function(arg_status, arg_params) {
            switch(arg_status){
                /*******************************************************************
                 * DNEVNE PONUDBE
                 *******************************************************************/
                case '2_marketer-added':
                    return '<strong>Ponudba čaka na dopolnitev trgovca</strong>';
                    break;
                /*******************************************************************
                 * DOBRODELNE KAMPANJE
                 *******************************************************************/
                case '3_marketer-added':
                    return '<strong>Kampanja čaka na dopolnitev organizacije</strong>';
                    break;
                default:
                    // do nothing
            }
        }
    };

	MHT.layout = {
		togglePrintWebLayout: function(showLayoutWithID)
		{
			if(showLayoutWithID == 'print')
			{
				$('#web-page, #userBackgroundImg, #background, #fader').hide();
				$('body').css('background', 'none');
				$('body').find('#background').fadeOut();
				$('#print-page').show();
			}
			else 
			{
				$('#print-page').html('').hide();
				//$('body').css('background', '#89B556');
				$('body').find('#background').fadeIn();
				$('body').find('.fader').fadeIn();
				$('#web-page').show();
			}
		}	
	};
	
	MHT.math = {
		toPrecision: function(number)
		{
			fractionPlaces = 2;	// 4
			number = new Number(number);
		
			
			if( number < 0.1 ) {
				fractionPlaces -= 1;
			}
			else if( number < 1 ) {
				fractionPlaces += 0;
			}
			else if( number < 10 ) {
				fractionPlaces += 1;
			}
			else if( number < 100 ) {
				fractionPlaces += 2;
			}
			else if( number < 1000 ) {
				fractionPlaces += 3;
			}
		
			return number.toPrecision(fractionPlaces);
		}
	};
	
	/**
	 * Class, ki mi generira XHTML za append v DOM na podlagi podanih
	 * podatkov!
	 */
	MHT.appLimitedEdition = {
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateMainCard01: function(data, uafNICK)
			{
				var micropon = data.micropons[0].micropon;
				var store    = micropon.store.stores[0].store;

                // Nastavim cookie zadnje obiskane lokacije
                $.cookie('_mhdistrict', micropon.districtslug, {path:'/', domain: 'microhint.com', expires: 200});
				
				var district_slug = store.store_locations.locations[0].location.district_slug;
				
				// FIXME še 100x preveri, če je vse nastavljeno in NULLable vrednosti!!
				
				var uafURL = '';
				if( undefined != document.username)
				{
					uafURL = '/uaf/'+ document.username;	// User affiliate URL
				}
				
				// If I came from user free affiliate link ;)
				if( undefined != uafNICK && null != uafNICK && '' != uafNICK ) {
					uafNICK = '/uaf/'+ uafNICK;
				} else {
					uafNICK = '';	// User affiliate URL
				}
				
				
				var districtName = $('.select-city:visible').text();
				var mpURL 		 = 'http://'+document.location.host +'/#!/micropon/'+store.store_slug+'/'+ micropon.slug + uafURL;
				var coURL 		 = '/#!/checkout/'+store.store_slug+'/'+ micropon.slug + uafNICK;
				var shareTitle   = micropon.headline +' ('+ districtName +')';
				var shareBody	 = decodeURIComponent(micropon.description);
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");
				// var shareBody	 = decodeURIComponent(micropon.description);
				
				var picURL		 = '/tmp/mppics/'+ micropon.pic_name;
				
				var picStripe		= '';								// obvestilo čez sliko
				var css_priceColor 	= 'color:#F99431;';		// Barva cene (oranžna aktive, siv neaktiven)
				var buyButton	   	= '<a href="'+coURL+'" class="gumb rounded buy-now" style="width:100px;"><span>Kupi!</span></a>';
				var giftBuy		  	= '<a href="'+coURL+'" class="send-as-a-gift" style="margin-left: 0px;">Kupi kot darilo</a>';
				
				/*
				 * PREVERIM ALI GRE ZA PREVIEW ALI KAJ DRUGEGA
				 * */
				if(micropon.workflow_status == 'review' || micropon.workflow_status == 'new' || micropon.workflow_status == 'draft') {
					// Review state
					picStripe 		= '<div class="deal-review-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:100px; color:#F99431; background: #fff; border: 1px solid #BEBEBE; font-size:16px;"><span>Nakup še ni možen</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				else if(micropon.workflow_status != 'running') {
					// Pretekla ponudba state
					picStripe 		= '<div class="deal-over-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:100px; color:#F99431; background: #fff; border: 1px solid #BEBEBE; font-size:16px;"><span>Nakup ni več možen</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				
				var shareEarning = MHT.math.toPrecision( parseFloat((micropon.max_discount_min_price*10)/100) );
				
				var offerPrice	 = MHT.math.toPrecision( parseFloat( micropon.max_discount_min_price ) );
				
				var priceArray	 = offerPrice.split('.',2);
				
				var smallerFont	= 'font-size:60px;';
				var priceWhole	= priceArray[0];
				var priceRest	= ','+ priceArray[1];
				
				if(priceRest == ',00') {
					priceRest	= '';
				}
				
				if(priceWhole >= 100 && priceRest == '') {
					smallerFont	= 'font-size:6px;';
				}
				else if(priceWhole >= 10 && priceRest != '') {
					 smallerFont	= 'font-size:43px;';
				}
				else if(priceWhole >= 10 && priceRest == '') {
					smallerFont	= 'font-size:56px;';
				}
				
				/* Preverim ali je podjetje DDV zavezanec */
				var ddv = '';
				if( store.id_za_ddv != '' && store.id_za_ddv != null && store.id_za_ddv != undefined ) {
					ddv = '*DDV je vključen v ceno';
				}

                /* Multimedijo vstavim */
                var multimedia      = '';
                var firstHack       = false;
                var firstImage      = '';
                var galleryID       = 'gallery1';
                if( micropon.multimedia != undefined ) {

                    multimedia      += '<ul style="z-index: 4; position: absolute; right: -12px; top: 8px;">';

                    $.each(micropon.multimedia, function(i, v){
                        if(v.uploader == '2'){
                            if(firstHack == true) {
                                multimedia      += '<li style=" line-height: 8px; padding: 0; margin: 3px 5px 0 0; list-style: none;"><a href="/tmp/mppics/'+v.file_name+'" rel="lightBox" data-item-gid="'+galleryID+'" style="display:block; text-decoration: none; border: solid 2px #fff;  -webkit-box-shadow: rgba(0, 0, 0, 0.796875) 0px 1px 3px; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"><img src="/tmp/mppics/'+v.file_name+'" height="30" width="30" style="border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"></a></li>';
                            }
                            else {
                                picURL      = firstImage  = '/tmp/mppics/'+v.file_name;
                                firstHack   = true;
                            }
                        }

                    });

                    multimedia += '</ul>';
                }
                var xhtml =
                    '<div class="panel-body">'
                        +'  <div id="market-sub" style="border-bottom_: 5px solid #5093B0; position: relative; background-color: #262626; font-family: arial rounded mt bold, helvetica, arial, sans-serif; font-weight:normal; -webkit-border-radius: 4px 4px 0 0; -moz-border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;">'
                        +'      <h1 style="color: white; text-transform: lowercase; padding: 10px 20px 10px; font-size: 16px; margin: 0px; font-weight:normal; line-height: 24px; letter-spacing: normal; padding-left: 40px; background: url(/public/images/vertical_sprite_16px.png) no-repeat 8px 6px;">Dnevna Ponudba</h1>'
                        +'      <a href="#" class="button newsletter-desc-tip" style="position:absolute; right:10px; top:10px;">obveščaj me<span class="mail icon" style="margin:auto auto auto 7px; background-position: 0 -499px;"></span></a>'

                        +'      <div class="tip-content" style="display:none; z-index:99999; background:#fff; position:absolute; top:60px; right:10px;">'
                        +'          '+ MHT.forms.newsletterSubscribtionSmallWidget()
                        +'      </div>'

                        +'  </div>'

                        +'	<div class="panel-innards clearfix">'
                        +' 		<div class="grid_5 rc-l alpha portrait" style="background: #efefef url('+picURL+') no-repeat top left">'
                        +'			&nbsp;'
                        +       multimedia
                        +' 		</div>'
                        +		picStripe
                        +'		<div class="grid_7 omega content">'
                        +'  		<div class="deal-title-b">'
                        +'    			<h1 style="color: #262626;">'+ micropon.headline +'</h1>'
                        +'    			<p style="font-size: 16px; color: #58595B; line-height: 18px;">'+ micropon.pitch_statement +'</p>'
                        +'  		</div>'
                        +'  		<div id="deal-buy-box">'
                        +'				<table class="deal-buy-box buy-now-active">'
                        +'					<tbody><tr>'
                        +'						<td style="text-align: center; width:99px;">'
                        +'  						<div class="deal-price deal-price-lg" style="'+css_priceColor+'">'
                        +'    							<span class="dollar_sign">€</span><span style="'+smallerFont+' line-height: 20px;">'+ priceWhole +'</span><span style="font-size:20px; line-height: 20px;">'+priceRest+'</span>'
                        +' 							</div>'
                        +' 						</td>'
                        +'						<td style="text-align: center; width:170px;">'
                        +							buyButton
                        +'							<br><span style="color:#999;">'+ddv+'<span>'
                        +'						</td>'
                        +'						<td style="text-align: center; padding: 0px 0 5px 0px;">'
                        +							giftBuy
                        +'						</td>'
                        +'					</tr></tbody>'
                        +'				</table>'
                        +'				<ul class="clearfix deal-info">'
                        +' 					<li style="width:120px;">'
                        +' 						<div class="value">'+ Globalize.format( micropon.original_price, 'n2' ) +' €</div>'
                        +' 						<div class="label">redna cena</div>'
                        +'					</li>'
                        +' 					<li class="purchased" style="width:170;">'
                        +'  					<div class="value">'+ parseInt(micropon.max_discount_percentage*100) +'%</div>'
                        +'   					<div class="label">prihranek</div>'
                        +' 					</li>'
                        +' 					<li class="last">'
                        +'  					<div class="value">'
                        +'							<div id="countdown">'
                        +'  							<span class="num">--</span>'
                        +'  							<span class="colon">:</span>'
                        +'   							<span class="num">--</span>'
                        +'  							<span class="colon">:</span>'
                        +'  							<span class="num">--</span>'
                        +' 							</div>'
                        +'						</div>'
                        +'  					<div class="label">Izteče se čez </div>'
                        +' 					</li>'
                        +'				</ul>'
                        +'				<div class="deal-description" style="min-height: 110px;">'
                        +					shareBody.truncateInline(430, 'xx-deal')
                        +' 				</div>'
                        +'				<div class="timeTracker floatLeft timeTrackerBig">'
                        +' 					<div class="timeCounter">'
                        +' 						<span class="floatRight">max: '+micropon.max_quantity+'</span>'
                        +' 						<span class="floatLeft"></span>'
                        +'     					<span class="percent">'+micropon.paid_count_bruto+' kupljenih</span>'
                        +'    					<div class="timeCounterRight" style="width:100%">'
                        +'    						<div class="timeCounterLeft" style="width:'+ parseInt((micropon.paid_count_bruto * 100)/micropon.max_quantity) +'%"></div>'
                        +'    					</div>'
                        +'					</div>'
                        +'				</div>'
                        +'				<div class="social_share">'
//				    +'  				<p><strong>Zasluži 10%('+shareEarning+'€)!</strong> Deli s prijatelji, in če kdo kupi, dobiš '+shareEarning+'€ v MT.</p>'
                    +'  				<p>Registriraj se, deli s prijatelji in ko kupijo, dobiš '+micropon.uaf_percent+'% ('+ Globalize.format( parseFloat( micropon.max_discount_min_price * (micropon.uaf_percent/100) ), 'n2' ) +'€) v MT</p>'
                    +'  				<ul class="clearfix">'
//				    +'   					<li class="first">'
//				    +'							<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.microhint.com%2F" scrolling="no" frameborder="0" style="height: 62px; width: 100%" allowTransparency="true"></iframe>'
//				    +'    					</li>'
                    +'   					<li class="first">'
                    +'    						 <a title="Share with Facebook" class="social-share-fb fb share-on-fb" href="'+mpURL+'" data-item-pic="'+picURL+'" data-item-status="'+strippedBody+'" data-item-title="'+shareTitle+'">Všeč mi je</a>'
                    +'    					</li>'
                    +'    					<li>'
                    +'							<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+mpURL+'" data-text="Ne zamudi odlične ponudbe: '+shareTitle+'" data-count="none" data-via="Microhint_com">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>'
                    +'  					</li>'
                    +'  					<li>'
                    +'    						<a style="width:60px;" title="Share by Email" class="social-share-email" href="//www.addthis.com/bookmark.php?pub=alanristic&amp;v=250&amp;source=tbx-250&amp;tt=0&amp;s=email&amp;url='+encodeURIComponent(mpURL)+'&amp;title='+shareTitle+'&amp;content=&amp;lng=en" target="_blank">Pošlji email</a>'
                    +'  					</li>'
                    +'  					<li class="last">'
                    +' 							<div class="addthis_toolbox addthis_default_style"  addthis:url="'+encodeURIComponent(mpURL)+'" addthis:title="'+encodeURIComponent(shareTitle)+'" addthis:description="'+decodeURIComponent('bla')+'">'
                    +'								<a class="addthis_button_compact" style="font-size:11px; font-weight: normal;">Deli drugam</a>'
                    +'							</div>'
                    +'  					</li>'
                    +'  				</ul>'
                    +'				</div>'
                    +'	      </div>'
                    +'	    </div>'
                    +'	  </div>'
                    +'	</div>'
                    +'<div class="clearfix"></div>';


				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateMainCard02: function(data)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;
				
				var arguments = micropon.coupon_arguments.split('|');
				var argItems  = '';
				$(arguments).each(function(i, v){
					//argItems += '<li>odličen stand-up večer <strong>za samo 4,90 <span class="caps">EUR</span></strong></li>';
					argItems += '<li>'+v+'</li>';
				});

				var highlights = micropon.coupon_highlights.split('|');
				var higItems   = '';
				$(highlights).each(function(i, v){
					//argItems += '<li>odličen stand-up večer <strong>za samo 4,90 <span class="caps">EUR</span></strong></li>';
					higItems += '<li>'+v+'</li>';
				});
				
				// Store Locations	FIXME tole bi morale biti lokacije prevzema micropona
				var locations = store.store_locations.locations;
				var locItems  = '';
				var css       = 'display: block;';
                $(locations).each(function(i, v){
					locItems += 
						 '<span class="street_1" style="'+css+' font-weight:normal;">'+v.location.street+' '+v.location.street_number+'</span>'
						+'<span style="'+css+'">'+v.location.postal_name+', '+v.location.postal_code+'</span>'
						+'<span class="phone" style="'+css+' margin-bottom:4px;">Tel: '+v.location.storeLocation.phone+'</span>';
//						+'<p class="directions"><a href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo</a></p>';
				    css = 'display:none;';
                });
				
				// dodam še lokacije prevzrema ponudbe
				var redeemLocations = micropon.locations.locations;
				var redeemLocItems 	= '';
				$(redeemLocations).each(function(i, v){
					redeemLocItems += 
						 '<li style="padding: 0 0 0 28px; background: url(/public/images/map-pin.png) no-repeat 0 1px; font-size: 12px; width:180px; float:left;">'
						+'<span class="street_1">'+v.location.street+' '+v.location.street_number+'</span><br>'
						+''+v.location.postal_name+', '+v.location.postal_code+'<br>'
						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
						+'<p class="directions" style="margin-bottom:8px;"><a style="font-size: 12px;" href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo &raquo;</a></p>'
						+'</li>';
				});
				
				
				var showWebAdresses = false;
				var webpage = '';
				if(store.company_webpage != undefined && store.company_webpage != null && store.company_webpage != '')
				{
					webpage = '<a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal; margin-right:8px;">www &raquo;</a>';
					showWebAdresses = true;
				}

				var fb = '';
				if(store.company_facebook != undefined && store.company_facebook != null && store.company_facebook != '')
				{
					fb = '<a href="'+store.company_facebook+'" target="_blank" style="margin-right:8px;">facebook &raquo;</a>';
					showWebAdresses = true;
				}
				
				
				var xhtml_webadresses = '';
				if (showWebAdresses)
				{
					xhtml_webadresses = ''
						+'	  		<div class="meta" style="margin-top:10px;">'
						+'				<span class="street_1" style="font-size:12px;">Na spletu</span><br>'
						+'				'+ webpage +' '+ fb
						+'	  		</div>';
				}
				
				var xhtml =
					 '<div class="gutter location-narrow rounded">'
					//+'	<h2 class="marker" style="margin-bottom:10px; font-size:15px;">O podjetju</h2>'
					//+	store.store_description.truncateInline(300, 'xx-company')

                     +'<div style="width: 210px; margin: 4px 15px 0 0; float: left;">'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_pen.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Dobro je vedeti / opombe</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: disc;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			higItems
					 +'		</ul>'
                     +'</div>'
                     +'<div style="width: 210px; margin: 4px 0 0 0; float: right;">'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_star.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Argumenti za nakup</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: disc;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			argItems
					 +'		</ul>'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_pen.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Ponudbo vnovči na:</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: none;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			redeemLocItems
					 +'		</ul>'
                     +'</div>'

				    +'</div>'
					
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:220px;">'
					+'	  <ul class="addresses" style="margin-top:6px;">'
						    
					+'	    <li class="address order-0" data-marker-index="0" style="font-size:12px;">'
					+'	  		<div class="pin" style="position: absolute; top: 0; left: 0;">'
					+'	          <span style="background-position:0px -0px">&nbsp;</span>'
					+'	      	</div>'
					+'	  		<div class="meta" style="padding-right:10px;">'
					+'	    		<span class="street_1">'+store.company_name+'</span><br>'
//					+'	    		<p class="directions" style="margin-bottom: 0px; font-weight:normal;"><a target="_blank">info@standupkomedija.com</a></p>'
//					+'	    		<p class="directions"><a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal;">'+store.company_webpage+'</a></p>'
					+'	  		</div>'
					+			xhtml_webadresses
					+'	  		<div class="meta" style="margin-top:4px;">'
					+'				<span class="street_1" style="font-size:12px;">Naslov in kontakti</span><br>'
					+				locItems
					+'	  		</div>'
					+'		</li>'
					+'	  </ul>'
					+'	  <div id="google-map" class="google-map  full" style="float:left; margin-top:10px; padding-right: 10px; position: relative; background-color: rgb(229, 227, 223); overflow-x: hidden; overflow-y: hidden; width:200px; height:180px;"></div>'
					+'</div>'	
					
					+'<div class="clearfix"></div>';
				
				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateMainCard03: function(mpID, districtSlug)
			{
				var content  = '';
				var micropon = '';
				var store    = '';
				
				$.get('search/district-micropons?count=100&district_slug='+ districtSlug +'&old=0', function(data, textStatus, XMLHttpRequest)
				{
					// Če imamo še kakšno ponudbo poleg trenutne
					if(data.micropons != undefined && data.micropons.length >= 1)
					{
						
						content	+'<ul>';
					
						$.each(data.micropons, function(i, v){
							
							//console.log(v);
							micropon = v.micropon;
							store    = micropon.store.stores[0].store; 
							
							if(mpID != v.micropon.id)
							{
								content += ''
									+'<li class="nearby-deal">'
									+'	<div class="img">'
									+'  	<a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'"><img alt="36" src="http://a3.ak.lscdn.net/imgs/8460150b-1581-4c40-a056-5c0923afc1fa/36.png"></a>'
									+'	</div>'
									+'	<p><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+ micropon.headline +'</a></p>'
									+'	<p class="title"><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+store.company_name+'</a></p>'
									// +'	<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Los Angeles Families</a></p>'
									+'</li>	'
									;
							}
							
						});
					
						content	+'</ul>';
						
						
					}
					else { content = 'Trenutno ni dodatne ponudbe'; }
					
					$('#additional-offer').after(content);
					
				});
				
				
				var xhtml =
					'<div class="gutter location-narrow rounded" style="width:330px;">'
					+'	<h2 id="additional-offer" style="margin-bottom:10px; font-size:15px;">dodatna ponudba na okraju</h2>'
					+'</div>'	
// 					
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:330px;">'
					+'	<h2 style="margin-bottom:10px; font-size:15px; display:relative;">Prispevaj v skuponost</h2>'
					
					+'	<ul>'
					+'		<li class="nearby-deal nearby-donator">'
					+'			<div class="img_">'
					+'  			<a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560"><img alt="36" src="/public/images/donator.jpg" width="200" height="112"></a>'
					+'				<span class="srce"></span>'
					+'				<a class="nearby-donator-nub">poglej <span style="font-size:13px;">&raquo;</span></a>'
					+'			</div>'
					+'			<p style="margin-top:2px;"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Invest in Kids</a></p>'
					//+'			<p class="title"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Childrens Clothing or Furniture</a></p>'
					+'			<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560" class="donator-quote">"When you\'re working with the community, you don\'t necessarily have the time or funds to stay on top of the latest research. We can do that legwork."</a></p>'
					+'		</li>	'
					+'	</ul>'
					
					
					
					+'</div>'	
					
					+'<div class="clearfix"></div>'
					;
				
				return xhtml;
			},
			/**
			 * Zgenerira widget za stranske ponudbe oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateSideDeals01: function(data)
			{
				var sideDeals = data.micropons.slice(1, data.micropons.length);
				
				var sideDealsXhtml = '';
				if( sideDeals.length > 0 )
				{
					sideDealsXhtml += 
						'<div class="side-box" style="width:232px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px; -webkit-box-shadow: rgba(0, 0, 0, 0.796875) 0px 1px 3px; background-position: initial initial; background-repeat: initial initial; padding:0;">'
						+'	<h2 style="font-size:14px; padding:12px 10px 4px 10px;">Več ponudb iz okolice</h2>';
					
					$(sideDeals).each(function(i, v){
						sideDealsXhtml += '<p class="area_deal"><a href="/#!/micropon/'+v.micropon.store.stores[0].store.store_slug+'/'+v.micropon.slug+'" class="deal_click_event_tracking_classes title"><span>'+v.micropon.store.stores[0].store.store_locations.locations[0].location.city+'</span><br><span class="pirce_ico">'+v.micropon.headline+'</span></a></p>';
					});
					
					sideDealsXhtml += 
						'</div>';
				}
				return sideDealsXhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateNanoponMainCard01: function(data, uafNICK)
			{
				var micropon = data.micropons[0].micropon;
				var store    = micropon.store.stores[0].store;

                console.log(micropon);
                console.log(store);

                // Nastavim cookie zadnje obiskane lokacije
                $.cookie('_mhdistrict', micropon.districtslug, {path:'/', domain: 'microhint.com', expires: 200});

				var district_slug = micropon.districtslug

				// FIXME še 100x preveri, če je vse nastavljeno in NULLable vrednosti!!

				var uafURL = '';
				if( undefined != document.username)
				{
					uafURL = '/uaf/'+ document.username;	// User affiliate URL
				}

				// If I came from user free affiliate link ;)
				if( undefined != uafNICK && null != uafNICK && '' != uafNICK ) {
					uafNICK = '/uaf/'+ uafNICK;
				} else {
					uafNICK = '';	// User affiliate URL
				}


				var districtName = $('.select-city:visible').text();
				var mpURL 		 = 'http://'+document.location.host +'/#!/micropon/'+store.store_slug+'/'+ micropon.slug + uafURL;
				var coURL 		 = '/#!/checkout/'+store.store_slug+'/'+ micropon.slug + uafNICK;
				var shareTitle   = micropon.headline +' ('+ districtName +')';
				var shareBody	 = micropon.description_description;
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");
				// var shareBody	 = decodeURIComponent(micropon.description);

				var picURL		 = '/tmp/mppics/'+ micropon.pic_name;

				var picStripe		= '';								// obvestilo čez sliko
				var css_priceColor 	= 'color:#F99431;';		// Barva cene (oranžna aktive, siv neaktiven)
				var buyButton	   	= '<a href="'+coURL+'" class="gumb rounded buy-now" style="width:100px;"><span>Kupi!</span></a>';
				var giftBuy		  	= '<a href="'+coURL+'" class="send-as-a-gift" style="margin-left: 0px;">Kupi kot darilo</a>';

				/*
				 * PREVERIM ALI GRE ZA PREVIEW ALI KAJ DRUGEGA
				 * */
				if(micropon.workflow_status == 'review' || micropon.workflow_status == 'new' || micropon.workflow_status == 'draft') {
					// Review state
					picStripe 		= '<div class="deal-review-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:100px; color:#F99431; background: #fff; border: 1px solid #BEBEBE; font-size:16px;"><span>Nakup še ni možen</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				else if(micropon.workflow_status != 'running') {
					// Pretekla ponudba state
					picStripe 		= '<div class="deal-over-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:100px; color:#F99431; background: #fff; border: 1px solid #BEBEBE; font-size:16px;"><span>Nakup ni več možen</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}

				var shareEarning = MHT.math.toPrecision( parseFloat((micropon.max_discount_min_price*10)/100) );

				var offerPrice	 = MHT.math.toPrecision( parseFloat( micropon.max_discount_min_price ) );

				var priceArray	 = offerPrice.split('.',2);

				var smallerFont	= 'font-size:60px;';
				var priceWhole	= priceArray[0];
				var priceRest	= ','+ priceArray[1];

				if(priceRest == ',00') {
					priceRest	= '';
				}

				if(priceWhole >= 100 && priceRest == '') {
					smallerFont	= 'font-size:6px;';
				}
				else if(priceWhole >= 10 && priceRest != '') {
					 smallerFont	= 'font-size:43px;';
				}
				else if(priceWhole >= 10 && priceRest == '') {
					smallerFont	= 'font-size:56px;';
				}

				/* Preverim ali je podjetje DDV zavezanec */
				var ddv = '';
				if( store.id_za_ddv != '' && store.id_za_ddv != null && store.id_za_ddv != undefined ) {
					ddv = '*DDV je vključen v ceno';
				}

                /* Multimedijo vstavim */
                var multimedia      = '';
                var firstHack       = false;
                var firstImage      = '';
                var galleryID       = 'gallery1';
                if( micropon.multimedia != undefined ) {

                    multimedia      += '<ul style="z-index: 4; position: absolute; right: -12px; top: 8px;">';

                    $.each(micropon.multimedia, function(i, v){
                        if(v.uploader == '2'){
                            if(firstHack == true) {
                                multimedia      += '<li style=" line-height: 8px; padding: 0; margin: 3px 5px 0 0; list-style: none;"><a href="/tmp/mppics/'+v.file_name+'" rel="lightBox" data-item-gid="'+galleryID+'" style="display:block; text-decoration: none; border: solid 2px #fff;  -webkit-box-shadow: rgba(0, 0, 0, 0.796875) 0px 1px 3px; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"><img src="/tmp/mppics/'+v.file_name+'" height="30" width="30" style="border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"></a></li>';
                            }
                            else {
                                picURL      = firstImage  = '/tmp/mppics/'+v.file_name;
                                firstHack   = true;
                            }
                        }

                    });

                    multimedia += '</ul>';
                }

                var highlights = micropon.coupon_highlights.split('|');
				var higItems   = highlights.join(' * ');


                // dodam še lokacije prevzrema ponudbe
				var redeemLocations = store.store_locations.locations;
				var redeemLocItems 	= '';
				$(redeemLocations).each(function(i, v){
					redeemLocItems +=
						 '<li style="padding: 0 0 0 28px; background: url(/public/images/map-pin.png) no-repeat 0 1px; font-size: 12px; width:180px; float:left;">'
						+'<span class="street_1">'+v.location.street+' '+v.location.street_number+', </span>'
						+''+v.location.postal_code+' '+v.location.postal_name+'<br>'
						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
						+'<p class="directions" style="margin-bottom:8px;"><a style="font-size: 12px;" href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo &raquo;</a></p>'
						+'</li>';
				});

                try{
                var xhtml =
                         '<div class="panel-body">'
                        +'  <div id="market-sub" class="heading-title rounded-top">'
                        +'      <h1 style="color: #bdda9b; text-transform: lowercase; padding: 8px 20px 10px; font-size: 23px; margin: 0px; font-weight:normal; line-height: 26px; letter-spacing: normal; padding-left: 40px; background: url(/public/images/vertical_sprite_green_16px.png) no-repeat 8px -60px;"><span class="logo-font">nanopon</span></h1>'
                        +       MHT.buttons.newsletterSub.init()
                        +'  </div>'
                        +'	<div class="panel-innards clearfix">'
                        +' 		<div class="grid_5  alpha portrait" style="background: #efefef url('+picURL+') no-repeat top left">'
                        +'			&nbsp;'
                        +       multimedia
                        +' 		</div>'
                        +		picStripe
                        +'		<div class="grid_7 omega content">'
                        +'  		<div class="deal-title-b">'
                        +'    			<h1 style="color: #262626;">'+ micropon.description_headline +'</h1>'
                        +'    			<p style="font-size: 16px; color: #58595B; line-height: 18px;">'+ micropon.pitch_statement +'</p>'
                        +'  		</div>'
                        +'  		<div id="deal-buy-box">'
                        +'				<table class="deal-buy-box buy-now-active">'
                        +'					<tbody><tr>'
                        +'						<td style="text-align: center; width:99px;">'
                        +'  						<div class="deal-price deal-price-lg" style="'+css_priceColor+'">'
                        +'    							<span class="dollar_sign">€</span><span style="'+smallerFont+' line-height: 20px;">'+ priceWhole +'</span><span style="font-size:20px; line-height: 20px;">'+priceRest+'</span>'
                        +' 							</div>'
                        +' 						</td>'
                        +'						<td style="text-align: center; width:170px;">'
                        +							buyButton
                        +'							<br><span style="color:#999;">'+ddv+'<span>'
                        +'						</td>'
                        +'						<td style="text-align: center; padding: 0px 0 5px 0px;">'
                        +							giftBuy
                        +'						</td>'
                        +'					</tr></tbody>'
                        +'				</table>'
                        +'				<ul class="clearfix deal-info">'
                        +' 					<li style="width:120px;">'
                        +' 						<div class="value">'+ Globalize.format( micropon.original_price, 'n2' ) +' €</div>'
                        +' 						<div class="label">redna cena</div>'
                        +'					</li>'
                        +' 					<li class="purchased" style="width:170;">'
                        +'  					<div class="value">'+ parseInt(micropon.max_discount_percentage*100) +'%</div>'
                        +'   					<div class="label">prihranek</div>'
                        +' 					</li>'
                        +' 					<li class="last">'
                        +'  					<div class="value">'
                        +'							<div id="countdown">'
                        +'  							<span class="num">--</span>'
                        +'  							<span class="colon">:</span>'
                        +'   							<span class="num">--</span>'
                        +'  							<span class="colon">:</span>'
                        +'  							<span class="num">--</span>'
                        +' 							</div>'
                        +'						</div>'
                        +'  					<div class="label">Izteče se čez </div>'
                        +' 					</li>'
                        +'				</ul>'
                        +'				<div class="deal-description" style="min-height: 110px;">'
                        +					shareBody.truncateInline(430, 'xx-deal')
                        +' 				</div>'
                        +'				<div class="timeTracker floatLeft timeTrackerBig">'
                        +' 					<div class="timeCounter">'
                        +' 						<span class="floatRight">max: '+micropon.max_quantity+'</span>'
                        +' 						<span class="floatLeft"></span>'
                        +'     					<span class="percent">'+micropon.paid_count_bruto+' kupljenih</span>'
                        +'    					<div class="timeCounterRight" style="width:100%">'
                        +'    						<div class="timeCounterLeft" style="width:'+ parseInt((micropon.paid_count_bruto * 100)/micropon.max_quantity) +'%"></div>'
                        +'    					</div>'
                        +'					</div>'
                        +'				</div>'
                        +'				<div class="social_share">'
//				    +'  				<p><strong>Zasluži 10%('+shareEarning+'€)!</strong> Deli s prijatelji, in če kdo kupi, dobiš '+shareEarning+'€ v MT.</p>'
                    +'  				<p>Registriraj se, deli s prijatelji in ko kupijo, dobiš '+micropon.uaf_percent+'% ('+ Globalize.format( parseFloat( micropon.max_discount_min_price * (micropon.uaf_percent/100) ), 'n2' ) +'€) v MT</p>'


                                         +'<ul class="services addthis_toolbox" addthis:url="'+mpURL+'" addthis:description="superkul" addthis:title="'+shareTitle+'" style="">'
                                        +'  <li class="share-facebook" style="margin-right: 0px !important; margin-bottom: 0px; padding-left:0; border-right:none;">'
                                        +'      <div class="option">'
                                        +'          <a class="share-facebook sd-button social-share-fb fb share-on-fb" href="'+mpURL+'" data-item-status="'+strippedBody+'" data-item-title="'+shareTitle+'" data-item-pic="'+picURL+'" data-item-caption="naredi me"><span>Facebook</span></a>'
                                        +'      </div>'
                                        +'  </li>'
                                        +'  <li class="share-googleplus_" style="margin-right: 0px !important; margin-bottom: 0px; padding-left:0; border-right:none;">'
                                        +'      <div id="googleplus" class="option">'
                    //                    +'          <a href="#" class="addthis_button_google_plusone share-googleplus sd-button"><span>Google</span></a>'

                                        +' <a class="share-googleplus sd-button" style="padding-top: 1px; padding-left: 1px;"><g:plusone size="small" annotation="none"></g:plusone><span style="display: inline;padding-left: 2px; line-height: 18px; float: right; padding-top: 0; margin-top: -1px;">Google</span></a>'
                                        +'  <script type="text/javascript">'
                                        +'      window.___gcfg = {lang: \'sl\'};'
                                        +'      (function() {                    '
                                        +'          var po = document.createElement(\'script\'); po.type = \'text\/javascript\'; po.async = true;  '
                                        +'          po.src = \'https:\/\/apis.google.com\/js\/plusone.js\';            '
                                        +'          var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);   '
                                        +'      })();      '
                                        +'  </script>'

                                        +'      </div>'
                                        +'  </li>'
                                        +'  <li class="share-twitter"  style="margin-right: 0px !important; margin-bottom: 0px; padding-left:0; border-right:none;">'
                                        +'      <div id="custom-tweet-button" class="option">'
                                        +'          <a href="http://twitter.com/share" class="share-twitter sd-button twitter-share-button" data-url="'+mpURL+'" data-text="Vsako dejanje šteje; '+shareTitle+'" data-count="none" data-via="Microhint_com"><span>Twitter</span></a>'
                                        +'      </div>'
                                        +'  </li>'
                                        +'  <li class="share-email"  style="margin-right: 0px !important; margin-bottom: 0px; padding-left:0; border-right:none;">'
                                        +'      <div class="option">'
                                        +'          <a href="#" class="addthis_button_email share-email sd-button"><span>Email</span></a>'
                                        +'      </div>'
                                        +'  </li>'
                                        +'  <li class="share-more" style="margin-right: 0px !important; margin-bottom: 0px; padding-left:0; border-right:none; padding-right: 0;">'
                                        +'      <div class="option">'
                                        +'          <a href="#" class="addthis_button_compact share-more sd-button" style="height: 18px;"><span style="background-position: 1px 1px;">Več</span></a>'
                                        +'      </div>'
                                        +'  </li>'
                                        +'</ul>'

                    +'				</div>'
                    +'	      </div>'
                    +'	    </div>'
                    +'	  </div>'
                    +'	</div>'
                    +'<div class="clearfix"></div>'

                    +'<div class="rounded-bottom" style="background-color: #E9E9E9; font: 12px/1.5 Helvetica,Arial,Liberation Sans,FreeSans,sans-serif; color: #3A3B3D !important; line-height: 18px !important;">'
                    +'  <div class="left" style="width:270px; padding:10px 0 0 14px;">'
                    +'      <h2 style="font-weight:normal; margin:0 0 10px 0;">lokacija</h2>'
                    +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: none;padding: 0 0 0 2px;margin: 0 0 14px 0;">'
					+			redeemLocItems
					+'		</ul>'
                    +'  </div>'
                    +'  <div class="left" style="padding: 10px 14px 0 14px; width: 380px;">'
                    +'      <h2 style="font-weight:normal; margin:0 0 6px 0;">opombe</h2>'
                    +'      <p style="color: #676767; font-size: 12px;">'+higItems+'</p>'
                    +'  </div>'
                    +'  <div class="clearfix"></div>'
                    +'</div>';

                }catch(e){}


				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateNanoponMainCard02: function(data)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;

				var arguments = micropon.coupon_arguments.split('|');
				var argItems  = '';
				$(arguments).each(function(i, v){
					//argItems += '<li>odličen stand-up večer <strong>za samo 4,90 <span class="caps">EUR</span></strong></li>';
					argItems += '<li>'+v+'</li>';
				});

				var highlights = micropon.coupon_highlights.split('|');
				var higItems   = '';
				$(highlights).each(function(i, v){
					//argItems += '<li>odličen stand-up večer <strong>za samo 4,90 <span class="caps">EUR</span></strong></li>';
					higItems += '<li>'+v+'</li>';
				});

				// Store Locations	FIXME tole bi morale biti lokacije prevzema micropona
				var locations = store.store_locations.locations;
				var locItems  = '';
				var css       = 'display: block;';
                $(locations).each(function(i, v){
					locItems +=
						 '<span class="street_1" style="'+css+' font-weight:normal;">'+v.location.street+' '+v.location.street_number+'</span>'
						+'<span style="'+css+'">'+v.location.postal_name+', '+v.location.postal_code+'</span>'
						+'<span class="phone" style="'+css+' margin-bottom:4px;">Tel: '+v.location.storeLocation.phone+'</span>';
//						+'<p class="directions"><a href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo</a></p>';
				    css = 'display:none;';
                });

				// dodam še lokacije prevzrema ponudbe
				var redeemLocations = micropon.locations.locations;
				var redeemLocItems 	= '';
				$(redeemLocations).each(function(i, v){
					redeemLocItems +=
						 '<li style="padding: 0 0 0 28px; background: url(/public/images/map-pin.png) no-repeat 0 1px; font-size: 12px; width:180px; float:left;">'
						+'<span class="street_1">'+v.location.street+' '+v.location.street_number+'</span><br>'
						+''+v.location.postal_name+', '+v.location.postal_code+'<br>'
						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
						+'<p class="directions" style="margin-bottom:8px;"><a style="font-size: 12px;" href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo &raquo;</a></p>'
						+'</li>';
				});


				var showWebAdresses = false;
				var webpage = '';
				if(store.company_webpage != undefined && store.company_webpage != null && store.company_webpage != '')
				{
					webpage = '<a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal; margin-right:8px;">www &raquo;</a>';
					showWebAdresses = true;
				}

				var fb = '';
				if(store.company_facebook != undefined && store.company_facebook != null && store.company_facebook != '')
				{
					fb = '<a href="'+store.company_facebook+'" target="_blank" style="margin-right:8px;">facebook &raquo;</a>';
					showWebAdresses = true;
				}


				var xhtml_webadresses = '';
				if (showWebAdresses)
				{
					xhtml_webadresses = ''
						+'	  		<div class="meta" style="margin-top:10px;">'
						+'				<span class="street_1" style="font-size:12px;">Na spletu</span><br>'
						+'				'+ webpage +' '+ fb
						+'	  		</div>';
				}

				var xhtml =
					 '<div class="gutter location-narrow rounded">'
					//+'	<h2 class="marker" style="margin-bottom:10px; font-size:15px;">O podjetju</h2>'
					//+	store.store_description.truncateInline(300, 'xx-company')

                     +'<div style="width: 210px; margin: 4px 15px 0 0; float: left;">'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_pen.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Dobro je vedeti / opombe</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: disc;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			higItems
					 +'		</ul>'
                     +'</div>'
                     +'<div style="width: 210px; margin: 4px 0 0 0; float: right;">'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_star.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Argumenti za nakup</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: disc;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			argItems
					 +'		</ul>'
                     +'		<h2 style="padding: 0 0 0 18px; background: url(/public/images/icn_pen.png) no-repeat 0 1px;font-size: 14px;line-height: 16px;color: #F47F20;margin: 0 0 16px 0;font-weight: bold;">Ponudbo vnovči na:</h2>'
					 +'		<ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: none;padding: 0 0 0 22px;margin: 0 0 14px 0;">'
					 +			redeemLocItems
					 +'		</ul>'
                     +'</div>'

				    +'</div>'

					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:220px;">'
					+'	  <ul class="addresses" style="margin-top:6px;">'

					+'	    <li class="address order-0" data-marker-index="0" style="font-size:12px;">'
					+'	  		<div class="pin" style="position: absolute; top: 0; left: 0;">'
					+'	          <span style="background-position:0px -0px">&nbsp;</span>'
					+'	      	</div>'
					+'	  		<div class="meta" style="padding-right:10px;">'
					+'	    		<span class="street_1">'+store.company_name+'</span><br>'
//					+'	    		<p class="directions" style="margin-bottom: 0px; font-weight:normal;"><a target="_blank">info@standupkomedija.com</a></p>'
//					+'	    		<p class="directions"><a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal;">'+store.company_webpage+'</a></p>'
					+'	  		</div>'
					+			xhtml_webadresses
					+'	  		<div class="meta" style="margin-top:4px;">'
					+'				<span class="street_1" style="font-size:12px;">Naslov in kontakti</span><br>'
					+				locItems
					+'	  		</div>'
					+'		</li>'
					+'	  </ul>'
					+'	  <div id="google-map" class="google-map  full" style="float:left; margin-top:10px; padding-right: 10px; position: relative; background-color: rgb(229, 227, 223); overflow-x: hidden; overflow-y: hidden; width:200px; height:180px;"></div>'
					+'</div>'

					+'<div class="clearfix"></div>';

				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateNanoponMainCard03: function(mpID, districtSlug)
			{
				var content  = '';
				var micropon = '';
				var store    = '';

				$.get('search/district-micropons?count=100&district_slug='+ districtSlug +'&old=0', function(data, textStatus, XMLHttpRequest)
				{
					// Če imamo še kakšno ponudbo poleg trenutne
					if(data.micropons != undefined && data.micropons.length >= 1)
					{

						content	+'<ul>';

						$.each(data.micropons, function(i, v){

							//console.log(v);
							micropon = v.micropon;
							store    = micropon.store.stores[0].store;

							if(mpID != v.micropon.id)
							{
								content += ''
									+'<li class="nearby-deal">'
									+'	<div class="img">'
									+'  	<a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'"><img alt="36" src="http://a3.ak.lscdn.net/imgs/8460150b-1581-4c40-a056-5c0923afc1fa/36.png"></a>'
									+'	</div>'
									+'	<p><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+ micropon.headline +'</a></p>'
									+'	<p class="title"><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+store.company_name+'</a></p>'
									// +'	<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Los Angeles Families</a></p>'
									+'</li>	'
									;
							}

						});

						content	+'</ul>';


					}
					else { content = 'Trenutno ni dodatne ponudbe'; }

					$('#additional-offer').after(content);

				});


				var xhtml =
					'<div class="gutter location-narrow rounded" style="width:330px;">'
					+'	<h2 id="additional-offer" style="margin-bottom:10px; font-size:15px;">dodatna ponudba na okraju</h2>'
					+'</div>'
//
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:330px;">'
					+'	<h2 style="margin-bottom:10px; font-size:15px; display:relative;">Prispevaj v skuponost</h2>'

					+'	<ul>'
					+'		<li class="nearby-deal nearby-donator">'
					+'			<div class="img_">'
					+'  			<a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560"><img alt="36" src="/public/images/donator.jpg" width="200" height="112"></a>'
					+'				<span class="srce"></span>'
					+'				<a class="nearby-donator-nub">poglej <span style="font-size:13px;">&raquo;</span></a>'
					+'			</div>'
					+'			<p style="margin-top:2px;"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Invest in Kids</a></p>'
					//+'			<p class="title"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Childrens Clothing or Furniture</a></p>'
					+'			<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560" class="donator-quote">"When you\'re working with the community, you don\'t necessarily have the time or funds to stay on top of the latest research. We can do that legwork."</a></p>'
					+'		</li>	'
					+'	</ul>'



					+'</div>'

					+'<div class="clearfix"></div>'
					;

				return xhtml;
			},
			/**
			 * Zgenerira widget za stranske ponudbe oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateNanoponSideDeals01: function(data)
			{
				var sideDeals = data.micropons.slice(1, data.micropons.length);

				var sideDealsXhtml = '';
				if( sideDeals.length > 0 )
				{
					sideDealsXhtml +=
						'<div class="side-box" style="width:232px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px; -webkit-box-shadow: rgba(0, 0, 0, 0.796875) 0px 1px 3px; background-position: initial initial; background-repeat: initial initial; padding:0;">'
						+'	<h2 style="font-size:14px; padding:12px 10px 4px 10px;">Več ponudb iz okolice</h2>';

					$(sideDeals).each(function(i, v){
						sideDealsXhtml += '<p class="area_deal"><a href="/#!/micropon/'+v.micropon.store.stores[0].store.store_slug+'/'+v.micropon.slug+'" class="deal_click_event_tracking_classes title"><span>'+v.micropon.store.stores[0].store.store_locations.locations[0].location.city+'</span><br><span class="pirce_ico">'+v.micropon.headline+'</span></a></p>';
					});

					sideDealsXhtml +=
						'</div>';
				}
				return sideDealsXhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateDonatorMainCard01: function(data, uafNICK)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;

                // Nastavim cookie zadnje obiskane lokacije
                $.cookie('_mhdistrict', micropon.districtslug, {path:'/', domain: 'microhint.com', expires: 200});
				
				var district_slug = store.store_locations.locations[0].location.district_slug;
				
				// FIXME še 100x preveri, če je vse nastavljeno in NULLable vrednosti!!
				
				var uafURL = '';
				if( undefined != document.username)
				{
					uafURL = '/uaf/'+ document.username;	// User affiliate URL
				}
				
				// If I came from user free affiliate link ;)
				if( undefined != uafNICK && null != uafNICK && '' != uafNICK ) {
					uafNICK = '/uaf/'+ uafNICK;
				} else {
					uafNICK = '';	// User affiliate URL
				}
				
				
				var districtName = $('.select-city:visible').text();
				var mpURL 		 = 'http://'+document.location.host +'/#!/micropon/'+store.store_slug+'/'+ micropon.slug + uafURL;
				var coURL 		 = '/#!/donate/'+store.store_slug+'/'+ micropon.slug + uafNICK;
				var shareTitle   = micropon.headline +' ('+ districtName +')';
				var shareBody	 = decodeURIComponent(micropon.description);
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");
				// var shareBody	 = decodeURIComponent(micropon.description);
				
				var picURL		 = '/tmp/mppics/'+ micropon.pic_name;
				
				var picStripe		= '';								// obvestilo čez sliko
				var css_priceColor 	= 'color:#F99431;';		// Barva cene (oranžna aktive, siv neaktiven)
				var buyButton	   	= '<a href="'+coURL+'" class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px;"><span>Doniraj 1€ / Microtočke</span></a>';
				var giftBuy		  	= '<a href="'+coURL+'" class="send-as-a-gift" style="margin-left: 0px;">Kupi kot darilo</a>';
				
				/*
				 * PREVERIM ALI GRE ZA PREVIEW ALI KAJ DRUGEGA
				 * */
				if(micropon.workflow_status == 'review' || micropon.workflow_status == 'new' || micropon.workflow_status == 'draft' || micropon.workflow_status == 'accepted') {
					// Review state
					picStripe 		= '<div class="deal-review-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px; color:#CCC; background: #fff; border: 1px solid #BEBEBE;"><span>Doniranje še ni možno</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				else if(micropon.workflow_status != 'running') {
					// Pretekla ponudba state
					picStripe 		= '<div class="deal-over-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px; color:#CCC; background: #fff; border: 1px solid #BEBEBE;"><span>Doniranje ni več možno</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				
				var shareEarning = MHT.math.toPrecision( parseFloat((micropon.max_discount_min_price*10)/100) );
				
				var offerPrice	 = MHT.math.toPrecision( parseFloat( micropon.max_discount_min_price ) );
				
				var priceArray	 = offerPrice.split('.',2);
				
//				console.log( priceArray );
				
				var smallerFont	= 'font-size:60px;';
				var priceWhole	= priceArray[0];
				var priceRest	= ','+ priceArray[1];
				
				if(priceRest == ',00') {
					priceRest	= '';
				}
				
				if(priceWhole >= 100 && priceRest == '') {
					smallerFont	= 'font-size:6px;';
				}
				else if(priceWhole >= 10 && priceRest != '') {
					 smallerFont	= 'font-size:43px;';
				}
				else if(priceWhole >= 10 && priceRest == '') {
					smallerFont	= 'font-size:56px;';
				}
				
				/* Preverim ali je podjetje DDV zavezanec */
				var ddv = '';
				if( store.id_za_ddv != '' && store.id_za_ddv != null && store.id_za_ddv != undefined ) {
					ddv = '*DDV je vključen v ceno';
				}
				
				
				
				//## **************
				
				var styleOne   = '';
				var styleTwo   = '';
				var styleThree = '';
				
				var prevGoal	 = parseFloat( 0 );
				var nextGoal 	 = parseFloat( 0 );
				var virtualTotal = parseFloat( 0 );
				var pristejemo	 = parseFloat( 0 );
				
				var tippingPointOne   = parseFloat( micropon.tipping_point_one   );
				var tippingPointTwo   = parseFloat( micropon.tipping_point_two   );
				var tippingPointThree = parseFloat( micropon.tipping_point_three );
				var paidTotal		  = parseFloat( micropon.paid_total 		 );
				
				
				var tippingPointOneGiveaway   = parseFloat( micropon.tipping_point_one_giveaway   );
				var tippingPointTwoGiveaway   = parseFloat( micropon.tipping_point_two_giveaway   );
				var tippingPointThreeGiveaway = parseFloat( micropon.tipping_point_three_giveaway );

                var tipText     = '';
                var barPercent  = 0;
                var cssRightTip = '';
				
				if (tippingPointOne > 0  && tippingPointOne > micropon.paid_total ) {
					nextGoal     = tippingPointOne - paidTotal ;
					virtualTotal = tippingPointOne;
					// prvi zelen
					styleOne     = 'color:#fff;';
					// drugi siv
					styleTwo     = 'color:#7c7c7c;';
					// tretji siv
					styleThree   = 'color:#7c7c7c;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
                    cssRightTip  = '';
				}
				else if (tippingPointTwo > tippingPointOne  && tippingPointTwo > paidTotal ) {
					prevGoal   = tippingPointOne;
					nextGoal   = tippingPointTwo - paidTotal ;
					//virtualTotal = tippingPointTwo + nextGoal;
					virtualTotal = tippingPointTwo;
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi zelen
					styleTwo   = 'color:#fff;';
					// tretji siv
					styleThree = 'color:#7c7c7c;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
				}
				else if (tippingPointThree > tippingPointTwo  && tippingPointThree > paidTotal ) {
					prevGoal   = tippingPointTwo;
					nextGoal   = tippingPointThree - paidTotal ;
					//virtualTotal = tippingPointThree + nextGoal;
					virtualTotal = tippingPointThree;
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi prečrtan
					styleTwo   = 'color:#b6ec46;';
					// tretji zelen
					styleThree = 'color:#fff;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
				}
				else {

					prevGoal = tippingPointThree;
                    virtualTotal = new Number(500);
					// surpassed all tipping points
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi prečrtan
					styleTwo   = 'color:#b6ec46;';
					// tretji prečrtan
					styleThree = 'color:#b6ec46;';
                    tipText      = 's partnerji smo prispevali '+Globalize.format((tippingPointOneGiveaway+tippingPointTwoGiveaway+tippingPointThreeGiveaway), 'n2')+'€ &raquo';
                    barPercent   = parseInt(85);
                    cssRightTip  = 'display: none;';
				}

                var multimedia = '';
                var firstHack     = false;
                var firstImage    = '';
                var galleryID     = 'gallery1';
                var galleryXhtml  = '';
                if( micropon.multimedia != undefined ) {

                    multimedia      += '<ul style="position: absolute; right: 0px; top: 46px;">';

                    $.each(micropon.multimedia, function(i, v){
                        if(v.uploader == '2'){
                            if(firstHack == true) {
                                multimedia      += '<li style=" line-height: 8px; padding: 0; margin: 3px 5px 0 0; list-style: none;"><a class="rounded" href="/tmp/mppics/'+v.file_name+'" rel="lightBox" data-item-gid="'+galleryID+'" style="display:block; text-decoration: none; border: solid 1px #3D3E3F;"><img class="rounded" src="/tmp/mppics/'+v.file_name+'" height="30" width="30"></a></li>';
                            }
                            else {
                                firstImage  = '/tmp/mppics/'+v.file_name;
                                firstHack   = true;
                            }
                        }
                    });

                    multimedia += '</ul>';
                }

				var xhtml =
//					'  <div id="market-sub" style="border-bottom_: 5px solid #5093B0; position: relative; background-color: #262626; font-family: arial rounded mt bold, helvetica, arial, sans-serif; font-weight:normal; -webkit-border-radius: 4px 4px 0 0; -moz-border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;">'
//                    +'      <h1 style="color: white; text-transform: lowercase; padding: 10px 20px 10px; font-size: 16px; margin: 0px; font-weight:normal; line-height: 24px; letter-spacing: normal; padding-left: 40px; background: url(/public/images/vertical_sprite_16px.png) no-repeat 8px 6px;">Dnevna Ponudba</h1>'
//                    +'      <a href="#" class="button newsletter-desc-tip" style="position:absolute; right:10px; top:10px;">obveščaj me<span class="mail icon" style="margin:auto auto auto 7px; background-position: 0 -499px;"></span></a>'
//                    +'      <div class="tip-content" style="display:none; z-index:99999; background:#fff; position:absolute; top:60px; right:10px;">'
//                    +'          '+ MHT.forms.newsletterSubscribtionSmallWidget()
//                    +'      </div>'
//                    +'</div>'

                     '<div id="market-sub" class="heading-title rounded-top">'
                    +'  <h1 style="color: #bdda9b; text-transform: lowercase; padding: 8px 20px 10px; font-size: 23px; margin: 0px; font-weight:normal; line-height: 26px; letter-spacing: normal; padding-left: 40px; background: url(/public/images/vertical_sprite_green_16px.png) no-repeat 8px -60px;"><span class="logo-font">Micronator</span> <span class="rounded" style="color:white; font-size: 16px; padding: 2px 6px 2px 6px; position: absolute; right: 110px; background:rgba(0, 0, 0, 0.25);">postani <span class="no_paid">__</span>. donator</span></h1>'
                    +   MHT.buttons.newsletterSub.init()
                    +'</div>'

                    +'<div class="image rounded-bottom" style="background: url('+firstImage+') no-repeat;">'
					+'	<div class="feature rounded">'
					+'		<h2>'+ micropon.headline +'</h2>'
					// +'		<a href="#" class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px;"><span>Doniraj 1€ / Microtočke</span></a>'
					+		buyButton
					+'		<h3>Vsako dejanje šteje.</h3>'
					+'	</div>'

					+'	<div class="philanthropy-summary rounded-bottom">'
					+'		<div class="philanthropy-title">'
					// +'			Andean Health '
					+'				<div class="timeTracker floatLeft timeTrackerBig" style="width: 280px; margin-bottom: 0px;">'
				    +' 					<div class="timeCounter" style="margin-top:0; margin-bottom:0;">'
				    // +' 						<span class="floatRight">max: '+micropon.max_quantity+'</span>'
				    +' 						<span class="floatRight" style="'+cssRightTip+'">'+Globalize.format((nextGoal+paidTotal), 'n2')+'€</span>'
				    +' 						<span class="floatLeft">'+Globalize.format(paidTotal, 'n2')+'€</span>'
//				    +'     					<span class="percent">'+paidTotal+'€</span>'
				    +'    					<div class="timeCounterRight" style="width:100%">'
				    +'    						<div class="timeCounterLeft" style="width:'+barPercent+'%"></div>'
				    +'							<div style="font-size:10px; position: absolute; top:-24px; right:0px;"><strong style="'+styleOne+'">+'+Globalize.format(tippingPointOneGiveaway,'n0')+'€</strong> <strong style="'+styleTwo+'">+'+Globalize.format(tippingPointTwoGiveaway,'n0')+'€</strong> <strong style="'+styleThree+'">+'+Globalize.format(tippingPointThreeGiveaway,'n0')+'€</strong></div><div class="progTooltip" style="border-radius: 4px; font-size:10px; line-height:16px; text-transform: normal; padding:0px 4px; padding-top:2px; color:#4b4243; font-weight:normal; position: absolute; top:-24px;left:-2px; font-family: Arial, sans-serif; padding: 1px 4px 1px 4px;">'+tipText+'<div class="arrTool" style="left: 150px;"></div></div>'		    +'    					</div>'		    +'					</div>'
				    +'				</div>'
					// +'				<div style="font-size:10px;"><strong>+50</strong> <strong>+100</strong> <strong>+200</strong></div>'
					+'		</div>'
					+'		<div class="donations-today">'
					+'			<h4>Skupaj zbrano</h4>'
					+'			<div class="value" data-id="153" id="donations_today">€ '+ Globalize.format( paidTotal, 'n2' )+'</div>'
					+'		</div>'
					+'		<div class="time-left">'
					+'			<h4>Izteče se čez</h4>'
					+'			<div class="value" id="countdown">'
					+'  			<span class="num">--</span>'
				    +'  			<span class="colon">:</span>'
				    +'   			<span class="num">--</span>'
				    +'  			<span class="colon">:</span>'
				    +'  			<span class="num">--</span>'
					+'			</div>'
					+'		</div>'
					+'	</div>'

					+'</div>'
                    + multimedia

				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateDonatorMainCard02: function(data)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;

                var _FB_picture = '';
                if( micropon.multimedia != undefined ) {

                    $.each(micropon.multimedia, function(i, v){
                        if(v.uploader == '2'){
                            _FB_picture = '/tmp/mppics/'+v.file_name;
                        }
                    });

                }

				// Store Locations	FIXME tole bi morale biti lokacije prevzema micropona
				var locations = store.store_locations.locations;
				var locItems  = '';
				$(locations).each(function(i, v){
					locItems += 
						 '<span class="street_1" style="font-weight:normal;">'+v.location.street+' '+v.location.street_number+'</span><br>'
						+''+v.location.postal_name+', '+v.location.postal_code+'<br>'
						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
						+'<p class="directions" style="margin-bottom: 6px;"><a href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal; font-size:11px;">Pripelji me na lokacijo</a></p>';
				});
				
				var showWebAdresses = false;
				var webpage = '';
				if(store.company_webpage != undefined && store.company_webpage != null && store.company_webpage != '')
				{
					webpage = '<a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal; margin-right:8px;">www &raquo;</a>';
					showWebAdresses = true;
				}

				var fb = '';
				if(store.company_facebook != undefined && store.company_facebook != null && store.company_facebook != '')
				{
					fb = '<a href="'+store.company_facebook+'" target="_blank" style="margin-right:8px;">facebook &raquo;</a>';
					showWebAdresses = true;
				}
				
				
				var xhtml_webadresses = '';
				if (showWebAdresses)
				{
					xhtml_webadresses = ''
						+'	  		<div class="meta" style="margin-top:10px;">'
						+'				<span class="street_1" style="font-size:12px;">Na spletu</span><br>'
						+'				'+ webpage +' '+ fb
						+'	  		</div>';
				}

				var districtName = micropon.district_name;
				var mpURL 		 = 'http://'+document.location.host +'/#!/micronator/'+store.store_slug+'/'+ micropon.slug;
				var coURL 		 = '/#!/micronator/'+store.store_slug+'/'+ micropon.slug;
				var shareTitle   = micropon.headline;
				var shareBody	 = decodeURIComponent(micropon.description);
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");
                var caption      = store.company_name +' @'+ districtName;

				var xhtml =
					 '<div class="gutter location-narrow rounded">'
//					 +'	<div class="social_share">'
//					 +'	<ul class="clearfix">'
//				    +'   	<li class="first">'
//				    +'    		<a title="Share with Facebook" style="" class="social-share-fb fb share-on-fb" href="'+mpURL+'" data-item-status="'+strippedBody+'" data-item-title="'+shareTitle+'">Všeč mi je</a>'
//				    +'    	</li>'
//				    +'    	<li>'
//				    +'			<a href="http://twitter.com/share" style="" class="twitter-share-button" data-url="'+mpURL+'" data-text="Ne zamudi odlične ponudbe: '+shareTitle+'" data-count="none" data-via="Microhint_com">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>'
//				    +'  	</li>'
//				    +'  	<li>'
//				    +'    		<a style="width:60px;" title="Share by Email" class="social-share-email" href="//www.addthis.com/bookmark.php?pub=alanristic&amp;v=250&amp;source=tbx-250&amp;tt=0&amp;s=email&amp;url='+encodeURIComponent(mpURL)+'&amp;title='+shareTitle+'&amp;content=&amp;lng=en" target="_blank">Pošlji email</a>'
//				    +'  	</li>'
//				    +'  	<li class="last">'
//				    +' 			<div class="addthis_toolbox addthis_default_style"  addthis:url="'+encodeURIComponent(mpURL)+'" addthis:title="'+encodeURIComponent(shareTitle)+'" addthis:description="'+decodeURIComponent('bla')+'">'
//				    +'				<a class="addthis_button_compact" style="font-size:11px; font-weight: normal; padding-top:4px;">Deli drugam</a>'
//				    +'			</div>'
//				    +'  	</li>'
//				    +'  </ul>'
//				    +'  </div>'
//				     +'	<div class="clearfix"></div>'

                    //+'	<h2 class="marker" style="margin-top:8px; margin-bottom:10px; font-size:15px;">Zgodba organizacije in poslanstvo</h2>'

					+'	<p class="start-quote tk-adelle">'+micropon.pitch_statement +'</p>'
					+'	<p>'+decodeURIComponent(micropon.description) +'</p>'
				    +'</div>'	
					
					+'<div style="float:right; padding: 5px 0 18px 18px; width:220px;">'


                    +'<ul class="services addthis_toolbox" addthis:url="'+mpURL+'" addthis:description="superkul" addthis:title="'+shareTitle+'" style="margin-top:10px;">'
                    +'  <li class="logo-font" style="float: none; font-size: 14px;">Skupaj dosežemo več za...</li>'
                    +'  <li class="share-facebook" style="margin-right: 55px !important;">'
                    +'      <div class="option">'
                    +'          <a class="share-facebook sd-button social-share-fb fb share-on-fb" href="'+mpURL+'" data-item-status="'+strippedBody+'" data-item-title="'+shareTitle+'" data-item-pic="'+_FB_picture+'" data-item-caption="'+caption+'"><span>Facebook</span></a>'
                    +'      </div>'
                    +'  </li>'
                    +'  <li class="share-googleplus_" style="margin-right: 55px !important;">'
                    +'      <div id="googleplus" class="option">'
//                    +'          <a href="#" class="addthis_button_google_plusone share-googleplus sd-button"><span>Google</span></a>'

                    +' <a class="share-googleplus sd-button" style="padding-top: 1px; padding-left: 1px;"><g:plusone size="small" annotation="none"></g:plusone><span style="display: inline;padding-left: 2px; line-height: 18px; float: right; padding-top: 0; margin-top: -1px;">Google</span></a>'
                    +'  <script type="text/javascript">'
                    +'      window.___gcfg = {lang: \'sl\'};'
                    +'      (function() {                    '
                    +'          var po = document.createElement(\'script\'); po.type = \'text\/javascript\'; po.async = true;  '
                    +'          po.src = \'https:\/\/apis.google.com\/js\/plusone.js\';            '
                    +'          var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);   '
                    +'      })();      '
                    +'  </script>'

                    +'      </div>'
                    +'  </li>'
                    +'  <li class="share-twitter"  style="margin-right: 55px !important;">'
                    +'      <div id="custom-tweet-button" class="option">'
                    +'          <a href="http://twitter.com/share" class="share-twitter sd-button twitter-share-button" data-url="'+mpURL+'" data-text="Vsako dejanje šteje; '+shareTitle+'" data-count="none" data-via="Microhint_com"><span>Twitter</span></a>'
                    +'      </div>'
                    +'  </li>'
                    +'  <li class="share-email"  style="margin-right: 135px !important;">'
                    +'      <div class="option">'
                    +'          <a href="#" class="addthis_button_email share-email sd-button"><span>Email</span></a>'
                    +'      </div>'
                    +'  </li>'
                    +'  <li class="share-more" style="margin-right: 5px !important;">'
                    +'      <div class="option">'
                    +'          <a href="#" class="addthis_button_compact share-more sd-button" style="height: 18px;"><span style="background-position: 1px 1px;">Več</span></a>'
                    +'      </div>'
                    +'  </li>'
                    +'  <li class="logo-font" style="float:right; line-height: 28px; padding-right: 16px; text-align:right; font-size: 14px; position:relative;">...'+MHT.widgets.badge.badgeDATA[micropon.badge_id].name+'<span class="badge" style="background: url('+MHT.widgets.badge.badgeDATA[micropon.badge_id].imgURL+') no-repeat 0 0;"></span></li>'
                    +'</ul>'
                    +'<div class="clearfix"></div>'

                    +'	  <ul class="addresses" style="margin-top:6px;">'
						    
					+'	    <li class="address order-0" data-marker-index="0" style="font-size:12px;">'
//					+'	  		<div class="pin" style="position: absolute; top: 0; left: 0;">'
//					+'	          <span style="background-position:0px -0px">&nbsp;</span>'
//					+'	      	</div>'
					+'	  		<div class="meta" style="padding-right:10px;">'
					+'	    		<span class="street_1">'+store.company_name+'</span><br>'
//					+'	    		<p class="directions" style="margin-bottom: 0px; font-weight:normal;"><a target="_blank">info@standupkomedija.com</a></p>'
//					+'	    		<p class="directions"><a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal;">'+store.company_webpage+'</a></p>'
					+'	  		</div>'
					+			xhtml_webadresses
					+'	  		<div class="meta" style="margin-top:4px; font-size:11px; font-family:Arial, sans-serif;"">'
					+'				<span class="street_1" style="font-size:12px;">Naslov in kontakti</span><br>'
					+				locItems
					+'	  		</div>'
					+'		</li>'
					+'	  </ul>'
					+'	  <div id="google-map" class="google-map  full" style="float:left; margin-top:0px; padding-right: 0px; position: relative; background-color: rgb(229, 227, 223); overflow-x: hidden; overflow-y: hidden; width:200px; height:180px;"></div>'

                    +'<div class="clearfix"></div>'

                    +'</div>'

                    +'<script charset="utf-8" src="//platform.twitter.com/widgets.js" type="text/javascript"></script>'
					
					+'<div class="clearfix"></div>';
				
				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateDonatorMainCard03: function(mpID, districtSlug)
			{
				var content  = '';
				var micropon = '';
				var store    = '';
				
				$.get('search/district-micropons?count=100&district_slug='+ districtSlug +'&old=0', function(data, textStatus, XMLHttpRequest)
				{
					// Če imamo še kakšno ponudbo poleg trenutne
					if(data.micropons!= undefined && data.micropons.length >= 1)
					{
						
						content	+'<ul>';
					
						$.each(data.micropons, function(i, v){
							
							micropon = v.micropon;
							store    = micropon.store.stores[0].store; 
							
							if(mpID != v.micropon.id)
							{
								content += ''
									+'<li class="nearby-deal">'
									+'	<div class="img">'
									+'  	<a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'"><img alt="36" src="http://a3.ak.lscdn.net/imgs/8460150b-1581-4c40-a056-5c0923afc1fa/36.png"></a>'
									+'	</div>'
									+'	<p><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+ micropon.headline +'</a></p>'
									+'	<p class="title"><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+store.company_name+'</a></p>'
									// +'	<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Los Angeles Families</a></p>'
									+'</li>	'
									;
							}
							
						});
					
						content	+'</ul>';
						
						
					}
					else { content = 'Trenutno ni dodatne ponudbe'; }
					
					$('#additional-offer').after(content);
					
				});

				var xhtml =
					'<div class="gutter location-narrow" style="width:330px;">'	
					+'	<h2 id="additional-offer" style="margin-bottom:10px; font-size:15px;">dodatna ponudba na okraju</h2>'
					+'</div>'
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:330px;">'
					+'	<h2 style="margin-bottom:10px; font-size:15px; display:relative;">Prispevaj v skuponost</h2>'
					+'	<ul>'
					+'		<li class="nearby-deal nearby-donator">'
					+'			<div class="img_">'
					+'  			<a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560"><img alt="36" src="/public/images/donator.jpg" width="200" height="112"></a>'
					+'				<span class="srce"></span>'
					+'				<a class="nearby-donator-nub">poglej <span style="font-size:13px;">&raquo;</span></a>'
					+'			</div>'
					+'			<p style="margin-top:2px;"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Invest in Kids</a></p>'
					+'			<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560" class="donator-quote">"When you\'re working with the community, you don\'t necessarily have the time or funds to stay on top of the latest research. We can do that legwork."</a></p>'
					+'		</li>	'
					+'	</ul>'
					+'</div>'
					+'<div class="clearfix"></div>'
					;
				
				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateEscapeMainCard01: function(data, uafNICK)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;

                // Nastavim cookie zadnje obiskane lokacije
                $.cookie('_mhdistrict', micropon.districtslug, {path:'/', domain: 'microhint.com', expires: 200});

				var district_slug = store.store_locations.locations[0].location.district_slug;

				// FIXME še 100x preveri, če je vse nastavljeno in NULLable vrednosti!!

				var uafURL = '';
				if( undefined != document.username)
				{
					uafURL = '/uaf/'+ document.username;	// User affiliate URL
				}

				// If I came from user free affiliate link ;)
				if( undefined != uafNICK && null != uafNICK && '' != uafNICK ) {
					uafNICK = '/uaf/'+ uafNICK;
				} else {
					uafNICK = '';	// User affiliate URL
				}


				var districtName = $('.select-city:visible').text();
				var mpURL 		 = 'http://'+document.location.host +'/#!/micropon/'+store.store_slug+'/'+ micropon.slug + uafURL;
				var coURL 		 = '/#!/donate/'+store.store_slug+'/'+ micropon.slug + uafNICK;
				var shareTitle   = micropon.headline +' ('+ districtName +')';
				var shareBody	 = decodeURIComponent(micropon.description);
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");
				// var shareBody	 = decodeURIComponent(micropon.description);

				var picURL		 = '/tmp/mppics/'+ micropon.pic_name;

				var picStripe		= '';								// obvestilo čez sliko
				var css_priceColor 	= 'color:#F99431;';		// Barva cene (oranžna aktive, siv neaktiven)
				var buyButton	   	= '<a href="'+coURL+'" class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px;"><span>Doniraj 1€ / Microtočke</span></a>';
				var giftBuy		  	= '<a href="'+coURL+'" class="send-as-a-gift" style="margin-left: 0px;">Kupi kot darilo</a>';

				/*
				 * PREVERIM ALI GRE ZA PREVIEW ALI KAJ DRUGEGA
				 * */
				if(micropon.workflow_status == 'review' || micropon.workflow_status == 'new' || micropon.workflow_status == 'draft' || micropon.workflow_status == 'accepted') {
					// Review state
					picStripe 		= '<div class="deal-review-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px; color:#CCC; background: #fff; border: 1px solid #BEBEBE;"><span>Doniranje še ni možno</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}
				else if(micropon.workflow_status != 'running') {
					// Pretekla ponudba state
					picStripe 		= '<div class="deal-over-en">&nbsp;</div>';
					css_priceColor 	= 'color:#97989A;';
					buyButton		= '<a class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px; color:#CCC; background: #fff; border: 1px solid #BEBEBE;"><span>Doniranje ni več možno</span></a>';
					giftBuy		   	= '<a class="send-as-a-gift" style="margin-left: 0px; color:#97989A;">Kupi kot darilo</a>';
				}

				var shareEarning = MHT.math.toPrecision( parseFloat((micropon.max_discount_min_price*10)/100) );

				var offerPrice	 = MHT.math.toPrecision( parseFloat( micropon.max_discount_min_price ) );

				var priceArray	 = offerPrice.split('.',2);

//				console.log( priceArray );

				var smallerFont	= 'font-size:60px;';
				var priceWhole	= priceArray[0];
				var priceRest	= ','+ priceArray[1];

				if(priceRest == ',00') {
					priceRest	= '';
				}

				if(priceWhole >= 100 && priceRest == '') {
					smallerFont	= 'font-size:6px;';
				}
				else if(priceWhole >= 10 && priceRest != '') {
					 smallerFont	= 'font-size:43px;';
				}
				else if(priceWhole >= 10 && priceRest == '') {
					smallerFont	= 'font-size:56px;';
				}

				/* Preverim ali je podjetje DDV zavezanec */
				var ddv = '';
				if( store.id_za_ddv != '' && store.id_za_ddv != null && store.id_za_ddv != undefined ) {
					ddv = '*DDV je vključen v ceno';
				}



				//## **************

				var styleOne   = '';
				var styleTwo   = '';
				var styleThree = '';

				var prevGoal	 = parseFloat( 0 );
				var nextGoal 	 = parseFloat( 0 );
				var virtualTotal = parseFloat( 0 );
				var pristejemo	 = parseFloat( 0 );

				var tippingPointOne   = parseFloat( micropon.tipping_point_one   );
				var tippingPointTwo   = parseFloat( micropon.tipping_point_two   );
				var tippingPointThree = parseFloat( micropon.tipping_point_three );
				var paidTotal		  = parseFloat( micropon.paid_total 		 );


				var tippingPointOneGiveaway   = parseFloat( micropon.tipping_point_one_giveaway   );
				var tippingPointTwoGiveaway   = parseFloat( micropon.tipping_point_two_giveaway   );
				var tippingPointThreeGiveaway = parseFloat( micropon.tipping_point_three_giveaway );

                var tipText     = '';
                var barPercent  = 0;
                var cssRightTip = '';

				if (tippingPointOne > 0  && tippingPointOne > micropon.paid_total ) {
					nextGoal     = tippingPointOne - paidTotal ;
					virtualTotal = tippingPointOne;
					// prvi zelen
					styleOne     = 'color:#fff;';
					// drugi siv
					styleTwo     = 'color:#7c7c7c;';
					// tretji siv
					styleThree   = 'color:#7c7c7c;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
                    cssRightTip  = '';
				}
				else if (tippingPointTwo > tippingPointOne  && tippingPointTwo > paidTotal ) {
					prevGoal   = tippingPointOne;
					nextGoal   = tippingPointTwo - paidTotal ;
					//virtualTotal = tippingPointTwo + nextGoal;
					virtualTotal = tippingPointTwo;
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi zelen
					styleTwo   = 'color:#fff;';
					// tretji siv
					styleThree = 'color:#7c7c7c;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
				}
				else if (tippingPointThree > tippingPointTwo  && tippingPointThree > paidTotal ) {
					prevGoal   = tippingPointTwo;
					nextGoal   = tippingPointThree - paidTotal ;
					//virtualTotal = tippingPointThree + nextGoal;
					virtualTotal = tippingPointThree;
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi prečrtan
					styleTwo   = 'color:#b6ec46;';
					// tretji zelen
					styleThree = 'color:#fff;';
                    tipText      = 'še '+Globalize.format(nextGoal, 'n2')+'€ in povišamo donacijo za &raquo';
                    barPercent   = parseInt((paidTotal*100) /virtualTotal);
				}
				else {

					prevGoal = tippingPointThree;
                    virtualTotal = new Number(500);
					// surpassed all tipping points
					// prvi prečrtan
					styleOne   = 'color:#b6ec46;';
					// drugi prečrtan
					styleTwo   = 'color:#b6ec46;';
					// tretji prečrtan
					styleThree = 'color:#b6ec46;';
                    tipText      = 's partnerji smo prispevali '+Globalize.format((tippingPointOneGiveaway+tippingPointTwoGiveaway+tippingPointThreeGiveaway), 'n2')+'€ &raquo';
                    barPercent   = parseInt(85);
                    cssRightTip  = 'display: none;';
				}

                var multimedia = '';
                var firstHack     = false;
                var firstImage    = '';
                var galleryID     = 'gallery1';
                var galleryXhtml  = '';
                if( micropon.multimedia != undefined ) {

                    multimedia      += '<ul style="position: absolute; right: 0px; top: 0;">';

                    $.each(micropon.multimedia, function(i, v){
                        if(v.uploader == '2'){
                            if(firstHack == true) {
                                multimedia      += '<li style=" line-height: 8px; padding: 0; margin: 3px 5px 0 0; list-style: none;"><a href="/tmp/mppics/'+v.file_name+'" rel="lightBox" data-item-gid="'+galleryID+'" style="display:block; text-decoration: none; border: solid 2px #fff;  -webkit-box-shadow: rgba(0, 0, 0, 0.796875) 0px 1px 3px; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"><img src="/tmp/mppics/'+v.file_name+'" height="30" width="30" style="border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;"></a></li>';
                            }
                            else {
                                firstImage  = '/tmp/mppics/'+v.file_name;
                                firstHack   = true;
                            }
                        }
                    });

                    multimedia += '</ul>';
                }

				var xhtml =
					'  <div id="market-sub" style="border-bottom_: 5px solid #5093B0; position: relative; background-color: #262626; font-family: arial rounded mt bold, helvetica, arial, sans-serif; font-weight:normal; -webkit-border-radius: 4px 4px 0 0; -moz-border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;">'
                    +'      <h1 style="color: white; text-transform: lowercase; padding: 10px 20px 10px; font-size: 16px; margin: 0px; font-weight:normal; line-height: 24px; letter-spacing: normal; padding-left: 40px; background: url(/public/images/vertical_sprite_16px.png) no-repeat 8px 6px;">Dnevna Ponudba</h1>'
                    +'      <a href="#" class="button newsletter-desc-tip" style="position:absolute; right:10px; top:10px;">obveščaj me<span class="mail icon" style="margin:auto auto auto 7px; background-position: 0 -499px;"></span></a>'
                    +'      <div class="tip-content" style="display:none; z-index:99999; background:#fff; position:absolute; top:60px; right:10px;">'
                    +'          '+ MHT.forms.newsletterSubscribtionSmallWidget()
                    +'      </div>'
                    +'  </div>'
                    +'<div class="image" style="background: url('+firstImage+') no-repeat; height: 310px;">'
//					+'	<div class="feature">'
//					+'		<h2>'+ micropon.headline +'</h2>'
//					// +'		<a href="#" class="gumb rounded buy-now" style="width:250px; font-size:24px; -webkit-border-radius:6px; border-radius:6px; -moz-border-radius: 6px;"><span>Doniraj 1€ / Microtočke</span></a>'
//					+		buyButton
//					+'		<h3>Vsako dejanje šteje.</h3>'
//					+'	</div>'

					+'	<div class="philanthropy-summary" style="height: auto;">'
//					+'		<div class="philanthropy-title">'
//					// +'			Andean Health '
//					+'				<div class="timeTracker floatLeft timeTrackerBig" style="width: 280px; margin-bottom: 0px;">'
//				    +' 					<div class="timeCounter" style="margin-top:0; margin-bottom:0;">'
//				    // +' 						<span class="floatRight">max: '+micropon.max_quantity+'</span>'
//				    +' 						<span class="floatRight" style="'+cssRightTip+'">'+Globalize.format((nextGoal+paidTotal), 'n2')+'€</span>'
//				    +' 						<span class="floatLeft">'+Globalize.format(paidTotal, 'n2')+'€</span>'
////				    +'     					<span class="percent">'+paidTotal+'€</span>'
//				    +'    					<div class="timeCounterRight" style="width:100%">'
//				    +'    						<div class="timeCounterLeft" style="width:'+barPercent+'%"></div>'
//				    +'							<div style="font-size:10px; position: absolute; top:-24px; right:0px;"><strong style="'+styleOne+'">+'+Globalize.format(tippingPointOneGiveaway,'n0')+'€</strong> <strong style="'+styleTwo+'">+'+Globalize.format(tippingPointTwoGiveaway,'n0')+'€</strong> <strong style="'+styleThree+'">+'+Globalize.format(tippingPointThreeGiveaway,'n0')+'€</strong></div><div class="progTooltip" style="border-radius: 4px; font-size:10px; line-height:16px; text-transform: normal; padding:0px 4px; padding-top:2px; color:#4b4243; font-weight:bold; position: absolute; top:-24px;left:-2px;">'+tipText+'<div class="arrTool" style="left: 150px;"></div></div>'		    +'    					</div>'		    +'					</div>'
//				    +'				</div>'
//					// +'				<div style="font-size:10px;"><strong>+50</strong> <strong>+100</strong> <strong>+200</strong></div>'
//					+'		</div>'
//					+'		<div class="donations-today">'
//					+'			<h4>Skupaj zbrano</h4>'
//					+'			<div class="value" data-id="153" id="donations_today">€ '+ Globalize.format( paidTotal, 'n2' )+'</div>'
//					+'		</div>'
//					+'		<div class="time-left">'
//					+'			<h4>Izteče se čez</h4>'
//					+'			<div class="value" id="countdown">'
//					+'  			<span class="num">--</span>'
//				    +'  			<span class="colon">:</span>'
//				    +'   			<span class="num">--</span>'
//				    +'  			<span class="colon">:</span>'
//				    +'  			<span class="num">--</span>'
//					+'			</div>'
//					+'		</div>'

                    +'      <div id="escapes-wrapper" class="omega">'
                    +'          <div id="escapes-title" class="deal-title" style="text-align:left; margin-left:14px;">'
                    +'              <h1 style="color: white !important; font-weight: normal; font-family: helvetica; font-size: 27px !important; padding: 10px 5px 0 5px !important; margin: 0 !important; line-height: normal; letter-spacing: normal;">History and Half-Smokes in the District</h1>'
                    +'              <p style="color: #808285; padding: 0px 6px; margin:0;">Hilton Garden Inn DC/Bethesda • Bethesda, MD</p>'
                    +'          </div>'
                    +'      </div>'

                    +'	</div>'

					+'</div>'
                    + multimedia

				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateEscapeMainCard02: function(data)
			{
				var micropon = data.micropons[0].micropon;
				var store = micropon.store.stores[0].store;

				// Store Locations	FIXME tole bi morale biti lokacije prevzema micropona
				var locations = store.store_locations.locations;
				var locItems  = '';
				$(locations).each(function(i, v){
					locItems +=
						 '<span class="street_1" style="font-weight:normal;">'+v.location.street+' '+v.location.street_number+'</span><br>'
						+''+v.location.postal_name+', '+v.location.postal_code+'<br>'
						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
						+'<p class="directions" style="margin-bottom: 6px;"><a href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal; font-size:11px;">Pripelji me na lokacijo</a></p>';
				});

				var showWebAdresses = false;
				var webpage = '';
				if(store.company_webpage != undefined && store.company_webpage != null && store.company_webpage != '')
				{
					webpage = '<a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal; margin-right:8px;">www &raquo;</a>';
					showWebAdresses = true;
				}

				var fb = '';
				if(store.company_facebook != undefined && store.company_facebook != null && store.company_facebook != '')
				{
					fb = '<a href="'+store.company_facebook+'" target="_blank" style="margin-right:8px;">facebook &raquo;</a>';
					showWebAdresses = true;
				}


				var xhtml_webadresses = '';
				if (showWebAdresses)
				{
					xhtml_webadresses = ''
						+'	  		<div class="meta" style="margin-top:10px;">'
						+'				<span class="street_1" style="font-size:12px;">Na spletu</span><br>'
						+'				'+ webpage +' '+ fb
						+'	  		</div>';
				}

                // dodam še lokacije prevzrema ponudbe
//				var redeemLocations = micropon.locations.locations;
//				var redeemLocItems 	= '';
//				$(redeemLocations).each(function(i, v){
//					redeemLocItems +=
//						 '<li style="padding: 0 0 0 28px; background: url(/public/images/map-pin.png) no-repeat 0 1px; font-size: 12px; width:180px; float:left;">'
//						+'<span class="street_1">'+v.location.street+' '+v.location.street_number+'</span><br>'
//						+''+v.location.postal_name+', '+v.location.postal_code+'<br>'
//						+'<span class="phone">Tel: '+v.location.storeLocation.phone+'</span>'
//						+'<p class="directions" style="margin-bottom:8px;"><a style="font-size: 12px;" href="http://maps.google.com/maps?q='+v.location.lat+', '+v.location.long+'" target="_blank" style="font-weight:normal;">Pripelji me na lokacijo &raquo;</a></p>'
//						+'</li>';
//				});

				var districtName = $('.select-city:visible').text();
				var mpURL 		 = 'http://'+document.location.host +'/#!/donator/'+store.store_slug+'/'+ micropon.slug;
				var coURL 		 = '/#!/donate/'+store.store_slug+'/'+ micropon.slug;
				var shareTitle   = micropon.headline +' ('+ districtName +')';
				var shareBody	 = decodeURIComponent(micropon.description);
				var strippedBody = shareBody.replace(/(<([^>]+)>)/ig,"");

				var xhtml =
					 '<div class="gutter location-narrow rounded">'
					 +'	<div class="social_share">'
//					 +'	<ul class="clearfix">'
//				    +'   	<li class="first">'
//				    +'    		<a title="Share with Facebook" style="" class="social-share-fb fb share-on-fb" href="'+mpURL+'" data-item-status="'+strippedBody+'" data-item-title="'+shareTitle+'">Všeč mi je</a>'
//				    +'    	</li>'
//				    +'    	<li>'
//				    +'			<a href="http://twitter.com/share" style="" class="twitter-share-button" data-url="'+mpURL+'" data-text="Ne zamudi odlične ponudbe: '+shareTitle+'" data-count="none" data-via="Microhint_com">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>'
//				    +'  	</li>'
//				    +'  	<li>'
//				    +'    		<a style="width:60px;" title="Share by Email" class="social-share-email" href="//www.addthis.com/bookmark.php?pub=alanristic&amp;v=250&amp;source=tbx-250&amp;tt=0&amp;s=email&amp;url='+encodeURIComponent(mpURL)+'&amp;title='+shareTitle+'&amp;content=&amp;lng=en" target="_blank">Pošlji email</a>'
//				    +'  	</li>'
//				    +'  	<li class="last">'
//				    +' 			<div class="addthis_toolbox addthis_default_style"  addthis:url="'+encodeURIComponent(mpURL)+'" addthis:title="'+encodeURIComponent(shareTitle)+'" addthis:description="'+decodeURIComponent('bla')+'">'
//				    +'				<a class="addthis_button_compact" style="font-size:11px; font-weight: normal; padding-top:4px;">Deli drugam</a>'
//				    +'			</div>'
//				    +'  	</li>'
//				    +'  </ul>'
				    +'  </div>'
				     +'	<div class="clearfix"></div>'
//					+'	<h2 class="marker" style="margin-top:8px; margin-bottom:10px; font-size:15px;">Zgodba organizacije in poslanstvo</h2>'

                    +'	<h2 class="marker" style="margin-top:8px; margin-bottom:10px; font-size:15px;">Zgodba organizacije in poslanstvo</h2>'
					+'	<p>'+decodeURIComponent(micropon.description) +'</p>'
                    +'  <h3 class="highlights-title">escape kit</h3>'
                    +'  <ul class="escape-kit">'
                    +'      <li>'
                    +'          A Two-Night Weekday Stay for Two in a Premiere Queen Room, from November to December 2011 or April 1 to June 16, 2012 ($149); or January to March 2012 ($129)'
                    +'      </li>'
                    +'      <li>'
                    +'          Daily Continental Breakfast for Two'
                    +'      </li>'
                    +'      <li>'
                    +'          Welcome Beverage and Cookies'
                    +'      </li>'
                    +'      <li>'
                    +'          Wine Tasting for Two'
                    +'      </li>'
                    +'      <li>'
                    +'          Soap from the Little Egg Harbor Soap Shop'
                    +'      </li>'
                    +'      <li>'
                    +'          Discounts to Local Shops'
                    +'      </li>'
                    +'  </ul>'
                    +'  <div class="clearfix"></div>'

                    +'	<p class="start-quote" style="font-size: 18px; margin:12px 0 12px 0; padding-left:26px; background: url(/public/images/testimonial-quote.jpg) no-repeat 0 0;">'+micropon.pitch_statement +'"</p>'
                    +'	<div id="google-map" class="google-map  full" style="float:left; margin-top:10px; padding-right: 10px; position: relative; background-color: rgb(229, 227, 223); overflow-x: hidden; overflow-y: hidden; width:420px; height:220px;"></div>'

                    +'  <ul style="font-size: 12px; line-height: 16px;color: #666;list-style-type: none;padding:0 0 0 0; margin:0 0 14px 0;">'
                    +'      <li style="margin-top:14px; padding: 0 0 0 28px; background: url(/public/images/map-pin.png) no-repeat 0 1px; font-size: 12px; width:180px; float:left;"><span class="street_1">Partizanska cesta 4</span><br>Sežana, 6210<br><span class="phone">Tel: 05 7310 122</span><p class="directions" style="margin-bottom:8px;"><a style="font-size: 12px;" href="http://maps.google.com/maps?q=45.7096, 13.8744" target="_blank">Pripelji me na lokacijo »</a></p></li>'
                    +'  </ul>'

                    +'</div>'

                    // SIDE COLUMN
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:220px;">'

                    +'  <ul>'
                    +'      <li>'
                    +'          <ul class="clearfix deal-info" style="width: 220px;">'
                    +'              <li style="width:110px;">'
                    +'                  <div class="value">6.00 €</div>'
                    +'                  <div class="label">redna cena</div>'
                    +'              </li>'
                    +'              <li class="purchased" style="width:100px; border-right: none;">'
                    +'                  <div class="value">50%</div>'
                    +'                  <div class="label">prihranek</div>'
                    +'              </li>'
                    +'          </ul>'
                    +'      <li>'
                    +'      <li>'
                    +'          <div class="deal-price deal-price-lg" style="color:#97989A; text-align: center; font-weight: bold; margin-top: 14px;">'
                    +'              <span class="dollar_sign">€</span><span style="font-size:60px; line-height: 20px;">3</span><span style="font-size:20px; line-height: 20px;"></span>'
                    +'          </div> '
                    +'      <li>'
                    +'      <li style="text-align: center; width: 220px; margin-bottom: 14px;margin-top: 14px;">'
                    +'          <a href="#" class="big button activated" style="width: 150px; font-weight:bold;">Kupi</a>'
                    +'      <li>'

                    +'      <li style="width: 120px; margin: 10px auto;">'
                    +'          <ul class="clearfix deal-info" style="width: 120px; margin: 10px auto;">'
                    +'              <li class="last">'
                    +'                  <div class="value">'
                    +'                      <div id="countdown" class="hasCountdown">--<span class="colon" style="padding:0 4px 0 2px;">:</span>--<span class="colon" style="padding:0 4px 0 2px;">:</span>--</div>'
                    +'                  </div>'
                    +'                  <div class="label">Izteče se čez </div>'
                    +'              </li>'
                    +'          </ul>'
                    +'      <li>'
                    +'  </ul>'

                    +'	  <ul class="addresses" style="margin-top:6px;">'
					+'	    <li class="address order-0" data-marker-index="0" style="font-size:12px;">'
					+'	  		<div class="pin" style="position: absolute; top: 0; left: 0;">'
					+'	          <span style="background-position:0px -0px">&nbsp;</span>'
					+'	      	</div>'
					+'	  		<div class="meta" style="padding-right:10px;">'
					+'	    		<span class="street_1">'+store.company_name+'</span><br>'
//					+'	    		<p class="directions" style="margin-bottom: 0px; font-weight:normal;"><a target="_blank">info@standupkomedija.com</a></p>'
//					+'	    		<p class="directions"><a href="'+store.company_webpage+'" target="_blank" style="font-weight:normal;">'+store.company_webpage+'</a></p>'
					+'	  		</div>'
					+			xhtml_webadresses
					+'	  		<div class="meta" style="margin-top:4px;">'
					+'				<span class="street_1" style="font-size:12px;">Naslov in kontakti</span><br>'
					+				locItems
					+'	  		</div>'
					+'		</li>'
					+'	  </ul>'

                    +'</div>'

					+'<div class="clearfix"></div>';

				return xhtml;
			},
			/**
			 * Zgenerira zgodnjo kartico oz. njen xhtml
			 * @data	Core_Micropons JSON collection
			 */
			generateEscapeMainCard03: function(mpID, districtSlug)
			{
				var content  = '';
				var micropon = '';
				var store    = '';

				$.get('search/district-micropons?count=100&district_slug='+ districtSlug +'&old=0', function(data, textStatus, XMLHttpRequest)
				{
					// Če imamo še kakšno ponudbo poleg trenutne
					if(data.micropons!= undefined && data.micropons.length >= 1)
					{

						content	+'<ul>';

						$.each(data.micropons, function(i, v){

							micropon = v.micropon;
							store    = micropon.store.stores[0].store;

							if(mpID != v.micropon.id)
							{
								content += ''
									+'<li class="nearby-deal">'
									+'	<div class="img">'
									+'  	<a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'"><img alt="36" src="http://a3.ak.lscdn.net/imgs/8460150b-1581-4c40-a056-5c0923afc1fa/36.png"></a>'
									+'	</div>'
									+'	<p><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+ micropon.headline +'</a></p>'
									+'	<p class="title"><a href="/#!/micropon/'+store.store_slug+'/'+ micropon.slug +'">'+store.company_name+'</a></p>'
									// +'	<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Los Angeles Families</a></p>'
									+'</li>	'
									;
							}

						});

						content	+'</ul>';


					}
					else { content = 'Trenutno ni dodatne ponudbe'; }

					$('#additional-offer').after(content);

				});

				var xhtml =
					'<div class="gutter location-narrow rounded" style="width:330px;">'
					+'	<h2 id="additional-offer" style="margin-bottom:10px; font-size:15px;">dodatna ponudba na okraju</h2>'
					+'</div>'
					+'<div style="float:right; padding: 10px 0 18px 18px; border-right: 1px solid #CCC; width:330px;">'
					+'	<h2 style="margin-bottom:10px; font-size:15px; display:relative;">Prispevaj v skuponost</h2>'
					+'	<ul>'
					+'		<li class="nearby-deal nearby-donator">'
					+'			<div class="img_">'
					+'  			<a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560"><img alt="36" src="/public/images/donator.jpg" width="200" height="112"></a>'
					+'				<span class="srce"></span>'
					+'				<a class="nearby-donator-nub">poglej <span style="font-size:13px;">&raquo;</span></a>'
					+'			</div>'
					+'			<p style="margin-top:2px;"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560">Invest in Kids</a></p>'
					+'			<p class="city"><a href="/deals/42997-children-s-clothing-or-furniture?msdc_id=560" class="donator-quote">"When you\'re working with the community, you don\'t necessarily have the time or funds to stay on top of the latest research. We can do that legwork."</a></p>'
					+'		</li>	'
					+'	</ul>'
					+'</div>'
					+'<div class="clearfix"></div>'
					;

				return xhtml;
			}
	};
	
	MHT.micropon = {
		/**
		 * Interpretira status iz DB -> human kind obliko
		 */
		interpretStatus: function(micropon)
		{
			var statusAction = {
				'status': '',	
				'action': ''	
			};
		
			switch(micropon.workflow_status)
			{
				case 'confirmed':
					statusAction = {
						'status': 'Potrjen',	
						'action': '<a class="xc_popin micropon_confirmed" data-item-storeslug="'+micropon.store.stores[0].store.store_slug+'" data-item-id="'+micropon.id+'">Poglej</a>'	
					};
					break;
				case 'redeemable':
					statusAction = {
							'status': 'V procesu unovčitev',	
							// XXX Tu bi načeloma dal zraven, kontrolo da si lahko pogledajo še - "sttatus" finished, ker ne morejno nič spemenit
							'action': '<a class="xc_popin micropon_redeemable" data-item-storeslug="'+micropon.store.stores[0].store.store_slug+'" data-item-id="'+micropon.id+'">Unovči</a>'	
					};
					break;
				case 'rejected':
					statusAction = {
							'status': 'Zavržen',	
							'action': '<a class="xc_popin micropon_rejected" data-item-storeslug="'+micropon.store.stores[0].store.store_slug+'" data-item-id="'+micropon.id+'">Poglej</a>'	
					};
					break;
				case 'editedMicrohint':
					statusAction = {
							'status': 'V preverjanju pri Trgovcu',	
							'action': '<a class="xc_popin micropon_editedMicrohint" data-item-storeslug="'+micropon.store.stores[0].store.store_slug+'" data-item-id="'+micropon.id+'">Poglej</a>'	
					};
					break;
				case 'new':
				default:
					// Tale link je ročno dodan! Načeloma ga tule sploh nebi nucal!
					statusAction = {
						'status': 'Skrbnik dopolni',	
						'action': '<a class="xc_popin micropon_editedMerchant" data-item-storeslug="'+micropon.store.stores[0].store.store_slug+'" data-item-id="'+micropon.id+'" data-item-id="'+micropon.micropon_brand_id+'">Poglej</a>'	
					};
					break;
			}
			
			return statusAction;
		}
	};
	
	MHT.popin = {
		/**
		 * Nafila obrazec - trgovec lahko SAMO pogleda
		 * kaj je vnesel, ne more pa nič spreminjati!
		 */
		micropon_editedMerchant: function($popin, storeSlug, itemID, brandID)
		{
			$popin.append(
				 '<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
				+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Pregled željene ponudbe in kreacija (predogleda) slednje</h1>'
				+'</div>'

				+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
				+ 	MHT.forms.store_buildOfferEditForm('editedMerchant',storeSlug, itemID, brandID)
				+'</div>'
				+'<div style="padding-top:28px;"></div>'
			);
		},
		/**
		 * Nafila obrazec - trgovec lahko SAMO pogleda
		 * kaj je vnesel, ne more pa nič spreminjati!
		 */
		micropon_new: function($popin, storeSlug)
		{
            $popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Kreiraj novo ponudbo ali ustvari kampanjo</h1>'
					+'</div>'
					
					+'<div style="margin:0 auto; padding:14px 14px 14px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+ 	MHT.forms.store_buildOfferForm('new', storeSlug)
					+'</div>'
					+'<div style="padding-top:28px;"></div>'
			);

		},
		/**
		 * Nafila obrazec - trgovec lahko SAMO pogleda
		 * kaj je vnesel, ne more pa nič spreminjati!
		 */
		micropon_editedMicrohint: function($popin, storeSlug, itemID)
		{
			$popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Pregled Micropona (pregleda Trgovec)</h1>'
					+'</div>'
					+'<div id="with-merchant-comments" style="margin:0 auto; padding-bottom:10px; width:720px;">'
					// Obrazec
					+'<div id="micropon-comment-box" class="post" style="margin:6px 0 0 0px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'  <div class="comment" style="padding:8px;">'
					+'   <div class="comment_inner">'
					+'      <div class="meta_data">'
					+'        <span class="author" ><img alt="daisy" style="float:left; margin: 0 4px 0 0px;" width="24" height="24" src="http://assets1.grouponcdn.com/images/defaults/avatars/6/user_square.png?2Kki-pYt" title="daisy"></span>'
					+'        <span class="author" style="font-size:14px;"><span style="font-size:12px;">Skrbnik</span> alanristic pravi: </span>'
					+'      </div>'
					+'      <div class="body clearfix" style="margin-top:14px;">'
					+'			<textarea name="msgpost" id="msgpost" cols="97" rows="4" style="display:none;">'
				    +'			</textarea>'
					+'		</div>'
					+'      <div class="chrome"></div>'
					+'    </div>'
					+'  </div>'
					+'</div>'
					+'</div>'
					+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+ 	MHT.forms.store_buildMicroponForm('editedMicrohint')
					+'</div>'
					+'<div style="padding-top:28px;"></div>'
			);
			
			// Naloudam MPvsebino če je potrebno
			MHT.forms.store_loadMicroponForm($popin, storeSlug, 'editedMicrohint', itemID);
		},
		/**
		 * Nafila obrazec - trgovec in skrbnik lahko SAMO pogledata, nič ne moreta
		 * spremeniti na obrazcu
		 */
		micropon_confirmed: function($popin, storeSlug, itemID)
		{
			$popin.append(
				 '<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
				+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Pregled Micropona (potrjen)</h1>'
				+'</div>'
				+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
				+ 	MHT.forms.store_buildMicroponForm('confirmed')
				+'</div>'
				+'<div style="padding-top:28px;"></div>'
			);
			
			// Naloudam MPvsebino če je potrebno
			MHT.forms.store_loadMicroponForm($popin, storeSlug, 'confirmed', itemID);
		},
		/**
		 * Nafila obrazec - trgovec in skrbnik lahko SAMO pogledata, nič ne moreta
		 * spremeniti na obrazcu
		 */
		micropon_rejected: function($popin, storeSlug, itemID)
		{
			$popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Pregled Micropona (potrjen)</h1>'
					+'</div>'
					+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+ 	MHT.forms.store_buildMicroponForm('rejected')
					+'</div>'
					+'<div style="padding-top:28px;"></div>'
			);
			
			// Naloudam MPvsebino če je potrebno
			MHT.forms.store_loadMicroponForm($popin, storeSlug, 'confirmed', itemID);
		},
		store_fixdata: function($popin, storeSlug, newOrEdit)
		{
			$popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Vnesi podatke o podjetju / trgovini</h1>'
					+'</div>'
					
					+'<div class="box profile-settings store-profile-settings" style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+ 	MHT.forms.store_buildStoreDataForm($popin, storeSlug)
					+'</div>'
					+'<div style="padding-top:28px;"></div>'
			);
			// Naloudam MPvsebino če je potrebno
			MHT.forms.store_loadStoreDataForm($popin, storeSlug, newOrEdit);
		},
		/**
		 * Nafila obrazec - trgovec in skrbnik lahko SAMO pogledata, nič ne moreta
		 * spremeniti na obrazcu
		 */
		micropon_redeemable: function($popin, storeSlug, itemID)
		{
			$popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Unovčitev kupljenih ponudb <a href="/#!/micropon/'+storeSlug+'/'+itemID+'/redeems-print" style="font-size:12px;float:none;" class="normal-button large" target="_blank">Natisni nevnovčene kode</a></h1>'
					+'</div>'

					+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'

					+'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
					+'		<div id="profile-error-placeholder"></div>'
					+'		<div class="group_desc">'
					+'			<h2>Pregled trenutnega stanja akcije in izplačilo</h2>'
					+'			<p>tu si lahko kjflajsčf časkdfj časjfčaskjfd</p>'
					+'		</div>'

					+'		<div style="font-size:12px;">'
					+'			<div style="float:left; width:330px; margin-left:2px; margin-top:10px;">'

					+'				<div style="float:left; width:165px; text-align:center;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-sold">0</div><div style="line-height:14px;">PRODANIH</div>'
					+'				</div>'
                    +'				<div style="float:left; width:82px; text-align:center; margin-top:0px;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-redeemed">0</div><div style="line-height:14px;">VNOVČENIH</div>'
					+'				</div>'
					+'				<div style="float:left; width:82px; text-align:center; margin-top:0px;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-povrnjenih">0</div><div style="line-height:14px;">POVRNJENIH</div>'
					+'				</div>'
                    +'				<div style="float:left; width:330px; text-align:center; margin-top:16px;">'
					+'					<div style="line-height:14px;">PRIČAKUJETE LAHKO ŠE <span style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-expected">0</span> OBISKOV</div>'
					+'				</div>'
					+'				<div class="clearfix"></div>'

					+'			</div>'

					+'			<div style="float:left; width:330px; text-align:center;">'
					+'				<div style="margin-top:8px;">'
					+'					<div style="float:left; margin-left: 38px;"><span>vaše trenutno stanje: <span><strong style="font-size:27px;" id="sum-total" data-item-total="0">0</strong></div> <a href="#" style="font-size:12px; margin-left:8px; margin-top: 7px; float:left;" class="normal-button large">izplačaj</a>'
					+'				</div>'
                    +'				<div style="float:left; width:165px; text-align:center; margin-top:8px;">'
					+'					<div style="line-height:14px;">IZPLAČANIH: <span style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-odkupljenih">0</span></div>'
					+'				</div>'
                    +'				<div style="float:left; width:165px; text-align:center; margin-top:8px;">'
					+'					<div style="line-height:14px;">NEIZPLAČANIH:  <span style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-neodkupljenih">0</span></div>'
					+'				</div>'
					+'			</div>'


					+'			<div class="clearfix"></div>'
					+'		</div>'

                    +'		<div class="group_desc" style="margin-top:16px;">'
					+'			<h2>Zgodovina izplačil (//todo)</h2>'
					+'		</div>'

					+'		<div class="group_desc" style="margin-top:16px;">'
					+'			<h2>Vnos vnovčitev</h2>'
					+'			<p>tu si lahko kjflajsčf časkdfj časjfčaskjfd</p>'
					+'		</div>'

					+'	<form action="/account/redeem-micropon" method="post" id="redeemForm">'
					+'<table id="subtotal" class="sweet_stache">'
					+'	<thead>'
					+'		<tr style="background:#DEE3CF;">'
					+'			<th class="description" style="text-align:center; padding:0px; width:20px;">#</th>'
					+'			<th class="description" style="text-align:center; padding:0px; width:100px;">Št.Micropona</th>'
					+'			<th class="description" style="text-align:center; padding:0px; width:100px;">ID za trgovca</th>'
					+'			<th class="description" style="text-align:center; padding:0px; width:100px;">Datum</th>'
					+'			<th class="description" style="text-align:center; padding:0px;  width:120px;">Znesek na računu</th>'
					+'			<th class="description" style="text-align:center; padding:0px;">Ocena stranke</th>'
					+'			<th class="description" style="text-align:center; padding:0px;">Vaš znesek</th>'
					+'		</tr>'
					+'	</thead>'

					+'	<tbody id="first-tr" data-item-currentnumber="0">'
					+'		<tr class="line_item acctual_deal_item">'
					+'			<td class="description" style="padding:0px;">'
					+'				'
					+'			</td>'
					+'			<td class="description" style="padding:0px;">'
					+'				<input type="text" name="no_micropon" id="no_micropon" style="width:100px; text-align:center;"/>'
					+'				<span></span>'
                    +'			</td>'
                    +'			<td class="description" style="padding:0px;">'
                    +'				 <input type="text" name="no_merchant" id="no_merchant" style="width:100px; text-align:center;"/>'
                    +'				<span></span>'
                    +'			</td>'
                    +'			<td class="description" style="padding:0px; text-align:center; font-size:12px;">'
                    +'				 <div style="text-align:center;">'+$.fn.formatDate(parseInt((new Date()).getTime()/1000)) +'</div>'
                    +'			</td>'
                    +'			<td class="description" style="padding:0px;">'
                    +'				  <div style="text-align:center;"><input type="text" name="no_bill" id="no_bill" style="width:50px; text-align:center;"/> EUR</div>'
                    +'				<span></span>'
                    +'			</td>'
                    +'			<td class="description" style="padding:0px; text-align:center;">'
                    +'					<select style="width:100px;" name="user_review" id="user_review">'
                    +'						<option value="" selected="selected">-- izberi --</option>'
                    +'						<option value="1">Odlična</option>'
					+'						<option value="0">Slaba</option>'
					+'					</select>'
					+'				<span></span>'
                    +'			</td>'
                    +'			<td class="description" style="padding:0px; text-align:center;">'
                    +'					<input type="hidden" name="mp_id" id="mp_id" value="'+itemID+'">'
                    +'					<input type="hidden" name="slug" id="slug" value="'+storeSlug+'">'
                    +'					<input type="hidden" name="offer_value_merchant" id="offer_value_merchant" value="">'
                    +'					<input type="submit" style="font-size:12px;float:none; width:80px;" class="normal-button large" value="Vnovči">'
                    +'			</td>'
                    +'		</tr>'
					+'	</tbody>'
					+'</table>'
					+'</form>'
					+'	</div>'
					+'</div>'

					+'<div style="padding-top:28px;"></div>'
			);

            $.get('/store/micropon?count=1&store_slug='+storeSlug+'&micropon_id='+itemID+'&cursor=1', function(data, textStatus, XMLHttpRequest)
			{
                var micropon            = data.micropons[0].micropon;
                var sumPaymentPending   = parseFloat(micropon.merchant_payment_pending);
                var sumSold             = parseInt(micropon.paid_count);
                var sumRedeemed         = parseInt(micropon.redeemed_count);
                var sumOdkupljenih      = 0;
                var sumExpected         = parseInt(micropon.paid_count) - parseInt(micropon.redeemed_count);
                var sumNeodkupljenih    = 0;
                var sumPovrnjenih       = parseInt(micropon.redeemed_fails_count);

                $popin.find('#sum-total').html( Globalize.format(sumPaymentPending, 'n2') +' €' );
                $popin.find('#sum-total').attr( 'data-item-total', sumPaymentPending );
                $popin.find('#sum-sold').html( Globalize.format(sumSold, 'n0') );
                $popin.find('#sum-povrnjenih').html( Globalize.format(sumPovrnjenih, 'n0') );
                $popin.find('#sum-redeemed').html( Globalize.format(sumRedeemed, 'n0') );
                $popin.find('#sum-expected').html( Globalize.format(sumExpected, 'n0') );
                $popin.find('#sum-odkupljenih').html( Globalize.format(sumOdkupljenih, 'n0') );
                $popin.find('#sum-neodkupljenih').html( Globalize.format(sumNeodkupljenih, 'n0') );
                $popin.find('#offer_value_merchant').val( micropon.offer_value_merchant );
            });

			$.get('/store/fetch-vouchers?store_slug='+storeSlug+'&type=redeemed&mp_id='+itemID, function(data, textStatus, XMLHttpRequest)
			{
				var codes       = '';
				var current_no  = 0;
				var user_review = 0;
				if(data != undefined)
				{
					//console.log(data);
                    var counter = data.length;
					$(data).each(function(i, v){

						if(v["redemption_user_rating"] == null) { user_review = '/'; }
						else if( v["redemption_user_rating"] == 0) { user_review = '<div>slaba</div>'; }
						else { user_review = '<div>odlična</div>'; }

						codes += ''
							+'			<tr class="line_item acctual_deal_item">'
							+'				<td class="description" style="padding:0px; text-align:center;">'+(counter--)+'.</td>'
							+'				<td class="description" style="padding:0px; text-align:center;">'+v["redemption_code"]+'</td>'
							+'				<td class="description" style="padding:0px; text-align:center;">'+v["redemption_secret_code"]+'</td>'
							+'				<td class="description" style="padding:0px; text-align:center; font-size:12px;">'+v["date_redeemed"]+'</td>'
							+'				<td class="description" style="padding:0px;"><div style="text-align:center;"><div style="width:72px; margin-left:8px; float:left;">'+Globalize.format(parseFloat(v["redeemed_bill_total"]), 'n2')+'</div> <div style="float:left;">EUR</div></div></td>'
							+'				<td class="description" style="padding:0px; text-align:center;"><span  style="font-size:12px;">'+user_review+'</span></td>'
							+'				<td class="description" style="padding:0px; text-align:center;">'+v.offer_value_merchant+' EUR</td>'
							+'			</tr>';
					});

					$popin.find('#first-tr').attr('data-item-currentnumber', data.length);

					$popin.find('#first-tr').after(codes);
				}
			});

			MHT.forms.store_redeemForm($popin, storeSlug, itemID);

		},
		/**
		 * Nafila obrazec - trgovec in skrbnik lahko SAMO pogledata, nič ne moreta
		 * spremeniti na obrazcu
		 */
		donator_redeemable: function($popin, storeSlug, itemID)
		{
			$popin.append(
					'<div style="margin:0 auto; margin-bottom:10px; padding:0; width:724px; background:transparent; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
					+'	<h1 style="margin:0; padding:0; font-size: 2.2em; color:#fff;">Pregled in izplačila donacij</h1>'
					+'</div>'

					+'<div style="margin:0 auto; padding:14px 14px 2px 14px; width:700px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'

					+'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
					+'		<div id="profile-error-placeholder"></div>'
					+'		<div class="group_desc">'
					+'			<h2>Pregled trenutnega stanja akcije in izplačilo</h2>'
					+'			<p>tu si lahko kjflajsčf časkdfj časjfčaskjfd</p>'
					+'		</div>'

					+'		<div style="font-size:12px;">'
					+'			<div style="float:left; width:350px; margin-left:2px; margin-top:10px;">'

					+'				<div style="float:left; width:130px; text-align:center;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-partners">___</div><div style="line-height:14px;">PARTNERJI</div>'
					+'				</div>'
					+'				<div style="float:left; width:130px; text-align:center;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:17px;" id="sum-donations" >___</div><div style="line-height:14px;">ŠT. DONACIJ</div>'
					+'				</div>'
					+'				<div class="clearfix"></div>'

					+'			</div>'

					+'			<div style="float:left; width:300px; text-align:center;">'
                    +'				<div style="float:left; width:160px; text-align:center;">'
					+'					<div style="line-height:14px; font-weight:bold; font-size:34px;"><span id="sum_total">___</span><span style="font-size:14px;">€</span></div><div style="line-height:14px; margin-top:4px;">TRENUTNO STANJE</div>'
					+'				</div>'
					+'				<div style="float:left; width:120px; text-align:center;">'
					+'					<div style="float:left;"><a href="#" style="font-size: 26px; padding: 12px;margin-top: -7px;float: left;line-height: 20px;" class="normal-button large">izplačaj</a></div>'
					+'				</div>'
					+'			</div>'


					+'			<div class="clearfix"></div>'
					+'		</div>'

					+'		<div class="group_desc" style="margin-top:16px;">'
					+'			<h2>Zgodovina transakcij na donacij</h2>'
					+'		</div>'

					+'	<form action="/account/redeem-micropon" method="post" id="redeemForm">'
					+'<table id="subtotal" class="sweet_stache">'
					+'	<thead>'
					+'		<tr style="background:#DEE3CF;">'
					+'			<th class="description" style="text-align:left; padding:0px; width:30px;">#</th>'
					+'			<th class="description" style="text-align:left; padding:0px; width:100px;">Datum</th>'
					+'			<th class="description" style="text-align:left; padding:0px;width: 400px;">Dogodek</th>'
					+'			<th class="description" style="text-align:right; padding:0px;">MT</th>'
					+'			<th class="description" style="text-align:right; padding:0px;">Znesek</th>'
					+'		</tr>'
					+'	</thead>'

					+'	<tbody id="first-tr">'
//                    +'		<tr class="line_item acctual_deal_item" style="font-weight: normal;">'
//                    +'			<td class="description" style="padding:0px;">'
//                    +'				 49.'
//                    +'			</td>'
//                    +'			<td class="description" style="padding:0px;">'
//                    +'				 <div style="text-align:left;">'+$.fn.formatDate(parseInt((new Date()).getTime()/1000)) +'</div>'
//                    +'			</td>'
//                    +'			<td class="description" style="padding:0px; text-align:left;">'
//                    +'				<div>bla alb alkjd fčalkjfdčalskdjf časldkjfačsdflkj</div>'
//                    +'			</td>'
//                    +'			<td class="description" style="padding:0px; text-align:right;">'
//                    +'					30'
//                    +'			</td>'
//                    +'			<td class="description" style="padding:0px; text-align:right;">'
//                    +'					64 <span style="font-size:11px;">EUR</span>'
//                    +'			</td>'
//                    +'		</tr>'
					+'	</tbody>'
					+'</table>'
					+'</form>'
					+'	</div>'
					+'</div>'

					+'<div style="padding-top:28px;"></div>'
			);

			$.get('/store/micropon?count=1&store_slug='+storeSlug+'&micropon_id='+itemID+'&cursor=1', function(data, textStatus, XMLHttpRequest)
			{
                var micropon     = data.micropons[0].micropon;
                var sumPartners  = new Number (0);
                var sumDonations = micropon.paid_count;
                var paidTotal    = parseFloat( micropon.paid_total );

                //console.log(micropon);

                if(micropon.tipping_point_one_reached == 1) { sumPartners += parseFloat(micropon.tipping_point_one_giveaway); }
                if(micropon.tipping_point_two_reached == 1) { sumPartners += parseFloat(micropon.tipping_point_two_giveaway); }
                if(micropon.tipping_point_three_reached == 1) { sumPartners += parseFloat(micropon.tipping_point_three_giveaway); }

                $popin.find('#sum-partners').html(  Globalize.format(sumPartners,   'n2') +' €' );
                $popin.find('#sum-donations').html( Globalize.format(sumDonations,  'n0') );
                $popin.find('#sum_total').html(     Globalize.format(paidTotal,     'n2') );
            });

			$.get('/store/fetch-transaction-history?store_slug='+storeSlug+'&mp_id='+itemID, function(data, textStatus, XMLHttpRequest)
			{
                var rows = '';
                var noTock  = '/';

                var text    = '';
                var how     = '';

				if(data != undefined)
				{
					//console.log(data);
					$(data).each(function(i, v){

                        if(parseInt(v.value) <= 0) { noTock = '/';               }
                        else                       { noTock = parseInt(v.value); }

                        switch(v.transaction_type_id) {
                            case '2':
                                text = 'Uporabnik je doniral';

                                switch(v.payment_gateway_id) {
                                    case '1':
                                        text += ' s svojimi MT(microtočkami)';
                                        break;
                                    case '2':
                                        text += ' prek UPN(univerzalnega plačilnega naloga)';
                                        break;
                                    case '3':
                                        text += ' z plačilno kartico';
                                        break;
                                }
                                break;
                            case '11':
                                text = 'Microhint in partnerji so povišali donacijo za '+v.money_value+' EUR';
                                break;
                        }

						rows += ''
							+'			<tr class="line_item acctual_deal_item" style="font-weight: normal;">'
							+'				<td class="description" style="padding:0px;">'+(i+1)+'.</td>'
							+'				<td class="description" style="padding:0px; font-size: 12px;">'+v.date_created+'</td>'
							+'				<td class="description" style="padding:0px; font-size: 12px; text-align:left;">'+text+'</td>'
							+'				<td class="description" style="padding:0px; text-align:right;">'+noTock+'</td>'
							+'				<td class="description" style="padding:0px; text-align:right;">'+ Globalize.format(parseFloat(v.money_value), 'n2') +' <span style="font-size:11px;">EUR</span></td>'
							+'			</tr>';
					});

					$popin.find('#first-tr').after(rows);
				}
			});
		}
	};
	
	/**
	 * Tale se zmeraj vsteli ko rabim popin
	 */
	$('.xc_popin').live('click', function(){
		
		$click_el  = $(this);
		itemID     = $click_el.attr('data-item-id');
		brandID     = $click_el.attr('data-item-brandid');
		storeSlug  = $click_el.attr('data-item-storeslug');
		$bbqItem   = $click_el.parents('.bbq-item');
		$popin	   = $bbqItem.find('.popin');
		$popnormal = $bbqItem.find('.popnormal');

		// Če klikne trgovec - nima pravice urejanja
		if($click_el.hasClass('micropon_editedMerchant'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
			MHT.popin.micropon_editedMerchant($popin, storeSlug, itemID, brandID);
		}
		// Trgovec ustvari nov micrpoon
		else if($click_el.hasClass('micropon_new'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
//			MHT.popin.micropon_new($popin, storeSlug);

            // naloži pravi obrazec
			if($click_el.hasClass('brand_escapes')) {
			    MHT.forms.showOfferForm_escapes($popin, storeSlug);
			}
			else if($click_el.hasClass('brand_philantroper')) {
				MHT.forms.showOfferForm_philantroper($popin, storeSlug);
			}
			else if($click_el.hasClass('brand_dailydeal')) {
				MHT.forms.showOfferForm_dailydeal($popin, storeSlug);
			}
		}
		else if($click_el.hasClass('micropon_editedMicrohint'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
			MHT.popin.micropon_editedMicrohint($popin, storeSlug, itemID);
		}
		else if($click_el.hasClass('micropon_confirmed'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
			MHT.popin.micropon_confirmed($popin, storeSlug, itemID);
		}
		else if($click_el.hasClass('micropon_rejected'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
			MHT.popin.micropon_rejected($popin, storeSlug, itemID);
		}
		else if($click_el.hasClass('micropon_redeemable'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});

            if($click_el.hasClass('donator')) {
                MHT.popin.donator_redeemable($popin, storeSlug, itemID);
            } else {
                MHT.popin.micropon_redeemable($popin, storeSlug, itemID);
            }
		}
		else if($click_el.hasClass('store_fixdata'))
		{
			$popin.html('<div style="padding:4px 0 4px 10px; "><a class="xc_popnormal" style="text-indent: -99999px; z-index: 10001; background-image: url(/public/images/overlay/close.png); position: absolute; right: -15px; top: -15px; cursor: pointer; height: 35px; width: 35px;">Zapri popin</a></div>');
			$popin.find('.xc_popnormal').bind('click', function(){
				$popnormal.show();
				$popin.hide().html('');
			});
			
			var newOrEdit = 'new';
			if($click_el.hasClass('edit')) { newOrEdit = 'edit'; }
			
			MHT.popin.store_fixdata($popin, storeSlug, newOrEdit);
		}
		
		// XXX: Ostali statusi
		
		$popnormal.hide();
		$popin.show();
		
		return false;
	});
	

	MHT.forms = {
			/**
			 * Init (all kind off) editors
			 */
			editors: {},
			/**
			 * WWWW: Prikaz obrazca
			 */
			showOfferEditForm_philantroper: function(storeSlug, itemID, brandID)
			{
//				console.log('Prikažem obrazec (za skrbnika) za DailyDeal');
				/* ****************************************** */
				/* Skrbnik uredi novo ponudbo (ali osnutek)   */
				/* ****************************************** */
				
				$.get('store/micropon?store_slug='+storeSlug+'&micropon_id='+itemID, function(data, textStatus, XMLHttpRequest){
					
					var micropon = data.micropons[0].micropon;
					
					// Zbildam obrazec
					var formAction				 = 'ampera/update-micropon-status';	// ciljni URL obrazca
					var headline	   			 = '';	// Naslov ponudbe
					var maxQuantityPerUserSelect = '';
					var addOpombeBtn 			 = '';	// Možnost dodajanja opomb (input)
					var addArgumentsBtn 		 = '';	// Možnost dodajanja Argumentov (input)
					var buttons      			 = '';	// Gumbi za upravljanje obrazca
					var picControls  			 = '';	// Linka za upravljanje slike micropona
					var isDisabled   			 = '';	// Stanje Inputov (če ne more user urejat, so onemogočeni)
					var disabledCSS  			 = '';	// CSS za dizejblan element (nekako je tole hack)
					var commentFiled			 = '';	// Določene akcije nucajo kometar pred izvršitvijo!
					
					var brandsSelection			 = '';
					var xhtml					 = '';
					
					// status: Active picture controls
					picControls = 
						'<div class="pic_controls">'
						+'  :: <a class="" id="dealpic_upload">Naloží svojo sliko</a>&nbsp;&nbsp;&nbsp;'
						+'  :: <a class="" id="xc_reset_dealpic">Zbríší trenutno slíko</a>'
						+'</div>';
					
					var form = 
						'<form action="'+formAction+'" method="post" id="newOfferRequest_dailydeal">'
						+'	<input type="hidden" name="brandid" value="3" />'
						+'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
						+'		<div id="profile-error-placeholder"></div>'
						
						+'		<div class="group_desc" style="margin-top: 8px;">'
					+'			<h2>Izbira okraja in datuma začetka donatorske kampanje</h2>'
					+'		</div>'
					+'		<ol>'

					+'  		<li>'
					+'  			<label for="district-selector"  style="padding-top:0px;">Okraj kampanje</label>'
					+'				<ul class="mht-districts" id="district-selector" style="margin-top:8px; margin-left: 144px;">'
					+'					<li id="district_8" class="data district" style="display:none; text-align:left; float:none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="8" data-item-slug="koprski-okraj"><span style="margin-bottom:0px;"></span>Koprski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_7" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="7" data-item-slug="novogoriski-okraj"><span style="margin-bottom:0px;"></span>Novogoriški okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_3" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="3" data-item-slug="ljubljanski-okraj"><span style="margin-bottom:0px;"></span>Ljubljanski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_6" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="6" data-item-slug="kranjski-okraj"><span style="margin-bottom:0px;"></span>Kranjski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_5" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="5" data-item-slug="celjski-okraj"><span style="margin-bottom:0px;"></span>Celjski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_9" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="9" data-item-slug="novomeski-okraj"><span style="margin-bottom:0px;"></span>Novomeški okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_4" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="4" data-item-slug="mariborski-okraj"><span style="margin-bottom:0px;"></span>Mariborski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_10" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="10" data-item-slug="murskosoboski-okraj"><span style="margin-bottom:0px;"></span>Murskosoboški okraj</a></strong>'
					+'					</li>'
					+'				</ul>'
					+'				<input type="hidden" name="districtslug" id="districtslug" value="'+ micropon.districtslug +'">'
					+'				<div class="clearfix"></div>'
					+'				<span style="display:block; color:red; float:none; margin-left:0px; font-weight:bold;" class="err-district"></span>'	
					+'  		</li>'
					
					+'  		<li class="value">'
						+'  			<label for="date_start"><strong class="asteric" style="font-size: 13px;">*</strong> Začetek kampanje</label>'
						+'				<div class="date_wrap">'
						+'					<span>OD: </span> <input name="date_start" id="date_start" class="date-pick" type="text" value="'+(new Date(micropon.date_start * 1000)).asString()+'"><span id="date_start_spinner" style="display:none; background:url(/public/images/spinner.gif) no-repeat 0 -4px; padding:0 16px 0 0;"></span>'
						+'					<input type="hidden" id="date_start_ts" value="'+(micropon.date_start * 1000)+'">'
						+'					<input type="hidden" id="date_end_ts" value="'+(micropon.date_end * 1000)+'">   '
						+'				</div>'
						+'				<span class="field_desc clearfix" style="width:auto;">Kdaj želiš, da se kampanje pojavi na microhint.com, kjer uporabniki lahko donirajo?</span>'
						+'  		</li>'
					
					+'		</ol>'
					+'		<div class="clearfix"></div>'
					
						
						+'		<div class="group_desc">'
						+'			<h2>Zippy naslov kampanje</h2>'
						+'			<p>Naslov mora pritegnit uporabnika takoj ko ga zagleda!</p>'						
						+'		</div>'
						+'		<div class="min-reached" style="display:none; font-size:1.2em; color:red; position:absolute; top:180px; right:100px; width:330px; padding:0 10px 0 10px;">Cena, ki jo stranka plača mora biti vsaj 1.5eur. To dosežete tako, da povišate redno ceno (namesto ene kave, ponudite dve) ali pa zmanjšate popust.</div>'
						+'		<ol>'
						// Headline description
						+'  		<li class="name">'
						+'  			<label for="headline_description">Org. nasl. kmapanje</label>'
						+'  			<input name="headline_description" class="disabled" id="headline_description" autocomplete="off" type="text" value="'+micropon.description_headline+'" disabled="disabled">'
						+'				<span class="field_desc">Na podlagi zgornjega naslova, vpiši ta zippy spodnji naslov, kot bo viden na javnem kampanje</span>'
						+'  		</li>'
						+'  		<li class="name" style="margin-bottom:20px;">'
						+'  			<label for="headline"><strong class="asteric" style="font-size: 13px;">*</strong> Naslov kampanje</label>'
						+'  			<input name="headline" id="headline" autocomplete="off" type="text" value="'+micropon.headline+'">'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc">'
						+'			<h2>Določi tipping pointe kampanje</h2>'
						+'			<p>Več kot damo, več bomo doblili ;)</p>'						
						+'		</div>'
						+'		<div class="min-reached" style="display:none; font-size:1.2em; color:red; position:absolute; top:180px; right:100px; width:330px; padding:0 10px 0 10px;">Cena, ki jo stranka plača mora biti vsaj 1.5eur. To dosežete tako, da povišate redno ceno (namesto ene kave, ponudite dve) ali pa zmanjšate popust.</div>'
						// XXX tule dodaj tipping pointe
						+'		<ol>'
						+'  		<li class="value">'
						+'  			<label for="tipping_point_one">Tiping point 01</label>'
						+'  			<input name="tipping_point_one" id="tipping_point_one" autocomplete="off" type="text" value="'+micropon.tipping_point_one+'"><strong style="font-size:13px; line-height: 26px;"><span style="font-size:16px;">€</span> dodamo mi zraven</strong>  <input name="tipping_point_one_giveaway" id="tipping_point_one_giveaway" autocomplete="off" type="text" value="'+micropon.tipping_point_one_giveaway+'"><strong style="font-size:13px;"><span style="font-size:16px;">€</span></strong>'
						+'  		</li>'
						+'  		<li class="value">'
						+'  			<label for="tipping_point_two">Tiping point 02</label>'
						+'  			<input name="tipping_point_two" id="tipping_point_two" autocomplete="off" type="text" value="'+micropon.tipping_point_two+'"><strong style="font-size:13px; line-height: 26px;"><span style="font-size:16px;">€</span> dodamo mi zraven</strong>  <input name="tipping_point_two_giveaway" id="tipping_point_two_giveaway" autocomplete="off" type="text" value="'+micropon.tipping_point_two_giveaway+'"><strong style="font-size:13px;"><span style="font-size:16px;">€</span></strong>'
						+'  		</li>'
						+'  		<li class="value">'
						+'  			<label for="tipping_point_three">Tiping point 03</label>'
						+'  			<input name="tipping_point_three" id="tipping_point_three" autocomplete="off" type="text" value="'+micropon.tipping_point_three+'"><strong style="font-size:13px; line-height: 26px;"><span style="font-size:16px;">€</span> dodamo mi zraven</strong>  <input name="tipping_point_three_giveaway" id="tipping_point_three_giveaway" autocomplete="off" type="text" value="'+micropon.tipping_point_three_giveaway+'"><strong style="font-size:13px;"><span style="font-size:16px;">€</span></strong>'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Slika kampanje</h2>'
						+'			<p>Sliko je potrebno obdelat in jo napimpat tako, da ti oči ven padejo ;)</p>'
						+'		</div>'
						+'		<ol>'
						+'  		<li class="name" style="margin-bottom:20px;">'
						+'  			<label for="merchant_pics" style="padding-top:0px;">Slikovni materjal</label>'
						+'				<ul id="userFiles" style="margin-left:160px; padding-top:2px;"><li>(Organizacija ni priložila nobene slike)</li></ul>'
						+'  			<span class="field_desc">Pa tale upload slik je potrebno na tabeli še ločeno dodat</span>'
						+'  		</li>'
						
						+'  		<li>'
						+'  			<label for="avatar"><strong class="asteric" style="font-size: 13px;">*</strong> Slike kampanje</label>'
					 	+'				<div id="fileupload" style="width: 444px; margin-left: 144px;">'
						// +'				<form action="/account/dealpic-upload?store_slug='+ storeSlug+'" method="POST" enctype="multipart/form-data"> '
						+'					<div class="fileupload-buttonbar"> '
						+' 						<label class="fileinput-button"> '
						+'							<span>Dodaj slike...</span> '
              			+' 							<input type="file" name="files[]" multiple> '
          				+'						</label>' 
			          	// +'					<button type="submit" class="start">Start upload</button> '
			          	// +'					<button type="reset" class="cancel">Cancel upload</button> '
			         	// +'					<button type="button" class="delete">Izbriši vse datoteke</button> '      
			          	+'						<div class="clearfix"></div>'	
			          	+'					</div> '
  						// +'				</form>' 
 						+'					<div class="fileupload-content">' 
     					+' 						<table class="files"></table> '
    					+' 						<div class="fileupload-progressbar"></div> '
 						+' 					</div> '
						+'				</div> '
						+'				<script id="template-upload" type="text/x-jquery-tmpl"> '
   						+'					<tr class="template-upload{{if error}} ui-state-error{{/if}}">'
    					+'						<td class="preview"></td>'
     					+'						<td class="name">${name}</td>'
     					+' 						<td class="size">${sizef}</td>'
     					+' 						{{if error}}'
      					+'						<td class="error" colspan="2">Napaka:'
        				+'							{{if error === \'maxFileSize\'}}Prevelika datoteka'
         				+'							{{else error === \'minFileSize\'}}Premajhna datoteka'
           				+'							{{else error === \'acceptFileTypes\'}}Dovoljene so samo slike'
             			+'							{{else error === \'maxNumberOfFiles\'}}Preveč datotek'
              			+'							{{else}}${error}'
               			+' 						{{/if}}'
            			+'						</td>'
       					+'						{{else}}'
           	 			+'						<td class="progress"><div></div></td>'
           				+'						<td class="start"><button>Start</button></td>'
       					+'						{{/if}}'
       					+'						<td class="cancel"><button>Cancel</button></td>'
  						+' 					</tr>'
						+'				</script> '
						+'				<script id="template-download" type="text/x-jquery-tmpl"> '
    					+'					<tr class="template-download{{if error}} ui-state-error{{/if}}">'
       					+'						{{if error}}'
          				+'						<td></td>'
          				+'	 					<td class="name">${name}</td>'
          				+'						<td class="size">${sizef}</td>'
          				+' 						<td class="error" colspan="2">Napaka:'
             			+' 							{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)'
             			+'							{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)'
             			+'							{{else error === 3}}File was only partially uploaded'
              			+'							{{else error === 4}}No File was uploaded'
             			+'							{{else error === 5}}Missing a temporary folder'
             			+' 							{{else error === 6}}Failed to write file to disk'
             		 	+'							{{else error === 7}}File upload stopped by extension'
             			+' 							{{else error === \'maxFileSize\'}}File is too big'
             			+' 							{{else error === \'minFileSize\'}}File is too small'
              			+' 							{{else error === \'acceptFileTypes\'}}Filetype not allowed'
              			+' 							{{else error === \'maxNumberOfFiles\'}}Max number of files exceeded'
             			+'  						{{else error === \'uploadedBytes\'}}Uploaded bytes exceed file size'
             			+'  						{{else error === \'emptyResult\'}}Empty file upload result'
             			+' 							{{else}}${error}'
            			+'  						{{/if}}'
         				+'						</td>'
      					+'						{{else}}'
          				+' 						<td class="preview">'
              			+' 							{{if thumbnail_url}}'
              			+'							<a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>'
             			+' 							{{/if}}'
           				+'						</td>'
         				+' 						<td class="name">'
         				+'							<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>'
         				+' 						</td>'
         				+'						<td class="size">${sizef}</td>'
          				+'						<td colspan="2"></td>'
       					+'						{{/if}}'
       					+' 						<td class="delete">'
            			+'							<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>'
       					+' 						</td>'
  						+' 					</tr>'
						+'				</script> '
						+'				<span class="field_desc">Slika naj čimbolje zajame vaše podjejte oz. produkt, ki ga ponujate</span>'
						+'  		</li>'		
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Sestavi opis kampanje</h2>'
						+'			<p>Nek superkul spremljajoči/opisen text, da se uporabniku zaresejo kolen ;)</p>'
						+'		</div>'
						+'		<ol>'
						+'  		<li class="dela_desc" style="margin-top: 8px;">'
						+'  			<label for="description_description"><strong class="asteric" style="font-size: 13px;">*</strong> Org. opis kamp.</label>'
						+'  			<div class="writeup" style="border-bottom:1px solid gray; border-top:1px solid gray; font-size:1.1em; margin-left:144px; padding:6px;">'+decodeURIComponent(micropon.description_description)+'</div>'
						+'				<span class="field_desc">Iz zgornjega trgovčevega opisa, sestavi opis ko ga želiš imeti na javnem utripu ponudbe</span>'
						+'  		</li>'
						+'  		<li class="dela_desc" style="margin-top: 8px;">'
						+'  			<label for="pitch_statement"><strong class="asteric" style="font-size: 13px;">*</strong> Pitch stavek</label>'
						+'  			<textarea style="height: 58px;" name="pitch_statement" id="pitch_statement">'+decodeURIComponent(micropon.pitch_statement)+'</textarea>'
						+'  		</li>'
						+'  		<li class="dela_desc" style="margin-top: 8px;">'
						+'  			<label for="deal_description"><strong class="asteric" style="font-size: 13px;">*</strong> Opis kampanje</label>'
						+'  			<textarea name="deal_description" id="deal_description">'+decodeURIComponent(micropon.description)+'</textarea>'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'	</div>'
						
						+'	<div id="micropon-comments"></div>'
						
						+'	<div class="box store-profile-settings button_wrap" style="padding:0px 12px 0px 12px; margin-bottom:6px; background:#fff;">'
						+'		<a href="#" id="open-reject-form" style="font-size:13px; display:block; text-align:center;">Želiš zavreči ponudbo ali vpisati komentar?</a>'
						+'	</div>'
						
						+'	<div id="msgpost-form-box" class="box store-profile-settings button_wrap" style="padding:4px 12px 14px 12px; margin-bottom:14px; background:#bdc4a8; display:none;">'
						+'		<label for="msgpost" style="float:none; width:430px; text-align:left;">Vpiši vzrok za zavrnitev ponudbe</label>'
						+'      <div class="body clearfix">'
						+'			<textarea name="msgpost" id="msgpost" cols="97" rows="14" style="width: 656px;"></textarea>'
						+'		</div>'
						+'	</div>'
						
						+'	<div class="box store-profile-settings button_wrap" style="padding:14px 0 14px 10px; margin-bottom:14px;">'
						+'		<div id="error-placeholder" class="error" style="font-size:1.2em; text-align:center; margin:0 0 8px 0px; display:none;"></div>'
						+'		<span class="store_finish" style="margin:0 44px 0 0px;"><input type="button" style="width: 230px;" class="normal-button large ajaxsubmit" value="Pošlji ponudbo v predogled" data-item-status="review" data-item-id="'+micropon.id+'" title="Ko je ponudba pripravljena, ta status obvesti trgovca naj pregleda ponudbo. Ko jo sprejme je postopek priprave ponudbe zaključen."></span>' 					
						+'		<span class="store_finish" style="margin:0 10px 0 0;"><input type="button" style="width: 130px;" class="normal-button large ajaxsubmit" value="Shrani osnutek " data-item-status="draft" data-item-id="'+micropon.id+'" title="Osnutek ponudbe shraniš in jo urejaš kasneje naprej. Trgovec ne dobi nobenega sporočila"></span>'
						+'		<span class="store_finish" style="margin:0 10px 0 0;"><input type="button" style="width: 100px;" class="normal-button large ajaxsubmit" value="Runtime Fix" data-item-status="runtime-update" data-item-id="'+micropon.id+'" title="Update ponudbe z novimi podatki - trenutni status ostane nespremenjen.""></span>' 					
						+'		<span class="store_finish" style="margin:0 0 0 0;"><input type="button" id="reject-btn" disabled="disabled" style="width: 100px;" class="normal-button large ajaxsubmit" value="Zavrzi" data-item-status="rejected" data-item-id="'+micropon.id+'" title="Ponudbo zavržeš - trgovec dobi obvestilo o zavrnjeni ponudbi"></span>' 					
						+'	</div>'
						
						
						+'	<input type="hidden" name="status" id="status" />'
						+'	<input type="hidden" name="mp_id" id="mp_id" value="'+itemID+'" />'
						+'</form>'
						+'';
					
					$('.mainContentPlaceHolder').replaceWith(form);
					
					var $form = $('form#newOfferRequest_dailydeal');
					
					
					/*** FILEUPLOAD za Skrnika ***/
					
					// Initialize the jQuery File Upload widget:
				    $form.find('#fileupload').fileupload({
					  	autoUpload: true,
					  	url: '/account/dealpic-upload?store_slug='+ storeSlug,
					}).bind('fileuploaddestroy', function (e, data) { return false; })
					  .bind('fileuploadfail', function (e, data) { console.log('error'); return false; });
				
					if(micropon.multimedia != null)
					{
						var files = [];
						var fileName = '';
						var hostName = window.location.host;
						
						var userFilesXhtml = '';
						
						$.each(micropon.multimedia, function(i, v){
							
							fileName = v['file_name'];

							if(v['uploader'] == '1') { userFilesXhtml += '<li><a href="/tmp/mppics/'+fileName+'" target="_blank">'+fileName+' (download)</a></li>'; }
							else {
								files.push(
									{
										"name"			:fileName,
										// "size"			:902604,
										"url"			:'\/tmp\/mppics\/'+fileName,
										"thumbnail_url"	:'\/tmp\/mppics\/thumbnails\/'+fileName,
										"delete_url"	:'\/account\/dealpic-upload?store_slug='+storeSlug+'&file='+fileName,
										"delete_type"	:'DELETE'
									}
								);
							}
							
						});
						
						if(userFilesXhtml != '') { $('#userFiles').html(userFilesXhtml); }
						
						
						// Fizično jih vstavim v file uploader
				        var fu = $('#fileupload').data('fileupload');
				        fu._adjustMaxNumberOfFiles(-files.length);
				        fu._renderDownload(files)
				            .appendTo($('#fileupload .files'))
				            .fadeIn(function () {
				                // Fix for IE7 and lower:
				                $(this).show();
				         	});
					}
				
				    // Open download dialogs via iframes,
				    // to prevent aborting current uploads:
				    $('#fileupload .files a:not([target^=_blank])').live('click', function (e) {
				        e.preventDefault();
				        $('<iframe style="display:none;"></iframe>')
				            .prop('src', this.href)
				            .appendTo('body');
				    });
					
					/*** end FILEUPLOAD za Skrnika ***/
					
					// ### Inicializacija elementov
					
//					if( micropon.workflow_status == 'rejected' )
//					{
						// XXX nafilam komentar-je (kaj se je dogajalo)
						$.get('ampera/browse-micropon-creation-comments?count=1&cursor=1&microponID='+ micropon.id, function(data, textStatus, XMLHttpRequest)
						{
							var comment = '';
							var avatar	= '';
							
							if(undefined != data)
							{
								$(data).each(function(i, v){
									// Zbildaj komentarje
									
									comment += 
										'<div class="post" style="margin:6px 0 0 0px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
										+'  <div class="comment" style="padding:8px; background: -moz-linear-gradient(top,#FFFCE9 0,#FFF8CC 60px)!important; background: -webkit-gradient(linear,0 0,0 60,from(#FFFCE9),to(#FFF8CC))!important; background: -moz-linear-gradient(top,#FFFCE9 0,#FFF8CC 60px)!important; border: 1px solid #FFE764; -webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0; -webkit-box-shadow: 2px 2px 8px #CCC; -moz-box-shadow: 2px 2px 8px #CCC; box-shadow: 2px 2px 8px #CCC;">'
										+'   <div class="comment_inner">'
										+'      <div class="meta_data">'
										+'        <span class="author" style="font-size:14px;">'+v.nickname+' pravi: </span>'
										+'        <span class="timestamp" style="font-size:12px; color:#666;">'+v.date_created+'</span>'
										+'      </div>'
										+'		<div class="clearfix"></div>'
										+'      <div class="body"><p>'+decodeURIComponent(v.content)+'</p></div>'
										+'      <div class="chrome"></div>'
										+'    </div>'
										+'  </div>'
										+'</div>';
								});
							}
							$form.find('#micropon-comments').before(comment);
						});
//					}

					function isDistrictSelected() {
						if ( $form.find('ul#district-selector li a.checked').length <= 0 ) {
							$form.find('span.err-district').html('<label style="width:304px" class="error">Okraj kjer se bo akcija izvedla mora biti izbran</label>');
							return false;
						}
						else {
							$form.find('span.err-district').html('');
							return true;
						}
					};

					// Custom district handling
					$('ul.mht-districts li a').live('click', function(e){
						var $clicked_el = $(this);
						var $ul = $clicked_el.parents('ul');
						$ul.find('li a').removeClass('checked');
						$clicked_el.addClass('checked');
						
						//console.log('bam!');
						$form.find('input#districtslug').val($clicked_el.attr('data-item-slug'));;
						
						isDistrictSelected();
						
						return false;
					});
					
					$.get('/store/store-data?store_slug='+ storeSlug, function(data, textStatus, XMLHttpRequest) 
					{
						
						var store = data.stores[0].store;
						
						/* Lokacije za prevzem unovčitev ponudbe */
						var companyLocations = [];
						var xhtmlItems = '';
						if( store.store_locations != undefined )
						{
							$.each(store.store_locations.locations, function(i, v)
							{
								// XXX koda za okraj
							});
						}
						
						$form.find('li.district a').each(function(i,v){
							$v = $(v);
							if($v.attr('data-item-slug') == micropon.districtslug) {
								$form.find('#'+ $v.parent().parent().attr('id') +' a').addClass('checked');
								$form.find('#'+ $v.parent().parent().attr('id')).show('fast');
							}
						});
						});
						
					
					// DATE settings
					$form.find('#date_start').datePicker({
						clickInput:false,
						createButton:false,
						//startDate: (new Date()).addDays(5).asString(),
						endDate: (new Date()).addMonths(4).asString(),
						selectWeek:true
					}).bind(
							'click',
							function()
							{
								var $o_dp 	 = $(this);
								
								$form.find('#date_start_spinner').fadeIn('fast');
								$o_dp.dpSetDisabled(true);
								
								var districtslug = $form.find('#districtslug').val();
							
								$.get('/store/get-reserved-donatordeal-dates?districtslug='+ districtslug, function(data){

									$o_dp.dpSetRenderCallback(function($td, thisDate, month, year)
									{
										if(!$.inArray((new Date(thisDate)).getTime(), data))
										{
											// XXX select week
											$td.addClass('disabled');
											$td.css({'background':'#96be68'});
											$td.text('R');
										}
									});
									
									$o_dp.dpSetDisabled(false);
									$o_dp.dpDisplay();
								});
							}
					 ).bind(
							'dpClosed',
							function(e, selectedDates)
							{
								var d = selectedDates[0];
								var ts;
								if (d) {
									d = new Date(d);
									ts = d.getTime();
								}
								
								// date_start
								if($(this).attr('id') == 'date_start' && d != undefined)
								{
									$form.find('#date_start_spinner').fadeOut('fast');
									
									$('#date_start_ts').val(ts);					// set start timestamp
									$('#date_end_ts').val(d.addDays(4).getTime());	// set end timestamp
									
									$form.find('#date_redeem_from').dpSetStartDate(d.addDays(1).asString());
								}
							}	
					);

                    MHT.forms.editors.contentEditor = new YAHOO.widget.SimpleEditor('deal_description', {
						height: '50px',
						width: '440px',
						dompath: false, //Turns on the bar at the bottom
						animate: false, 	//Animates the opening, closing and moving of Editor windows
						autoHeight: true,
						ptags:		true,
						toolbar: {
						titlebar: false,
						buttons: [
						          { group: 'textstyle',
						        	  buttons: [
						        	            { type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' },
						        	            { type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' },
						        	            { type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' },
						        	            { type: 'separator' },
						        	            { type: 'push', label: 'Subscript', value: 'subscript'},
						        	            { type: 'push', label: 'Superscript', value: 'superscript' },
						        	            { type: 'separator' },
						        	            { type: 'color', label: 'Barva izbranega texta', value: 'forecolor' },
						        	            { type: 'color', label: 'Barva ozadja izbranega texta', value: 'backcolor' },
						        	            { type: 'separator' },
						        	            { type: 'push', label: 'Odstranni urejanje', value: 'removeformat' },
						        	            ]
						          },
						          { type: 'separator' },
						          { type: 'separator' },
						          { group: 'indentlist',
						        	  buttons: [
						        	            { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
						        	            { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }
						        	            ]
						          },
						          { type: 'separator' },
						          { group: 'insertitem',
						        	  buttons: [
						        	            { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink'},
						        	            ]
						          }
						          ]
					    }
					});
					MHT.forms.editors.contentEditor.render();
					
					MHT.forms.editors.commentEditor = new YAHOO.widget.SimpleEditor('msgpost', {
						height: '50px',
						width: '674px',
						dompath: false, //Turns on the bar at the bottom
						animate: false, 	//Animates the opening, closing and moving of Editor windows
						autoHeight: true,
						ptags:		true,
						toolbar: {
						titlebar: false,
						buttons: [
						          { group: 'textstyle',
						        	  buttons: [
						        	            { type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' },
						        	            { type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' },
						        	            { type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' },
						        	            { type: 'separator' },
						        	            { type: 'push', label: 'Subscript', value: 'subscript'},
						        	            { type: 'push', label: 'Superscript', value: 'superscript' },
						        	            { type: 'separator' },
						        	            { type: 'color', label: 'Barva izbranega texta', value: 'forecolor' },
						        	            { type: 'color', label: 'Barva ozadja izbranega texta', value: 'backcolor' },
						        	            { type: 'separator' },
						        	            { type: 'push', label: 'Odstranni urejanje', value: 'removeformat' },
						        	            ]
						          },
						          { type: 'separator' },
						          { group: 'alignment',
						        	  buttons: [
						        	            { type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },
						        	            { type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },
						        	            { type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' },
						        	            ]
						          },
						          { type: 'separator' },
						          { group: 'indentlist',
						        	  buttons: [
						        	            { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
						        	            { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }
						        	            ]
						          },
						          { type: 'separator' },
						          { group: 'insertitem',
						        	  buttons: [
						        	            { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink'},
						        	            ]
						          }
						          ]
					}
					});
					MHT.forms.editors.commentEditor.render();
				
					// Vstavim layer pred submitom, da lahko še predprocess naredim
					$(':button').live('click', function(){
						var status = $(this).attr('data-item-status');
						
						$form.find('input[name=status]').val(status);
						
						$form.submit();
					});

					// ### Validacija in submit
					var validator = $form.validate({ 
						rules: {
							headline: { 
								required  : true,
								minlength : 10,
								maxlength : 70
							}
						}, 
						messages: {
								headline: { 
									required : jQuery.format("Naslov ponudbe je obvezen podatek"),
									minlength: jQuery.format("Naslov naj vsebuje vsaj {0} znakov"),
									maxlength: jQuery.format("Naslov naj vsebuje največ {0} znakov")
								}
						}
					}); 
						
					$form.find('.ajaxsubmit').bind('click', function()
					{
						$form.validate();
							
						var $click_el = $(this);
							
						// // Vsaj ena lokacija mora biti izbrana (in en okraj)
						if(!isDistrictSelected()) {
							return false;
						}

                        if(MHT.forms.editors.contentEditor != undefined) {
							MHT.forms.editors.contentEditor.saveHTML();	// Shranim vsebino obrazca
						}

						if(MHT.forms.editors.commentEditor != undefined) {
							MHT.forms.editors.commentEditor.saveHTML();	// Shranim vsebino obrazca
						}
							
						var query = {
							//# Obvezni podatki v vseh primerih
							'store_slug': 			   	  storeSlug,											// NOT NULL
							'headline_description':    	  $form.find('input#headline_description').val(),		// NOT NULL
							'date_start_ts': 			  $form.find('input#date_start_ts').val(),				// NOT NULL
							'date_end_ts': 			   	  $form.find('input#date_end_ts').val(),				// NOT NULL (tale se mora nastavit, ko prvega zberem glede na Brand)
									
							'status': 				      $click_el.attr('data-item-status'),
							'mp_id': 				      $form.find('input#mp_id').val(),
                            'districtslug':               $form.find('#districtslug').val(),

                            // TODO FIXAJ tule, naj ima dinamične procente, ne ?!?!?!?!?!
                            'offer_value_merchant':      '0',
                            'offer_value_mh':            '0',

							//# Neobvezni podatki (oz. za brand)
							'headline': 				 $form.find('input#headline').val(),								// NOT NULL
							'original_price': 			 $form.find('input[name="price_original"]').val(),	// DEFAULT
                            'tipping_point_one':            $form.find('input[name="tipping_point_one"]').val(),
                            'tipping_point_one_giveaway':   $form.find('input[name="tipping_point_one_giveaway"]').val(),
                            'tipping_point_two':            $form.find('input[name="tipping_point_two"]').val(),
                            'tipping_point_two_giveaway':   $form.find('input[name="tipping_point_two_giveaway"]').val(),
                            'tipping_point_three':          $form.find('input[name="tipping_point_three"]').val(),
                            'tipping_point_three_giveaway': $form.find('input[name="tipping_point_three_giveaway"]').val(),
                            'pitch_statement':              $form.find('textarea[name="pitch_statement"]').val()
						};
							
                        if(MHT.forms.editors.contentEditor != undefined) {
							query.description = encodeURIComponent(MHT.forms.editors.contentEditor.get('element').value);
						}
						else {
							query.description = $form.find('textarea#deal_description').val();
						}
							
						/* sestavim še slike */
						var pics = $form.find('#fileupload td.name a');
						$.each(pics, function(i, v) {
							query['multimedia['+i+']'] = $(v).text();
						});
						
						if(MHT.forms.editors.commentEditor != undefined) { 
							query.msgpost = encodeURIComponent(MHT.forms.editors.commentEditor.get('element').value); 
						}
						else {
							query.msgpost = $form.find('textarea#deal_description').val();
						}
							
						$('.appended').remove();
							
						var $buttonWrap = $form.find('.button_wrap');
						$buttonWrap.block({ 
							message: '<div><span style="padding: 0 20px 0 0; background: url(/public/images/spinner.gif) no-repeat 100% 0">Procesiram zahtevo...</span></div>', 
							css: { 
								border	 : '0px solid #a00',
								margin	 : '0px 0px 0px 0px',
								padding	 : '8px 14px 8px 14px',
								width 	 : '200px',
								fontSize : '1.2em'
							} 
						});
							
						var jqxhr = $.ajax({ 
							type: 	'POST',
                            dataType: 'json',
							url: 	"ampera/update-micropon-status",
							data:  	query
						});
							
						jqxhr.success(function(data) 
						{ 
							$buttonWrap.unblock();
									
							if(data.notice != undefined && data.notice.msgType == 'success')
							{
								//window.location = gotoURL;
								$form.find('#success-placeholder').html(data.notice.msg).fadeIn('fast');
									
								// Ugasnem popin in sfejdam element v tabeli
								$form.parent().parent().find('a.xc_popnormal').click();
								$.scrollTo(0, 500);
									
									
								// TODO: Tule je posebna akcija, ker je MP nov - posebej obdelaj, samo stanje spremeni!
								$('#intable_micropon_'+ query['mp_id']).css({'background':'#89B556', 'color':'#fff'}).fadeOut('slow');
								MHT.utils.flashMessanger(data.notice.msgType, data.notice.msg);
									
							} 
							else if(data.notice != undefined && data.notice.msgType == 'error')
							{
								$form.find('#error-placeholder').html(data.notice.msg).fadeIn('fast');
							} 
							else if( data.notice == undefined ) 
							{
								$form.find('#error-placeholder').html('Opala, tehničen škrat - očitno :| Refresh(osvežtev) strani je obvezna za pravilno delovnaje.').fadeIn('fast');
							}
						}).error(function() { 
							alert("error"); 
						}).complete(function() {});
							
							
						return false;
					});
				});
			},
			/**
			 * WWWW: Prikaz obrazca
			 */
			showOfferEditForm_dailydeal: function(storeSlug, itemID, brandID)
			{
				$.get('store/micropon?store_slug='+storeSlug+'&micropon_id='+itemID, function(data, textStatus, XMLHttpRequest){
					
					var micropon = data.micropons[0].micropon;
					
					/* Nafilam Opombe */
					var drobnitiskItems = '';
					if(micropon.coupon_highlights != '')
					{
						var arguments = micropon.coupon_highlights.split('|');
						
						$(arguments).each(function(i, v){
							drobnitiskItems += '<li>'+v+'<input type="hidden" name="notes[]" value="'+v+'"><a class="remove xc_remove_oitem">Odstrani</a></li>';
						});
					}
					
					/* Nafilam Argumente */
					var argumentsItems = '';
					if(micropon.coupon_arguments != '')
					{
						var arguments = micropon.coupon_arguments.split('|');
						
						$(arguments).each(function(i, v){
							argumentsItems += '<li>'+v+'<input type="hidden" name="arguments[]" value="'+v+'"><a class="remove xc_remove_oitem">Odstrani</a></li>';
						});
					}
					
					// Zbildam obrazec
					var formAction				 = 'ampera/update-micropon-status';	// ciljni URL obrazca
					var headline	   			 = '';	// Naslov ponudbe
					var maxQuantityPerUserSelect = '';
					var addOpombeBtn 			 = '';	// Možnost dodajanja opomb (input)
					var addArgumentsBtn 		 = '';	// Možnost dodajanja Argumentov (input)
					var buttons      			 = '';	// Gumbi za upravljanje obrazca
					var picControls  			 = '';	// Linka za upravljanje slike micropona
					var isDisabled   			 = '';	// Stanje Inputov (če ne more user urejat, so onemogočeni)
					var disabledCSS  			 = '';	// CSS za dizejblan element (nekako je tole hack)
					var commentFiled			 = '';	// Določene akcije nucajo kometar pred izvršitvijo!
					
					var brandsSelection			 = '';
					var xhtml					 = '';
					
					// status: Active picture controls
					picControls = 
						'<div class="pic_controls">'
						+'  :: <a class="" id="dealpic_upload">Naloží svojo sliko</a>&nbsp;&nbsp;&nbsp;'
						+'  :: <a class="" id="xc_reset_dealpic">Zbríší trenutno slíko</a>'
						+'</div>';
					
					var form = 
						'<form action="'+formAction+'" method="post" id="newOfferRequest_dailydeal">'
						+'	<input type="hidden" name="brandid" value="2" />'
						+'	<div class="box profile-settings store-profile-settings" id="deal_registration">'
						+'		<div id="profile-error-placeholder"></div>'
						
						+'		<div class="group_desc" style="margin-top: 8px;">'
					+'			<h2>Izbira okraja dnevne ponudbe in lokacij prevzema oz. unovčitve micropona</h2>'
					+'		</div>'
					+'		<ol>'
					+'  		<li>'
					+'  			<label for="loc-selector"  style="padding-top:0px;">Lokacije unovčitve</label>'
					+'				<ul class="mht-locations" id="loc-selector" style="margin-top:8px; margin-left: 144px;">'
					+'				</ul>'
					+'				<div class="clearfix"></div>'
					+'  		</li>'
					+'  		<li style="margin-top:0px;">'
					+'  			<label for="loc-selector"></label>'
					+'				<ol style="margin-top:0px;">'
					+'					<li style="text-align:left;">'
					+'  					<strong><a rel="#new-location" style="font-size:12px">+ Dodaj lokacijo</a></strong>'
					+'					</li>'
					+'				</ol>'
					+'				<div class="clearfix"></div>'
					+'				<span style="display:block; color:red; float:none; margin-left:0px; font-weight:bold;" class="err-location"></span>'	
					+'  		</li>'

					+'  		<li>'
					+'  			<label for="district-selector"  style="padding-top:0px;">Okraj akcije</label>'
					+'				<ul class="mht-districts" id="district-selector" style="margin-top:8px; margin-left: 144px;">'
					+'					<li id="district_empty" class="data" style="text-align:left; float:none; padding-top:2px; list-style-type:none;">'
					+'						<strong style="font-size:12px;">( najprej dodajte in izberite lokacije unovčitve, nato lahko izberete okraj )</strong>'
					+'					</li>'
					+'					<li id="district_8" class="data district" style="display:none; text-align:left; float:none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="8" data-item-slug="koprski-okraj"><span style="margin-bottom:0px;"></span>Koprski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_7" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="7" data-item-slug="novogoriski-okraj"><span style="margin-bottom:0px;"></span>Novogoriški okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_3" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="3" data-item-slug="ljubljanski-okraj"><span style="margin-bottom:0px;"></span>Ljubljanski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_6" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="6" data-item-slug="kranjski-okraj"><span style="margin-bottom:0px;"></span>Kranjski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_5" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="5" data-item-slug="celjski-okraj"><span style="margin-bottom:0px;"></span>Celjski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_9" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="9" data-item-slug="novomeski-okraj"><span style="margin-bottom:0px;"></span>Novomeški okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_4" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="4" data-item-slug="mariborski-okraj"><span style="margin-bottom:0px;"></span>Mariborski okraj</a></strong>'
					+'					</li>'
					+'					<li id="district_10" class="data district" style="display:none; text-align:left; float: none; padding-top:2px;">'
					+'						<strong><a style="font-size:12px;" data-item-id="10" data-item-slug="murskosoboski-okraj"><span style="margin-bottom:0px;"></span>Murskosoboški okraj</a></strong>'
					+'					</li>'
					+'				</ul>'
					+'				<input type="hidden" name="districtslug" id="districtslug" value="'+ micropon.districtslug +'">'
					+'				<div class="clearfix"></div>'
					+'				<span style="display:block; color:red; float:none; margin-left:0px; font-weight:bold;" class="err-district"></span>'	
					+'  		</li>'
					
					+'		</ol>'
					+'		<div class="clearfix"></div>'
					
						
						+'		<div class="group_desc">'
						+'			<h2>Zippy naslov ponudbe</h2>'
						+'			<p>Naslov mora pritegnit uporabnika takoj ko ga zagleda!</p>'						
						+'		</div>'
						+'		<div class="min-reached" style="display:none; font-size:1.2em; color:red; position:absolute; top:180px; right:100px; width:330px; padding:0 10px 0 10px;">Cena, ki jo stranka plača mora biti vsaj 1.5eur. To dosežete tako, da povišate redno ceno (namesto ene kave, ponudite dve) ali pa zmanjšate popust.</div>'
						+'		<ol>'
						// Headline description
						+'  		<li class="name">'
						+'  			<label for="headline_description">Trgovec ponuja</label>'
						+'  			<input name="headline_description" class="disabled" id="headline_description" autocomplete="off" type="text" value="'+micropon.description_headline+'" disabled="disabled">'
						+'				<span class="field_desc">Na podlagi zgornjega naslova, vpiši ta zippy spodnji naslov, kot bo viden na javnem utripu ponudbe</span>'
						+'  		</li>'
						+'  		<li class="name" style="margin-bottom:20px;">'
						+'  			<label for="headline" style="padding-top:0px;"><strong class="asteric">*</strong> Naslov ponudbe</label>'
						+'  			<input name="headline" id="headline" autocomplete="off" type="text" value="'+micropon.headline+'">'
						+'  		</li>'
						+'  		<li class="name" style="margin-bottom:20px;">'
						+'  			<label for="pitch_statement" style="padding-top:0px;"><strong class="asteric">*</strong> Podnaslov</label>'
						+'  			<input name="pitch_statement" id="pitch_statement" autocomplete="off" type="text" value="'+micropon.pitch_statement+'">'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc">'
						+'			<h2>Določite vrednost Micropon-a in njegov opis</h2>'
						+'			<p>Popust naj bo čimvečji. Stranke bodo bolj verjetno kupile tisti Micropon, ki bo imel večji popust.</p>'						
						+'		</div>'
						+'		<div class="min-reached" style="display:none; font-size:1.2em; color:red; position:absolute; top:180px; right:100px; width:330px; padding:0 10px 0 10px;">Cena, ki jo stranka plača mora biti vsaj 1.5eur. To dosežete tako, da povišate redno ceno (namesto ene kave, ponudite dve) ali pa zmanjšate popust.</div>'
						+'		<ol>'
						+'  		<li class="value">'
						+'  			<label for="price_original"><strong class="asteric">*</strong> Redna cena (v €)</label>'
						+'  			<input name="price_original" id="price_original" autocomplete="off" type="text" value="'+micropon.original_price+'">'
//						+'  			<input name="price_original" id="price_original" autocomplete="off" type="hidden" value="'+micropon.max_discount_min_price+'">'
						+'  		</li>'
						+'  		<li class="value">'
						+'  			<label for="max_discount_percentage"><strong class="asteric">*</strong>Popust (v %)</label>'
						+'  			<input name="max_discount_percentage" id="max_discount_percentage" autocomplete="off" type="text" value="'+(micropon.max_discount_percentage * 100)+'">'
						+'  		</li>'
						+'  		<li class="value">'
						+'  			<label for="buy_max_quantity"><strong class="asteric">*</strong> Max. lahko proda</label>'
						+'  			<input name="buy_max_quantity" id="buy_max_quantity" autocomplete="off" type="text" value="'+micropon.max_quantity+'"> Microponov'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Slika ponudbe</h2>'
						+'			<p>Sliko je potrebno obdelat in jo napimpat tako, da ti oči ven padejo ;)</p>'
						+'		</div>'
						+'		<ol>'
                        +'  		<li class="name" style="margin-bottom:20px;">'
						+'  			<label for="merchant_pics" style="padding-top:0px;">Slikovni materjal</label>'
						+'				<ul id="userFiles" style="margin-left:160px; padding-top:2px;"><li>(Organizacija ni priložila nobene slike)</li></ul>'
						+'  			<span class="field_desc">Pa tale upload slik je potrebno na tabeli še ločeno dodat</span>'
						+'  		</li>'

						+'  		<li>'
						+'  			<label for="avatar"><strong class="asteric" style="font-size: 13px;">*</strong> Slike kampanje</label>'
					 	+'				<div id="fileupload" style="width: 444px; margin-left: 144px;">'
						// +'				<form action="/account/dealpic-upload?store_slug='+ storeSlug+'" method="POST" enctype="multipart/form-data"> '
						+'					<div class="fileupload-buttonbar"> '
						+' 						<label class="fileinput-button"> '
						+'							<span>Dodaj slike...</span> '
              			+' 							<input type="file" name="files[]" multiple> '
          				+'						</label>'
			          	// +'					<button type="submit" class="start">Start upload</button> '
			          	// +'					<button type="reset" class="cancel">Cancel upload</button> '
			         	// +'					<button type="button" class="delete">Izbriši vse datoteke</button> '
			          	+'						<div class="clearfix"></div>'
			          	+'					</div> '
  						// +'				</form>'
 						+'					<div class="fileupload-content">'
     					+' 						<table class="files"></table> '
//    					+' 						<div class="fileupload-progressbar"></div> '
 						+' 					</div> '
						+'				</div> '
						+'				<script id="template-upload" type="text/x-jquery-tmpl"> '
   						+'					<tr class="template-upload{{if error}} ui-state-error{{/if}}">'
    					+'						<td class="preview"></td>'
     					+'						<td class="name">${name}</td>'
     					+' 						<td class="size">${sizef}</td>'
     					+' 						{{if error}}'
      					+'						<td class="error" colspan="2">Napaka:'
        				+'							{{if error === \'maxFileSize\'}}Prevelika datoteka'
         				+'							{{else error === \'minFileSize\'}}Premajhna datoteka'
           				+'							{{else error === \'acceptFileTypes\'}}Dovoljene so samo slike'
             			+'							{{else error === \'maxNumberOfFiles\'}}Preveč datotek'
              			+'							{{else}}${error}'
               			+' 						{{/if}}'
            			+'						</td>'
       					+'						{{else}}'
           	 			+'						<td class="progress"><div></div></td>'
           				+'						<td class="start"><button>Start</button></td>'
       					+'						{{/if}}'
       					+'						<td class="cancel"><button>Cancel</button></td>'
  						+' 					</tr>'
						+'				</script> '
						+'				<script id="template-download" type="text/x-jquery-tmpl"> '
    					+'					<tr class="template-download{{if error}} ui-state-error{{/if}}">'
       					+'						{{if error}}'
          				+'						<td></td>'
          				+'	 					<td class="name">${name}</td>'
          				+'						<td class="size">${sizef}</td>'
          				+' 						<td class="error" colspan="2">Napaka:'
             			+' 							{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)'
             			+'							{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)'
             			+'							{{else error === 3}}File was only partially uploaded'
              			+'							{{else error === 4}}No File was uploaded'
             			+'							{{else error === 5}}Missing a temporary folder'
             			+' 							{{else error === 6}}Failed to write file to disk'
             		 	+'							{{else error === 7}}File upload stopped by extension'
             			+' 							{{else error === \'maxFileSize\'}}File is too big'
             			+' 							{{else error === \'minFileSize\'}}File is too small'
              			+' 							{{else error === \'acceptFileTypes\'}}Filetype not allowed'
              			+' 							{{else error === \'maxNumberOfFiles\'}}Max number of files exceeded'
             			+'  						{{else error === \'uploadedBytes\'}}Uploaded bytes exceed file size'
             			+'  						{{else error === \'emptyResult\'}}Empty file upload result'
             			+' 							{{else}}${error}'
            			+'  						{{/if}}'
         				+'						</td>'
      					+'						{{else}}'
          				+' 						<td class="preview">'
              			+' 							{{if thumbnail_url}}'
              			+'							<a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>'
             			+' 							{{/if}}'
           				+'						</td>'
         				+' 						<td class="name">'
         				+'							<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>'
         				+' 						</td>'
         				+'						<td class="size">${sizef}</td>'
          				+'						<td colspan="2"></td>'
       					+'						{{/if}}'
       					+' 						<td class="delete">'
            			+'							<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>'
       					+' 						</td>'
  						+' 					</tr>'
						+'				</script> '
						+'				<span class="field_desc">Slika naj čimbolje zajame vaše podjejte oz. produkt, ki ga ponujate</span>'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Sestavi opis ponudbe</h2>'
						+'			<p>Nek superkul spremljajoči/opisen text, da se uporabniku zaresejo kolen ;)</p>'
						+'		</div>'
						+'		<ol>'
						+'  		<li class="dela_desc" style="margin-top: 8px;">'
						+'  			<label for="description_description"><strong class="asteric">*</strong> Trgovčev opis</label>'
						+'  			<div class="writeup" style="border-bottom:1px solid gray; border-top:1px solid gray; font-size:1.1em; margin-left:144px; padding:6px;">'+decodeURIComponent(micropon.description_description)+'</div>'
						+'				<span class="field_desc">Iz zgornjega trgovčevega opisa, sestavi opis ko ga želiš imeti na javnem utripu ponudbe</span>'
						+'  		</li>'
						+'  		<li class="dela_desc" style="margin-top: 8px;">'
						+'  			<label for="deal_description"><strong class="asteric">*</strong> Opis ponudbe</label>'
						+'  			<textarea name="deal_description" id="deal_description">'+decodeURIComponent(micropon.description)+'</textarea>'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Pogoji in argumenti ponudbe</h2>'
						+'			<p>Preglej pogoje in argumente. Po potrebi dodaj naše ali pokliči trgovca in preveri</p>'
						+'		</div>'
						+'		<ol>'
						+'  		<li>'
						+'  			<label for="buy_max_quantity_per_user">Opombe/Drobni tisk</label>'
						+'				<ul class="mht-checkbox vertical">'
						+'					<li class="hideField" id="opombe_li">'
						+'						<span class="hidden-input">'
						+'							<ul id="opombe" class="opombe">'
						+								drobnitiskItems
						+'							</ul>'
						+'							<input type="text" id="oitem-val" style="width:360px; margin-top:0px;margin-left:0px;"> <input type="submit" id="add-oitem" data-item-field="notes" class="normal-button large" style="padding: 5px 9px; height: 30px; vertical-align: bottom;" value="Dodaj">'
						+'							<span class="field_desc hidden-input" style="margin-left:0px;">Če kaj manjka ali vidiš da bo uporabnikom nejasno dodaj (kontraktiraj trgovca če ne veš točnega pogoja)</span>'
						+'						</span>'
						+'					</li>'
						+'				</ul>'
						+'				<div class="clearfix"></div>'
						+'  		</li>'
						+'  		<li>'
						+'  			<label for="buy_max_quantity_per_user">Argumenti za nakup</label>'
						+'				<ul class="mht-checkbox vertical">'
						+'					<li class="hideField" id="argumenti_li">'
						+'						<span class="hidden-input">'
						+'							<ul id="opombe" class="argumenti">'
						+								argumentsItems
						+'							</ul>'
						+'							<input type="text" id="oitem-val" style="width:360px; margin-top:0px;margin-left:0px;"> <input type="submit" id="add-oitem" data-item-field="arguments" class="normal-button large" style="padding: 5px 9px; height: 30px; vertical-align: bottom;" value="Dodaj">'
						+'						</span>'
						+'					</li>'
						+'				</ul>'
						+'				<div class="clearfix"></div>'
						+'  		</li>'
						+'		</ol>'
						+'		<div class="clearfix"></div>'
						+'		<div class="group_desc" style="margin-top: 18px;">'
						+'			<h2>Določite urnik prodaje in unovčitev Micropona</h2>'
						+'		</div>'
						+'		<ol>'
						+'  		<li class="value" style="margin-top:34px;">'
						+'  			<label for="date_start"><strong class="asteric">*</strong>Začetek ponudbe</label>'
						+'				<div class="date_wrap">'
						+'					<span>OD: </span> <input name="date_start" id="date_start" class="date-pick" type="text" value="'+(new Date(micropon.date_start * 1000)).asString()+'"><span id="date_start_spinner" style="display:none; background:url(/public/images/spinner.gif) no-repeat 0 -4px; padding:0 16px 0 0;"></span>'
						+'					<input type="hidden" id="date_start_ts" value="'+(micropon.date_start * 1000)+'">'
						+'					<input type="hidden" id="date_end_ts" value="'+(micropon.date_end * 1000)+'">   '
						+'				</div>'
						+'				<span class="field_desc clearfix" style="width:auto;">Kdaj želite, da se ponudba pojavi na microhint.com, kjer jo lahko uporabniki kupijo?</span>'
						+'  		</li>'
						+'  		<li class="value">'
						+'  			<label for="date_redeem_from"><strong class="asteric">*</strong>Unovčitev</label>'
						+'				<div class="date_wrap">'
						+'					<span>OD: </span> <input name="date_redeem_from" id="date_redeem_from" class="date-pick" type="text" value="'+(new Date(micropon.date_redeem_from * 1000)).asString()+'">'
						+'					<input type="hidden" id="date_redeem_from_ts" value="'+(micropon.date_redeem_from * 1000)+'">'
						+'					<span>DO: </span> <input name="date_voucher_expiration" id="date_voucher_expiration" class="date-pick" type="text" value="'+(new Date(micropon.date_voucher_expiration * 1000)).asString()+'">'
						+'					<input type="hidden" id="date_voucher_expiration_ts" value="'+(micropon.date_voucher_expiration * 1000)+'">   '
						+'				</div>'
						+'				<span class="field_desc clearfix" style="width:auto;">Kdaj lahko stranka pride k vam s kupljenim Microponom in prevzame izdelek oz. opravi storitev?</span>'
						+'  		</li>'
						+'  	</ol>'
						+'		<div class="clearfix"></div>'
						+'	</div>'
						
						+'	<div id="micropon-comments"></div>'
						
						+'	<div class="box store-profile-settings button_wrap" style="padding:0px 12px 0px 12px; margin-bottom:6px; background:#fff;">'
						+'		<a href="#" id="open-reject-form" style="font-size:13px; display:block; text-align:center;">Želiš zavreči ponudbo ali vpisati komentar?</a>'
						+'	</div>'
						
						+'	<div id="msgpost-form-box" class="box store-profile-settings button_wrap" style="padding:4px 12px 14px 12px; margin-bottom:14px; background:#bdc4a8; display:none;">'
						+'		<label for="msgpost" style="float:none; width:430px; text-align:left;">Vpiši vzrok za zavrnitev ponudbe</label>'
						+'      <div class="body clearfix">'
						+'			<textarea name="msgpost" id="msgpost" cols="97" rows="14" style="width: 656px;"></textarea>'
						+'		</div>'
						+'	</div>'
						
						+'	<div class="box store-profile-settings button_wrap" style="padding:14px 0 14px 10px; margin-bottom:14px;">'
						+'		<div id="error-placeholder" class="error" style="font-size:1.2em; text-align:center; margin:0 0 8px 0px; display:none;"></div>'
						+'		<span class="store_finish" style="margin:0 44px 0 0px;"><input type="button" style="width: 230px;" class="normal-button large ajaxsubmit" value="Pošlji ponudbo v predogled" data-item-status="review" data-item-id="'+micropon.id+'" title="Ko je ponudba pripravljena, ta status obvesti trgovca naj pregleda ponudbo. Ko jo sprejme je postopek priprave ponudbe zaključen."></span>'
						+'		<span class="store_finish" style="margin:0 10px 0 0;"><input type="button" style="width: 130px;" class="normal-button large ajaxsubmit" value="Shrani osnutek " data-item-status="draft" data-item-id="'+micropon.id+'" title="Osnutek ponudbe shraniš in jo urejaš kasneje naprej. Trgovec ne dobi nobenega sporočila"></span>'
						+'		<span class="store_finish" style="margin:0 10px 0 0;"><input type="button" style="width: 100px;" class="normal-button large ajaxsubmit" value="Runtime Fix" data-item-status="runtime-update" data-item-id="'+micropon.id+'" title="Update ponudbe z novimi podatki - trenutni status ostane nespremenjen.""></span>'
						+'		<span class="store_finish" style="margin:0 0 0 0;"><input type="button" id="reject-btn" disabled="disabled" style="width: 100px;" class="normal-button large ajaxsubmit" value="Zavrzi" data-item-status="rejected" data-item-id="'+micropon.id+'" title="Ponudbo zavržeš - trgovec dobi obvestilo o zavrnjeni ponudbi"></span>'
						+'	</div>'
						
						
						+'	<input type="hidden" name="status" id="status" />'
						+'	<input type="hidden" name="mp_id" id="mp_id" value="'+itemID+'" />'
						+'</form>'
						+'';
					
					$('.mainContentPlaceHolder').replaceWith(form);
					
					var $form = $('form#newOfferRequest_dailydeal');
				
                    /*** FILEUPLOAD za Skrnika ***/

					// Initialize the jQuery File Upload widget:
				    $form.find('#fileupload').fileupload({
					  	autoUpload: true,
					  	url: '/account/dealpic-upload?store_slug='+ storeSlug,
					}).bind('fileuploaddestroy', function (e, data) { return false; })
					  .bind('fileuploadfail', function (e, data) { console.log('error'); return false; });

					if(micropon.multimedia != null)
					{
						var files = [];
						var fileName = '';
						var hostName = window.location.host;

						var userFilesXhtml = '';

						$.each(micropon.multimedia, function(i, v){

							fileName = v['file_name'];

							if(v['uploader'] == '1') { userFilesXhtml += '<li><a href="/tmp/mppics/'+fileName+'" target="_blank">'+fileName+' (download)</a></li>'; }
							else {
								files.push(
									{
										"name"			:fileName,
										// "size"			:902604,
										"url"			:'\/tmp\/mppics\/'+fileName,
										"thumbnail_url"	:'\/tmp\/mppics\/thumbnails\/'+fileName,
										"delete_url"	:'\/account\/dealpic-upload?store_slug='+storeSlug+'&file='+fileName,
										"delete_type"	:'DELETE'
									}
								);
							}

						});

						if(userFilesXhtml != '') { $('#userFiles').html(userFilesXhtml); }


						// Fizično jih vstavim v file uploader
				        var fu = $('#fileupload').data('fileupload');
				        fu._adjustMaxNumberOfFiles(-files.length);
				        fu._renderDownload(files)
				            .appendTo($('#fileupload .files'))
				            .fadeIn(function () {
				                // Fix for IE7 and lower:
				                $(this).show();
				         	});
					}

				    // Open download dialogs via iframes,
				    // to prevent aborting current uploads:
				    $('#fileupload .files a:not([target^=_blank])').live('click', function (e) {
				        e.preventDefault();
				        $('<iframe style="display:none;"></iframe>')
				            .prop('src', this.href)
				            .appendTo('body');
				    });

					/*** end FILEUPLOAD za Skrnika ***/
					
					// ### Inicializacija elementov
					
//					if( micropon.workflow_status == 'rejected' )
//					{
						// XXX nafilam komentar-je (kaj se je dogajalo)
						$.get('ampera/browse-micropon-creation-comments?count=1&cursor=1&microponID='+ micropon.id, function(data, textStatus, XMLHttpRequest)
						{
							var comment = '';
							var avatar	= '';
							
							if(undefined != data)
							{
								$(data).each(function(i, v){
//									console.log(v);
									// Zbildaj komentarje
									
									comment += 
										'<div class="post" style="margin:6px 0 0 0px; background:#fff; border-top-left-radius: 6px 6px; border-top-right-radius: 6px 6px; border-bottom-right-radius: 6px 6px; border-bottom-left-radius: 6px 6px;">'
										+'  <div class="comment" style="padding:8px; background: -moz-linear-gradient(top,#FFFCE9 0,#FFF8CC 60px)!important; background: -webkit-gradient(linear,0 0,0 60,from(#FFFCE9),to(#FFF8CC))!important; background: -moz-linear-gradient(top,#FFFCE9 0,#FFF8CC 60px)!important; border: 1px solid #FFE764; -webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0; -webkit-box-shadow: 2px 2px 8px #CCC; -moz-box-shadow: 2px 2px 8px #CCC; box-shadow: 2px 2px 8px #CCC;">'
										+'   <div class="comment_inner">'
										+'      <div class="meta_data">'
										+'        <span class="author" style="font-size:14px;">'+v.nickname+' pravi: </span>'
										+'        <span class="timestamp" style="font-size:12px; color:#666;">'+v.date_created+'</span>'
										+'      </div>'
										+'		<div class="clearfix"></div>'
										+'      <div class="body"><p>'+decodeURIComponent(v.content)+'</p></div>'
										+'      <div class="chrome"></div>'
										+'    </div>'
										+'  </div>'
										+'</div>';
								});
							}
							$form.find('#micropon-comments').before(comment);
						});
//					}

					function isRedemptionLocationsSelected() {
						if ( $form.find('ul.mht-locations li a.checked').length <= 0 ) {
							$form.find('span.err-location').html('<label style="width:304px" class="error">Vsaj ena lokacija unovčitve mora biti izbrana.</label>');
							return false;
						}
						else {
							$form.find('span.err-location').html('');
							return true;
						}
					};
	
					function isDistrictSelected() {
						if ( $form.find('ul#district-selector li a.checked').length <= 0 ) {
							$form.find('span.err-district').html('<label style="width:304px" class="error">Okraj kjer se bo akcija izvedla mora biti izbran</label>');
							return false;
						}
						else {
							$form.find('span.err-district').html('');
							return true;
						}
					};

					// Custom district handling
					$('ul.mht-districts li a').live('click', function(e){
						var $clicked_el = $(this);
						var $ul = $clicked_el.parents('ul');
						$ul.find('li a').removeClass('checked');
						$clicked_el.addClass('checked');
						
						$form.find('input#districtslug').val($clicked_el.attr('data-item-slug'));;
						
						isDistrictSelected();
						
						return false;
					});
					
					function noVisibleDistricts() {
							var no_districts = $form.find('li.district:visible').length;
							
							if(no_districts <= 0) {
								// prikaži privzeteha
								$form.find('#district_empty').slideDown('fast');
							}
							else if(no_districts > 0) {
								// skrij privzetega
								$form.find('#district_empty').slideUp('fast');
							}
					};
					
					// Custom checkbox handling
					$('ul.mht-locations li a').live('click', function(e){
						var $clicked_el = $(this);
						var postalcode = $clicked_el.attr('data-item-postalcode');
						
						noVisibleDistricts();
						
						/*
						 * Če imam še kakšnega odkulkanega, ki je iz izstega okraja ne smem skrit okraja
						 */
						function canHide(min, max) {
							var $locations = $form.find('ul.mht-locations li a.checked');
							var najdenih = $locations.length;
							
							while(najdenih > 0)
							{
								if ( ($($locations[najdenih-1]).attr('data-item-postalcode') >= min && $($locations[najdenih-1]).attr('data-item-postalcode') <= max) ) {
									return false;
								}
								najdenih--;
							}
							return true;
						};
						
						if($clicked_el.hasClass('checked')) 
						{ 
							// Skenslam
							$clicked_el.removeClass('checked'); 
							
							//** Za vsako lokacijo pregledam v katerem okraju je (po poštni št.) in "prikažem ta okraj"
							//		- to je 1. korak
							if( postalcode >= 1000 && postalcode <= 1434 ) {
								if ( canHide(1000, 1434) )  {
									$form.find('#district_3').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_3 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 2000 && postalcode <= 2394 ) {
								if ( canHide(2000, 2394) )  {
									$form.find('#district_4').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_4 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 3000 && postalcode <= 3342 ) {
								if ( canHide(3000, 3342) )  {
									$form.find('#district_5').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_5 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 4000 && postalcode <= 4294 ) {
								if ( canHide(4000, 4294) )  {
									$form.find('#district_6').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_6 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 5000 && postalcode <= 5297 ) {
								if ( canHide(5000, 5297) )  {
									$form.find('#district_7').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_7 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 6000 && postalcode <= 6333 ) {
								if ( canHide(6000, 6333) )  {
									$form.find('#district_8').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_8 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 8000 && postalcode <= 8362 ) {
								if ( canHide(8000, 8362) )  {
									$form.find('#district_9').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_9 a').removeClass('checked'); });
								}
							}
							else if( postalcode >= 9000 && postalcode <= 9265 ) {
								if ( canHide(9000, 9265) )  {
									$form.find('#district_10').slideUp('fast', function(){ noVisibleDistricts(); $form.find('#district_10 a').removeClass('checked'); });
								}
							}
						}
						else 
						{ 
							// Označim
							$clicked_el.addClass('checked'); 
							
							//** Za vsako lokacijo pregledam v katerem okraju je (po poštni št.) in "prikažem ta okraj"
							//		- to je 1. korak
							if( postalcode >= 1000 && postalcode <= 1434 ) {
								$form.find('#district_3').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 2000 && postalcode <= 2394 ) {
								$form.find('#district_4').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 3000 && postalcode <= 3342 ) {
								$form.find('#district_5').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 4000 && postalcode <= 4294 ) {
								$form.find('#district_6').slideDown('fast',	noVisibleDistricts);
							}
							else if( postalcode >= 5000 && postalcode <= 5297 ) {
								$form.find('#district_7').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 6000 && postalcode <= 6333 ) {
								$form.find('#district_8').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 8000 && postalcode <= 8362 ) {
								$form.find('#district_9').slideDown('fast', noVisibleDistricts);
							}
							else if( postalcode >= 9000 && postalcode <= 9265 ) {
								$form.find('#district_10').slideDown('fast', noVisibleDistricts);
							}
						}
						
						isRedemptionLocationsSelected();	// samo preverim če je lokacija izbrana ali ne
						
						return false;
					});
					
					$.get('/store/store-data?store_slug='+ storeSlug, function(data, textStatus, XMLHttpRequest) 
					{
						
						var store = data.stores[0].store;
						
						var selectedLocatoins = [];
						$.each(micropon.locations.locations, function(i, v){
							selectedLocatoins.push(v.location.id);
						});
					
						/* Lokacije za prevzem unovčitev ponudbe */
						var companyLocations = [];
						var xhtmlItems = '';
						if( store.store_locations != undefined )
						{
							$.each(store.store_locations.locations, function(i, v)
							{
								companyLocations.push(v.location.id);
								checked = '';	// reset before reuse
								
								if( MHT.utils.inArray(selectedLocatoins, '', v.location.id) ) {
									checked = 'checked';
								}
								
								xhtmlItems +=  '<li class="data" data-item-address="'+ v.location.street +' '+ v.location.street_number +'" data-item-storelocation-phone="'+ v.location.storeLocation.phone +'" data-item-storelocation-name="'+ v.location.storeLocation.name +'" data-item-city="'+ v.location.city +'" data-item-googleaddress="'+ v.location.google_address +'" data-item-lat="'+ v.location.lat +'" data-item-long="'+ v.location.long +'" data-item-postalcode="'+ v.location.postal_code +'" data-item-street="'+ v.location.street +'" data-item-streetnumber="'+ v.location.street_number +'" style="text-align:left; float: none; padding-top:2px;">'
								+'	<strong><a class="'+checked+'" style="font-size:12px;" data-item-postalcode="'+ v.location.postal_code +'"><span style="margin-bottom:0px;"></span>'+ v.location.street +' '+ v.location.street_number +', '+ v.location.postal_code +' '+ v.location.city +'</a></strong>'
								+'</li>'
								+'';
							});
						}
						else 
						{
							xhtmlItems = '<div style="margin-bottom: 4px;">( Nobene lokacije še nimate določene )</div>';
						}
						
						// odam še že označene lokacije ponudbe
						$.each(micropon.locations.locations, function(i, v)
						{
							if( MHT.utils.inArray(companyLocations, '', v.location.id) <= 0 ) {
								xhtmlItems +=  '<li class="data" data-item-address="'+ v.location.street +' '+ v.location.street_number +'" data-item-storelocation-phone="'+ v.location.storeLocation.phone +'" data-item-storelocation-name="'+ v.location.storeLocation.name +'" data-item-city="'+ v.location.city +'" data-item-googleaddress="'+ v.location.google_address +'" data-item-lat="'+ v.location.lat +'" data-item-long="'+ v.location.long +'" data-item-postalcode="'+ v.location.postal_code +'" data-item-street="'+ v.location.street +'" data-item-streetnumber="'+ v.location.street_number +'" style="text-align:left; float: none;">'
								+'	<strong><a class="checked"><span></span>'+ v.location.street +' '+ v.location.street_number +', '+ v.location.postal_code +' '+ v.location.city +'</a></strong>'
								+'</li>';
							}
						});
						$form.find('ul#loc-selector').html(xhtmlItems);
						
						$form.find('li.district a').each(function(i,v){
							$v = $(v);
							if($v.attr('data-item-slug') == micropon.districtslug) {
								$form.find('#'+ $v.parent().parent().attr('id') +' a').addClass('checked');
								$form.find('#'+ $v.parent().parent().attr('id')).show('fast', noVisibleDistricts);
							}
						});
						
						
						$form.find('ul#loc-selector').html(xhtmlItems);
								
								/** Izbirnik lokacij **/
								$form.find('a[rel="#new-location"]').live('click', function(e){
									
									var $clicked_el = $(this);				// <a> link for following
									
									var $formA = $('#new-location > form');
									
									$clicked_el.overlay({
										// some mask tweaks suitable for modal dialogs
										mask: {
										color: '#333',
										loadSpeed: 200,
										opacity: 0.4
										},
										closeOnClick: false,
										onBeforeLoad: function(e){
											
											// Empty previously entered data
											$formA.find(':input').not(':button, :submit').val('');
											
											// Init validator
											var validator = $formA.validate({ 
										        rules: { 
													location_custom_name: { 
												    	minlength: 4,
												    	maxlength: 100
												    },
												    street_name: { 
												    	required: true,
												    	minlength: 6,	
												    	maxlength: 50		
												    }, 
												    city_name: { 
												    	required: true,
												    	minlength: 6,	
												    	maxlength: 40		
												    }, 
												    postalcode_number: { 
												    	required: true,
												    	digits: true,
												    	minlength: 4,	
												    	maxlength: 4	
												    }, 
												    store_phone: { 
												    	minlength: 6,		// email
												    	maxlength: 15		// landphone
												    }
										        }, 
										        messages: { 
										        	location_custom_name: { 
											        	minlength: jQuery.format("Vnesi vsaj {0} znakov"), 
											        	maxlength: jQuery.format("Vnesi največ {0} znakov")
											        },
											        street_name: { 
											        	required: "Ime ulice je obvezen podatek" ,
											        	minlength: jQuery.format("Vnesi vsaj {0} znakov"), 
											        	maxlength: jQuery.format("Vnesi največ {0} znakov")
											        },
											        city_name: { 
											        	required: "Ime mesta ali vasi je obvezen podatek" ,
											        	minlength: jQuery.format("Vnesi vsaj {0} znakov"), 
											        	maxlength: jQuery.format("Vnesi največ {0} znakov")
											        },
											        postalcode_number: { 
											        	required: "Ime mesta ali vasi je obvezen podatek" ,
											        	digits: "Samo številka pošte je dovoljena, brez imena" ,
											        	minlength: jQuery.format("Poštna številka ima {0} številke"), 
											        	maxlength: jQuery.format("Poštna številka ima {0} številke")
											        },
											        store_phone: { 
											        	minlength: jQuery.format("Vnesi vsaj {0} znakov"), 
											        	maxlength: jQuery.format("Vnesi največ {0} znakov")
											        }
										        },
										        // specifying a submitHandler prevents the default submit, good for the demo 
										        submitHandler: function(form) { 
										        	
										        	// Try to pinpoint store address
										        	var location = MHT.utils.geocodeLocation( $(form).find('input[name="street_name"]').val(), $(form).find('input[name="postalcode_number"]').val() );
										        	
										        	var locationCustomName = $(form).find('input[name="location_custom_name"]').val();
										        	var locationCustomPhone = $(form).find('input[name="store_phone"]').val();
										        	
										        	setTimeout(function() {
										        		$('#loc-selector').append(''
										        				+'<li class="data" data-item-address="'+ location.address +'" data-item-city="'+ location.city +'" data-item-googleaddress="'+ location.google_address +'" data-item-lat="'+ location.lat +'" data-item-long="'+ location.long +'" data-item-postalCode="'+ location.postalCode +'" data-item-street="'+ location.street +'" data-item-streetnumber="'+ location.streetNumber +'" data-item-storelocation-phone="'+ locationCustomPhone +'" data-item-storelocation-name="'+ locationCustomName +'" style="text-align:left;float:none;">'
										        				+'	<strong><a class="checked"><span></span> '+ location.address +', '+ location.postalCode +' '+ $(form).find('input[name="city_name"]').val() +'</a> <a class="xc_remove_item">(odstrani)</a></strong>'
										        				+'</li>'
										        		);
										        	}, 1000);
										        	
										        	// Closing overlay
										        	$clicked_el.data('overlay').close();
										        	return false;
										        }, 
										        success: function(label) {} 
										    });
										},
										onLoad: function(e) { 
											$formA.find(':input').eq(0).focus();
										},
										onClose: function(e){ },
										load: true
									});
									return false;
								});
							});
					
					// DATE settings
					$form.find('#date_start').datePicker({
						clickInput:false,
						createButton:false,
						//startDate: (new Date()).addDays(5).asString(),
						endDate: (new Date()).addMonths(4).asString()
					}).bind(
							'click',
							function()
							{
								var $o_dp 	 = $(this);
								
								$form.find('#date_start_spinner').fadeIn('fast');
								$o_dp.dpSetDisabled(true);
								
								var districtslug = $form.find('#districtslug').val();
							
								$.get('/store/get-reserved-dailydeal-dates?districtslug='+ districtslug, function(data){

									$o_dp.dpSetRenderCallback(function($td, thisDate, month, year)
		
