﻿//Variable Declarations
var tempValue = "";
var MySearchTag = "";
var MyParagraph1Height = 0;
var MyParagraph2Height = 0;
var MyTotalPar = 0;
var TheImageSrc = "";
var TheHrefSrc = "";
//Variables for Random News
var TotalNewsNum;
var MyFirstId = 0;
var MySecondId;
var TheNewHTML;
 
// Swap Images Roll over Roll Out 
function ChangeImage(imgID, imgSrc) {
  $("#MenuImg" + imgID).attr({'src':imgSrc});
}
/*if ($('#LeftMenuContentor li').hasClass("L2")) {
  $('#LeftMenuContentor').css({ "padding-top" : "20px", "padding-left" : "20px" });
  $('#LeftMenuContentor li.L2, #LeftMenuContentor li.L2_Active').css("padding-left","23px");
}*/
$(window).resize(function(){ CalcToCall(); });
$(window).scroll(function(){ CalcToCall(); });
// OnLoadActions
$(function(){
  /* helpdeskStart - nuno.b - 13/02/2012 @ 12:55 (Corrigir a possição das colunas da direita e da esquerda) #5113 */
  if ($('#paraEsquerda').length > 0) {
    var str_display = "none";
    $('#paraEsquerda, #paraDireita').css('float','left');
    $('#paraEsquerda').children('div').each(function() {
      if ($(this).css('display') != 'none') {
        str_display = 'block';
      }
    });
    if (str_display == 'none') { $('#paraDireita').css('margin-left','10px'); }
    $('#paraEsquerda').css({'display': str_display, 'width': '360px'});
  }
  /* helpdeskEnd */
  /* Correcção as regiões. 1ª imagem estava mal, assim corrigimos todas. */
  $('.Slider').find('img.mask').css('margin-left','-25px');
  /* correcção da tabela de serviços - espaçamentos */
  $('table.servicesTable2Col > tbody > tr > td').css({'width': '40%'});
  $('table.servicesTable2Col > tbody > tr > td:eq(1)').css({'padding-left': '40px'});
  /* Correcção para o .paragraph que contem a table*/
  if ($('.Table_WhiteGrey').length) {
    var tableHeight = $('.Table_WhiteGrey').parents('table').height();
    var divHeight = $('.Table_WhiteGrey').parents('.paragraphText').height();
    if (divHeight < tableHeight) {
      $('.Table_WhiteGrey').parents('.paragraphText').height( (tableHeight + divHeight));
    }
  }
  /* Adicionar separador para o Template de experiences para do footer*/
  if ($('.experienceMore').length) {
    $('.experienceMore #RightColumn .Paragraph').not(' :last-child ').after('<div class="BottomSeparator"></div>');
  }
  /* Regra para elementos de três colunas, que deve ter graybackground exepto no 1º paragrafo. */
  if ($('#CenterColumn > div').length) {
    $('#CenterColumn > div:not(:first-child)').each(function() {
      $(this).addClass('GrayBackground');
    });
  }
  if ($('.GrayBackground object').length) {
    $('.GrayBackground object').parent().css('margin-left','0px');
  }
  if ($('#buttonMenu').length)  $('#buttonMenu').parents('.Paragraph').css('padding-bottom', '0px');
  /* Correcção da tabela de t/experiences da localização*/
  if ($('.bigGreyTable td').length) {
    $('.bigGreyTable td').not(':first').each(function() {
      if ($(this).find('img').length) {
        $(this).width($(this).find('img').width());
      }
    });
    $('.bigGreyTable td:first').height('25');
  }
  /* Correcao dos tratamentos*/
  $(".TreatmentsList li:odd").each(function() {
    $(this).outerWidth($(this).outerWidth()-11);
    $(this).find('.NewsListTextContentor').css({'float':'left','padding':'0px'});
  });
  $(".TreatmentsList li:even").css('padding-right','10px');
  /**/
  if ($('.GrayBackground').length) {
    $('.ImageMask').each(function(){
      if ($(this).parents('.GrayBackground').length)
        $(this).css('background-image', 'url("/Files/System/TivoliHotels/Layout/Mask_grey.png")');
    });
    $('.mask').each(function(){
      if ($(this).parents('.GrayBackground').length)
        $(this).attr('src', '/Files/System/TivoliHotels/Layout/Mask_grey.png');
    });
  }
  if ($('.GrayCenterBackground').length) {
    $('.ImageMask').each(function(){
      if ($(this).parents('.GrayCenterBackground').length)
        $(this).css('background-image', 'url("/Files/System/TivoliHotels/Layout/Mask_grey.png")');
    });
    $('.mask').each(function(){
      if ($(this).parents('.GrayCenterBackground').length)
        $(this).attr('src', '/Files/System/TivoliHotels/Layout/Mask_grey.png');
    });
  }
  /* Correcções de noticias (Hoteis Ofertas Especiais) */
  if ($('.FloatingLeft').length) {
    $('.FloatingLeft').each(function() {
      $(this).parents('div.Paragraph').css({ 'float':'left', 'padding':'0' }).find('.paragraphText').css({'padding':'0'});
    });
    $('.FloatingLeft:last').each(function() {
      $(this).parents('div.Paragraph').css({ 'float':'left', 'padding':'0', 'padding-left':'24px' }).find('.paragraphText').css({'padding':'0'});
    });
  /* Correction bug ID = 307 */
    $('.FloatingLeft').each(function() {
      if ($(this).parents('div.Paragraph').find('table').hasClass('colorTable') == true) {
        $(this).parents('div.Paragraph').find('div').css('width','315px');
        $(this).parents('div.Paragraph').filter(":even").css({'width':'330px'});
        $(this).parents('div.Paragraph').filter(":odd").css({'width':'330px', 'float':'right'});
        $(this).parents('div.Paragraph').find('div.NewsListText, div.NewsListHeading').css('width','300px');
        $(this).parents('div.Paragraph').find('div.newsImage').css('width','92px');
        $(this).parents('div.Paragraph').find('.colorTable').css('width','340px');
      }
    });
  }
  if ($('#buttonMenu').length) {
    $('#buttonMenu').parents('.GrayBackground').css({ 'height' : '40px', 'display' : 'block' });
  }
  /* Correcção dos espaçamentos dos ipapers */
  $('table.iPapers').each(function() {
    $(this).find('tbody > tr:first > td:first > table > tbody > tr > td > img').each(function() {
      $(this).parents('.iPapers').find('iframe').each(function() {
        $(this).parent().css('padding-left', '0'); 
      });
    });
  });
  /*Correcção dos icons da ipaper */
  if ($('.iPapers table img').length) {
    $('.iPapers table img').each(function(){
      $(this).parent().height(40);
      var ipaper = $(this).attr('src').toLowerCase();
      var tamanho = ipaper.indexOf("ipapericon.gif");
      if (tamanho > 0) {
        $(this).attr({'align': 'left', 'alt':'Ipaper icon'});
        $(this).css({'margin-left': '-5px','margin-right': '5px'});
        $(this).parents('table:first').attr('align', 'left');
        $(this).parents('table:first').parent().prepend($(this));
      }
    });
  }
  $('.Paragraph').each(function() {
    if (!$(this).hasClass('GrayBackground')) {
      if ($(this).children('.T11-B11_image')) {
        $(this).children('.T11-B11_image').css({'padding-left':'23px', 'padding-right':'18px' });
      } 
      else if ($(this).children('.B11-T11_image')) {
        $(this).children('.B11-T11_image').css({'padding-left':'23px', 'padding-right':'18px' });
      }
    }
  });
  $('.servicesTable .mask:last').css('padding-bottom', '0');
 /* $('.GrayBackground table .paragraphText, .GrayBackground .paragraphText table').each(function() {
    $(this).find('img:first').css('margin-left','-12px');
  });
  $('.GrayBackground .paragraphText').each(function() {
    $(this).find('img:first').css('margin-left','-12px');
  });
*/
  $('.GrayBackground .paragraphText').each(function() {
    var string = $(this).html();
    var stringToSearch = string.substr(0,20);
    if (stringToSearch.search(/table/i) != -1) {
      $(this).find('img:first').css('margin-left','-12px');
    }
  });
  /* Correct photo's table */
  $('.GrayBackground table').each(function() {
    if ($(this).attr('cellspacing') == 10) {
      $(this).css('margin-left','-10px');
    }
  });
  var pesquisa = $(this).val();

  $('#q').focus(function () {
    if ($(this).val() != ' ') { $(this).val(''); }
  });
  $('#q').focusout(function() {
    if (($(this).val() == " ") || (!$(this).val())) { $(this).val(pesquisa); }
  });
  if ($('#folderMenu').length || $('#buttonMenu').length) {
    $('.GrayBackground').each(function() {
      $(this).css('border-bottom', '1px solid #F8F8F8');
    });
    $('#folderMenu').parents('.paragraphText, .Paragraph').css('padding-bottom', '0');
    if ($('#buttonMenu').parents(".paragraphText").hasClass('GrayBackground') == false) {
      $('#buttonMenu').parents(".paragraphText").css("padding-left", "0");
    }
  }
  if ($('ul.HotelsMenu').length) {
    $('li.L3_Active ul.M3 > li:nth-child(4)').css({"background": "url('/Files/System/TivoliHotels/Layout/separadorHoteis.jpg') no-repeat left bottom", "padding-bottom":"11px"});
    $('li.L3_Active ul.M3 > li:nth-child(5)').css("padding-top", "11px");
  }
  $('.wrapRssVol img[alt="Música"]').hover(
    function() { $(this).attr("src", "/Files/System/TivoliHotels/Layout/colunaSemSom.gif"); },
    function() { $(this).attr("src", "/Files/System/TivoliHotels/Layout/iconVolume.gif"); }
  );
  CalcToCall();
  var temp;
  $("#LanguageMenu a img").hover(
    function() { temp = $(this).attr("src"); $(this).attr("src", $(this).attr("usemap"));  },
    function() { $(this).attr("src", temp);
  });
  // Top Menu
  try {
    $('#MainMenu .M0 .L1, #MainMenu .M0 .L1_Active').hover(function(e) {
        var menu = $('ul',$(this));
        menu.css('width',menu.width());
        if(menu.width() < menu.parent().width()) {
          menu.width(menu.parent().width());
        }
      $(this).children('ul').hoverFlow(e.type, {
        'height': 'show',
        'marginTop': 'show',
        'marginBottom': 'show',
        'paddingTop': 'show',
        'paddingBottom': 'show' 
      });
    }, function(e) {
      $(this).children('ul').delay(200).hoverFlow(e.type, {
        'height': 'hide',
        'marginTop': 'hide',
        'marginBottom': 'hide',
        'paddingTop': 'hide',
        'paddingBottom': 'hide' 
      });
    });
  }
  catch(err) { }
  //Menus Laterais
  if ($('#topLeft').length ) {
    addAcordion();
  }
  // Accordions
  $('.ExpPacksAccordion ul li').bind('mouseenter',function(e) {
    var containerToSlide = $(this).find('.ShowHideContentor');  
    $('.ExpPacksAccordion ul li .ShowHideContentor').not(containerToSlide).animate({
      'height': '1px'
    },{ queue:false, duration:900 });
    containerToSlide.animate({
      'height': '96px'
    },{ queue:false, duration:900 });
    }).bind('mouseleave', function () {
      var containerToSlide = $(this).find('.ShowHideContentor');  
      containerToSlide.animate({
      'height': '1px'
    },{ queue:false, duration:900 });
  });
  $('.ExpPacksAccordion ul li:first').trigger('mouseenter').trigger('mouseleave');
  $('.TExperienceAccordion ul li').bind('mouseenter',function(e) {
          //Mouse Over Images
    TheImageSrc = $(this).children('a').children('div').children('img').attr('src');
    $(this).children('a').children('div').children('img').attr({'src': TheImageSrc.slice(0,(TheImageSrc.length - 4)) + "_over" + TheImageSrc.slice((TheImageSrc.length - 4),TheImageSrc.length) });
    var containerToSlide = $(this).find('.ShowHideContentor');  
    $('.TExperienceAccordion ul li .ShowHideContentor').not(containerToSlide).animate({
      'height': 0
    },{ queue:false, duration:1000 });
    containerToSlide.animate({
      'height': (parseInt(containerToSlide.children('div.theLastChild').height()) + 35) + 'px'
    },{ queue:false, duration:1000 });
  }).bind('mouseleave', function () {
    //Mouse Over Images
    $(this).children('a').children('div').children('img').attr({'src': TheImageSrc});
    var containerToSlide = $(this).find('.ShowHideContentor');  
    containerToSlide.animate({
      'height': 0
    },{ queue:false, duration:1000 });
  });
  $(".h2 img").parent().css({'background-image':'none','padding':'0px','margin':'0px'});
  $(".Paragraph .NoNewsMsg").parent().parent().css({ 'display': 'none' });
  $('.TExperienceAccordionHotels img, .whiteBorder .TExperienceAccordion img, #TH2_GHA .TExperienceAccordion img').each(function(e) {
    TheImageSrc = $(this).attr('src');
    $(this).attr({'src': TheImageSrc.slice(0,(TheImageSrc.length - 4)) + "2" + TheImageSrc.slice((TheImageSrc.length - 4),TheImageSrc.length) });
  });
  // News Paging
  $(".NewsPaging a b").parent().addClass("active");
  $(".Paragraph #SmallMapHolder").parent().parent().addClass("relative");
  //for table row
  $(".Table_WhiteGrey tbody").each(function(i) {
    $(this).children("tr:even").addClass("even");
    $(this).children("tr:odd").addClass("odd");
  });
  $(".table_eventos tbody tr:even").addClass("even");
  $(".table_eventos tbody tr:odd").addClass("odd");
  $(".table_eventos tbody tr td:nth-child(1)").css('text-align', 'left');
  $(".HotelDetails tbody").each(function(i) {
    $(this).children("tr:last").addClass("LastRow");
  });
  /* Correction of last TD width: 50px; align: left added by nuno.b@alencastre.net @ 16:10 2/5/11 */
  $('.Table_WhiteGrey tr').each(function() {
    $(this).find('td:last').css({
      'width' : '50px',
      'text-align' : 'left',
      'padding-right' : '0px'
    });
  });
  /* Correction of .Table_WhiteGrey that is inside a table - added by nuno.b @ 16:10 2/5/11 */
  $('table .Table_WhiteGrey tr').each(function() {
    if ($(this).parent('tr').hasClass('even')) {
      $(this).find('td:last').css({
        'text-align' : 'right',
        'padding-right' : '0px'
      });
    }
  });
  /* Correction of .Table_WhiteGrey that is inside a table with a class called TKIDS - added by nuno.b@alencastre.net @ 16:10 2/5/11 */
  $('table.TKids .Table_WhiteGrey tr').each(function() {
    $(this).find('td:last').css({
      'width' : '',
      'text-align' : 'right',
      'padding-right' : '0px'
    });
  });
  $(".Hotel_Reservations tbody tr").each(function(i) {
    $(this).children("td:last").addClass("right_bkg");
  });
//  $(".Hotel_Reservations img").each(function(i) {
//    TheImageSrc = $(this).attr('src');
//    $(this).attr({'src': '/admin/public/getimage.aspx?&Image=' + TheImageSrc + '&Resolution=75&Compression=80&Width=122&Height=100&Crop=0' });
//  });
  $(".Contacts_Table td:nth-child(2)").addClass("left_dotted_separator");
  //check if has content
  $(".table_links tbody tr td:nth-child(2)").each(function(i) {
    if($(this).html() != "&nbsp;") {
      $(this).addClass("right_bkg");
    }
    else {
      $(this).css({'background-color' : 'transparent'});
    }
  });
  
  // Airports Table
  $(".AirportTable td:nth-child(1) img").each(function(i) {
    TheImageSrc = $(this).attr('src');
    $(this).wrap('<div class="DetailsImageList" style="background-image: URL(/admin/public/getimage.aspx?&Image=' + TheImageSrc + '&Resolution=75&Compression=80&Width=92&Height=74&Crop=0);"><div style="display:none;" /><img src="/Files/System/TivoliHotels/Layout/mask_grey.png" /></div>');
  });
  
  // Image Bank
  $("table.ImageBank td a").parent().addClass("ImageBankLink");
  $("table.ImageBank td img").parent().parent().addClass("ImageBankImg");
  $("table.ImageBank td img").parent().parent().removeClass("ImageBankLink");
  $("table.ImageBank td img").css({'width':'122px','height':'100px'});
  $("table.ImageBank tr").find(".ImageBankLink:last").addClass("right_bkg");
    
  if($('.PS_Hotel #GreyContentor').height() < 100) {
    $('.PS_Hotel #GreyContentor').css({display: "none"});
  }
  
  //For Table Absolute Images
  $(".table_eventos a").each(function(i) {
    TheHrefSrc = $(this).attr('href');
    if (TheHrefSrc.search(/.jpg/) > 0) {
      $(this).after('<div class="ImageEventsHolder"><div id="ImageEvents' + i + '" class="ImageEvents"><a href="#" onmouseout="HideImageEvents(' + i + ')"><img src="' + TheHrefSrc + '" /></a></div></div>');
      $(this).after('&nbsp;&nbsp;<span class="lupa">&nbsp;</span>');
      $(this).mouseover(function(t) { ShowImageEvents(i); });
    }
  });
  
  /*MyTotalPar = $("#LeftColumn .Paragraph").size();
  for ( i=0 ; i < MyTotalPar ; i++) {
    MyParagraph1Height = parseInt($("#PS_2Column #LeftColumn .Paragraph:eq(" + i + ")").height());
    MyParagraph2Height = parseInt($("#PS_2Column #RightColumn .Paragraph:eq(" + i + ")").height());
    if(MyParagraph1Height > MyParagraph2Height) {
      $("#PS_2Column #RightColumn .Paragraph:eq(" + i + ")").css({minHeight: MyParagraph1Height});
    } 
    else {
      $("#PS_2Column #LeftColumn .Paragraph:eq(" + i + ")").css({minHeight: MyParagraph2Height });
    }
  }*/
  
  //Grey Bkg Spacing and margins correction
  $("#PS_Grey #CenterColumn .Paragraph img").not("#PS_Grey #CenterColumn .T11-B11_image img, #PS_Grey #CenterColumn .B11-T11_image img, #PS_Grey #CenterColumn a img").each(function(i) {
    if($(this).width() == "404") {
      $(this).wrap('<div style="position: relative; height:' + $(this).height() + 'px;"><div style="position: absolute; left: -6px;" /></div>');
    }
  });
  $("#PS_Grey #CenterColumn .Paragraph a img").each(function(i) {
    if($(this).width() == "404") {
      $(this).parent().wrap('<div style="position: relative; height:' + $(this).height() + 'px;"><div style="position: absolute; left: -6px;" /></div>');
    }
  });
  
  //Set iframe background transparent
  $('.T11-B11_MiniPapers iframe').attr('allowTransparency', 'true');
  
  $("#PS_Grey #CenterColumn .Paragraph h1").wrap('<div class="TitleHolder" />');
  $("#PS_Grey #CenterColumn .Paragraph:nth-child(1) h2").not('.NewsItem_Title h2').wrap('<div class="TitleHolder" />');
  $("#PS_Grey #CenterColumn .Paragraph:nth-child(2) h1, #PS_Grey #CenterColumn .Paragraph:nth-child(2) h2").each(function(i) {
    $("#PS_Grey #CenterColumn .Paragraph:nth-child(1)").wrap('<div class="TitleImgContentorHotel" />');
  });
  
  // News Random
  $(".NewsListContentorRandom").each(function(i) {
    $(this).children('ul').children('li').each(function(e) {
      if($(this).hasClass("NewsFixTrue")) {
        MyFirstId = e+1;
      }
    });
    
    TotalNewsNum = $(this).children('ul').children('li').size();
  
    if(MyFirstId == 0) {
      MyFirstId = (Math.floor(Math.random()*TotalNewsNum))+1;
      $(this).children('ul').children('.Item' + MyFirstId).css({'display':'block'});
    }
    else {
      $(this).children('ul').prepend('<li class="NewsFixFalse" style="display: block; border: 0px;">' + $(this).children('ul').children('.NewsFixTrue').html() + '</li>');
    }
    MySecondId = (Math.floor(Math.random()*TotalNewsNum))+1;
    if (MySecondId == MyFirstId) {
      if(MySecondId == TotalNewsNum) {
        MySecondId = Math.floor(MySecondId) - 1;
      }
      else {
        MySecondId = Math.floor(MySecondId) + 1;
      }
    }
  
    if($("#PS_2Column_tkids .NewsListContentorRandom").html() == null) {
      $(this).children('ul').children('.Item' + MySecondId).css({'display':'block'});
    }
  
    MyFirstId = 0;
  });
  $(".NewsListContentor2Col").each(function(i) {
    TotalNewsNum = $(this).children('ul').children('li').size()-1;
    if(MyFirstId == 0) {
      MyFirstId = (Math.floor(Math.random()*TotalNewsNum))+1;
      $(this).children('ul').children('.Item' + MyFirstId).css({'display':'block', 'float':'left','width':'290px'});
    }
    else {
      $(this).children('ul').prepend('<li class="NewsListItem" style="display: block; float: left;">' + $(this).children('ul').children('.NewsFix').html() + '</li>');
    }
    MySecondId = (Math.floor(Math.random()*TotalNewsNum))+1;
    if (MySecondId == MyFirstId) {
      if(MySecondId == TotalNewsNum) {
        MySecondId = Math.floor(MySecondId) - 1;
      }
      else {
        MySecondId = Math.floor(MySecondId) + 1;
      }
    }
    $(this).children('ul').children('.Item' + MySecondId).css({'display':'block', 'float':'right', 'padding-right':'15px','width':'290px' });
    $(this).children('ul').children('.Item' + MySecondId).each(function() {
       if ($(this).hasClass('tkids')) {
         $(this).css('margin-right','10px');
       }
    });
    MyParagraph1Height = parseInt($(this).children('ul').children('.Item' + MyFirstId).children('div').children('div').children('div').children('.ResizeContentor').height());
    MyParagraph2Height = parseInt($(this).children('ul').children('.Item' + MySecondId).children('div').children('div').children('div').children('.ResizeContentor').height());
    if(MyParagraph1Height > MyParagraph2Height) {
      $(".ResizeContentor").css({minHeight: MyParagraph1Height});
    } 
    else {
      $(".ResizeContentor").css({minHeight: MyParagraph2Height});
    }
    MyFirstId = 0;
  });
  
  //Date Validation
  $("#dia_44079, #mes_44079, #ano_44079").keyup(function() {
    this.value = this.value.replace(/[^0-9\.]/g,'');
  });
 /* $('.paragraphText').each(function() {
    $(this).find('img:first-child').css("background","#888888");
  });*/
  if ($('.GolfTop').length) {
    $('.GolfTop').each(function() {
      $(this).addClass("GrayBackground");
    });
  }
  if ($('#buttonMenu').length) {
    $('#buttonMenu').parents('div.GrayBackground').css('padding', '0');
  }
  if ($('.TabelaParceiros').length) {
    $('.TabelaParceiros td').each(function() {
      if ($(this).find('img').length) {
        var largura = 0;
        $(this).find('img:last').css('margin-right','0');
        $(this).find('img').each(function() {
          largura = largura + $(this).outerWidth(true);
        });
        $(this).width(largura);
      }
      else {
        $(this).css('text-align', 'right');
      }
    });
  }
  /* correctionStart - nuno.b - 15/06/2011 @ 12:15 (correction of fotter menu social width) */
  var total = ( parseInt($('.CopyRight .FirstElement').width())   +   parseInt($('.CopyRight .MiddleElem').width())   +    parseInt($('.CopyRight .LastElem').width()) );
  var resto = (parseInt($('#DwFooter').width()) - parseInt(total));
  var padding = (parseInt( parseInt(resto) / parseInt(2) ));
  $('.CopyRight .MiddleElem').css('padding-left', Math.floor( padding ) + 'px');
  $('.CopyRight .MiddleElem').css('padding-right', Math.round( padding ) + 'px');
  /* correctionEnd */
  if ($('#PS_Homepage').length) {
    $('#PS_Homepage .NewsListItem').each(function() {
      var left = $(this).css('float');
      if (left == 'right') {
        $(this).css('padding-right', '27px');
      }
    });
  }
  /* Correccao do graybackground, quando está no centro (PSetup 3 cols)*/
  if ( $('#CenterColumn').length ) {
    $('#CenterColumn .GrayBackground:first').css('padding-top','0px');
    $('#CenterColumn .GrayBackground:first .parapraphImageTop').css({'padding-bottom':'18px', 'padding-top':'0px'}); /* bug ID = 325 */
  }
  /* Correcção a tabela dos congressos */
  $('.Table_WhiteGrey tr').each(function(){
    if ($(this).children('td').size() == 2) {
      $(this).children('td:last').css('text-align','right');
    }
    else {
      $(this).children('td').css('text-align','left');
    }
  });
/* correctionStart - nuno.b @ 25/10/2011 @ 18:10 (date ID = 9661 BUGID = 344) */
  if ($('#Form_CandidaturaBR_Data_year')) {
    var min = $('#Form_CandidaturaBR_Data_year option:first-child').val();
    for (i=min-1; i >= 1900; i--) {
      $('#Form_CandidaturaBR_Data_year').prepend('<option value="' +  i + '">' + i + '</option>');
    }
    $('#Form_CandidaturaBR_Data_year option:last-child').remove();
  }
/* correctionEnd*/
});
 
$(window).load(
  function() {
    //Hotel Details
    $(".HotelDetails img").each(function(i) {
      TheImageSrc = $(this).attr('src');
      if(parseInt($(this).width()) > 100) {
        $(this).wrap('<div class="DetailsImageList" style="background-image: URL(/admin/public/getimage.aspx?Image=' + TheImageSrc + '&amp;Resolution=75&amp;Compression=80&amp;Width=92&amp;Height=74&amp;Crop=0);"><div class="DetailsImage" id="HotelDetailsImage' + i + '" style="z-index:2009"><a href="#" onmouseout="HideDetailsImage(' + i + ')" orgSrc="' + TheImageSrc + '" /></div><a href="#" onmouseover="ShowDetailsImage(' + i + ')"><img src="/Files/System/TivoliHotels/Layout/mask_f8plus.png" /></a></div>');
      }
      else {
        $(this).wrap('<div class="DetailsImageList" style="background-image: URL(/admin/public/getimage.aspx?Image=' + TheImageSrc + '&amp;Resolution=75&amp;Compression=80&amp;Width=92&amp;Height=74&amp;Crop=0);"><div style="display:none;" /><img src="/Files/System/TivoliHotels/Layout/mask_f8plus.png" /></div>');
      }
    });
    $(".HotelDetails .ImageContainer").css("visibility", "visible");
    $(".HotelDetails .ImageContainer > div").css("height", "74px");
    $(".DetailsImageList").hover(
      function () {
        $(this).css('z-index', '999999999');
      }, 
      function () {
        $(this).css('z-index', '');
      }
    );
  }
); 
 
function CalcToCall() {
/* Click To Call Function, this is to calculate de position of the button on resize/scroll */
  if ($("#clickToCall").length != 0) {
    var $scrollingDiv = $("#clickToCall");
    var tamanho = 426;
  }
  if ($("#clickToCallNoGrafic").length != 0) {
    var $scrollingDiv = $("#clickToCallNoGrafic");
    var tamanho = 82;
  }
  if ($scrollingDiv) {
    var DwMain = parseInt($("#DWMain").outerWidth(true));
    var WrapDiv = $("#DWMain").parent().outerWidth(true);
    var Dividor = (WrapDiv - DwMain);
    Dividor = Math.round(Dividor/2);
    var marginLeft = (DwMain + Dividor);  
    $scrollingDiv
    .stop()
    if ($(window).scrollTop() >= tamanho) {
      $scrollingDiv.css({
        "position" : "fixed",
        "top" : "0px",
        "left" : (parseInt(marginLeft)+1) + "px"
      });
      if (marginLeft < DwMain) { 
        $("#DWMain").css("margin-left" , "100px"); 
      }
    }
    else { 
      $scrollingDiv.css({
        "top": "",
        "left": "",
        "position": ""
      });
    }
  }
}
   
function ShowDetailsImage(TheImage) {
  $('#HotelDetailsImage' + TheImage).css({display: 'block'});
}
function HideDetailsImage(TheImage) {
  $('#HotelDetailsImage' + TheImage).css({display: 'none'});
}
function ShowImageEvents(TheImage) {
  $('#ImageEvents' + TheImage).css({display: 'block'});
}
function HideImageEvents(TheImage) {
  $('#ImageEvents' + TheImage).css({display: 'none'});
}
 
// Search Module Validations
function CheckField (FieldID, FieldValue, TheString) {
 tempValue = document.getElementById(FieldID).value;
 if (tempValue == FieldValue) {
   document.getElementById(FieldID).value = "";
 }
 if (tempValue == "") {
   document.getElementById(FieldID).value = TheString;
 }
}
function GetSearchTag(errorMessage,TheBoxMessage,ThePageId) {
  MySearchTag = document.getElementById("q").value;
    if(MySearchTag != "" && MySearchTag != TheBoxMessage){
/* helpdeskStart - nuno.b - 27/01/2012 @ 14:29 (change "&amp;q" for "&q") #5119 */ 
      window.location = "/Default.aspx?ID=" + ThePageId + "&q=" + MySearchTag;
/* helpdeskEnd */
    }
    else {
      alert(errorMessage);
   }
}
 
function getPageLanguage(pageId, destinationArea) {
  $.ajax({
    url: location.protocol + "//" + location.hostname + "/admin/public/getnavigationxml.aspx?Expand=1&ID=" + pageId,
    success: function(data){
      var xml;
      if ($.browser.msie && typeof data == "string") {
        xml = new ActiveXObject("Microsoft.XMLDOM");
        xml.async = false;
        xml.loadXML(data);                
      } else {
         xml = data;
      }
      
      var pathToPage = [];
      $(xml).find("Page[InPath='True']").each(function() {
        pathToPage.push($(this).attr("Sort"));
      });
      getDestinationHref(destinationArea, pathToPage);
    }
  });
}
 
function getDestinationHref(destinationArea, pathToPage) {
  $.ajax({
    url: location.protocol + "//" + location.hostname + "/admin/public/getnavigationxml.aspx?AreaId=" + destinationArea,
    success: function(data){
      var xml;
      if ($.browser.msie && typeof data == "string") {
        xml = new ActiveXObject("Microsoft.XMLDOM");
        xml.async = false;
        xml.loadXML(data);                
      } else {
         xml = data;
      }
      
      jQuerySelector = "";
      for(i=0;i<pathToPage.length;i++) {
        jQuerySelector+="Page[AbsoluteLevel='" + (i+1) + "'][Sort='" + pathToPage[i] + "'] ";
      }
      if ($(xml).find(jQuerySelector).length) {
        $(xml).find(jQuerySelector).each(function() {
          window.location = $(this).attr("FriendlyHref");
        });
      }
      else {
        window.location = "/Default.aspx?AreaId=" + destinationArea;
      }
    }
  });
}
  
function loadTopGraphic(dest, swfpath, xmlpath, lang) {
  var fileExt = swfpath.substr(swfpath.length-3, swfpath.length);
  if (fileExt != 'swf') {
    $(dest).append('<img src="/x.gif" alt="&nbsp;" id="slashLeft" /><img src="/admin/public/getimage.aspx?Image=' + swfpath + '&amp;Width=788&amp;Height=340&amp;Crop=5"  alt="Top Flash" />');
  }
  else {
    $(dest).flash(
      {
        src: swfpath,
        width: 788,
        height: 340,
        flashvars: { swfpath:'/Files/System/TivoliHotels/Flash/', xmlpath:xmlpath, contextid:'-1', langid:lang }
      },
      { version: 8 }
    );
  }
}

function loadNewsTopGraphic(dest, swfpath) {
  var fileExt = swfpath.substr(swfpath.length-3, swfpath.length);
  if (fileExt != 'swf') {
    $(dest).append('<img src="/x.gif" alt="&nbsp;" id="slashLeft" /><img src="/admin/public/getimage.aspx?Image=' + swfpath + '&amp;Width=788&amp;Height=340&amp;Crop=0"  alt="Top Flash" />');
  }
  else {
    $(dest).flash(
      {
        src: swfpath,
        width: 788,
        height: 340
      },
      { version: 8 }
    );
  }
}


function loadRoomsTopGraphic(dest, swfpath, xmlpath, lang) {
  var fileExt = swfpath.substr(swfpath.length-3, swfpath.length);
  if (fileExt != 'swf') {
    $(dest).append('<img src="/x.gif" alt="&nbsp;" id="slashLeft" /><img src="' + swfpath + '" height="424" alt="Top Flash" />');
  }
  else {
    $(dest).flash(
      {
        src: swfpath,
        width: 788,
        height: 424,
        flashvars: { swfpath:'/Files/System/TivoliHotels/Flash/', xmlpath:xmlpath, contextid:'-1', langid:lang }
      },
      { version: 8 }
    );
  }
}

function buildColumns(object, totalColumns) {
  for (i=1;i<=totalColumns;i++) {
   $(object).append('<div class="Columns ColumnHolder' + i + '"></div>');
   $(object + ' div.Column' + i).appendTo(object + ' div.ColumnHolder' + i);
   if (i == totalColumns) {
     $(object + ' div.FormBtns').appendTo(object + ' div.ColumnHolder' + i);
     $(object).append('<div class="clear"></div>');
   }
  }
  $(object + ' .Columns').css({
    float: "left",
    "width": 98/totalColumns + "%"
  });
}
 
function foldersWidth() {
  if ($("#folderMenu ul").length) {
    $("#folderMenu").children("li").css({
      float: 'left',
      'width':(100/$("#folderMenu").children("li").length) + '%'
    });
  }
}
 
function ClickContact(hotelName) {
  hotelName = hotelName.toLowerCase();
  var hotelID = 0;
  /*if (hotelName == 'vic') {
         if ('pt-PT' == languageTag) { hotelID = 60; }
    else if ('en-GB' == languageTag) { hotelID = 5126; }
    else if ('es-ES' == languageTag) { hotelID = 5968; }
    else if ('fr-FR' == languageTag) { hotelID = 6774; }
    else if ('de-DE' == languageTag) { hotelID = 7580; }
    else if ('pt-BR' == languageTag) { hotelID = 9919; }
  }
  else*/ if (hotelName == 'vil') {
         if ('pt-PT' == languageTag) { hotelID = 282223; }
    else if ('en-GB' == languageTag) { hotelID = 282233; }
    else if ('es-ES' == languageTag) { hotelID = 282253; }
    else if ('fr-FR' == languageTag) { hotelID = 689123; }
    else if ('de-DE' == languageTag) { hotelID = 282243; }
    else if ('pt-BR' == languageTag) { hotelID = 282223; }
  }
  else if (hotelName == 'por') {
         if ('pt-PT' == languageTag) { hotelID = 310883; }
    else if ('en-GB' == languageTag) { hotelID = 310843; }
    else if ('es-ES' == languageTag) { hotelID = 310903; }
    else if ('fr-FR' == languageTag) { hotelID = 689063; }
    else if ('de-DE' == languageTag) { hotelID = 310863; }
    else if ('pt-BR' == languageTag) { hotelID = 310883; }
  }
  else if (hotelName == 'car') {
         if ('pt-PT' == languageTag) { hotelID = 348565; }
    else if ('en-GB' == languageTag) { hotelID = 348555; }
    else if ('es-ES' == languageTag) { hotelID = 348575; }
    else if ('fr-FR' == languageTag) { hotelID = 689073; }
    else if ('de-DE' == languageTag) { hotelID = 348585; }
    else if ('pt-BR' == languageTag) { hotelID = 348565; }
  }
  else if (hotelName == 'lag') {
         if ('pt-PT' == languageTag) { hotelID = 310873; }
    else if ('en-GB' == languageTag) { hotelID = 310833; }
    else if ('es-ES' == languageTag) { hotelID = 310893; }
    else if ('fr-FR' == languageTag) { hotelID = 689103; }
    else if ('de-DE' == languageTag) { hotelID = 310853; }
    else if ('pt-BR' == languageTag) { hotelID = 310873; }
  }
  /*else if (hotelName == 'res') {
         if ('pt-PT' == languageTag) { hotelID = 65; }
    else if ('en-GB' == languageTag) { hotelID = 5148; }
    else if ('es-ES' == languageTag) { hotelID = 5954; }
    else if ('fr-FR' == languageTag) { hotelID = 6760; }
    else if ('de-DE' == languageTag) { hotelID = 7566; }
    else if ('pt-BR' == languageTag) { hotelID = 9905; }
  }
  else if (hotelName == 'coi') {
         if ('pt-PT' == languageTag) { hotelID = 67; }
    else if ('en-GB' == languageTag) { hotelID = 5299; }
    else if ('es-ES' == languageTag) { hotelID = 6105; }
    else if ('fr-FR' == languageTag) { hotelID = 6911; }
    else if ('de-DE' == languageTag) { hotelID = 7717; }
    else if ('pt-BR' == languageTag) { hotelID = 10062; }
  }*/
  else if (hotelName == 'lis') {
         if ('pt-PT' == languageTag) { hotelID = 282143; }
    else if ('en-GB' == languageTag) { hotelID = 282153; }
    else if ('es-ES' == languageTag) { hotelID = 282173; }
    else if ('fr-FR' == languageTag) { hotelID = 689052; }
    else if ('de-DE' == languageTag) { hotelID = 282163; }
    else if ('pt-BR' == languageTag) { hotelID = 282143; }
  }
  else if (hotelName == 'jar') {
         if ('pt-PT' == languageTag) { hotelID = 348355; }
    else if ('en-GB' == languageTag) { hotelID = 348345; }
    else if ('es-ES' == languageTag) { hotelID = 348365; }
    else if ('fr-FR' == languageTag) { hotelID = 689093; }
    else if ('de-DE' == languageTag) { hotelID = 348375; }
    else if ('pt-BR' == languageTag) { hotelID = 348355; }
  }
  else if (hotelName == 'ori') {
         if ('pt-PT' == languageTag) { hotelID = 282183; }
    else if ('en-GB' == languageTag) { hotelID = 282193; }
    else if ('es-ES' == languageTag) { hotelID = 282213; }
    else if ('fr-FR' == languageTag) { hotelID = 689062; }
    else if ('de-DE' == languageTag) { hotelID = 282203; }
    else if ('pt-BR' == languageTag) { hotelID = 282183; }
  }
/*  else if (hotelName == 'pal') {
         if ('pt-PT' == languageTag) { hotelID = 75; }
    else if ('en-GB' == languageTag) { hotelID = 5463; }
    else if ('es-ES' == languageTag) { hotelID = 6269; }
    else if ('fr-FR' == languageTag) { hotelID = 7075; }
    else if ('de-DE' == languageTag) { hotelID = 7881; }
    else if ('pt-BR' == languageTag) { hotelID = 10231; }
  }*/
  else if (hotelName == 'sin') {
         if ('pt-PT' == languageTag) { hotelID = 348425; }
    else if ('en-GB' == languageTag) { hotelID = 348405; }
    else if ('es-ES' == languageTag) { hotelID = 348435; }
    else if ('fr-FR' == languageTag) { hotelID = 689133; }
    else if ('de-DE' == languageTag) { hotelID = 348445; }
    else if ('pt-BR' == languageTag) { hotelID = 348425; }
  }
  /*else if (hotelName == 'eco') {
         if ('pt-PT' == languageTag) { hotelID = 546; }
    else if ('en-GB' == languageTag) { hotelID = 5076; }
    else if ('es-ES' == languageTag) { hotelID = 5882; }
    else if ('fr-FR' == languageTag) { hotelID = 6688; }
    else if ('de-DE' == languageTag) { hotelID = 7494; }
    else if ('pt-BR' == languageTag) { hotelID = 9831; }
  }
  else if (hotelName == 'sao') {
         if ('pt-PT' == languageTag) { hotelID = 81; }
    else if ('en-GB' == languageTag) { hotelID = 5527; }
    else if ('es-ES' == languageTag) { hotelID = 6333; }
    else if ('fr-FR' == languageTag) { hotelID = 7139; }
    else if ('de-DE' == languageTag) { hotelID = 7945; }
    else if ('pt-BR' == languageTag) { hotelID = 10297; }
  }*/
console.log(hotelID);
  if (hotelID == 0) {
    alert('erro');
    //top.location.href = document.location.href ;
  }
  else {
    webVoicePop(hotelID);
  }
}
function PreSelectHotel(pageId, lang) {
  var HotelValue = "-1";
      
       //         PT               EN                ES                FR                DE                BR
       if (pageId == 60  || pageId == 5162 || pageId == 5968 || pageId == 6774 || pageId == 7580 || pageId == 9919)  HotelValue = "27500"; // TIVOLI VICTORIA - VILAMOURA
  else if (pageId == 297 || pageId == 5199 || pageId == 6005 || pageId == 6811 || pageId == 7617 || pageId == 9957)  HotelValue = "27497"; // TIVOLI MARINA VILAMOURA
  else if (pageId == 324 || pageId == 5238 || pageId == 6044 || pageId == 6850 || pageId == 7656 || pageId == 9998)  HotelValue = "27511"; // TIVOLI MARINA PORTIMAO
  else if (pageId == 350 || pageId == 5268 || pageId == 6074 || pageId == 6880 || pageId == 7686 || pageId == 10030) HotelValue = "27512"; // TIVOLI CARVOEIRO
  else if (pageId == 64  || pageId == 5116 || pageId == 5922 || pageId == 6728 || pageId == 7534 || pageId == 9872)  HotelValue = "27510"; // TIVOLI LAGOS
  else if (pageId == 65  || pageId == 5148 || pageId == 5954 || pageId == 6760 || pageId == 7566 || pageId == 9905)  HotelValue = "27499"; // THE RESIDENCES AT VICTORIA
  else if (pageId == 67  || pageId == 5299 || pageId == 6105 || pageId == 6911 || pageId == 7717 || pageId == 10062) HotelValue = "27504"; // TIVOLI COIMBRA
  else if (pageId == 69  || pageId == 5329 || pageId == 6135 || pageId == 6941 || pageId == 7747 || pageId == 10093) HotelValue = "27509"; // TIVOLI LISBOA
  else if (pageId == 434 || pageId == 5396 || pageId == 6202 || pageId == 7008 || pageId == 7814 || pageId == 10162) HotelValue = "27508"; // TIVOLI JARDIM
  else if (pageId == 458 || pageId == 5364 || pageId == 6170 || pageId == 6976 || pageId == 7782 || pageId == 10129) HotelValue = "27507"; // TIVOLI ORIENTE
 // else if (pageId == 481 || pageId == 5428 || pageId == 6234 || pageId == 7040 || pageId == 7846 || pageId == 10195) HotelValue = "27503";  TIVOLI MADEIRA
  else if (pageId == 75  || pageId == 5463 || pageId == 6269 || pageId == 7075 || pageId == 7881 || pageId == 10231) HotelValue = "27505"; // TIVOLI PALÁCIO DE SETEAIS
  else if (pageId == 526 || pageId == 5494 || pageId == 6300 || pageId == 7106 || pageId == 7912 || pageId == 10263) HotelValue = "27506"; // TIVOLI SINTRA
  else if (pageId == 546 || pageId == 5076 || pageId == 5882 || pageId == 6688 || pageId == 7494 || pageId == 9831)  HotelValue = "27501"; // TIVOLI ECORESORT PRAIA DO FORTE
  else if (pageId == 81  || pageId == 5527 || pageId == 6333 || pageId == 7139 || pageId == 7945 || pageId == 10297) HotelValue = "27498"; // TIVOLI SÃO PAULO - MOFARREJ
  
  if ($('#hotel').length > 0 && HotelValue != "-1") {
    $('#hotel').getSetSSValue(HotelValue);
  }
  var selecionado = $('#hotel option[value="' + HotelValue + '"]').text(); // Get selected hotel name from option menu
  $('#hotel option[value="' + HotelValue + '"]').attr('selected','selected'); // Set selected hotel because of sinxys, to send the correct hotel.
  $('.selectedHotels .selectedTxt').text(selecionado); // change selected hotel
  $('.selectedHotels a.hiLite').removeClass('hiLite'); // Remove all the highlighted hotels from ul dropdown.
  $('.selectedHotels ul li').find('a').each(function() { 
    if ($(this).text() == selecionado) { // check if the name is equal 
      $(this).addClass('hiLite');  //change highlighted hotel on the ul dropdown.
    }
  });
  var PageIds = new Array();
  var TemplateIds = new Array();
  PageIds = [297, 5199, 6005, 6811, 7617, 9957,   // TIVOLI MARINA VILAMOURA
             324, 5238, 6044, 6850, 7656, 9998,   // TIVOLI MARINA PORTIMAO
             350, 5268, 6074, 6880, 7686, 10030,  // TIVOLI CARVOEIRO
             64,  5116, 5922, 6728, 7534, 9872,   // TIVOLI LAGOS
             69,  5329, 6135, 6941, 7747, 10093,  // TIVOLI LISBOA
             434, 5396, 6202, 7008, 7814, 10162,  // TIVOLI JARDIM
             458, 5364, 6170, 6976, 7782, 10129,  // TIVOLI ORIENTE
             526, 5494, 6300, 7106, 7912, 10263]; // TIVOLI SINTRA
  TemplateIds = [282223, 282233, 282253, 689123, 282243, 282223,  // TIVOLI MARINA VILAMOURA
                 310883, 310843, 310903, 689063, 310863, 310883,  // TIVOLI MARINA PORTIMAO
                 348565, 348555, 348575, 689073, 348585, 348565,  // TIVOLI CARVOEIRO
                 310873, 310833, 310893, 689103, 310853, 310873,  // TIVOLI LAGOS
                 282143, 282153, 282173, 689052, 282163, 282143,  // TIVOLI LISBOA
                 348355, 348345, 348365, 689093, 348375, 348355,  // TIVOLI JARDIM
                 282183, 282193, 282213, 689062, 282203, 282183,  // TIVOLI ORIENTE
                 348425, 348405, 348435, 689133, 348445, 348425]; // TIVOLI SINTRA
  
  for(i=0;i<PageIds.length;i++) {
    if (pageId == PageIds[i]) {
      sufix = "";
//           if ((i+1)%5 == 0) sufix = "_de";
//      else if ((i+1)%4 == 0) sufix = "_fr";
//      else if ((i+1)%3 == 0) sufix = "_es";
//      else if ((i+1)%2 == 0) sufix = "_en";
        if (lang != "pt") sufix = "_"+lang;
      TemplateVar = "Template=" + TemplateIds[i];
      $('#clickToCall').css('display', 'block')
      $('#clickToCall a').bind("click", function() {
        webVoicePop(TemplateVar);
      });
      //$('#clickToCall').css('display', 'block').find('a').attr('onclick','webVoicePop(TemplateVar)');
      // $("#ReservationsForm").append('<div class="ClickToCall"><a href="javascript:void(0);" onclick="webVoicePop(TemplateVar)"><img src="/Files/Billeder/bot_clicktocall' + sufix + '.gif" title="ClickToCall" alt="ClickToCall" /></a></div>');
      break;
    }
  }
}
 
    
/* helpdeskStart - nuno.b - 22/11/2011 @ 10:50 - (Correction of the month name) #4440*/
  function correctFormMonth(str_theForm) {
    var int_option = 0;
    var obj_date = new Date();
    $(str_theForm).find('select').each(function() {
      $(this).find('option').each(function() {
        int_option +=1;
      });
      if (int_option == 12) {
        if ((languageTag  == "pt-BR") || (languageTag == "pt-BR")) {
          $(this).html('<option value="1">Jan</option><option value="2">Fev</option><option value="3">Mar</option><option value="4">Abr</option><option value="5">Mai</option><option value="6">Jun</option><option value="7">Jul</option><option value="8">Ago</option><option value="9">Set</option><option value="10">Oct</option><option value="11">Nov</option><option value="12">Dez</option>');
        }
        else if (languageTag == "fr-FR") {
          $(this).html('<option value="1">Jan</option><option value="2">Fév</option><option value="3">Mar</option><option value="4">Avr</option><option value="5">Mai</option><option value="6">Jui</option><option value="7">Jui</option><option value="8">Aoû</option> value="9">Sep</option><option value="10">Oct</option><option value="11">Nov</option><option value="12">Déc</option>');
        }
        else if (languageTag == "de-DE") {
          $(this).html('<option value="1">Jan</option><option value="2">Feb</option><option value="3">Mär</option><option value="4">Apr</option><option value="5">Mai</option><option value="6">Jun</option><option value="7">Jul</option><option value="8">Aug</option><option value="9">Sep</option><option value="10">Okt</option><option value="11">Nov</option><option value="12">Dez</option>');
        }
        else if (languageTag == "es-ES") {
          $(this).html('<option value="1">Ene</option><option value="2">Feb</option><option value="3">Mar</option><option value="4">Abr</option><option value="5">May</option><option value="6">Jun</option><option value="7">Jul</option><option value="8">Ago</option><option value="9">Sep</option><option value="10">Oct</option><option value="11">Nov</option><option value="12">Dic</option>');
        }
        else if (languageTag == "en-GB") {
          $(this).html('<option value="1">Jan</option><option value="2">Feb</option><option value="3">Mar</option><option value="4">Apr</option><option value="5">May</option><option value="6">Jun</option><option value="7">Jul</option><option value="8">Aug</option><option value="9">Sep</option><option value="10">Oct</option><option value="11">Nov</option><option value="12">Dec</option>');
        }
        
        /* commentStart - nuno.b - 22/11/2011 @ 11:30 - (Defining the current month) #4440 */
        $(this).find('option').each(function() {
          if ($(this).val() == (obj_date.getMonth()+1)) {
            $(this).attr('selected', 'selected');
          }
        });
        /* commentEnd */
      }
      int_option = 0;
    }); 
  }
/* helpdeskEnd */
       
//jquery tools overlay
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);
(function(b){b.tools=b.tools||{};b.tools.expose={version:"1.0.5",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function a(){if(b.browser.msie){var f=b(document).height(),e=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,f-e<20?e:f]}return[b(window).width(),b(document).height()]}function c(h,g){var e=this,j=b(this),d=null,f=false,i=0;b.each(g,function(k,l){if(b.isFunction(l)){j.bind(k,l)}});b(window).resize(function(){e.fit()});b.extend(this,{getMask:function(){return d},getExposed:function(){return h},getConf:function(){return g},isLoaded:function(){return f},load:function(n){if(f){return e}i=h.eq(0).css("zIndex");if(g.maskId){d=b("#"+g.maskId)}if(!d||!d.length){var l=a();d=b("<div/>").css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:0,zIndex:g.zIndex});if(g.maskId){d.attr("id",g.maskId)}b("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",g.color)}if(g.closeOnEsc){b(document).bind("keydown.unexpose",function(o){if(o.keyCode==27){e.close()}})}if(g.closeOnClick){d.bind("click.unexpose",function(o){e.close(o)})}}n=n||b.Event();n.type="onBeforeLoad";j.trigger(n);if(n.isDefaultPrevented()){return e}b.each(h,function(){var o=b(this);if(!/relative|absolute|fixed/i.test(o.css("position"))){o.css("position","relative")}});h.css({zIndex:Math.max(g.zIndex+1,i=="auto"?0:i)});var m=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(g.loadSpeed,g.opacity,function(){if(d.height()!=m){d.css("height",m)}n.type="onLoad";j.trigger(n)})}f=true;return e},close:function(k){if(!f){return e}k=k||b.Event();k.type="onBeforeClose";j.trigger(k);if(k.isDefaultPrevented()){return e}d.fadeOut(g.closeSpeed,function(){k.type="onClose";j.trigger(k);h.css({zIndex:b.browser.msie?i:null})});f=false;return e},fit:function(){if(d){var k=a();d.css({width:k[0],height:k[1]})}},bind:function(k,l){j.bind(k,l);return e},unbind:function(k){j.unbind(k);return e}});b.each("onBeforeLoad,onLoad,onBeforeClose,onClose".split(","),function(k,l){e[l]=function(m){return e.bind(l,m)}})}b.fn.expose=function(d){var e=this.eq(typeof d=="number"?d:0).data("expose");if(e){return e}if(typeof d=="string"){d={color:d}}var f=b.extend({},b.tools.expose.conf);d=b.extend(f,d);this.each(function(){e=new c(b(this),d);b(this).data("expose",e)});return d.api?e:this}})(jQuery);
