
/*
 * This jquery script has the effect of highlighting each menu item when the user
 * mouses over it.
 */
if (location.host=='localhost') {
var basepath='/Sociotype/';
}
else {var basepath="/";}

$(document).ready(function(){
    $("#self_type_process").mouseover(function(){
        $(this).hide();
        //$("#s").load(basepath+'ot/profile/sociotype.php');
    }
)
})

$(document).ready(function(){

   $(".main_menu").mouseover(function(){
     $(this).css("background-color", "#AACCFF");
 }).mouseout(function(){
    $(this).css("background-color", "#5588FF")
 })
      })

/*
* This jq script highlights the menu of the page that the user is currently viewing.
 */
$(document).ready(highlight_menu);
function highlight_menu(){
if (location.pathname==basepath+"index.php") {
$("#Home").css("background-color", "#114499");
$("#Home").unbind("mouseover").unbind("mouseout");}
else if (location.pathname==basepath+"profile.php" || location.pathname==basepath+"profile/") {
$("#Profile").css("background-color", "#114499");
$("#Profile").unbind("mouseover").unbind("mouseout");}
else if (location.pathname==basepath+"theory/" || location.pathname==basepath+"theory/") {
$("#Theory").css("background-color", "#114499");
$("#Theory").unbind("mouseover").unbind("mouseout");}
else if (location.pathname==basepath+"test.php") {
$("#Test").css("background-color", "#114499");
$("#Test").unbind("mouseover").unbind("mouseout");}
else if (location.pathname==basepath+"community.php") {
$("#Community").css("background-color", "#114499");
$("#Community").unbind("mouseover").unbind("mouseout");}
else if (location.pathname==basepath+"forum.php") {
$("#Forum").css("background-color", "#114499");
$("#Forum").unbind("mouseover").unbind("mouseout");}
}

//The next two functions and related variables deal with the sociotest display.
var set1q=22; //the # of questions in the first set
var set2q=12; //the # of questions in the second set
var minq=.75; //this is the % of questions that need to be answered.
$(document).ready(function(){
        $("#s1").click(function(){
            z=0;
            for (i=0; i<set1q; i++){
                if ($("#s1_"+i).fieldValue()!=0) {
                z++;
                }
            }
            if (z>=set1q*minq) {
                $("#formsub1").show();
                $("#toolow").hide();
            }
                else {
                $("#toolow").text("Please answer at least "+Math.ceil(set1q*minq-z)+" more questions to continue.");
            }
    });
})

//This script deals with the user_search display.
$(function(){
    $("#user_search #username1").hide();
    $("#user_search #type").hide();
    $("#user_search #quadra").hide();
    $("#user_search #club").hide();
    $("#user_search #temperament").hide();
    $("#user_search #type_pref").hide();
    //$("#user_search, #param").show();
    $("#user_search #param").change(function(){
    if ($("#user_search #param").fieldValue()=="username"){
        show_search("#username1");}
    if ($("#user_search #param").fieldValue()=="type"){
        show_search("#type");}
    if ($("#user_search #param").fieldValue()=="quadra"){
        show_search("#quadra");}
    if ($("#user_search #param").fieldValue()=="club"){
        show_search("#club");}
    if ($("#user_search #param").fieldValue()=="temperament"){
        show_search("#temperament");}

    })
    })

function show_search(x){
    $("#user_search #username1").hide();
    $("#user_search #type").hide();
    $("#user_search #quadra").hide();
    $("#user_search #club").hide();
    $("#user_search #temperament").hide();
    $("#user_search #type_pref").hide();
    $(x).show();
    if (x=="#type") {$("#type_pref").show();}
}