/*CVS Add-ins*/
/*
$Revision: 1.1 $
$RCSfile: plakat_behaviour.js,v $
author: JDE/IHE
*/

/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/*
    plakatbehaviour.js
    27.07.2009 JDE/IHE
*/
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */

/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */

/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/*Copyright (c) A&B FACE2NET GmbH*/

function check(){ alert("JS eingebunden"); }

var mandatorygroup = new Array();

mandatorygroup[0] = new Object();
mandatorygroup[0]["checkbox"] = "consent_mobile";
mandatorygroup[0]["field"] = "mobile";
mandatorygroup[1] = new Object();
mandatorygroup[1]["checkbox"] = "consent_infopost";
mandatorygroup[1]["field"] = "street";
mandatorygroup[2] = new Object();
mandatorygroup[2]["checkbox"] = "consent_infopost";
mandatorygroup[2]["field"] = "zipcity";


function set_formbehaviour(){

 $(mandatorygroup).each(function(i) {

   toggle_mandatory('#'+mandatorygroup[i].checkbox, '#'+mandatorygroup[i].field, 'span.consent_'+mandatorygroup[i].field);

 });

}


function toggle_mandatory(checkbox_id, field_id, span_class){

 var mandatoryhint = '<acronym style="color:red" title="Pflichtfeld">*</acronym>';

 $(checkbox_id).click(function() {

  var l = $(field_id).val().length;

  if( l==0 )
  {
    if( $(checkbox_id+':checked').length==1 )
    {
      $(span_class).html(mandatoryhint);
    } else {
      $(span_class).html('');
    }
  } else {
    $(span_class).html('');
  }

 });
 
}


/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/*loadEvents*/
addLoadEvent(set_formbehaviour);
