$(document).ready(function() {

	// Add rounded corners
	if (!$.support.cssProperty('borderRadius'))
	{
		$('.rounded').corner('5px keep');
		roundDiv('content');
	}

	if ($('body.solutions').length || $('body.components').length)
	{
		$('#subnav ul').menu();
	}

	// Download datasheet popup
	if ($('body.components .datasheets'))
	{
		var links = $('body.components .download');
		links.each(function(index, elem)
		{
			$(this).qtip({
				content: {
					text: $(this).siblings('.datasheets')
				},
				position: {
					my: 'top center',
					at: 'bottom center',
					target: 'event'
				},
				show: {
					event: 'mouseenter',
					delay: 0,
					solo: true
				},
				hide: {
					fixed: false,
					event: 'unfocus'
				},
				style: {
					classes: 'ui-tooltip-forge ui-tooltip-rounded ui-tooltip-shadow'
				}
			});
		});
	}
});

function roundDiv(id)
{
	var tmp_width = $('#'+id+'').css('width'); //get the width of target el
	$('#'+id+'').css('width', ''); //clear width value (or else corners screws up)
	$('#'+id+'').wrap('<div class="rounded_border" style="width: ' +tmp_width+ ';"></div>'); //apply border
	$('#'+id+'').corner('round 5px').parent().css('padding', '1px').corner('round 6px'); //round box and border
}

/**
 * jQuery.support.cssProperty
 * To verify that a CSS property is supported (or any of its browser-specific implementations)
 *
 * @param string p - css property name
 * [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
 *
 * @Author: Axel Jack Fuchs (Cologne, Germany)
 * @Date: 08-29-2010 18:43
 *
 * Example: $.support.cssProperty('boxShadow');
 * Returns: true
 *
 * Example: $.support.cssProperty('boxShadow', true);
 * Returns: 'MozBoxShadow' (On Firefox4 beta4)
 * Returns: 'WebkitBoxShadow' (On Safari 5)
 */
$.support.cssProperty = (function() {
  function cssProperty(p, rp) {
    var b = document.body || document.documentElement,
    s = b.style;

    // No css support detected
    if(typeof s == 'undefined') { return false; }

    // Tests for standard prop
    if(typeof s[p] == 'string') { return rp ? p : true; }

    // Tests for vendor specific prop
    v = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'],
    p = p.charAt(0).toUpperCase() + p.substr(1);
    for(var i=0; i<v.length; i++) {
      if(typeof s[v[i] + p] == 'string') { return rp ? (v[i] + p) : true; }
    }
  }

  return cssProperty;
})();
