/**
Funktionssammlung für die neue Cluburlaub (19.07.2010)
*/
$(function(){
    $("ul.formHotelSuche input.hotelsuche").bind("keyup", function(event) {
        if(event.keyCode != 38 && event.keyCode != 40 && event.keyCode != 13)
        {
            if($(this).val().length > 0)
            {
                $.get(strAjaxPfad+"cluburlaub.ax.php",{
                    action : "liveSearch",
                    suchstring : $(this).val()
                },function(data){
                    $("div.liveSearch").remove();
                    $("ul.formHotelSuche input.hotelsuche").after("<div class='liveSearch'>"+data+"</div>");
                    $("div.liveSearch").css({
                        "position":"absolute",
                        "border":"1px #A9D1E9 solid",
                        "font-size":"10px",
                        "width":"250px",
                        "margin-left":"165px",
                        "background-color":"#fff"
                    }).find("li:first").addClass("active");   
                });
            }
        }
    });
        
    $("ul.formHotelSuche input.hotelsuche").live(($.browser.opera ? "keypress" : "keydown"), function(event) {
        switch(event.keyCode) {
            case 38: //up
                event.preventDefault();
                 $("div.liveSearch li.active").removeClass("active").prev().addClass("active");
            break;
            
            case 40: //down
                event.preventDefault();
                 $("div.liveSearch li.active").removeClass("active").next().addClass("active");
            break;    
            case 13: //enter
                event.preventDefault();
                window.location = $("div.liveSearch li.active a").attr("href");
            break;    
        }
    });
});

/**
Funktion um einen Textbasierte Antwort eines AJAX-Requests zu splitten
*/
function text_2_array(strText)
{                  
    //zeilenweise splitten
    var arr = new Array();
    var t = strText.split("|");       
    var arrReturn = new Array();   
    for(var i = 0;i<t.length;i++)
    {                
        arrReturn[i] = new Array();
        arrReturn[i] = t[i].split(";"); 
    } 
    return arrReturn;                                          
}

/**
*   Baut aus einem Text der per Ajax geholt wird options-felder
*/
function text_2_optionFields(strText)
{
    var arr = text_2_array(strText);
    var ret = "";
    for(var i = 0; i < arr.length; i++)
    {
        ret+= '<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
    }
    return ret;
}     
/**
*   Gibt den aktuellen Timestamp zurück
*/
function clb_timestamp()
{
    var jetzt = new Date();
    return jetzt.getTime();
}
function loadZimmer(intAnlagenID,saison)
{
    elementID = "dialog"+clb_timestamp();
    $("<div id='"+elementID+"' class='premiumDialog'></div>")
    .appendTo("body")
    .html('<iframe src="'+CluburlaubURL+'/frames/zimmer.php?anlagen_id='+intAnlagenID+'&saison='+saison+'" frameborder="0" scrolling="no" height="300px" width="700px"></iframe>')
    .dialog({
        title:"Zimmerskizzen",
        width:750,
        height:550,
        modal:true,
        open: function(event, ui) {
            $('#'+elementID+' iframe').load(function()
        	{
                if((this.contentWindow.document.body.offsetHeight+20) > 550)
                {
                    // Set inline style to equal the body height of the iframed content.
                    this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                    $("#"+elementID).dialog({height: (this.contentWindow.document.body.offsetHeight+20)});
                }
        	});     
        }
    });
}
function open_tiefstpreisgarantie(event)
{
    var jetzt = new Date();
    elementID = "dialog"+jetzt.getTime();

    var dialog = $("<div id='"+elementID+"'></div>");

    dialog.html('<iframe src="'+CluburlaubURL +'/frames/tiefspreisinfo.php" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Cluburlaub.de Tiefstpreis-Garantie",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('#'+elementID+' iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});
        }
    });
    return false;
}

function open_honeymoon(elementID,anlagen_id)
{
    if(elementID == "none")
    {
        var jetzt = new Date();
        elementID = "dialog"+jetzt.getTime();
    }
    var dialog = $("<div id='"+elementID+"'></div>");
    dialog.html('<iframe src="frames/honeymoon.php?anlagen_id='+anlagen_id+'" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Honeymoon",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
}

function open_fruehbucher(elementID,anlagen_id,katego)
{
    if(elementID == "none")
    {
        var jetzt = new Date();
        elementID = "dialog"+jetzt.getTime();
    }
    var dialog = $("<div id='"+elementID+"'></div>");
    dialog.html('<iframe src="'+CluburlaubURL+'/frames/fruehbucher.php?anlagen_id='+anlagen_id+'&amp;katego='+katego+'" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Fr&uuml;hbucher Info",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
    return false;
}

function open_premiumclub()
{
    //alle bestehenden PremiumDialoge löschen
    $("div.premiumDialog").remove();
    
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    var dialog = $("<div id='"+elementID+"' class='premiumDialog'></div>");
    
    dialog.html('<iframe src="'+CluburlaubURL+'/frames/premiumclub.php" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Was ist ein Premiumclub?",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
    return false;
}
function open_kategorie(katName)
{
    //alle bestehenden PremiumDialoge löschen
    $("div.katDialog").remove();
    
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    var dialog = $("<div id='"+elementID+"' class='katDialog'></div>");
    
    dialog.html('<iframe src="'+CluburlaubURL+'/frames/kategorie.php?kat='+katName+'" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Information",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
    return false;
}

function open_topStrandclubs()
{
    //alle bestehenden PremiumDialoge löschen
    $("div.premiumTopTenStrand").remove();
    
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    var dialog = $("<div id='"+elementID+"' class='premiumTopTenStrand'></div>");
    
    dialog.html('<iframe src="'+CluburlaubURL+'/frames/top-strandclubs.php" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Unsere TopTen-Strandclubs",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
    return false;
}

function open_topWinterclubs()
{
    //alle bestehenden PremiumDialoge löschen
    $("div.premiumTopTenWinter").remove();
    
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    var dialog = $("<div id='"+elementID+"' class='premiumTopTenWinter'></div>");
    
    dialog.html('<iframe src="'+CluburlaubURL+'/frames/top-winterclubs.php" frameborder="0" scrolling="no" height="100px" width="100px"></iframe>')
    .dialog({
        title:"Unsere TopTen-Bergclubs",
        minWidth:300,
        minHeight:100,
        open: function(event, ui) {
            $('iframe').load(function()
        	{
        		// Set inline style to equal the body height of the iframed content.
        		this.style.height = (this.contentWindow.document.body.offsetHeight+20)+ 'px';
                dialog.dialog("option", "height", (this.contentWindow.document.body.offsetHeight+80));

                this.style.width = (this.contentWindow.document.body.offsetWidth+35) + 'px';
                dialog.dialog("option", "width", (this.contentWindow.document.body.offsetWidth+80));
        	});     
        }
    });
    return false;
}


function clb_createSelect(strName,strID,strClass)
{
    var selectElement = $("<select></select>");
    $(selectElement).attr({
        'name'              : strName,
        'id'                : strID,
        'class'             : strClass
    });
    return selectElement;
}


function clb_getLaenderSelect(strName,strID,strClass,intSelectedLand)
{
    var selectElement = clb_createSelect(strName,strID,strClass);
    var data = $.ajax({
        url     : strAjaxPfad+"/laender.ax.php",
        async   : false,
        data    : ({
            'action'            : "getLaenderSelect",
            'land_id'           : intSelectedLand   
        })
    }).responseText;
    
    if(data.substr(0,1) != "#")
    {
        $(selectElement).append(data);   
    }
    return $(selectElement);
}

function clb_getLaenderSelectByVeranstalter(strName,strID,strClass,intVeranstalterID)
{
    var selectElement = clb_createSelect(strName,strID,strClass);
    $(selectElement).append('<option value="0">- Laender -</option>');
    var data = $.ajax({
        url     : strAjaxPfad+"/laender.ax.php",
        async   : false,
        data    : ({
            'action'            : "getLaenderSelectByVeranstalter",
            'ver_id'            : intVeranstalterID   
        })
    }).responseText;
    
    if(data.substr(0,1) != "#")
    {
        $(selectElement).append(data);   
    }
    return $(selectElement);
}

function clb_getEignungSelectByVeranstalter(strName,strID,strClass,intKatID)
{
    var data = $.ajax({
        url     : strAjaxPfad+"/cluburlaub.ax.php",
        async   : false,
        data    : ({
            'action'            : "getEignungSelectBox",
            'ver_id'            : intKatID   
        })
    }).responseText;
    
    if(data.substr(0,1) != "#")
    {
        return data;   
    }
}


function superSucheChange(start)
{
    var fk_veranstalter_id = $("p.ss_veranstalter select").val();
    //schiff wurde gewählt
    if(fk_veranstalter_id == 9 || fk_veranstalter_id == 13){
        $.get(schiffe_ajax_url,{
            action : 'getSchiffeGebieteDropDown',
            fk_veranstalter_id : fk_veranstalter_id
        },function(data){
            if(data.substr(0,1) != "#")
            {
                $("#supersuche p.ss_select2 select").html(data).hide();
            }else
            {
                Console.Log("Fehler");
            } 
        });
        //datepicker setzen
        $("#supersuche p.ss_select3")
        .html('<input type="text" class="datepicker" style="width:107px" name="termin" id="datum_ab" value="- Termin -" />')
        .css("padding-top","4px");
        
        $("#supersuche p.ss_select3 input").datepicker({
		changeMonth: true,
		numberOfMonths: 3,
                dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
                monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],"dateFormat":"dd.mm.yy"});
        
        $("#supersuche p.ss_veranstalter select").css({
            "background-color":"#FFD98F"
        });
        $("#supersuche form").attr("action",CluburlaubURL+"/schiffsuche.html");
        $("#supersuche input.hiddenSuche").attr("name","schiffssuche");
    //Clubanlage
    }else
    {
        if(start == 0)
        {
            $("#supersuche p.ss_select2").empty();
            $("#supersuche p.ss_select3").empty();
            $("#supersuche p.ss_select2").append(clb_getLaenderSelectByVeranstalter("laender","id","class",fk_veranstalter_id));
            $("#supersuche p.ss_select3").append(clb_getEignungSelectByVeranstalter("geeignet","id","class",0));
            if($("#supersuche form").hasClass("ml"))
            {
                $("#supersuche form").attr("action",CluburlaubURL+"/"+$("#supersuche form").attr("rel")+"/suche/");
            }else
            {
                $("#supersuche form").attr("action",CluburlaubURL+"/suche.html");
            }
            $("#supersuche input.hiddenSuche").attr("name","supersuche");
        }
    }
}
function clb_getVeranstalterSelect(strName,strID,strClass,intSelectedVeranstater)
{
    var selectElement = clb_createSelect(strName,strID,strClass);
    
    $.get(strAjaxPfad+"/veranstalter.ax.php",{
        'action'            : "getVeranstalterSelectOutput",
        'veranstalter_id'   : intSelectedVeranstater    
    },function(data){
        if(data.substr(0,1) != "#")
        {
            $(selectElement).append(data);   
        }
        return $(selectElement);
    });
}

function openForumAntwortEdit(intAntwortID)
{
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    $("body").append("<div id='"+elementID+"' class='forumAntwortBearbeiten'></div>");
    $.get(strAjaxPfad+"/forum.ax.php",{
        'action'                    : "admin_editAntwortDialog",
        'fk_clubforum_antworten_id' : intAntwortID
    },function(data){
        if(data.substr(0,1) != "#")
        {
            $("#"+elementID).html(data).dialog({
                    title:"Antwort bearbeiten",
                    width:500
            });
            
            $("#"+elementID + " input.submit").click(function(){
                $.post(strAjaxPfad+"/forum.ax.php?action=admin_editAntwortSave",{
                    'fk_clubforum_antworten_id' : intAntwortID,
                    'titel' : $("#"+elementID + " input.titel").val(),
                    'text' : $("#"+elementID + " textarea").val(),
                    'pub' : $("#"+elementID + " input.pub").attr("checked")
                },function(){
                    location.reload();
                });
            });
        }
    });
    return false;
}

function openForumThemaEdit(intThemenID)
{
    //neus div element erstellen
    elementID = "dialog"+clb_timestamp();
    $("body").append("<div id='"+elementID+"' class='forumAntwortBearbeiten'></div>");
    
    $.get(strAjaxPfad+"forum.ax.php",{
        'action'                 : "admin_editThemenDialog",
        'fk_clubforum_themen_id' : intThemenID
    },function(data){
        if(data.substr(0,1) != "#")
        {
            $("#"+elementID).html(data).dialog({
                    title:"Thema bearbeiten",
                    width:700
            });
            
            $("#"+elementID + " input.submit").click(function(){
                $.post(strAjaxPfad+"/forum.ax.php?action=admin_editThemaSave",{
                    'fk_clubforum_themen_id'    : intThemenID,
                    'name'                      : $("#"+elementID + " input.name").val(),
                    'autor'                     : $("#"+elementID + " input.autor").val(),
                    'ueberarbeiteter_url_name'  : $("#"+elementID + " input.ueberarbeiteter_url_name").val(),
                    'meta_titel'                : $("#"+elementID + " input.meta_titel").val(),
                    'meta_description'          : $("#"+elementID + " input.meta_description").val(),
                    'meta_robots'               : $("#"+elementID + " input.meta_robots").val(),
                    'pub' : $("#"+elementID + " input.pub").attr("checked")
                },function(){
                    location.reload();
                });
            });
        }
    });
    return false;
}

function deleteForumAntwort(intAntwortID)
{
    if(confirm("Diese Antwort wirklich löschen?"))
    {
        $.get(strAjaxPfad+"/forum.ax.php",{
            'action'                    : "admin_deleteAntwort",
            'fk_clubforum_antworten_id' : intAntwortID
        },function(data){
            location.reload();
        });
    }
    return false;
}
$(function(){
    $("#content_right .uebersicht li.colapse a.expand").bind("click",function(event){
        veranstalter_expand($(this));
        event.preventDefault() 
    });
});
function veranstalter_expand(obj)
{
    $(obj).parent().find("ul.anlagen").show(); 
    $(obj).removeClass("expand").addClass("close");
    $(obj).find("span").removeClass("v-icon-plus").addClass("v-icon-minus");
    $("#content_right .uebersicht li.colapse a.close").bind("click",function(event){
        veranstalter_close($(this));
        event.preventDefault() 
    });
}
function veranstalter_close(obj)
{
    $(obj).parent().find("ul.anlagen").hide(); 
    $(obj).removeClass("close").addClass("expand");
    $(obj).find("span").removeClass("v-icon-minus").addClass("v-icon-plus");
    $("#content_right .uebersicht li.colapse a.expand").bind("click",function(event){
        veranstalter_expand($(this));
        event.preventDefault() 
    });
}

function startVideo(filmurl)
{
	//document.getElementById('vid_schatten_overlay').style.display = '';	
    var text = '<div style="width:500px; height:400px; z-index:10000; position:absolute; left:280px; top:70px;" id="div_player">';
    text+= '<input type="image" src="'+CluburlaubURL+'/img/layout/close.png" value="Schließen" onclick="location.href=\''+CluburlaubURL +'/videos.php\';" style="float:right;"/>';
    text+= '<a href="'+filmurl+'" id="player"></a>';
    text+= '<br />';
    text+= '<center><input type="button" value="Zurück zu den Videos" onclick="location.href=\''+CluburlaubURL +'/videos.php\';" style="width:100%;" /></center>';
    text+= '</div>';
    $("body").append('<div id="overlay">&nbsp;</div>');
    $("#overlay").css({
   	    'filter' :'alpha(opacity=80)',
        '-moz-opacity' :'0.8', 
        'opacity' : '0.8',
        'left' : '-10px',
        'right' : '-10px',
        'position':'absolute',
        'background-color' : 'black',
        'z-index':'9999'
    }).append(text);
    $("#left").css("overflow","visible");
	flowplayer("player", "flowplayer/flowplayer-3.1.5.swf", { 
		clip: { 
			autoPlay:true, 
			scaling:'orig', 
			onStart: function(clip) { 
				$("#player").css({
					height :  (clip.metaData.height-3)+"px",
					width : (clip.metaData.height*(clip.metaData.width/clip.metaData.height)-43)+"px"
				});
				$("#div_player").css({
					height :  (clip.metaData.height-3)+"px",
					width : (clip.metaData.height*(clip.metaData.width/clip.metaData.height)-43)+"px"
				});
			} 
		} 
	}); 
}

function stopVideo()
{
	document.getElementById('vid_schatten_overlay').style.display = 'none';	
	document.getElementById('div_player').style.display = 'none';		
	
}

function startVideoPortal()
{

	document.getElementById('player_portal').style.display = '';	
	document.getElementById('vid_schatten_overlay').style.display = '';	
	
	flowplayer("player_portal", "club_maske_final.swf?org_url=anlage.php", { 
	    clip:  { 
	        autoPlay: true, 
	        autoBuffering: true  
	    } 
	});
}

function deaktiviereFlashClubFilm()
{
	var pfad = location.href;	
	
	pfad = pfad.replace("#", "");
	location.href = pfad;
	
	document.getElementById('player_portal').style.display = 'none';
	document.getElementById('vid_schatten_overlay').style.display = 'none';	
}


    function get_eventsuche_untertypen()
    {
        $("#eventsuche_unterTyp select").empty().append("<option>wird geladen...</option>");
        $.get("ajax/events.ax.php?action=getUnterTypen&kat="+$("#eventsuche_kategorie").val(),function(data){
           $("#eventsuche_unterTyp select").empty().append(text_2_optionFields(data));
           $("#eventsuche_unterTyp").show();
        });
    }
    function get_eventsuche_submit()
    {
        var kat             = $("#eventsuche_kategorie").val();
        var u_kat           = $("#eventsuche_UnterKategorie").val();
        var datum_monat     = $("#eventsuche_monat").val(); 
        var datum_jahr      = $("#eventsuche_jahr").val(); 
        var veranstalter    = $("#eventsuche_veranstalter").val(); 
        $("#eventsContent").load("ajax/events.ax.php?action=suche&kat="+kat+"&u_kat="+u_kat+"&datum_monat="+datum_monat+"&datum_jahr="+datum_jahr+"&veranstalter="+veranstalter);
    }
function clb_anfrage(strName,strTitel,strText)
{
    var dialog = $("<div id='dialog"+clb_timestamp()+"'></div>").css("width","500px");
    dialog.append("<p><strong>Anfrage für:</strong> "+strTitel+"</p>");
    dialog.append("<p>"+strText+"</p>");
    var dialogUL = $("<ul class='dialogForm dialogForm02'></ul>");
    dialog.append(dialogUL);
    var arr = new Array();
    arr[0] = new Array("-","-");
    arr[1] = new Array("Frau","Frau");
    arr[2] = new Array("Herr","Herr");
    dialogUL.append(clb_form_liste("select","Anrede:*","anrede","",arr));
    dialogUL.append(clb_form_liste("input","Name:*","name","text",""));
    dialogUL.append(clb_form_liste("input","Vorame:*","vorname","text",""));
    dialogUL.append(clb_form_liste("input","Telefonnummer:**","telefon","text",""));
    dialogUL.append(clb_form_liste("input","E-Mail-Adresse:**","mail","text",""));
    dialogUL.append(clb_form_liste("textarea","Infos:","infos","",""));
    dialogUL.append(clb_form_liste("input","","submit","submit","Angebot unverbindlich anfragen"));
    dialog.append("<p><br/><em>* Pflichtfeld, ** E-Mail oder Telefonnummer müssen angegeben werden</em></p>");
    dialog.dialog({
        "title" : strName,
        width : 500,
        height : 500
    });
    
    dialog.find("input[name=submit]").click(function(event){
        if(dialog.find("select[name=anrede]").val().length == 1)
        {
            alert("Sie müssen eine Anrede eingeben");
        }else if(dialog.find("input[name=name]").val().length == 0)
        {
            alert("Sie müssen einen Namen angeben");
        }else if(dialog.find("input[name=vorname]").val().length == 0)
        {
            alert("Sie müssen einen Vornamen angeben");
        }else if(dialog.find("input[name=telefon]").val().length == 0 && dialog.find("input[name=mail]").val().length == 0)
        {
            alert("Sie müssen entweder eine Telefonnummer oder eine E-Mail-Adresse angeben, damit wir Sie kontaktieren können");
        }else
        {
            $.post(strAjaxPfad+"cluburlaub.ax.php",{
                'action'        : 'CluburlaubExklusivAnfrage',
                'anrede'        : dialog.find("select[name=anrede]").val(),
                'name'          : dialog.find("input[name=name]").val(),
                'vorname'       : dialog.find("input[name=vorname]").val(),
                'telefon'       : dialog.find("input[name=telefon]").val(),
                'mail'          : dialog.find("input[name=mail]").val(),
                'infos'         : dialog.find("textarea[name=infos]").val(),
                'angebotTitel'  : strTitel,
                'angebotText'   : strText
            },function(data){
                if(data.substr(0,1) == "#")
                {
                    alert(data.substr(1));
                }else
                {
                    dialog.dialog("close");
                }
            });    
        }        
    });
}

function clb_form_liste(strFormType,strName,strFormName,strType,strValue)
{
    var li = $("<li></li>");
    switch(strFormType)
    {
        case "input":
            li.append(clb_form_input(strName,strFormName,strType,strValue));
        break;
        case "select":
            li.append(clb_form_select(strName,strFormName,strType,strValue));
        break;
        case "textarea":
            li.append(clb_form_textarea(strName,strFormName,strType,strValue));
        break;
    }
    return li;
}

function clb_form_input(strName,strFormName,strType,strValue)
{
    return $('<label>'+strName+'</label><input type="'+strType+'" name="'+strFormName+'" value="'+strValue+'" />');
}
function clb_form_textarea(strName,strFormName,strType,strValue)
{
    return $('<label>'+strName+'</label><textarea name="'+strFormName+'" cols="40" rows="4">'+strValue+'</textarea>');
}
function clb_form_select(strName,strFormName,emptyVar,arrOption)
{
    var label       = $("<label>"+strName+"</label>");
    var eleSelect   = $('<select name="'+strFormName+'"></select>');
    for(var i=0;i<arrOption.length;i++)
    {
        eleSelect.append('<option value="'+arrOption[i][0]+'">'+arrOption[i][1]+'</option');
    };
    return $.merge(label,eleSelect);
}









