jQuery(document).ready(function() {
  // border radius
  jQuery.support.borderRadius = false;
	jQuery.each(['BorderRadius','MozBorderRadius','WebkitBorderRadius','OBorderRadius','KhtmlBorderRadius','borderTopLeftRadius'], function() {
		if (document.body.style[this] !== undefined) jQuery.support.borderRadius = true;
		return (!jQuery.support.borderRadius);
	});
  
  // add corner image to specified elements when border radius is not supported
  if (!jQuery.support.borderRadius) {
    // images
    $('#content .specs img').each(function() {
      $(this).wrap('<div style="position:relative"></div>');
      $wrapper = $(this).after($('<div class="imagewrapper-corners"></div>')).next();
      $wrapper.css({
        'position' : 'absolute',
        'top' : this.offsetTop + 1,
        'left' : this.offsetLeft + 1,
        'width' : $(this).outerWidth() - 2,
        'height' : $(this).outerHeight() - 2
      });
    });
  
    $('#header, #content .promo, #content .itemlist li, #content .questions li, #content .imagewrapper-corners, .personal div#logo').each(function() {
      $elem = $(this);
      if ($elem.css('position') == 'static')
        $elem.css('position', 'relative');
      
      var corners = {
        'left top'    : 'corner-tl.gif',
        'right top'   : 'corner-tr.gif',
        'right bottom': 'corner-br.gif',
        'left bottom' : 'corner-bl.gif'
      };

      $.each( corners, function(pos, img) {
        var $corner = $('<div></div>').css({
          'background' : "transparent url('/~siteDesign/site/~img/" + img + "') no-repeat " + pos,
          'position' : 'absolute',
          'width' : '3px',
          'height' : '3px',
          'margin' : 0,
          'padding' : 0
        });
        
        // position
        $corner.css(pos.split(' ')[0] == 'left' ? 'left' : 'right', '-1px');
        $corner.css(pos.split(' ')[1] == 'top' ? 'top' : 'bottom',  '-1px');
        
        $elem.append($corner);
      });
    });
  }
  
  // clickable blocks
  $('.itemlist li, .promo, .personal div#logo').each(function() {
    var a = $(this).find('a')[0];
    if (a) {
      if ($(this).css('position') == 'static')
        $(this).css('position', 'relative');
      
      // set pointer on current element (ie ...)
      $(this).css('cursor', 'pointer');
      
      // clone the physical element      
      $(a).clone().css({
        'background-image' : 'url(/~siteDesign/site/~img/transparent.gif)',
        'background-color' : 'transparent',
        'display' : 'block',
        'width' : '100%',
        'height' : '100%',
        'position' : 'absolute',
        'margin' : 0,
        'padding' : 0,
        'top' : 0,
        'left' : 0
      }).text('').appendTo($(this)).children().remove();
    }
  });
  
  // create element for the login dialog
  $('<div id="jqModalLogin" class="jqmWindow"></div>').appendTo('body').jqm({ajax: '/~popups/benchmark.cfm'}).ajaxComplete(function() {
    $(this).prepend('<div class="close"><a href="#"><span>X</span></a></div>').jqmAddClose('.close a');
  });
  
  // create element for the login dialog
  $('<div id="jqModalContact" class="jqmWindow"></div>').appendTo('body').jqm({ajax: '/~popups/contact.cfm'}).ajaxComplete(function() {
    $(this).prepend('<div class="close"><a href="#"><span>X</span></a></div>').jqmAddClose('.close a');
  });  
  
  if($(".subMenuSub").length != 0){
  	$("#sub-nav > ul > li > a.active > span").css("background", "transparent url('/~siteDesign/site/~img/arrowDown.gif') no-repeat right 1em");
  }
  
});
  
// login form
function showLogin() {
  var elem = $('#jqModalLogin');
  if (elem.length > 0) {
    $('#jqModalLogin').jqmShow();
    return false;
  }
  return true;
}

// login form
function showContact() {
  var elem = $('#jqModalContact');
  if (elem.length > 0) {
    $('#jqModalContact').jqmShow();
    return false;
  }
  return true;
}

/*
// Fonts
//$.getScript('/~siteDesign/site/~scripts/cufon-yui.js', function() {
  //$.getScript('/~siteDesign/site/~scripts/DINPro_Medium_500.font.js', function() {
    $('h1,h2,.itemlist li a,.promo a,.more a .title,.navlink,.button,#main-nav li a').not('.questions h2').each(function() {
      Cufon.replace(this, { fontFamily: "DINPro Medium" });
    });

  //});

  //$.getScript('/~siteDesign/site/~scripts/DIN_Light_300.font.js', function() {
    $('.intro').each(function() {
      Cufon.replace(this, { fontFamily: "DIN Light" });
    });

  //});
  
  
//});
*/

Cufon.replace('h1,h2,.itemlist li a,.promo a,.more a .title,.navlink,.button,#main-nav li a', { fontFamily: 'DINPro Medium' });
Cufon.replace('.intro', { fontFamily: 'DIN Light' });

