$(document).ready(function() {  
    $('#recommform input[type="text"]').addClass("idleField");  
    $('#recommform input[type="text"]').focus(function() {  
        $(this).removeClass("idleField").addClass("focusField");  
        if (this.value == this.defaultValue){  
            this.value = '';  
        }  
        if(this.value != this.defaultValue){  
            this.select();  
        }  
    });  
    $('#recommform input[type="text"]').blur(function() {  
        $(this).removeClass("focusField").addClass("idleField");  
        if ($.trim(this.value == '')){  
            this.value = (this.defaultValue ? this.defaultValue : '');  
        }  
    });  
});  




function toggleGridMenu(obj,open){
	if (open == true){
		$('#'+obj).show();
		$('#'+obj).parent().children('h2').addClass('viewtogglerdown');
	}
	else if (open == false) {
		$('#'+obj).hide();
		$('#'+obj).parent().children('h2').removeClass('viewtogglerdown');
	}
	else if(!open) {

		if ($('#'+obj).css('display') == 'none') {
			$('#'+obj).show();
			$('#'+obj).parent().children('h2').addClass('viewtogglerdown')
		}
		else {
			$('#'+obj).hide();
			$('#'+obj).parent().children('h2').removeClass('viewtogglerdown')

		}
	}
}


function setBirthDate(){
	day =	$("#date_of_birth_day option:selected").val();
	month = $("#date_of_birth_month option:selected").val();
	year =  $("#date_of_birth_year option:selected").val();
	pageElem('tx_pprecommendation_pi1[date_of_birth]').value=day+'.'+month+'.'+year;
}
function pageElem( objId ) {
	if(document.getElementById( objId ))
		return( document.getElementById( objId ) );
	else return false;
}
function starsmouseover(no,ulid) {
	for (i=0;i<=4;i++) {
		if (i  <= no) {
			$('#'+ulid ).children('li:eq('+i+')').addClass("fullstar_hover");
		}
		else 
			$('#'+ulid ).children('li:eq('+i +')').addClass("nostar_hover");
	}
}
function setmouseout() {
	$('.vote_stars_list').mouseout(function(){
		$(this).children('li').removeClass("fullstar_hover");
		$(this).children('li').removeClass("nostar_hover");
	});
}
function updateVoteStars(data) {
	voteglobalresult = data.globalresult -1;
	voteresult = data.globalresult -1;
	rv = Math.round(voteresult*100)/100;
	grv = Math.round(voteglobalresult*100)/100;
	for (i=0;i<=4;i++) {
		if (i  <= voteresult) {
			$('#'+data.cat_name ).children('li:eq('+i+')').attr('class',"fullstar");
		}
		else {
			$('#'+data.cat_name ).children('li:eq('+i+')').attr('class',"nostar");
			if (voteresult != rv && i  == Math.round(rv)) {
				$('#'+data.cat_name ).children('li:eq('+i+')').attr('class',"halfstar");
			}
		}
	}
	for (i=0;i<=4;i++) {
		if (i  <= voteglobalresult)
			$('#globalStars').children('li:eq('+i+')').attr('class',"fullstar");
		else {
			$('#globalStars' ).children('li:eq('+i+')').attr('class',"nostar");
			if (voteglobalresult != grv && i  == Math.round(grv)) {
				$('#globalStars' ).children('li:eq('+i+')').attr('class',"halfstar");
			}
		}
	}
	$('#'+data.cat_name+'_fips').html(data.globalresult);
	$('#'+data.cat_name+'_count').html(data.globalcount);
	$('#voteglobal_count').html(' / '+data.globalcount);
	$('#voteglobal_result').html(Math.round(data.globalresult*100)/100);

}

function hideComment(){
	$('#comment_add').slideToggle(500);
	$('#messagebox').val('');
	$('#addbutton').show();
}
function showCommentForm(counterID,digits){
	$('#comment_add').slideToggle(500);
	$('#messagebox').val('');
	$('#addbutton').hide();
	$('#'+counterID).val(digits);
}