$j=jQuery.noConflict();
$j.fx.speeds._default = 1000;
$j(function() {
    $j('.opener').click(function() {
        var popener = $j(".opener").offsetParent()
        if (popener.size() > 0) {
            var off = popener.offset();
        }
        $j('#dialog').dialog({
            autoOpen: false,
            position: [off.left+473,off.top+225],                                    
            width: 650,      
            height: 400
        });
        var inhalt = $j(this).attr('inhalt');
        var title= $j(this).attr('title');
        var img= $j(this).attr('img');
        var img2= $j(this).attr('img2');
        var img3= $j(this).attr('img3');
        var img4= $j(this).attr('img4');
        var img5= $j(this).attr('img5');
        var video = $j(this).attr('video');
        inhalt = inhalt.replace(/___/g,"<br />");
        inhalt = inhalt.replace(/=b=/g,"<b>");
        inhalt = inhalt.replace(/#b#/g,"</b>");
        inhalt = inhalt.replace(/-img-/g,"<img src='fileadmin/templates/" + img + "'  />");
        inhalt = inhalt.replace(/-img2-/g,"<img src='fileadmin/templates/" + img2 + "'  />");
        inhalt = inhalt.replace(/-img3-/g,"<img src='fileadmin/templates/" + img3 + "'  />");
        inhalt = inhalt.replace(/-img4-/g,"<img src='fileadmin/templates/" + img4 + "'  />");
        inhalt = inhalt.replace(/-img5-/g,"<img src='fileadmin/templates/" + img5 + "'  />");
        inhalt = inhalt.replace(/-video-/g,"<iframe width='560' height='349' src='"+ video + "' frameborder='0' allowfullscreen></iframe>");
        $j('#dialog').html(inhalt);
        $j('#dialog').dialog('option','title',title);
        $j('#dialog').dialog('open');
        return false;        
    });
    
    $j('.main_pic').mouseover(function(){
      $j('#overBild').attr("src", 'fileadmin/templates/screen_film_ow_play.png' );
  }).mouseout(function(){
            $j('#overBild').attr("src", 'fileadmin/templates/screen_film_ow.png');
    });
});
// 3 buttons
$j(function() {
    $j('.open').click(function() {
        $j('#c511,#c1093,.neu-button2').show(1);
        $j('.weitere').show(1);
    });
    $j('.close').click(function() {
        $j('#c511,#c1093,.neu-button2').hide(1);
        $j('.weitere').hide(1);
    });
    $j('#nurbeiuns').click(function() {
      $j('#c982').toggle();
      $j('#nurbeiunsnicht').toggle();
    });
    $j('#keq_4_6').click(function(){
      $j('#keq_4_6_text').show();
    });
    $j('#keq_4_7').click(function(){
      $j('#keq_4_6_text').hide();
    });
});
// wichtige weitere Dienstleistungen
$j(function() {
    $j('.weitere').click(function() {
        $j('#c588,#c645,#c946,#c1047').show();
        $j('.noweitere,.neu-button,.daumen').show();
        $j('.weitere').hide();
    });
    $j('.noweitere').click(function() {
        $j('#c588,#c645,#c946,#c1047').hide();
        $j('.weitere').show();
        $j('.noweitere,.neu-button,.daumen').hide();
    });
});

$j(function(){
    $j('#newstickeran').click(function(){
        $j('#powermaildiv_uid262').show(1);
        $j('#newstickeran').hide(1);
        $j('#newstickeraus').show(1);
    });
    $j('#newstickeraus').click(function(){
        $j('#powermaildiv_uid262').hide(1);
        $j('#newstickeraus').hide(1);
        $j('#newstickeran').show(1);
    });
});  
$j(document).ready(function(){
  
    //Formulare Urlaubstipp sichtbar machen
    if (window.location.search == "?id=220&lm"){
        $j('#c659').show();
        $j('.jscalendar').attr("readonly", true);  
    }
    if (window.location.search == "?id=220&anreise"){
        $j('#c660').show();  
        $j('.jscalendar').attr("readonly", true);
    }
    if (window.location.search == "?id=220&wohnung"){
        $j('#c661').show();
        $j('.jscalendar').attr("readonly", true);  
    }
  
   //Formulare Deeplink sichtbar machen
    if (window.location.search == "?id=456&lm"){
        $j('#c1273').show();
        $j('.jscalendar').attr("readonly", true);  
    }
    if (window.location.search == "?id=456&anreise"){
        $j('#c1272').show();  
        $j('.jscalendar').attr("readonly", true);
    }
    if (window.location.search == "?id=456&wohnung"){
        $j('#c1274').show();
        $j('.jscalendar').attr("readonly", true);  
    }
  //Ende
    if (window.location.search == "?tabelle="){
        $j('#c511,#c645,#c588,.neu-button2,#c1093').show(1);
        $j('.weitere,.neu-button,.daumen').show(1);
        $j('#c829').hide(1);
        $j('#c701').hide(1);    
    }
    if (window.location.search == "?tabelle2"){
        $j('.weitere,.neu-button,.daumen').show(1);
        $j('#c588,#c645,#c511,#c1047,.neu-button2,#c1093').show(1);
        $j('#c829').hide(1);
        $j('#c701').hide(1);   
    }   
    if (window.location.search == "?tabelle2="){
        $j('.weitere,.neu-button,.daumen').show(1);
        $j('#c588,#c645,#c511,#c1093,#c1047,.neu-button2').show(1);
        $j('#c829').hide(1);
        $j('#c701').hide(1);   
    }
    if (window.location.search == "?forum"){
      $j('#c724').show(1);
    }
});

$j(function(){
    $j('.jscalendar').attr("readonly", true);
});
$j(function() {
    $j('.anreise').click(function() {
        window.location.href='/index.php?id=220&anreise';  
    });
    $j('.lastminute').click(function() {
        window.location.href='/index.php?id=220&lm';
    });
    $j('.wohnung').click(function() {
        window.location.href='/index.php?id=220&wohnung';
    });
});
$j(function() {
    $j('.anreiseDeep').click(function() {
        window.location.href='/index.php?id=456&anreise';  
    });
    $j('.lastminuteDeep').click(function() {
        window.location.href='/index.php?id=456&lm';
    });
    $j('.wohnungDeep').click(function() {
        window.location.href='/index.php?id=456&wohnung';
    });
});
    
$j(function() {
    $j('.mit-hinzufuegen').click(function(){
        $j('#c662').show();
        $j('.powermail_uid252').val('');
        $j('.powermail_uid254').val('');
        $j('.powermail_uid253').val('');
        $j('.powermail_uid255').val('');
        $j('.powermail_uid279').val('');
        $j('#mitarbeiterId').val('');
    });
});
$j(function() {
    $j('#partner-hinzufuegen').click(function(){
        $j('.powermail_uid207').val('');
        $j('.powermail_uid208').val('');
        $j('.powermail_uid205').val('');
        $j('.powermail_uid206').val('');
        $j('.powermail_uid209').val('');
        $j('.powermail_uid204').val('');
        $j('#partner-input').val('');
    });
});
$j(function() {      
    $j('#accordion').accordion({
        navigation: true,
        autoHeight: false,
        collapsible: true,
        active: 0
    });
   $j('#accordion2').accordion({
        navigation: true,
        autoHeight: false,
        collapsible: true,
        active: false
    });
});
    
$j(function() {
    $j('.powermail_uid81').change(function(){          
      var verz = $j(this).val();
      $j(".verzeichnisfrei").hide();
        $j.ajax({
            url: 'https://www.officez.de/api/index.php?user=api_oweg&pwrd=api_oweg&verzeichnis='+verz+'&callback=?',
            dataType:'jsonp',
            success: function(data){
                //alert(data.wert);
                if(data.wert=='false'){

                    $j("#alertbox").dialog({
                        modal: true,
                        resizable: false,
                        buttons: {
                            'Neues Verzeichnis wählen': function() {
                                $j(this).dialog('close');
                            }
                        }
                  
                    });
                    $j('.input_verzeichnis').val('');
                }
                if(data.wert=='true'){
                    $j(".verzeichnisfrei").show(1);
                }
                if(data.wert=='zeichen'){
                    $j('.powermail_uid81').val('');
                    $j("#zeichen").dialog({
                        modal: true,
                        resizable: false,
                        buttons: {
                            'Zurück zur Eingabe!': function() {
                                $j(this).dialog('close');
                            }
                        }
                  
                    });
                    $j('.input_verzeichnis').val('');
                }
            }
        });
        
      
    });
});
