﻿
$(function(){

    var expIcons = new Array();
    expIcons["exp"] = new Array("/images/icons/silk/tick.png","/images/icons/silk/tick_off.png");
    expIcons["int"] = new Array("/images/icons/silk/lightbulb.png","/images/icons/silk/lightbulb_off2.png");
    expIcons["not"] = new Array("/images/icons/silk/cross.png","/images/icons/silk/cross_off.png");

    $("img",".experience-select").click(function(){
        $$ = $(this); //the clicked one;
        var container = $(this).parent();
        var selected = $$.get(0).className;
        switch (selected){
            case "exp":
                $("input",container).val(2);
                if (typeof OnExperienceChecked == 'function'){
                    OnExperienceChecked(container.attr("title"));
                }
                break;
            case "int":
                $("input",container).val(1);
                if (typeof OnExperienceUnchecked == 'function'){
                    OnExperienceUnchecked(container.attr("title"));
                }
                break;
            case "not":
                $("input",container).val(0);
                if (typeof OnExperienceUnchecked == 'function'){
                    OnExperienceUnchecked(container.attr("title"));
                }
                break;
        }
        $("img",container).each(function(){
            this.src = (expIcons[this.className][(selected == this.className)?0:1]);                       
        });   
    });
    
    $(".has-default").each(function(){
        $(this).focus(function(){
            if ($(this).val()==$(this).attr("title"))
                $(this).val("").removeClass("default");
        }).blur(function(){
            if ($(this).val()=="" || $(this).val()==$(this).attr("title"))
                $(this).val($(this).attr("title")).addClass("default");
        });
        $(this).blur();
        
    });
            

});




