/*
 *
 */
/*
 * $Id$
 */
$(document).ready(function(){
  get_status();
  description_tooltip();
  bind_ajax_file_upload();
  // replaced with setting pn:default search_field_events();
  pn_submenu();
  replaceSelectBox();
  //replaceFileUpload();
  globalStatusMessage();
  globalMsg();
  pn_confirmed();
  pn_defaulttext();
  //pn_teaser(0); /* old function to slide home-teaserboxes */
  // new slider on home and magazine
	pn_home_topteaser();
  pn_questionroller();
  object_starrating();
  //pn_ie6buttonFix();
  //filterReplace();
  //pn_editable();
  pn_feedback();
  //  pn_effects();
  //  pntextresize();
  pn_loginfield();
  pn_jsCheck();
  pn_usermeeting();
  // server_check();
  poll();
  infobox();
  //plusCheck();
  profile_admin();
  like_object();
  dont_like_object();
  feed_showsimilar();
  global_search();
  
  $('#disturberBox').click(function() {
    location.href = $(this).attr('pn:href');
    return false;
  });
  $('.home-banner').click(function() {
    location.href = $(this).attr('pn:href');
    return false;
  });
  $('.top-sliderbar').click(function() {
    location.href = $(this).attr('pn:href');
    return false;
  });
  $('#skincancer_teaser').click(function(){
    location.href="http://adserver.adtech.de/?adlink%7C3.0%7C247%7C1628510%7C1%7C16%7CAdId=5398773;BnId=2"
  });
});

/**
 * Check for and display status messages which should not be cached even for anonymous users
 */
function get_status() {
  $.ajax({
    url: '/status',
    success: function(status, textStatus) {
      if (status && status.login) {
        if ($('#feedback').length > 0) {
          $('#feedback .feedintro').html(status.login);
        }
        else {
          $('<div id="feedback"><p class="feedintro">' + status.login + '</p></div>').prependTo('#container');
        }
        
        $('#UserEmail').attr('disabled', 'DISABLED');
        $('#password').attr('disabled', 'DISABLED');
        $('#pwdoverlay').attr('disabled', 'DISABLED');
        
        $('#register-now').css('display', 'none');
      }
    },
    dataType: 'json'
  });
}

function plusCheck() {
  var hname = window.location.hostname;
  //alert(hname.indexOf('plusdevx'));

  if(hname.indexOf('plusdev') != '-1') {
    if (! $('body').hasClass('avatar')) {
      $('body').css({
        'background-image' : 'url(/img/plusdev.png)',
        'background-repeat' : 'repeat'
      });
    }
  }

}

function infobox() {
  $('.infobox a.closebox').click(
    function() {
      $(this).parent().fadeOut();
    }
  );
}

function poll() {
  $('#votebtn').click(function() {
    $(this).attr('disabled', 'disabled');

    var poll_type = $('#PollType').attr('value');
    var poll_id = $('#PollId').val();
    var answers = new Array();
    if(poll_type == 'single') {
      answers = {
        "data[PollVote][answer_id]": $('.singlevoteoption:checked').val(),
        "data[PollVote][poll_id]": poll_id
      };
    } else if(poll_type == 'multi') {
      answers = $('.multivoteoption:checked').serializeArray();
    }

    $('#poll_content').load(
      '/umfrage/' + poll_id + '/abstimmen',
      answers
    );
  });

  //only 3 answers may be selected
  $('.multivoteoption').change(function() {
	  var counter = $('.multivoteoption:checked').length;
	  if(counter > 3) {		  
		  $(this).attr('checked',false);
	  }
  });
}

function server_check() {
  var str = document.location.toString();
  var bar = $('<div id="topbar"></div>').css({'position':'fixed', 'height':'17px','width':'100%','top':'0','zIndex':'100','background':'url("/img/bg_white_opac80.png") repeat scroll left top transparent', 'borderBottom':'1px solid #ccc', 'textAlign':'center', 'color': '#000', 'fontSize':'1.1em'});
  if(str.indexOf('nico') != -1) {
  bar.prependTo('body').html('Nico seine Umgebung');
  }
  if(str.indexOf('andreas') != -1) {
    bar.prependTo('body').html('Andy seine Umgebung');
  }
  if(str.indexOf('jens') != -1) {
	    bar.prependTo('body').html('Jens seine Umgebung');
	  }
  if(str.indexOf('anja') != -1) {
	    bar.prependTo('body').html('Anja ihre Umgebung');
	  }
}

/*
pntextresize = function() {
    $('<a href="#">textPlus</a>').prependTo('body').click(function(){
        $('body').css({'fontSize': parseFloat($('body').css('fontSize'))+2+'px'});
    });
}
*/

function description_tooltip(context) {
  $('.description').hover (
    function() {$(this).children('p').css({'display':'block'})},
    function() {$(this).children('p').css({'display':'none'})}
  );
};

function pn_feedback() {
  function feedback_success(data, status) {
    $('#feedback').after(data);
    globalStatusMessage();
  }

  $('#feedback a.feedintro').click(function(){
      $('#feedback form').toggle('fast');
      return false;
  });

  $('#FeedbackAddForm').submit(function() {
    $('#FeedbackAddForm').fadeOut();

    var user_id = $('#FeedbackUserId').val();
    var url = $('#FeedbackUrl').val();
    var subject = $('#FeedbackArea').val();
    var body = $('#FeedbackFeedback').val();
    $('#FeedbackArea').val('');
    $('#FeedbackFeedback').val('');

    $.post('/feedbacks/add', {
      'data[Feedback][user_id]': user_id,
      'data[Feedback][url]': url,
      'data[Feedback][area]': subject,
      'data[Feedback][feedback]': body
    }, feedback_success, 'html');

    return false;
  });
}


/**
 * Function to upload a file via AJAX.
 */
function bind_ajax_file_upload() {
  $('button.ajaxFileUploadBtn').click(function() {
    $('div.loading')
    .ajaxStart(function(){
        $(this).show();
    })
    .ajaxComplete(function(){
        $(this).hide();
    });

    $.ajaxFileUpload({
      url: location.href,
      secureuri: false,
      fileElementId: $("input.ajaxFileUploadInp").attr('id'),
      dataType: 'json',
      success: function(data, status) {
        $('#newGroupPic').attr('src', data.path);
      },
      error: function(data, status, e) {
        $('div.ajaxFileUploadMsg').html(data.message);
      }
    });

    return false;
  });
}


function search_field_events() {
  $('.searchfield').live('focus', function() {
    if($(this).attr('old:value') == undefined || $(this).attr('old:value') == $(this).attr('value')) {
      $(this).attr('old:value', $(this).attr('value'));
      $(this).attr('value', '')
    }
  });
  $('.searchfield').live('blur', function() {
    if($(this).attr('value') == '') {
      $(this).attr('value', $(this).attr('old:value'))
    }
  });
}


function pn_submenu() {
    if($("ul.subnavoption")) {
        $("li.dropdown a.droplink").click(function(){$('#catdropdown').slideToggle('fast')});
    }
}

/*
function gallery_add_image(img_path) {
  $('#image_list').append(img_path);
  $('#ImagesFile').attr('value', '');
  $('#ImagesDescription').attr('value', '');
}
*/

var replaceSelectBox = function() {
  var _datamodel = $('.categorybox select').attr('pn:modelname');
  if(_datamodel != undefined) {
    var selectbox = '';
    var _cat_id = '';
    var _cat_name = '';
    $('.categorybox select').children('optgroup').each(function() {
      selectbox += '<ul><li><b>' + $(this).attr('label') + '</b></li>';
      $(this).children('option').each(function(){
        if($(this).attr('selected')) {
          _cat_id = $(this).val();
          _cat_name = $(this).text();
        }
        selectbox += '<li><a href="#" class="' + $(this).val() + '">' + $(this).text() + '</a></li>';

      });
      selectbox += '</ul>';
    });

    selectbox = '<div id="catname">&nbsp;' + _cat_name + '</div><div class="selectbox">' + selectbox + '<input type="hidden" id="category_list" name="data[' + _datamodel + '][cat_id]" value="' + _cat_id + '"></div>';

    $(".categorybox select").replaceWith(selectbox);
    $(".selectbox").hide();
    selectBoxFunctions();
  }
}

function filterReplace() {
    var selectbox = '';

    $('.categorybox select').children('optgroup').each(function() {
      selectbox += '<ul><li><b>' + $(this).attr('label') + '</b></li>';
      $(this).children('option').each(function(){
        if($(this).attr('selected')) {
          _cat_id = $(this).val();
          _cat_name = $(this).text();
        }
        selectbox += '<li><a href="http://google.de">' + $(this).text() + '</a></li>';

      });
      selectbox += '</ul>';
    });

    selectbox = "<a href='#' class='arrow'>Kategorie</a><div class='selectbox'>" + selectbox + "</div>";

   $(".categorybox select").replaceWith(selectbox);
    $(".selectbox").hide();

   $(".categorybox a:first").toggle(
    function(){$('.selectbox').slideDown(200)},
    function(){$('.selectbox').slideUp(200)}
   );

  $(".selectbox ul li a").click(function() {
    $(this).attr('value',$(this).attr('class'));
  });
}

var selectBoxFunctions = function () {
  $(".categorybox").click(
    function(){$('.selectbox').slideToggle(200);
   });

  $(".selectbox ul li a").click(function() {
    $(".categorybox #catname").text($(this).text());
    $(".categorybox input#category_list").attr('value', $(this).attr('class'));
  });
}


function globalStatusMessage() {
  if($('div[id^=globalStatus]')) {
    $('div[id^=globalStatus]').click(function(){$(this).hide()});
   /* $('div[id^=globalStatus]').wait(4000).fadeOut(); */
  }
}

function globalMsg() {

}

function pn_confirmed() {
  $('a.confirm').click(function() {
    if($(this).attr('pn:confirm') != undefined) {
      return confirm($(this).attr('pn:confirm'));
    }
    else {
      return confirm($(this).attr('title')+'?');
    }
  });
}

function pn_defaulttext() {
  $('input, textarea').focus(function() {
    if ($(this).val() == $(this).attr('pn:default') && $(this).attr('class') != 'nodefault') {
      $(this).val('');
    }
  });

  $('input, textarea').blur(function() {
    if ($(this).val() == '' && $(this).attr('class') != 'nodefault') {
      $(this).val($(this).attr('pn:default'));
    }
  });

  $('form').submit(function() {
    $(this).find('input, textarea').each(function() {
      if ($(this).val() == $(this).attr('pn:default')) {
        $(this).val(($(this).attr('class') != 'notempty' ? '(leer)' : ''));
      }
    });
    return true;
  });
}

function pn_home_topteaser() {
  var timer;
  var active = 0;
  var count = $('#home-teaser>div').length;
  var mouseover = false;
  
  // inner function - e.g. to stop any animation on mouse over
  function _pn_home_topteaser() {
    var time = 3000; // miliseconds
    
    //$('#block-linkatory0').html(active);
    
    /* core function to run the slider - shows the active box */
		if (count > 1) {
			$('#b' + active).wait(time).fadeOut('slow',
					function() {
						active += 1;
						if (active == count) {
							active = 0;
						}
						$('#b' + active).fadeIn('slow');
						if (!mouseover) {
							_pn_home_topteaser(); // recursive call
						}
					}
				);
		}
  }

  _pn_home_topteaser(); // important for first function call

  $('#home-teaser')
    .mouseover(function(e) { 
      mouseover = true;
      $('#home-teaser>div').stop(true, true); // Complete animation for all boxes
      clearTimeout(timer); // reset the timer
      if ($(e.target).hasClass('top-sliderbar')) {
        active = parseInt($(e.target).attr('pn:n')); //changes strings into integer given from pseudo-class-id 
        $('#home-teaser>div').stop(true).hide(); // stop animations and hide all boxes
        $('#b' + active).show(); // show only the very active box
      }
    })
    .mouseout(function() { 
      mouseover = false;
      _pn_home_topteaser(); 
    });
}

/* old function to slide home-teaserboxes */
function pn_teaser() {
    var time = 7000;
    $('#home-teaser div:first').wait(time).fadeOut('slow',
    function() {
      $(this).next('div').hide().fadeIn('slow');
      $(this).remove().clone().appendTo('#home-teaser').hide();
      pn_teaser();
    });
}

function object_starrating() {
  $('.starrating').hover(
    function() {
      $(this).attr('style', 'background-position: -75px 0');
    },
    function() {
      $(this).removeAttr('style');
    }
  );

  $('.starrating > a').click(function() {

    var stars = $(this).attr('pn:stars');
    var ratetype = $(this).attr('pn:ratetype');
    var rateid = $(this).parent('.starrating').attr('pn:rateid');
    var rateurl = $('#starrating_' + rateid).attr('pn:rateurl');
    var ratetype = $('#starrating_' + rateid).attr('pn:ratetype');

    $.post(
      rateurl,
      {
        "data[Rating][id]": rateid,
        "data[Rating][type]": ratetype,
        "data[Rating][stars]": stars
      },
      function() {
        $('#starrating_' + rateid).unbind();
        $('#starrating_' + rateid + ' > a').unbind();
        $('#starrating_' + rateid).attr('class', 'starratingdisabled hasrated rating' + stars);
        $('#starrating_' + rateid).removeAttr('style');
      }
    );
  });
}

function like_object() {
  $('.likethis > a').live('click', function() {

    var object_id = $(this).parent('.likethis').attr('pn:object_id');
    var likeurl = $('#like_' + object_id).attr('pn:likeurl');

    $(this).unbind();
    $(this).removeAttr('href');
    $(this).css('color', 'rgb(190, 190, 190)');

    $('#likecontainer_' + object_id).load(
      likeurl,
      {
        "data[Like][object_id]": object_id,
        "data[Like][value]": 1
      });

     return false;
  });
}

function dont_like_object() {
  $('.dontlikethis > a').live('click', function() {

    var object_id = $(this).parent('.dontlikethis').attr('pn:object_id');
    var likeurl = $('#dontlike_' + object_id).attr('pn:likeurl');

    $(this).unbind();
    $(this).removeAttr('href');
    $(this).css('color', 'rgb(190, 190, 190)');

    $('#likecontainer_' + object_id).load(
      likeurl,
      {
        "data[Like][object_id]": object_id,
        "data[Like][value]": 0
      });
      return false;
  });
}


var debug = 'on'
function pn_debug() {
    if(debug == 'on') {
        $(".cake-sql-log").fadeIn();
        debug = 'off';
    } else {
        $(".cake-sql-log").fadeOut();
        debug = 'on';
    }
}


function pn_ie6buttonFix() {
  if($.browser.msie) {
    $('button.btnorange').mousedown(function() {
      $(this).children('span').css('height', '25px');
      $(this).css('marginTop', parseInt($(this).css('marginTop')) - 1 + 'px');
      $(this).children('span').css('width', parseInt($(this).children('span').width()) + 2 + 'px');
      $(this).children('span').css('paddingLeft', (parseInt($(this).children('span').css('paddingLeft')) - 1) + 'px');
      $(this).css('marginLeft', parseInt($(this).css('marginLeft')) - 1 + 'px');
    });
    $('button.btnorange').mouseup(function() {
      $(this).children('span').css('height', '24px');
      $(this).css('marginTop', parseInt($(this).css('marginTop')) + 1 + 'px');
      $(this).children('span').css('width', parseInt($(this).children('span').width()) - 2 + 'px');
      $(this).children('span').css('paddingLeft', (parseInt($(this).children('span').css('paddingLeft')) + 1) + 'px');
      $(this).css('marginLeft', parseInt($(this).css('marginLeft')) + 1 + 'px');
    });
  }
}


function pn_loginfield() {
  $('#pnlogin').click(function() { $('#overlay-login').show().focus();$('#pnlogin-link').show();$('#UserEmail').focus();  return false; });
  $('#pnlogin-close').click(function() { $('#overlay-login').hide(); return false; });
  $('#pnlogin-link').click(function() { $('#overlay-login').hide(); return false; });
  
  if($('#loginbox-top .loginarea #UserEmail').val() == '') {
      $('#loginbox-top .loginarea #UserEmail').val('E-Mail').bind('click', function(){
      $(this).val('');
      });
      pwdfield();
  } else {
      $('#loginbox-top .loginarea #password').select();
  }

    function pwdfield() {
        $('#loginbox-top .loginarea #password').hide();
        $('#loginbox-top .loginarea #pwdoverlay').show().bind('click, focus', function(){
          $(this).hide();
          $('#loginbox-top .loginarea #password').show().focus();
        });
      }


}

function pn_jsCheck() {
  $('#contact input#javascript').val('Javascript: on');
}

function pn_usermeeting() {
  var um_arr = $('#meeting_frame ul');
  var um_arr_length = um_arr.length;
  var c = 0;

$('#user_meeting .nextmeeting').click(function(){
    $(um_arr[c]).hide();
    if(c<parseFloat(um_arr_length-1)) {
      c++;
    } else {
      c = 0;
    }

    $(um_arr[c]).fadeIn();
    return false;
});

$('#user_meeting .prevmeeting').click(function(){
$(um_arr[c]).hide();
    if(c>0) {
      c--;
    } else {
      c = parseFloat(um_arr_length-1);
    }

    $(um_arr[c]).fadeIn();
    return false;
});



}


function bind_autocomplete(extraParams) {
  $('#UserLocale').unbind();
  $('#UserLocale').autocomplete(
		'/profiles/getlocales',
		{
			delay: 10,
			minChars: 2,
			matchSubset: 1,
			matchContains: 1,
			cacheLength: 10,
			onItemSelect: profile_set_selected_locale,
			autoFill: false,
      cellSeparator: '|%%|',
      extraParams: extraParams
		}
	);
}

function profile_set_selected_locale(li) {
  if (li.extra) {
    var val = $.trim(li.selectValue ? li.selectValue : li.innerHTML);
    var tmp1 = val.split(',');
    var tmp2 = tmp1[0].split(' ');
    var plz = tmp2.shift();
    var city = tmp2.join(' ');
    if(plz != 'undefined' && plz != '' && city != 'undefined' && city != '') {

      // Set the helperfield to determine if the user enters sth new.
      $('#UserLocalefield').val(val);

      // Set the locale-ID-field (hidden-field)
      $('#UserLocaleId').val(li.extra[0]);
      // Set the zip_code-field (hidden-field)
      $('#edit-zip_code').val(plz);
      // Update the span showing the city
      $('span.value-zip_code').text(plz);
      // Set the city-field (hidden-field)
      $('#edit-city').val(city);
      // Update the span showing the city
      $('span.value-city').html(city);
    }
    else {
      alert("Ein Fehler ist aufgetreten und Ihr Ort konnte nicht gespeichert werden.\nBitte wenden Sie sich via Kontaktformular an das Team.");
    }
	}
}



function profile_admin() {
  $('#profile-admin-handle').hover(function() {
    $('#profile-admin-popup').show();
  }, function() {
    $('#profile-admin-popup').hide();
  });
}

function global_search() {
  var $global_search_field = $('#global_search_field');
  if ($global_search_field.length > 0) {
    $global_search_field
      .data('bgimage',$('#global_search_field').css('backgroundImage'))
      .css({ border: '1px solid #ddd', padding: '2px' });
  }  
  
  $('#global_search_type #dropdownbutton').click(function(){
    var soption = $('#global_search_type ul');
    if(soption.attr('class') == 'hidden') {
      soption.show();
      soption.attr('class', 'visible');
    } else {
      soption.hide();
      soption.attr('class', 'hidden');
    }
  });

  set_search_fields($('#searchtype').val());

  $('#global_search_type a').bind('click', function() {
    set_search_fields($(this).attr('name'));
    $('#global_search_type ul').hide().attr('class', 'hidden');

   return false;
  });

  $('#cse-search-box').submit(function() {

    var searchtype = $('#searchtype').attr('value');

    // If we do an internal search, don't post the search, make a get out of it, because it should be trackable via google
   /* if(searchtype == 'groups' || searchtype == 'questions' || searchtype == 'galleries' || searchtype == 'articles') {
      window.location = $(this).attr('action').replace('[search]', $('#global_search_field').attr('value'));
      return false;
    }*/
    if(searchtype == 'groups' || searchtype == 'questions' || searchtype == 'galleries' || searchtype == 'articles') {

      var search = $("#global_search_field").val(); 
      var actionValue = $("#cse-search-box").attr("action") ;
      search = jQuery.trim(search);
      window.location = $(this).attr('action').replace('[search]', encodeURIComponent(search));
      return false;
    }
  });
}

function set_search_fields(name) {
  var action = $('#global_search_type a[name=' + name + ']').attr('href');
  var text = $('#global_search_type a[name=' + name + ']').text();
  $('#cse-search-box').attr('action', action == 'undefined' ? $('#global_search_type a[name=search]').attr('href') : action);
  $('#global_search_type #dropdownbutton span').text(text == '' ? $('#global_search_type a[name=search]').text() : text);

  switch(name) {
    case 'groups':
      $('#global_search_field').attr('name', 'data[Group][search]').css({backgroundImage: 'none'});
      $('#cse-search-box').attr('method', 'post');
      break;
    case 'questions':
      $('#global_search_field').attr('name', 'data[Question][search]').css({backgroundImage: 'none'});
      $('#cse-search-box').attr('method', 'post');
      break;
    case 'galleries':
      $('#global_search_field').attr('name', 'data[Gallery][search]').css({backgroundImage: 'none'});
      $('#cse-search-box').attr('method', 'post');
      break;
    case 'articles':
      $('#global_search_field').attr('name', 'data[Article][search]').css({backgroundImage: 'none'});
      $('#cse-search-box').attr('method', 'post');
      break;
    default:
    case 'search':
      $('#global_search_field').attr('name', 'q').css({backgroundImage: $('#global_search_field').data('bgimage')});
      $('#cse-search-box').attr('method', 'get');
      break;
  }
  $('#searchtype').attr('value', name);
}

function feed_showsimilar() {
var def_text = '';
  $('a.similar_items').toggle(function(){
    $('div#'+$(this).attr('items')).fadeIn();
    def_text = $(this).text();
    $(this).text($(this).text()+' ausblenden');
  }, function(){
    $('div#'+$(this).attr('items')).fadeOut();
     $(this).text(def_text);
  });

  $('#block-home-newsfeed li a').each(function(){
    $(this).attr({'href': $(this).attr('href')+'#nf'});
  });
}

function ListenToKeyUp(keyEvent) {
  if (!keyEvent)
    keyEvent = window.event;
  if (keyEvent.which) {
    PressedKeyCode = keyEvent.which;
  } else if (keyEvent.keyCode) {
    PressedKeyCode = keyEvent.keyCode;
  }

  if (PressedKeyCode == 13 && !logged_in) { /* we trigger the Enter-Key (Win), but only if user isn't logged in */
    /* Show the loginfield */
    $('#overlay-login').show();
    $('#pnlogin-link').show();
    $('#UserEmail').focus();
    
    return false;
  }
  if (PressedKeyCode == 27 && !logged_in) { /* we trigger the Esc-Key (Win), but only if user isn't logged in */
    /* Hide the loginfield */
    $('#overlay-login').hide();
    $('#pnlogin-link').hide();
    return false;
  }
}

document.onkeyup = ListenToKeyUp;

function pn_questionroller() {
  var timer;
  var active = 0;
  var countqe = $('#questions-container>div').length;
  var mouseover = false;
  
  // inner function - e.g. to stop any animation on mouse over
  function _pn_roller() {
    var time = 3000; // miliseconds
    
    /* core function to run the slider - shows the active box 
    * the question container slides down width 2 visible question boxes (75px down)
    */
    timer = setTimeout(function() {
      //$('#qe_' + active).prependTo('#questions-container');
      $('#questions-container').animate({'top':'+=75'}, 500,
        function() {
          active += 1;
          if (!mouseover) {
            _pn_roller(); // recursive call
          } 
          if (active == 1) { // we need redundant (cloned) question-blocks to fill thw whitespace in question-container
            for (i = 0; i <= countqe; i++) {
              $('#qe_' + i).clone().prependTo('#questions-container').css('top','-'+((i+countqe) * 75)+'px');
            }
          }
          // now we delete the cloned boxes to avoid data crap
          if (active == countqe) {
            active = 0;
            for (i = 0; i <= countqe; i++) {
                $('#qe_' + i).remove();
            }
            $('#qe_' + active).prependTo('#questions-container');
            $('#questions-container').css('top','75px');
          }
          if ($('#questions-container').css('top') > (countqe * 75)) {
            $('#questions-container').css('top','75px');
          }
        }
      );
    }, time);
  }

  _pn_roller(); // important for first function call

  $('#questions-container')
    .mouseover(function(e) { 
      mouseover = true;
      $('#questions-container>div').stop(true, true); // Complete animation for all boxes
      clearTimeout(timer); // reset the timer
      if ($(e.target).hasClass('entry-container')) {
        $('#questions-container>div').stop(true); // stop animations
      }
    })
    .mouseout(function() { 
      mouseover = false;
      _pn_roller(); 
    });
}

