jQuery.noConflict();
function formCallback(result, form) {
  window.status = "valiation callback for form '" + form.id + "': result = " + result;
}
function handleAjaxDialog(link,relation){
  if(link.indexOf('?') === -1) var linkDelimiter = '?';
  else var linkDelimiter = '&';
  jQuery.ajax({
   url: link + linkDelimiter + 'type=99',
   beforeSend: function(){
    $ajaxDialogBox = jQuery('<div></div>')
     .hide()
     .attr({ title : 'loading...' })
    ;
    if(relation.substr(0,6) == 'accept'){
    $ajaxDialogBox.dialog({
     modal:true,
     width:700,
     height:500,
     buttons: {
      'akzeptieren': function() {
        jQuery(this).dialog('close');
        if(relation.substr(7,5) == 'check'){
         jQuery('#' + relation.substr(7)).attr('checked','checked').focus().blur();
         jQuery('#' + relation.substr(13)).attr('value',(jQuery('input[name=value_' + relation.substr(13) + ']').attr('value')));
        }
       },
       'ablehnen': function() {
        jQuery(this).dialog('close');
        if(relation.substr(7,5) == 'check'){
         jQuery('#' + relation.substr(7)).attr('checked','').focus().blur();
         jQuery('#' + relation.substr(13)).attr('value','');
        }
       }
     }
    });
    }
    else{
     $ajaxDialogBox.dialog({
      modal:true,
      width:700,
      height:500
     });
    }
    $ajaxDialogBox.dialog();   
   },
   success: function(result){
     $ajaxDialogBox.dialog( "option", "title", jQuery(result).filter('#headline').html());
     $ajaxDialogBox.append(jQuery(result).filter('#content'));
   }
  });
}

function sleep(ms){
 var zeit=(new Date()).getTime();
 var stoppZeit=zeit+ms;
 while((new Date()).getTime()<stoppZeit){};
}

jQuery(document).ready(function(){
 jQuery(".lightbox").lightbox( {navbarOnTop: 0 , resizeSpeed: 300 , overlayOpacity: 0.4, strings : { prevLinkTitle: "vorheriges Bild", nextLinkTitle: "nächstes Bild", prevLinkText:  "&laquo;&nbsp;&nbsp;", nextLinkText:  "&nbsp;&nbsp;&raquo;",closeTitle: "schließen", image: "Bild", of: "von"}});
 jQuery('#loginnavi li').mouseover(function(){ jQuery(this).addClass('ui-state-hover') });
 jQuery('#loginnavi li').mouseout(function(){ jQuery(this).removeClass('ui-state-hover') });
 jQuery('a').click(function(){ jQuery(this).blur() });
 jQuery('#logoutform input').click(function(){ jQuery(this).blur() });
 jQuery('.ajaxdialog').click(function(){
  if(this.rel && jQuery(this).parents().is("form") === true) var relation = this.rel;
  else var relation = '';
  handleAjaxDialog(this.href,relation);
  return false;
 });
 jQuery('#headerlink').click(function(){
   window.location.href='/kontakt/#tab-messe';
 });
 
 
 jQuery('#bookmarkServices').css({ 'display':'none' });
 jQuery('#bookmarkServices').dialog({ autoOpen:false,width:210,height:80,minHeight:80,modal:true,resizable:false });
 jQuery('#bookmarkLink').click(function(e) { jQuery('#bookmarkServices').dialog('open'); return false; });
 jQuery('.tx-mmforum-pi1-attachment a').has('img').lightbox();
});
