var HtmlSelectOptions = {}
var HtmlCheckBoxOptions = {}


HtmlCheckBoxOptions = {
  add: function(container_id, dom_id, dom_name, text, value, selected) {
    //alert(document.getElementById(dom_id).value);
    //if (document.getElementById(dom_id)) return;
      
    var li = document.createElement('li');
    
    var option = document.createElement('input');
    option.type = 'checkbox';            
    option.id = dom_id;     
    option.setAttribute('name', dom_name);
    option.setAttribute('value', value); 
        
    var label = document.createElement('label');   
    label.appendChild(document.createTextNode(text));
    
    li.appendChild(option);
    li.appendChild(label);
    
    document.getElementById(container_id).appendChild(li);
    if (selected) option.setAttribute('checked', true);
  },
  
  
  load: function(container_id, dom_id, options, selected) {
    if (options == null) return;
    options.each(function(item, index) {
      HtmlCheckBoxOptions.add(container_id, dom_id, item[0], item[1], item[1] == selected);
    });
  }
}

HtmlSelectOptions = {
  clear: function(dom_id) {
    with(document.getElementById(dom_id)) {
      while (hasChildNodes()) removeChild(lastChild);
      selectedIndex = 0;
    }
  },
  add: function(dom_id, text, value, selected) {
    var option = document.createElement('option');
    option.appendChild(document.createTextNode(text));
    option.setAttribute('value', value);
    if (selected) option.setAttribute('selected', 'selected');
    document.getElementById(dom_id).appendChild(option);
  },
  load: function(dom_id, options, selected) {
    if (options == null) return;
    options.each(function(item, index) {
      HtmlSelectOptions.add(dom_id, item[0], item[1], item[1] == selected);
    });
  }
}  

jQuery.fn.dock = function() {
    $(this).show();
    $(this).Fisheye({
        maxWidth: 90,
        items: 'a',
        itemsText: 'span',
        container: '.dock-container2',
        itemWidth: 55,
        proximity: 50,
        alignment: 'left',
        valign: 'bottom',
        halign: 'center'
      }
    );
}

toogle_amateur_data = function() {
    selected = false
    jQuery('#amateur_roles :checkbox').each(function() {if (this.checked) selected = true;})
    selected ? jQuery('#amateur_data').show() : jQuery('#amateur_data').hide();
}

toogle_roles_data = function() {
    selected = false
    jQuery('#select_roles :checkbox').each(function() {if (this.checked) selected = true;})
    selected ? jQuery('#roles_data').show() : jQuery('#roles_data').hide();
}
       
jQuery(document).ready(function() {  
    jQuery('.change_password').click(function() {
            $("#box_change_password").toggle();
        }
    );          
    
    jQuery('#select_roles :checkbox').click(function() {
        toogle_roles_data();
    })

	jQuery('#amateur_roles :checkbox').click(function() {
        toogle_amateur_data();
    })
    
    //BEGIN LOGIN FUNCTIONS
    jQuery('#open_login_window').click(function() {
            jQuery('#overlay').show();
            jQuery('#container_login').show();
            jQuery('#login_message').html('');
            jQuery('#user_username').focus();
        }
    );        
    jQuery('#btn_close_login').click(function() {
            jQuery("#container_login").hide();
            jQuery("#overlay").hide();
        }
    );    
    //END LOGIN FUNCTIONS
    

    //BEGIN LOGIN FUNCTIONS
    jQuery('.force_open_login_window').click(function() {
            jQuery('#overlay').show();
            jQuery('#container_login').show();
            jQuery('#login_message').html('');
            jQuery('#login_url').val(location.href);
            jQuery('#user_username').focus();
        }
    );        
    jQuery('#btn_close_login').click(function() {
            jQuery("#container_login").hide();
            jQuery("#overlay").hide();
        }
    );    
    //END LOGIN FUNCTIONS
    
    
    //BEGIN CONTACT FUNCTIONS
    jQuery('#open_contact_window').click(function() {
            jQuery('#overlay').show();
            jQuery('#container_contact').show();
            jQuery('#contact_message').html('');
            //jQuery('#user_username').focus();
        }
    );        
    jQuery('#btn_close_contact').click(function() {
            jQuery("#container_contact").hide();
            jQuery("#overlay").hide();
        }
    );    
    //END CONTACT FUNCTIONS    
    

    //BEGIN BECOME AMATEUR
    jQuery('#open_become_amateur_window').click(function() {
            jQuery('#overlay').show();
            jQuery('#container_become_amateur').show();
        }
    );
    jQuery('#btn_close_become_amateur').click(function() {
            jQuery("#container_become_amateur").hide();
            jQuery("#overlay").hide();
        }
    );
	//END BECOME AMATEUR
    
    //BEGIN MANAGE PROFILE FUNCTIONS
    jQuery('#open_manage_profile_window').click(function() {
            jQuery('#overlay').show();
            jQuery('#container_manage_profile').show();
        }
    );        
    jQuery('#btn_close_manage_profile').click(function() {
            jQuery("#container_manage_profile").hide();
            jQuery("#overlay").hide();
        }
    );    
    //END MANAGE PROFILE FUNCTIONS            
    
  }
)        


