function tooltip_show (element)
{
  debug('show=' + element);
  $(element).attr({ src: "../../assets/common/pfeil_mehr_termine_active.gif" });
}
function tooltip_hide (element)
{
  debug('hide=' + element);
  $(element).attr({ src: "../../assets/common/pfeil_mehr_termine.gif" });
}

function debug(error)
{
  if (window.console)
  {
    console.debug(error);
  }
}

function updateSeminarDropDown()
{
	seminar_id 		= $('#seminare').val();
	if (seminar_id > 0)
	{
		$.post( "../../content_scripts/ajax_innomotion.php?action=get_seminar_link&seminar_id=" + seminar_id + '&lang=de',
	    function(data)
	    {
	    	if (data)
	    	{
					location.href = data;
					return true;
				}
	    }
		);
	}

	kategorie_ids = $('#rubrik').val();
	region 				= $('#region').val();
	seminar_id		= $('#seminare').val();
	$.post( "../../content_scripts/ajax_innomotion.php?action=update_seminar_drop_down&kategorie_ids=" + kategorie_ids + '&region=' + region + '&seminar_id=' + seminar_id,
    function(data)
    {
   		$("select#seminare").html(data);
    }
	);
}

function ip_expander(id)
{
  var expander = document.getElementById('ip_expander_'+id);
  var teaser = document.getElementById('ip_teaser_'+id);

  closeDenRest(id);

  if (expander.style.display!='block')
  {
//  	document.all.expander.style.setAttribute('display', 'block', 'false');
//  	document.all.teaser.style.setAttribute('display', 'none', 'false');


    expander.style.display = 'block';
    teaser.style.display = 'none';
  }
  else
  {
    expander.style.display = 'none';
    teaser.style.display = 'block';
  }
}

/**
  *
  */
function closeDenRest(the_one)
{
  var all_details = document.getElementById('all_details').value;
  if (all_details)
  {

     var arr_details = all_details.split(',');

     for (i=0 ; my_id = arr_details[i] ; i++)
     {

       var my_expander = document.getElementById('ip_expander_'+my_id);
       var my_teaser = document.getElementById('ip_teaser_'+my_id);
       if (my_teaser && my_expander && my_id!=the_one)
       {
         my_expander.style.display = 'none';
         my_teaser.style.display = 'block';
       }
     }

  }
}

function sendForm(div)
{

     var options = {
        beforeSubmit:  showRequestForm,	  // pre-submit callback
        target:        '.inner_content'   // target element(s) to be updated with server response
		};
		$("#" + div).submit(function()
		{
	    $(this).ajaxSubmit(options);
			return false;
		});
}

function sendAnmeldung()
{
      var options = {
        target:        '#temp_div'   // target element(s) to be updated with server response
				//beforeSubmit:  showRequestForm  // pre-submit callback
				//success:       showResponseForm  // post-submit callback

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    };

    // bind form using 'ajaxForm'
    $('#form_anmeldung').ajaxSubmit(options);
}

function sendEmailFragen()
{
	url = $('#form_email_fragen').attr('action');
	$.post(url,
	{
		betreff: $('#form_email_fragen #_betreff').val(),
		text: $('#form_email_fragen #_text').val(),
		email: $('#form_email_fragen #_email').val()
	},
	function(data)
	{
		eval(data);
	});
}

// pre-submit callback
function showRequestForm(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
//    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];

//    alert('About to submit: \n\n' + queryString);

		if ( $('#content3').length != 0 )	div = '#content3';
		else															div = '#content';

		$(div).html('<div class="inner_content"></div>');
		return true;
    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
//    return true;
}

// post-submit callback
function showResponseForm(responseText, statusText)  {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

    // if the ajaxSubmit method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property

    // if the ajaxSubmit method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server

    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
        '\n\nThe output div should have already been updated with the responseText.');
}

function openpopup2(url) {//PopUp Druckvorschau
	open(url,'popup',	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=620,height=600');
}

function checkChangePassword()
{
		value = $("#passwort_aendern:checked").length;

		if (value == 1)  $("#change_password").fadeIn();
		else						 $("#change_password").fadeOut();
}

function checkAuswahlRechnung()
{

		id = $("#_rechnung").val();

		if (id == 2)  $("#rechnungsadress").fadeIn();
		else					$("#rechnungsadress").fadeOut();
}


function geo_decode(anchor) {
  var href = anchor.getAttribute('href');
  var address = href.replace(/.*contact\/([a-z0-9._%-]+)\+([a-z0-9._%-]+)\+([a-z.]+)/i, '$1' + '@' + '$2' + '.' + '$3');
  if (href != address) {
    anchor.setAttribute('href', 'mailto:' + address);
	}
}



