$(document).ready(function(){
	$("span",$("div.dropDownItem")).click(function(){
		$("div.dropDownCont",$(this).parent()).toggle();
	});

	var ev = 0;
	
	$(".votResp").each(function(i){		
		ev += Number($(this).attr("vot"));
	});
	
	$(".votResp").each(function(i){
		$("div.perc",$(this)).css("width",(Number($(this).attr("vot"))*100/ev)+"%");
	});
	
	if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") > -1){
		menuIe60();
	}
	
});

function ve(){
	var v = $("input:checked",$("table.enquete")).val();
	if(v == undefined || v == null){
		alert("Você precisa escolher uma opção para votar.");
	} else {
		document.location.href="/sigmaone/?actionButton=votar&value="+v;
	}
}

function inputTip(v,p){
	$("input:not([type='submit'])",$(p)).css("color","#cccccc").val(v).focus(function(){

		if($(this).val() == v){
			$(this).css("color","#000000").val("");
		}

	}).blur(function(){

		if($(this).val() == ""){
			$(this).css("color","#cccccc").val(v);
		}

	});
}

function hideElements(elm){
	
	var elm = String(elm);
	
	$(elm).hide();
	
}
function showElements(elm){
	
	var elm = String(elm);
	
	$(elm).show();
	
}

function noZeroInit(event, field) {
	
	var keyCode;
	if (document.all) {
		keyCode = event.keyCode;
	} else if (document.getElementById) {
		keyCode = event.which;
	} else if (document.layers) {
		keyCode = event.which;
	} 
	
	if(keyCode == 48 && field.value == '') {
		return false;
	}
}

function getQuantidade(q) {

	var valueStr = q.value + '';

	while(valueStr.charAt(0) == '0') {
		valueStr = valueStr.substring(1);
		q.value = valueStr; 
	}

	if (valueStr == '') {
		q.value = $("input[type=hidden]", $(q).parent()).val();
	}
}

function menuIe60(){
	
	$("li",$("ul.jsddm")).each(function(){
		
		var l = $("a",$(this)).html().length;
		
		$(this).css("width",l*5);
		
	});
	
}



