function set_current (node) {
    var lis = node.find('li');
    var done = false;
    lis.each(function () {
	    if (done) return true;

	    if ($(this).find('a').attr('href') == document.location.pathname) {
		$(this).addClass('current');
		done = true;
	    }
	});
}


function product_detail () {
    $('.product-table a').mouseover(function () {
	    if ($(this).attr('id').match(/2$/)) {
		var blank = "#sBLANK2";
	    } else {
		var blank = "#sBLANK";
	    }
	    var css_spec = "#" + $(this).attr('id') + "-details";
	    $(blank).hide();
	    $(css_spec).fadeIn(200);
	});
    $('.product-table a').mouseout(function () {
	    if ($(this).attr('id').match(/2$/)) {
		var blank = "#sBLANK2";
	    } else {
		var blank = "#sBLANK";
	    }
	    var css_spec = "#" + $(this).attr('id') + "-details";
	    $(css_spec).hide();	    
	    $(blank).show();
	});
    $('.product-detail').hide();
    $('#sBLANK').show();
    $('#sBLANK2').show();
}


function product_detail2 () {
    var details = {
	'Pro': 'Pro: Skill analysis and feedback',
	'Student': 'Student: Power with simplicity',
	'Digitiser': 'Digitiser: 2D modelling of the human body',
	'TimeWARP': 'TimeWARP: Hands-free delayed playback',
	'Server License Management System': 'siliconcoach Server: Web-based license management'
    };

    $('.product-table').each(function () {
	    var tab = $(this);
	    var target_id = "#" + tab.attr('target');        
	    var as = tab.find('a');
        //var as = tab.find('img');
	    $(target_id).hide();
	    as.mouseover(function () {
		    var target = $(target_id);
            var product = $(this).attr('alt');            
          //  target.html(details[product]);           
		  target.html(details[$(this).html()]);
		    // target.slideDown(200);
		    target.show();
		    return false;
		});
	    as.mouseout(function () {
		    $(target_id).hide();
		    $(target_id).html('');
		    return false;
		});
	});
}


// dom ready
$(function () {
	var index = 0;
	$('.alternate').children().each(function () {
		if ((index % 2) !== 0) {
			$(this).addClass('rounded dark outside');
		}
		index++;
	});


	$('.rounded').corner();
    
    
    /*
    $('.roundedpenz').corner({
			  tl: { radius: 8 },
			  tr: false,
			  bl: false,
			  br: { radius: 8 },
			  antiAlias: true,
			  autoPad: true,
			  validTags: ["div"] });
	*/
	set_current($('#top-nav'));
	set_current($('.subnav ul'));

	product_detail2();

	$('#reseller_email').click(function () {
		$(this).attr('value', '');
		$(this).click(function () {});
		return false;
	    });
	$('#reseller_pass').click(function () {
		$(this).attr('value', '');
		$(this).blur();
		$(this).click(function () {});
		$(this).replaceWith($('<input type="password" name="password" id="reseller_pass" value="" />'));
		// $(this).attr('type', 'password');
		$('#reseller_pass').focus();

		return false;
	    });
});

$(window).load(function () {$('.rounded').corner(); });
