﻿var opera = (navigator.appName.indexOf("Opera") != -1) ? true : false;
var firefox = navigator.userAgent.toLowerCase();
firefox = (firefox.indexOf("firefox") != -1) ? true : false;
var safari = navigator.userAgent.toLowerCase();
safari = ((safari.indexOf("safari") != -1) && (safari.indexOf("chrome") == -1)) ? true : false;
var chrome = navigator.userAgent.toLowerCase();
chrome = (chrome.indexOf('chrome') != -1) ? true : false;
var msie_only = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
var msie_old = false; // MSIE versions older than 7
var msie_80 = false; // MSIE version 8.0 or newer
var msie_70 = false; // MSIE vesrion 7.0
var msie_60 = false; // only MSIE 6.0
var msie_55 = false; // only MSIE 5.5

if (msie_only) {
  fullVerStr = navigator.appVersion;
  verStr = fullVerStr.substring(fullVerStr.indexOf('MSIE') + 4, fullVerStr.length);
  verStr = verStr.substring(0, verStr.indexOf(';'));
  msie_old = (parseFloat(verStr) < 7.0) ? true : false;
  msie_80 = (parseFloat(verStr) >= 8.0) ? true : false;
  msie_70 = (parseFloat(verStr) == 7.0) ? true : false;
  msie_60 = (parseFloat(verStr) == 6.0) ? true : false;
  msie_55 = (parseFloat(verStr) == 5.5) ? true : false;
}

document.writeln('<style type="text/css">\n/*<![CDATA[*/\n');
if (msie_80) {
  document.writeln('.LargeLinkBox h3 {line-height:20px; font-weight:bold}\n');
  document.writeln('.Radio, .CheckBox {margin-left:4px; margin-right:2px;}\n');
}

if (msie_70) {
  document.writeln('.LargeLinkBox h3 {line-height:20px; font-weight:bold}\n');
  document.writeln('.AddThisButton {top:350px}\n');
  document.writeln('.NewBanner h1.BannerText {padding-top:20px}\n');
  document.writeln('.NewBanner {padding-top:20px}\n');
  document.writeln('.NewBanner img {top:30px}\n');
  document.writeln('#dialog .Radio {top:-3px}\n');
  document.writeln('.RbVerticalList label {top:1px; left:-7px}\n');
  document.writeln('.RbVerticalList input {left:-7px;}\n');
}

if (msie_old) {
  document.writeln('.LargeLinkBox h3 {line-height:20px; font-weight:bold}\n');
  document.writeln('.WebPartListBox .DragList {height:91px}}\n');
  document.writeln('.LogOutButton {top:83px; right:12px;}\n');
  document.writeln('.GlobalNav {position:relative; top:5px;}\n');
  document.writeln('.List {width:819px}\n');
  document.writeln('.ContentsBlock .CentreColumn {width:819px}\n');
  document.writeln('.ProjectHolder .ProjectMinis .ImageHolder {padding-right:5px}\n');
  document.writeln('.NewBanner {padding-top:0px}\n');
  document.writeln('.Navigation .NavCornerRight  {right:-1px}\n');
  document.writeln('.ThreeColumn .HR  {width:317px}\n');
  document.writeln('.FloatRightAd {top:-7px}\n');
  document.writeln('.CallBackRequest .CallBackBottom {bottom:-11px}\n');
  document.writeln('.Navigation a {position:relative; top:-5px; display:inline; padding:0px 15px 12px 15px;}\n');
  document.writeln('.AccessDiv .AccessSection {width:170px; margin-right:20px; margin-left:10px}\n');
  document.writeln('.Navigation  {padding-bottom:0px; height:15px !important;}\n');
  document.writeln('.Navigation div {padding:5px 6px 0px 6px; height:23px; }\n');
  document.writeln('.RbHorizontalList input {left:-7px;}\n');
  document.writeln('.RbHorizontalList label {left:-7px;}\n');
  document.writeln('.RbVerticalList label {top:1px; left:-7px}\n');
  document.writeln('.RbVerticalList input {left:-7px;}\n');

}
if (msie_only) {
  document.writeln('.RbVerticalList {left:-6px; top:-2px;}\n');
  document.writeln('.RbVerticalList input {position:relative; top:3px}\n');
  document.writeln('.CbVerticalList {left:-6px; top:-2px;}\n');
  document.writeln('.CbVerticalList input {position:relative; top:3px}\n');
}
if (opera) {
  document.writeln('.Radio, .CheckBox {margin-left:3px; margin-right:2px;}\n');
  document.writeln('.RbHorizontalList input {}\n');
  document.writeln('.RbHorizontalList label {top:0px;}\n');
  document.writeln('.RbVerticalList {left:-1px;}\n');
  document.writeln('.RbVerticalList input {margin-top:2px; margin-bottom:3px;}\n');
  document.writeln('.CbVerticalList {left:-1px;}\n');
  document.writeln('.CbVerticalList input {margin-top:2px; margin-bottom:3px;}\n');
}
if (firefox) {
  document.writeln('.Radio, .CheckBox {margin:4px; margin-right:3px; top:2px;}\n');
  document.writeln('.RbHorizontalList label {top:-3px;}\n');
  document.writeln('.RbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.RbVerticalList label {position:relative; top:-3px; margin-left:6px;}\n');
  document.writeln('.CbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.CbVerticalList label {position:relative; top:-3px; margin-left:6px;}\n');
}
if (safari) {
  document.writeln('.Radio, .CheckBox {margin:4px; top:0px;}\n');
  document.writeln('.RbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.RbVerticalList label {top:-3px; margin-left:7px;}\n');
  document.writeln('.CbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.CbVerticalList label {margin-left:7px;}\n');
}
if (chrome) {
  document.writeln('.RbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.RbVerticalList label {top:-3px; margin-left:7px;}\n');
  document.writeln('.CbVerticalList input {margin-top:4px; margin-bottom:3px;}\n');
  document.writeln('.CbVerticalList label {position:relative; top:-2px; margin-left:7px;}\n');
  document.writeln('.AccessCBList label {top:-2px;}\n');
}
document.writeln('/*]]>*/\n</style>\n');

function CorrectPngForIE6(id_or_parent_id) {
  if (msie_old) {
    var img_ref;
    if (document.getElementById(id_or_parent_id).nodeName.toLowerCase() == "img") {
      img_ref = document.getElementById(id_or_parent_id);
    } else {
      img_ref = document.getElementById(id_or_parent_id).getElementsByTagName("img")[0];
    }
    img_ref.src = "/images/spacer.gif";
  }
}


//Limits length of text in textarea "element" (dom reference), writes information in "info" (id), counts characters
function checkLength(element, info, max_length) {
  var actual_length = element.value.length;
  var characters_left = max_length - actual_length;
  if (characters_left < 0) characters_left = 0;

  if (actual_length == 0) {
    document.getElementById(info).innerHTML = "Maximum text length is " + max_length + " characters.";
  }
  if ((actual_length > 0) && (actual_length <= max_length)) {
    document.getElementById(info).innerHTML = "You may enter " + characters_left + " more characters.";
  }
  if (actual_length > max_length) {
    element.value = element.value.substr(0, max_length);
    document.getElementById(info).innerHTML = "You may enter " + characters_left + " more characters.";
  }
}

//init a textarea, textarea_container - id, for charaacters limit
function initLengthInfo(textarea_container, info_id, max_length) {
  if (document.getElementById(textarea_container)) {
    element_ref = document.getElementById(textarea_container).getElementsByTagName("textarea")[0];
    checkLength(element_ref, info_id, max_length);
  }
}

//for search panel
function clearSearchField(field_to_clear) {
  var tmp_obj = field_to_clear.previousSibling;
  tmp_obj = tmp_obj.previousSibling;
  var initial_value = tmp_obj.value;
  if (initial_value == field_to_clear.value) field_to_clear.value = "";
}

//for search panel
function fillSearchField(field_to_fill) {
  var tmp_obj = field_to_fill.previousSibling;
  tmp_obj = tmp_obj.previousSibling;
  var initial_value = tmp_obj.value;
  if (field_to_fill.value == "") field_to_fill.value = initial_value;
}

//STATUS OF COMPLETED MODULES / PROGRESS INDICATION
function toCookie(cookie_id, value) {
  var exp = new Date();
  exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 365));
  var cookie_name = "OBS" + cookie_id + "=" + value;
  var cookie_expires = "expires=" + exp.toGMTString();
  document.cookie = cookie_name + ";" + cookie_expires + "; path=/";
}

//Returns value stored in cookie with given id, or -1 if cookie didn't exist (or is expired), multi value cookies resistant.
function fromCookie(cookie_id) {
  var labelName = "OBS" + cookie_id;
  var labelLen = labelName.length;
  var cookieData = document.cookie;
  var cLen = cookieData.length;
  var i = 0;
  var cEnd;
  while (i < cLen) {
    var j = i + labelLen;
    if (cookieData.substring(i, j) == labelName) {
      cEnd = cookieData.indexOf(";", j);
      if (cEnd == -1) {
        cEnd = cookieData.length;
      }
      return unescape(cookieData.substring(j + 1, cEnd));
    }
    i++;
  }
  return "-1";
}

function __printPage(strUrl) {
  var newWindow = window.open(strUrl, "Print", "toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=700");
}

function __popupPage(strUrl) {
  var newWindow = window.open(strUrl, "PopUp", "toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=916,height=600,top=200,left=200");
}

function openWysiwyg(html_source_id, html_destination_id, editor_width, editor_height, popup_width, popup_height, popup_left, popup_top) {

  var dynamic_url = "http://" + document.domain;
  if (document.URL.indexOf(":81/") > -1) dynamic_url += ":81";
  if (document.URL.indexOf("localhost") > -1) dynamic_url = "http://obs-group.obs-group.co.uk"

  var ww = window.open("", "EditorWindow", "resizable=no,width=" + popup_width + ",height= " + popup_height + ",top=" + popup_top + ",left= " + popup_left);

  ww.document.open();
  ww.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n<head>\n<title>Content editor</title>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n</head>\n<body>');
  ww.document.writeln('<div style="margin-left:auto; margin-right:auto; width:' + editor_width + 'px;">');
  ww.document.writeln('<object type="application/x-xstandard" id="editor1" width="' + editor_width + '" height="' + editor_height + '">');
  ww.document.writeln('<param name="Value" value="' + htmlEncode(document.getElementById(html_source_id).value) + '" />');

  ww.document.writeln('<param name="ImageLibraryURL"      value="' + dynamic_url + '/xstandard/imagelibrary.aspx" />');
  ww.document.writeln('<param name="AttachmentLibraryURL" value="' + dynamic_url + '/xstandard/attachmentlibrary.aspx" />');
  ww.document.writeln('<param name="LinkLibraryURL"       value="' + dynamic_url + '/xstandard/linklibrary.aspx" />');
  ww.document.writeln('<param name="Styles"               value="' + dynamic_url + '/xstandard/editor-styles.xml" />');
  ww.document.writeln('<param name="License"              value="' + dynamic_url + '/xstandard/license.txt" />');
  ww.document.writeln('<param name="CSS"                  value="' + dynamic_url + '/xstandard/general.css" />');

  ww.document.writeln('<param name="ProxySetting" value="direct" />'); //if default proxy settings stops it from working
  ww.document.writeln('<param name="EnableTimestamp" value="no" />'); //the comment inserted at the begining of html
  ww.document.writeln('<param name="EnablePasteMarkup" value="no" />'); //copying from word with formating retained - doesn't work good enough
  ww.document.writeln('<param name="Lang" value="en" />');
  ww.document.writeln('<param name="Dir" value="ltr" />');
  ww.document.writeln('<param name="ClassImageFloatLeft"  value="LeftImage" />');
  ww.document.writeln('<param name="ClassImageFloatRight" value="RightImage" />');
  ww.document.writeln('<param name="ToolbarWysiwyg" value="ordered-list, unordered-list, definition-list, draw-layout-table, draw-data-table, separator, image, hyperlink, attachment, source, preview, help" />');
  ww.document.writeln('<param name="ToolbarPreview" value="wysiwyg, source, preview" />');
  ww.document.writeln('<param name="ToolbarSource" value="word-wrap, validate,, wysiwyg, source, preview" />');
  ww.document.writeln('<param name="Base" value="' + dynamic_url + '/cms-uploaded/" />');
  ww.document.writeln('</object>');

  ww.document.writeln('<div>\n<span style="float:right; height:16px; display:block; margin-top:10px; background-color:#003366;"><a style="font-weight:bold; font-size:10px; font-family:Verdana; text-decoration:none; color:#fff; padding:1px 8px 2px 8px; display:block;" href="javascript:self.opener.document.getElementById(\'' + html_destination_id + '\').value=document.getElementById(\'editor1\').value; self.close();" title="Close">Close</a></span>\n</div>');
  ww.document.writeln('</body>\n</html>');
  ww.document.close();
}

function htmlEncode(s) {
  var str = new String(s);
  str = str.replace(/&/g, "&amp;");
  str = str.replace(/</g, "&lt;");
  str = str.replace(/>/g, "&gt;");
  str = str.replace(/"/g, "&quot;");
  return str;
}

function glowBox(clicked) {
  var option_selected = $(clicked).find('option:selected').val()
  var c = 0
  $(clicked).parent().parent().parent().parent().parent().find('.WebPartTable .WebPartListBox').find(".GlowSpan").fadeOut(300)
  if (option_selected == 'Header') { $(clicked).parent().parent().parent().parent().parent().find('.WebPartTable .WebPartListBox').eq(0).find(".GlowSpan").fadeIn(400) }
  if (option_selected == 'Middle') { $(clicked).parent().parent().parent().parent().parent().find('.WebPartTable .WebPartListBox').eq(1).find(".GlowSpan").fadeIn(400) }
  if (option_selected == 'Footer') { $(clicked).parent().parent().parent().parent().parent().find('.WebPartTable .WebPartListBox').eq(2).find(".GlowSpan").fadeIn(400) }
}


function switchToHighContrast() {
  if ((fromCookie("HighContrast") == "0") || (fromCookie("HighContrast") == "2") || (fromCookie("HighContrast") == "3") || (fromCookie("HighContrast") == "-1")) {
    if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
    if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
    if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
    if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = false;
    toCookie("HighContrast", "1");
  }
}

function switchToHighContrast2() {
  if ((fromCookie("HighContrast") == "0") || (fromCookie("HighContrast") == "1") || (fromCookie("HighContrast") == "3") || (fromCookie("HighContrast") == "-1")) {
    if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
    if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
    if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
    if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = false;
    toCookie("HighContrast", "2");
  }
}

function switchToHighContrast3() {
  if ((fromCookie("HighContrast") == "0") || (fromCookie("HighContrast") == "2") || (fromCookie("HighContrast") == "1") || (fromCookie("HighContrast") == "-1")) {
    if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
    if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
    if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
    if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = false;
    toCookie("HighContrast", "3");
  }
}

function switchToDefault() {
  if ((fromCookie("HighContrast") == "1") || (fromCookie("HighContrast") == "2") || (fromCookie("HighContrast") == "3") || (fromCookie("HighContrast") == "-1")) {
    if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
    if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
    if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
    toCookie("HighContrast", "0");
  }
}

if (fromCookie("HighContrast") == "1") {
  if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
  if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
  if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
  if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = false;
}
else if (fromCookie("HighContrast") == "2") {
  if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
  if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
  if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
  if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = false;
}
else if (fromCookie("HighContrast") == "3") {
  if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
  if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
  if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
  if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = false;
}
else {
  if (document.getElementsByTagName("link")[2]) document.getElementsByTagName("link")[2].disabled = true;
  if (document.getElementsByTagName("link")[3]) document.getElementsByTagName("link")[3].disabled = true;
  if (document.getElementsByTagName("link")[4]) document.getElementsByTagName("link")[4].disabled = true;
}

function textSize1() {
  $("body").css("fontSize", "62.5%");
  toCookie("TextSize", "1");
}

function textSize2() {
  $("body").css("fontSize", "82.5%");
  toCookie("TextSize", "2");
}

function textSize3() {
  $("body").css("fontSize", "100%");
  toCookie("TextSize", "3");
}

function initcheckTextSize() {
  document.writeln('<style type="text/css">\n/*<![CDATA[*/\n');
  if (fromCookie("TextSize") == "3") {
    document.writeln('body {font-size:100%;}\n');
  }
  else if (fromCookie("TextSize") == "2") {
    document.writeln('body {font-size:82.5%;}\n');
  }
  else {
    document.writeln('body {font-size:62.5%;}\n');
  }
  document.writeln('/*]]>*/\n</style>\n');
}

function initCheckTabPosition() {
  var alt_text = $('.NewBanner2 img').attr('alt')
  $('.Navigation div').each(function() {
    if ($(this).find('a').html() == alt_text) {
      $(this).addClass('Selected')
    }
  });
}

function initProjectPage() {
  $('.ProjectHolder').each(function() {
    $(this).find('.MainImage').attr('src', $(this).find('.ImageHolder').eq(0).find('img').attr('src'))
    $(this).find('.ImageHolder:last').css('paddingRight','0px')
    $(this).find('.ImageHolder img').css('opacity', '0.3')
    $(this).find('.ImageHolder').eq(0).find('img').addClass('SelectedImage')
    $(this).find('.ImageHolder').eq(0).find('img').css('opacity','1')
  });
};

function projectImageChange(clicked) {
  var new_src = $(clicked).find("img").attr("src");
  $(clicked).closest(".Project").find(".ProjectPic").attr("src", new_src);
  if ($(clicked).is(".ActiveImage")) { }
  else {
    $(clicked).parent().find(".ActiveImage").find("div").fadeIn(500);
    $(clicked).parent().find(".ActiveImage").removeClass("ActiveImage");
    $(clicked).addClass("ActiveImage");
  }
}

function projectFirstImage() {
  $('.Project').each(function() {
    $(this).find('.ImageHolder').eq(0).addClass('ActiveImage')
  });
}

function initArticleList() {
  var new_height = 0;
  var old_height = 0;
  $('.ListDropDown .ListDropDownLink a').click(function(){
    new_height = $(this).parent().next('.ListArticles').height() + 50
  });
  var hidden_field_year = $('.ListHiddenFields input:eq(0)').attr('value')
  var hidden_field_month = $('.ListHiddenFields input:eq(1)').attr('value')
  var list_height = $('.ListPage').height();
  
  $("div.ListPage").find("div.ListMonths").each(function() {
    $(this).css('height', ($(this).find('h2.ListDropDownLink').length) * 2.7 + 'em')
  });
  var list_page = $('div.ListPage')
  var list_months = list_page.find('div.ListMonths')
  var top_level_links = $(".ListPage").find(".ListDropDownLink:not(.ListDropDown .ListDropDownLink)")
  list_months.eq(hidden_field_year).css("display", "block").find("div.ListDropDown").eq(hidden_field_month).css("display", "block")
  list_months.eq(hidden_field_year).css("display", "block").find("h2.ListDropDownLink").eq(hidden_field_month).find('a').addClass('Active')
  //top_level_links.eq(hidden_field_year).css("backgroundImage", "url(/images/default/minus-blue.gif)")
  top_level_links.eq(hidden_field_year).find('a').addClass('Active')
  var visible_link = $('h2.ListDropDownLink:visible')
  old_height = ((visible_link.height()) * 20) + ((visible_link.height()) * $('h2.LinkYear').length)

  if ($('.ListArticles:visible').height() > $('.ListPage').height()) {
    $('.ListPage').css('height', $('.ListArticles:visible').height())
  }


  $("h2.ListDropDownLink a").click(function() {
  if ($(this).parent().next("div.ListDropDown").is(":hidden")) {
    if (new_height >= old_height) {
        list_page.animate({ height: new_height }, 400)
      }
      else if (new_height < old_height) {
        list_page.animate({ height: old_height }, 400)
      }
      if ($(this).closest('div.ListDropDown').is('div.ListMonths')) {
          $('.Active').removeClass('Active')
          $(this).addClass('Active')
        $(this).parent().parent().find("div.ListDropDown").slideUp(400);
        $('div.ListHiddenFields input:eq(1)').attr('value', $(this).closest('div.ListMonths').find('h2.ListDropDownLink').index($(this).parent()))
      }
      else {
        $(this).parent().parent().find('.Active:not(div.ListMonths .Active)').removeClass('Active')
        $(this).addClass('Active')
        //$('h2.ListDropDownLink').css("backgroundImage", "url(/images/default/plus-blue.gif)")
        $(this).parent().parent().find("div.ListDropDown:not(div.ListDropDown div.ListDropDown)").slideUp(400);
        $('div.ListHiddenFields input:eq(0)').attr('value', $('.ListDropDownLink:not(.ListMonths .ListDropDownLink)').index($(this).parent()))
      }

      $(this).parent().next("div.ListDropDown").slideDown(400);
      //$(this).parent().css("backgroundImage", "url(/images/default/minus-blue.gif)")
    }
    else {
      if ($(this).closest('div.ListDropDown').is('div.ListMonths')) {
          $(this).removeClass('Active')
        $('div.ListHiddenFields input:eq(1)').attr('value', '0')
      }
      else {
        $('div.ListHiddenFields input:eq(0)').attr('value', '0')
      }
      $(this).parent().next("div.ListDropDown").slideUp(400);
      //$(this).parent().css("backgroundImage", "url(/images/default/plus-blue.gif)")
      list_page.animate({ height: old_height }, 400)

    }
    return false;
  })
   
}



function updateWebPage() {
  var listbox_index = $('.WebPartTable select').length;
  for (var j = 0; j < listbox_index; j++) {
    var value_index = $('.WebPartListBox').eq(j).find('select option').length;
    var hidden_field = $('.HiddenFields').find('input').eq(j);
    var list_string = ''
    for (var i = 0; i < value_index; i++) {
      var current_value = $('.WebPartListBox').eq(j).find('select option').eq(i).attr('value') + ','
      var list_string = list_string + current_value
    }
    $(hidden_field).attr('value', list_string)
  }
}


function popDrag(id1, id2) {
  var this_draglist = document.getElementById(id2);
  var this_contents = ''
  $('#' + id1 + ' option').each(function() {
    var this_value = $(this).attr('value');
    this_contents += '<div value=' + this_value + ' class="drag">' + $(this).html() + '</div>'
  });
  this_draglist.innerHTML = this_contents
}

function dragInit() {
  $('.WebPartPosTable .DragList div').click(function() {
    $('.DragList div').removeClass('SelectedDiv')
    $(this).addClass('SelectedDiv')
    var look_for = $(this).parent().find('div').index(this)
    $(this).closest('td').find('option').eq(look_for).attr('selected', 'selected')
    var grab_value = $(this).attr('value')
    $('option[value=' + grab_value + ']').attr('selected', 'selected')
    $('div[value=' + grab_value + ']').addClass('SelectedDiv')
  });
  $('.WebPartPosTable .DragList div').dblclick(function() {
    $('.EditWebPart').click()
    return false
  });
  bindDrag();
}

function dragInit2() {
  $('.DragList div').click(function() {
    $('.DragList div').removeClass('SelectedDiv')
    $(this).addClass('SelectedDiv')
    var look_for = $(this).parent().find('div').index(this)
    $(this).closest('td').find('option').eq(look_for).attr('selected', 'selected')
    var grab_value = $(this).attr('value')
    $('option[value=' + grab_value + ']').attr('selected', 'selected')
    $('div[value=' + grab_value + ']').addClass('SelectedDiv')
  });
  $('.DragList div').dblclick(function() {
    $('#filter_text_id').removeAttr('value')
    filterFunction('DropInit1', '')
    var grab_value = $(this).attr('value')
    $('option[value=' + grab_value + ']').attr('selected', 'selected')
    $('div[value=' + grab_value + ']').addClass('SelectedDiv')
    $('.EditWebPart').click()
    return false
  });
  bindDrag();
}

function bindDrag() {
  var drag_contents = 0;
  var drag_value = 0;
  $(function() {
    $(".drag")
		.bind("dragstart", function(event) {
		  $(this).closest('td').find('option').eq($(this).parent().find('div').index(this)).addClass('RemoveOption')
		  var $drag = $(this), $proxy = $drag.clone();
		  $drag.addClass("outline");
		  $drag.css("opacity", "0.5");
		  return $proxy.appendTo(document.body).addClass("ghost");
		})
		.bind("drag", function(event) {
		  $('.SelectedDiv').removeClass('SelectedDiv')
		  $(event.dragProxy).css({
		    position: "absolute",
		    cursor: "move",
		    zIndex: "1000",
		    left: event.offsetX,
		    top: event.offsetY,
		    opacity: "0.5"
		  });
		  drag_contents = $(this).html()
		  drag_value = $(this).attr('value')
		})
		.bind("dragend", function(event) {
		  $(event.dragProxy).fadeOut("normal", function() {
		    $(this).remove();
		  });
		  if (drag_contents != 0 && $(this).closest('td').find('select option.RemoveOption').length == 0) {
		    $(this).closest('td').find('select').html($(this).closest('td').find('select').html() + '<option value=' + drag_value + '>' + drag_contents + '</option>')
		  }
		  $(this).removeClass("outline");
		  $(this).css("opacity", "1");
		});
    $('.drop')
		.bind("dropstart", function(event) {
		  if (this == event.dragTarget.parentNode) return false;
		  $(this).addClass("active");
		})
		.bind("drop", function(event) {
		  $(this).append(event.dragTarget);
		})
		.bind("dropend", function(event) {
		  $(this).removeClass("active");
		});

  });
}

var load_timer;
var load_var = 0;
function animLoad() {
  if (load_var == 1) {
    $('.NewBanner img').fadeIn(350, function() {
      $('.CallBackRequest').slideDown(250, function() {
        $('.NewBanner .BannerText').slideDown(150)
        $('.NewBanner img').removeAttr('style')
        $('.NewBanner img').css('display', 'block')
        $('.TwitterOBS').fadeIn(350)

      });
    });
    clearTimeout(load_timer);
  }
  else {
    load_var++;
    setTimeout('animLoad()', 500)
  }
}

function animLoad2() {
  //alert($('.NewBanner2 .BannerText').text().eq(0))
  $('.NewBanner2 h1').each(function() {
    var this_index = $('.NewBanner2 h1').index(this)
    if ($('.NewBanner2 h1:eq(' + this_index + ') span').length > 1) {
      $('.NewBanner2 h1:eq(' + this_index + ') span:first').addClass('BannerTextL1')
      $('.NewBanner2 h1:eq(' + this_index + ') span:last').addClass('BannerTextL3')
    }
  });
  if ($('.NewBanner2').is('.Blue')) {
    Cufon.replace('.NewBanner2 span', {
      fontFamily: 'Arial-Bold',
      color: '-linear-gradient(#3899CD, #57A9D5, #3899CD)'
    });
  }
  else if ($('.NewBanner2').is('.Orange')) {
    Cufon.replace('.NewBanner2 span', {
      fontFamily: 'Arial-Bold',
      color: '-linear-gradient(#CD4841, #D76D68, #CD4841)'
    });
  }
  else if ($('.NewBanner2').is('.Orange2')) {
    Cufon.replace('.NewBanner2 span', {
      fontFamily: 'Arial-Bold',
      color: '-linear-gradient(#FF7F00, #FF9933, #FF7F00)'
    });
  }
  else {
    Cufon.replace('.NewBanner2 span', {
      fontFamily: 'Arial-Bold',
      color: '-linear-gradient(#6E850E, #85A211, #6E850E)'
    });
  }
  Cufon.now()
  //alert($('.NewBanner2 p:first span').length)
  if ($('body').width() < 998) {
    $('.NewBanner2 span:first').css('left', '0px')
  }
}



function mapInitialize() {
  if (google.maps.BrowserIsCompatible() && document.getElementById("MapCanvas")) {
    var map = new google.maps.Map2(document.getElementById("MapCanvas"));
    map.enableContinuousZoom();
    map.enableScrollWheelZoom();

    map.setCenter(new google.maps.LatLng(51.521500, -0.081939), 15);

    map.addControl(new google.maps.SmallMapControl());
    map.addControl(new google.maps.MapTypeControl(true));

    var marker = new google.maps.Marker(new google.maps.LatLng(51.523616, -0.083439));
    map.addOverlay(marker);

  }
}


//Add This Button
var addthis_brand = "OBS Group";
var addthis_header_color = "#FFF";
var addthis_header_background = "#7C97A1";
//END


function publicLinkExt() {

  $('body').find('a').each(function() {
    if ($(this).attr('onclick') || $(this).attr('target')) {
      $(this).after('&nbsp;<img src="/images/default/exitlink.gif" class="ExternalLinkImg" alt=""/>')
    }
  });
}


$(document).ready(function() {


  if ($('.MapCanvas').length == 1) {
    mapInitialize()
  }

  $('.ScrollProjectHolder').cycle({
    fx: 'scrollLeft',
    speed: 900,
    timeout: 3000,
    next: '.ScrollProjectNext',
    prev: '.ScrollProjectPrev',
    cleartype: true,
    manualTrump: false,
    cleartypeNoBg: true
  });


  $('.ProjectHolder .MainImage, .ProjectStatic .ExpandArrow').click(function() {
    var main_index = $(this).closest('.ProjectInner').find('.MainImage').index($(this).closest('.ProjectStatic').find('.MainImage'));
    if (main_index == 2 || main_index == 3) {
      $(this).addClass('LastMainImage')
    }
    if ($(this).closest('.ProjectHolder').width() < '650') {
      $('.ActiveHolder').removeClass('ActiveHolder')
      $(this).closest('.ProjectHolder').addClass('ActiveHolder')
      $('.ActiveInner').removeClass('ActiveInner')
      $(this).closest('.ProjectInner').addClass('ActiveInner')
      if ($(this).is('.LastMainImage')) {
        $('.ProjectHolder:not(.ActiveHolder)').animate({ width: '316px' }, 400)
        $('.ProjectHolder:not(.ActiveHolder)').find('img:eq(0)').addClass('MainImage')
        $('.ProjectHolder:not(.ActiveHolder)').find('img:eq(0)').removeClass('MainImageClicked')
        $('.ProjectHolder:not(.ActiveHolder)').find('.ExpandArrow').removeClass('ExpandBack')
        $('.ProjectInner:not(.ActiveInner)').animate({ left: '0px' }, 400)
        $(this).closest('.ProjectHolder').animate({ width: '652px' }, 400)
        $(this).closest('.ProjectInner').animate({ left: '-335px' }, 400)
        $(this).closest('.ProjectStatic').find('.MainImage').addClass('MainImageClicked')
        $(this).closest('.ProjectStatic').find('.MainImage').removeClass('MainImage')
        $(this).closest('.ProjectStatic').find('.ExpandArrow').addClass('ExpandBack')
      }
      else {
        $('.ProjectInner').animate({ left: '0px' }, 400)
        $('.ProjectHolder:not(.ActiveHolder)').animate({ width: '316px' }, 400)
        $('.ProjectHolder:not(.ActiveHolder)').find('img:eq(0)').addClass('MainImage')
        $('.ProjectHolder:not(.ActiveHolder)').find('img:eq(0)').removeClass('MainImageClicked')
        $('.ProjectHolder:not(.ActiveHolder)').find('.ExpandArrow').removeClass('ExpandBack')
        $(this).closest('.ProjectHolder').animate({ width: '652px' }, 400)
        $(this).closest('.ProjectStatic').find('.MainImage').addClass('MainImageClicked')
        $(this).closest('.ProjectStatic').find('.MainImage').removeClass('MainImage')
        $(this).closest('.ProjectStatic').find('.ExpandArrow').addClass('ExpandBack')
      }
    }
    else {
      $(this).closest('.ProjectInner').animate({ left: '0px' }, 400)
      $(this).closest('.ProjectHolder').animate({ width: '316px' }, 400, function() {
        $(this).find('.MainImageClicked').addClass('MainImage')
        $(this).find('.MainImageClicked').removeClass('MainImageClicked')
      })
      $(this).closest('.ProjectStatic').find('.ExpandArrow').removeClass('ExpandBack')
    }
    return false;
  });

  $('.ProjectCloseButton').click(function() {
    $(this).closest('.ProjectInner').animate({ left: '0px' }, 400)
    $('.ExpandArrow').removeClass('ExpandBack')
    $(this).closest('.ProjectHolder').animate({ width: '316px' }, 400, function() {
      $(this).closest('.ProjectHolder').find('.MainImageClicked').addClass('MainImage')
      $(this).closest('.ProjectHolder').find('.MainImageClicked').removeClass('MainImageClicked')
    })
  });

  $('.ProjectHolder .ProjectMinis .ImageHolder').click(function() {
    $(this).parent().find('img').css('opacity', '0.3')
    $(this).find('img').css('opacity', '1')
    $(this).parent().find('img').removeClass('SelectedImage')
    $(this).find('img').addClass('SelectedImage')
    $(this).closest('.ProjectStatic').find('.MainImage').attr('src', $(this).find('img').attr('src'))
    $(this).closest('.ProjectStatic').find('.MainImageClicked').attr('src', $(this).find('img').attr('src'))
    return false;
  });

  $('.ProjectHolder .ProjectMinis .ImageHolder').hover(function() {
    $(this).find('img').css('opacity', '1')
  }, function() {
    if ($(this).find('img').is(':not(.SelectedImage)')) {
      $(this).find('img').css('opacity', '0.3')
    }
  });


  $(".ImageHolder").mouseenter(function() {
    $(this).find("div").fadeOut(150);
  }).mouseleave(function() {
    if ($(this).is(".ActiveImage")) { }
    else { $(this).find("div").fadeIn(500) };
  }
  )

  $(".ImageHolder div").css("opacity", "0.7")

  $(".ThreeColumn").eq(0).find(".Column").eq(1).css("margin", "0px 19px 0px 19px");
  $(".ThreeColumn").eq(1).find(".Column").eq(1).css("margin", "0px 19px 0px 19px");
  $(".ThreeColumn").eq(2).find(".Column").eq(1).css("margin", "0px 19px 0px 19px");
  $(".ThreeColumn").eq(3).find(".Column").eq(1).css("margin", "0px 19px 0px 19px");
  $(".ThreeColumn2").find(".Column").eq(1).css("margin", "0px 19px 0px 19px");
  $(".ThreeColumn .Column").css("visibility", "visible")
  $(".ThreeColumn2 .Column").css("visibility", "visible")

  $(".WebPartListBox .DragList").click(function() {
    if ($(this).parent().parent().find(".GlowSpan").is(":hidden")) {
      $(this).parent().parent().parent().parent().find(".GlowSpan").fadeOut(300)
      $(this).parent().parent().find(".GlowSpan").fadeIn(400)
    }
    if ($(this).parent().find('select').is('.ListBoxHeader')) { change_dropdown = 0 }
    else if ($(this).parent().find('select').is('.ListBoxMiddle')) { change_dropdown = 1 }
    else { change_dropdown = 2 }
    $('.PositionDropDown').find('option').eq(change_dropdown).attr('selected', 'selected')
  });


  $('.WebPartTools .WebUp').click(function() {
    var active_option = $(this).closest('.WebPartListBox').find('select option:selected')
    var inactive_option = $(this).closest('.WebPartListBox').find('select option:selected').prev('option')
    var active_div = $(this).closest('td').find('.SelectedDiv')
    var inactive_div = $(this).closest('td').find('.SelectedDiv').prev('div')
    if ($(this).closest('.WebPartListBox').find('select option').index($(this).closest('.WebPartListBox').find('select option:selected')) != 0) {
      $(active_option).addClass('RemoveThis')
      $(active_option).clone().insertBefore(inactive_option)
      $('.RemoveThis').eq(1).remove()
      $('.RemoveThis').attr('selected', 'selected')
      $('.RemoveThis').removeClass()

      $(active_div).addClass('RemoveDiv')
      $('.RemoveDiv').clone(true).insertBefore(inactive_div)
      $('.RemoveDiv').eq(1).remove()
      $('.RemoveDiv').addClass('.SelectedDiv')
      $('.RemoveDiv').removeClass('RemoveDiv')
    }
  });
  $('.WebPartTools .WebDown').click(function() {
    var active_option = $(this).closest('.WebPartListBox').find('select option:selected')
    var inactive_option = $(this).closest('.WebPartListBox').find('select option:selected').next('option')
    var active_div = $(this).closest('td').find('.SelectedDiv')
    var inactive_div = $(this).closest('td').find('.SelectedDiv').next('div')

    if ($(this).closest('.WebPartListBox').find('select option').index($(this).closest('.WebPartListBox').find('select option:selected')) != ($(this).closest('.WebPartListBox').find('select option').length) - 1) {
      $(active_option).addClass('RemoveThis')
      $(active_option).clone().insertAfter(inactive_option)
      $('.RemoveThis').eq(0).remove()
      $('.RemoveThis').attr('selected', 'selected')
      $('.RemoveThis').removeClass()
      $(active_div).addClass('RemoveDiv')
      $(active_div).clone(true).insertAfter(inactive_div)
      $('.RemoveDiv').eq(0).remove()
      $('.RemoveDiv').addClass('.SelectedDiv')
      $('.RemoveDiv').removeClass('RemoveDiv')
    }
  });
  $('.WebPartTools .WebRemove').click(function() {
    var active_option = $(this).closest('.WebPartListBox').find('select option:selected')
    var active_div = $(this).closest('td').find('.SelectedDiv')
    $(active_option).remove()
    $(active_div).remove()
  });


  $(".ForJQDiv input").keypress(function(event) {
    if (event.keyCode == 13) {
      $(".Default").click();
      return false;
    }
    else {
      return true;
    }

  });

  //FIX FOR ENTER BUTTON FUNCTIONALITY ON CONTACT PAGE

  //    $('.ForJQDiv input').keydown(function() {
  //    $('.DefaultButton:eq(1) input').removeAttr('disabled')
  //    $('.DefaultButton:eq(0) input').attr('disabled', 'disabled')
  //  });
  //    $('.ForJQDiv2 input').keydown(function() {
  //    $('.DefaultButton:eq(0) input').removeAttr('disabled')
  //   $('.DefaultButton:eq(1) input').attr('disabled', 'disabled')
  //    });


  //use closest below
  //Highlight on focus - selects, textareas, textboxes
  $("select.WithFocusHighlight, textarea.WithFocusHighlight, input.WithFocusHighlight").focus(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").addClass("FormBoxHighlighted");
  });
  $("select.WithFocusHighlight, textarea.WithFocusHighlight, input.WithFocusHighlight").blur(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").removeClass("FormBoxHighlighted");
  });

  //Highlight on focus - single checkbox/radiobutton
  $("span.WithFocusHighlight > input").focus(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").addClass("FormBoxHighlighted");
  });
  $("span.WithFocusHighlight > input").click(function() { //added onclick because of safari
    $(this).focus();
  });
  $("span.WithFocusHighlight > input").blur(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").removeClass("FormBoxHighlighted");
  });

  //Highlight on focus - radiobutton/checkbox lists
  $("table.WithFocusHighlight").find("input").focus(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").addClass("FormBoxHighlighted");
  });
  $("table.WithFocusHighlight").find("input").click(function() { //added onclick because of safari
    $(this).focus();
  });
  $("table.WithFocusHighlight").find("input").blur(function() {
    $(this).closest(".FormBox, .FormBoxFullWidth").removeClass("FormBoxHighlighted");
  });

  //validation highlight
  $(".WithFocusHighlight").closest(".FormBox").find(".ValidationInfo").each(function() {
    if ($(this).closest(".InnerFormBox").length == 1) {
      $(this).closest(".InnerFormBox").find("input").addClass("InputFieldHighlighted");
      $(this).closest(".InnerFormBox").find("select").addClass("InputFieldHighlighted");
      $(this).closest(".InnerFormBox").find("textarea").addClass("InputFieldHighlighted");
    } else {
      $(this).closest(".FormBox").find("input").addClass("InputFieldHighlighted");
      $(this).closest(".FormBox").find("select").addClass("InputFieldHighlighted");
      $(this).closest(".FormBox").find("textarea").addClass("InputFieldHighlighted");
    }
  });

  var current_year = new Date()
  $('.GetYear').html(current_year.getFullYear())

  var add_this = "this, '', '[URL]', '[TITLE]'"
  $('.AddThisButton').html('<div class="addthis_toolbox addthis_default_style"><a href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4b1659a65851d6bb" class="addthis_button_compact ShareButton"><img class="AddThisLinkSpacer" src="/images/spacer.gif" /></a><a class="addthis_button_facebook addthisFacebook"><img class="AddThisLinkSpacer" src="/images/spacer.gif" /></a><a class="addthis_button_myspace addthisMyspace"><img class="AddThisLinkSpacer" src="/images/spacer.gif" /></a><a class="addthis_button_google addthisGoogle"><img class="AddThisLinkSpacer" src="/images/spacer.gif" /></a><a class="addthis_button_twitter addthisTwitter"><img class="AddThisLinkSpacer" src="/images/spacer.gif" /></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b1659a65851d6bb"></script>')
$('.AddThisButton').fadeIn(1000)



//  $('a').click(function() {
//    alert($(this).attr().length)
//  });


});

///////Filter functions start///////////
//function invoked onload at body tag; or just before closiong body tag
function initArrays() {
  select_objects = document.getElementsByTagName('select'); //must be global
  all_selects = new Array();  //must be global, 3 dimensional array [ids of all selects][counter of each option in given select]['value' or 'text']= value or text of given option in given select
  options_selected = new Array(); //must be global, 2 dimensional array [ids of selects on which onchange or onkeydown function was invoked][values of selected options for associative addressing]=true ,but this boolean value is not used, existence of array entry is tested.

  for (var i = 0; i < select_objects.length; i++) {
    var index = select_objects[i].id;  // id of select tag
    all_selects[index] = new Array();
    options_selected[index] = new Array();
    for (var j = 0; j < select_objects[i].length; j++) {  //number of options elements in given select tag
      all_selects[index][j] = new Array();
      all_selects[index][j]['value'] = select_objects[i].options[j].value;
      all_selects[index][j]['text'] = select_objects[i].options[j].text;
    } //for j
  } //for i
}

//function invoked onkeyup of input tag containing search phrase
function filterFunction(container_id, filter) {
  //container_id - id of a div containing related ddl
  //filter - reference to input tag containing filter phrase or "" for bringing back all options into select
  //sel - reference to related dropdownlist (select)
  var container_ref = document.getElementById(container_id);
  var sel = container_ref.getElementsByTagName("select")[0];
  if (sel) {
    var select_id = sel.id;
  } else {
    return; //if sendForm gives unpredictable id of other listboxes that don't use filter
  }

  if (options_selected[select_id].length == 0)
    selectFunction(document.getElementById(select_id)); //remember already selected options, not only these selected manualy
  sel.options.length = 0;
  var k = 0;
  for (var i = 0; i < all_selects[select_id].length; i++) {
    var t = all_selects[select_id][i]['text'];
    var t_for_search = t.toLowerCase();
    var v = all_selects[select_id][i]['value'];
    var filter_text = (typeof filter == "object") ? filter.value.toLowerCase() : '';
    if (t_for_search.indexOf(filter_text) >= 0)  // == to search from the begining of the listbox item
      sel.options[k++] = new Option(t, v, false, (typeof options_selected[select_id][v] != "undefined"));
  }
}

//function invoked onchange at select tag
function selectFunction(this_select) {
  var number_of_options = this_select.options.length;  //in given select
  for (var i = 0; i < number_of_options; i++) {
    if (this_select.options[i].selected == true) {
      options_selected[this_select.id][this_select.options[i].value] = true;
    } else {
      if (typeof options_selected[this_select.id][this_select.options[i].value] != "undefined")
        delete options_selected[this_select.id][this_select.options[i].value];
    }
  }
}

///////Filter functions end///////////


function initNavigation() {
  $('.Navigation div:last').css('paddingRight', '0px')
  $('.Navigation a').each(function() {
    if (window.location.href.indexOf($(this).attr('href')) != -1) {
      $(this).parent().addClass('Selected')
    }
    if (window.location.href == 'http://www.obs-group.co.uk/' || window.location.href == 'http://obs-group.obs-group.co.uk/') {
      $('.Navigation a:first').parent().addClass('Selected')
    }
  });
}

function checkTestiColumn() {
  if ($('.TestimonialColumn').length > 0) {
    $('.Contents .HR:not(.ThreeCol .HR)').css('width','670px')
  }
}


function checkOccasion() {
  if (!msie_60) {
    var today = new Date()
    var this_month = (today.getMonth() + 1)
    if (this_month == 12) {
      var doc_height = $(window).height()
      var anim_height = (Math.ceil(doc_height / 350) * 350)
      $('.ChristmasSnowflakes').css('display', 'block')
      $('.ChristmasSnowflakes').css('height', doc_height + 'px')
      $('.ChristmasSnowflakes div,.ChristmasSnowflakes span').css('height', (anim_height * 2) + 'px')
      letItSnow(anim_height)
      letItSnow2(anim_height)
      //$('.OccasionChristmas').css('display', 'block')
      //$('.ChristmasSpacer').css('display', 'block')
      
    }
  }
}

function letItSnow(anim_height) {
  $('.ChristmasSnowflakes div').animate({ bottom: '-' + anim_height + 'px' }, 60000, 'linear', function() {
    $('.ChristmasSnowflakes div').css('bottom', '0px')
    letItSnow(anim_height);
  })
}

function letItSnow2(anim_height) {
  $('.ChristmasSnowflakes span').animate({ bottom: '-' + anim_height + 'px' }, 120000, 'linear', function() {
  $('.ChristmasSnowflakes span').css('bottom', '0px')
  letItSnow2(anim_height);
  })
}

