var IE = document.all?true:false;
$J.fn.trimval = function() {
	return $J(this).val().toString().replace(/^\s+|\s+$/g,"");
};

$J(document).ready(function() {
	$J('.btn_over').mouseover(function(){
		$J(this).attr('src', $J(this).attr('src').toString().replace('.g','_over.g'));
    }).mouseout(function(){
		$J(this).attr('src', $J(this).attr('src').toString().replace('_over.g','.g'));
    });
	$J('input[type="radio"][name="division"]').click(function(){
		$J('input[type="radio"][name="division"]').removeAttr('checked');
		$J('input[type="radio"][name="division"][value="'+$J(this).val()+'"]').attr('checked', 'true');
		if($J(this).val()== "s"){
			$J('#firstname_of_student_4').parents("div.team_member").each(function(){
				$J(this).css('display', 'none');
				$J(this).find('input').val('');
			})
			$J('.university').each(function(){
				$J(this).css('display', 'none');
				$J(this).find('input').val('');
			})
			$J('.secondary').css('display', 'inline');
		}else{
			$J('#firstname_of_student_4').parents("div.team_member").css('display', 'inline');
			$J('.university').css('display', 'inline');
			$J('.secondary').each(function(){
				$J(this).css('display', 'none');
				$J(this).find('input').val('');
			})
		}
	});

	$J("#country").change(function() 
    { 
        if($J("#country").val() == 25){
			$J("#other_country").show();
		} else {
			$J("#other_country").hide();
		}
    }); 
	
	$J("#source_of_challenge").change(function() 
    { 
        if($J("#source_of_challenge").val() == 5){
			$J("#other_source_of_challenge").show();
		} else {
			$J("#other_source_of_challenge").hide();
		}
    }); 
	
	$J('table.whole_table').css('background-color', '#eaeaea');
	$J('table.whole_table').css('border', '#eaeaea solid 2px');
	
	$J('tr.background:even td').css('background-color', '#f8f8f8');
	$J('tr.background:odd td').css('background-color', '#f3f3f3');
	$J('tr.background td').css('border', '#d0d0d0 solid 1px');
	
	$J('td.input_td').css('background-color', '#f2f2f2');
	$J('td.input_td').css('border', '#d0d0d0 solid 1px');
	
	var current_dir = location.href.replace(/\/[^\/\.]*\.php.*/gi, '').match(/[^\/]*$/i);
	var current_page = location.href.match(/[^\/]*$/i).toString().replace(/\?.*$/i,'');
	$J('#topBtns a').each(function(){
		if($J(this).attr('href').search(current_dir) != -1){
			$J(this).replaceWith($J(this).html().replace('.g','_over.g'));
		}
	});
	$J('.subnavtext a').each(function(){
		if($J(this).attr('href').search(current_page) != -1){
			$J(this).parent().toggleClass("subnavtext_o");
			$J(this).replaceWith($J(this).html());
		}
	});
});