function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                val[c] = val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length);
        }
        obj.value = val.join(' ');
}

function radio_button_checker(fname,name)
{
var selectBox = document.forms[fname][name];
var user_input = selectBox.options[selectBox.selectedIndex].value
if(user_input!="")
{
	return true;
}
return false;
}

function validate_email(address) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) {
   		alert('Por favor escribe un email VALIDO');
   		return false;
   }
   return true;
}

function checkSurvey(){
for(i=1;i<10;i++){
if(!radio_button_checker("survey","q"+i)) {alert("Por favor selecciona una respuesta para la pregunta "+i+".");return false;}
}
if (!document.forms["survey"].category3 || document.forms["survey"].category3.value=="") {alert("Por favor escribe tu email");return false;}
if (!validate_email(document.forms["survey"].category3.value)) {
		alert('Por favor escribe correctamente tu email');
		return false;
	}
if(!document.forms["survey"].category2 || document.forms["survey"].category2.value=="") {alert("Por favor dinos tu nombre");return false;}
$("#progressdiv").show();
$("#surveydiv").hide();
document.forms["otherform"].category2.value=document.forms["survey"].category2.value;
document.forms["otherform"].category3.value=document.forms["survey"].category3.value;
document.forms["otherform"].submit();

setTimeout("progress1();",30);
return false;
}
var globalCheck=new Array();
var globalIds=new Array();
var currentCheck=0;
function loadAnalysis(){
$("#progressdiv").hide();

oldtext=$("#summarydiv").html();
oldtext=oldtext.replace(/\[name\]/g,document.forms["survey"].category2.value);
$("#summarydiv").html(oldtext);
$("#summarydiv").show();
$("#submitbutton").attr("value","");
}

var currentProgress=1;
function progress1()
{currentProgress+=3;
if(currentProgress<150){$("#progressdone").css("padding","0 "+currentProgress+"px");setTimeout("progress1();",30);}
else{
for(i=0;i<currentCheck;i++)
{
if(globalCheck[i]()) {
oldtext=$("#"+globalIds[i]).html();
oldtext=oldtext.replace(/\[name\]/g,document.forms["survey"].category2.value);
$("#"+globalIds[i]).html(oldtext);
$("#"+globalIds[i]).show();
}
 else $("#"+globalIds[i]).hide();
}
loadAnalysis();}
}
