function getComboLocations(b){var a=0;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxxml.p",data:{scope:"LocationsInCity",city:b},dataType:"xml",success:function(d){var c="location",b="idlocationcombo";document.getElementById(b).options.length=$(d).find(c).size()+1;document.getElementById(b).selectedIndex=0;document.getElementById(b).options[0].value="0";document.getElementById(b).options[0].text=cLanguage!="en"?"<selecteer locatie indien aanwezig>":"<select location if available>";$(d).find(c).each(function(){a++;document.getElementById(b).options[a].value=$(this).attr("idlocation");document.getElementById(b).options[a].text=$(this).attr("name")})},error:function(){alert("Something went wrong (locations)")}})}function handleCitySearchChanged(){var a="citysearch";if(document.getElementById("city").value=="")document.getElementById("city").value=document.getElementById(a).value;getComboLocations(document.getElementById(a).value)}function focusNextField(d){var c=document.getElementById(d),a=$(c).parents("form").eq(0).find(":input"),b=a.index(c);if(b==a.length-1)a[0].select();else{a[b+1].focus();a[b+1].select()}}function getComboConcepts(){var a="idconcept",g=document.getElementById(a).value,c="",f=document.getElementById("possibleorganisers").value,d=[],b=0,e;d=f.split(",");for(b=0;b<d.length;b++){e=document.getElementById("coorganiser"+d[b]);if(e.checked){if(c!="")c=c+",";c=c+d[b]}}b=0;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxxml.p",data:{scope:"PartyConcept",commasepidorganisers:c},dataType:"xml",success:function(d){var c="partyconcept";document.getElementById(a).options.length=$(d).find(c).size()+1;document.getElementById(a).selectedIndex=0;document.getElementById(a).options[0].value="0";document.getElementById(a).options[0].text=cLanguage!="en"?"nvt":"n/a";$(d).find(c).each(function(){b++;document.getElementById(a).options[b].value=$(this).attr(a);document.getElementById(a).options[b].text=$(this).attr("nameconcept");if(document.getElementById(a).options[b].value==g)$(a).selectedIndex=b})},error:function(){alert("Something went wrong (comboConcepts)")}})}function handleEmailChanged(){var d=document.getElementById("email").value,g=document.getElementById("iditem").value,f=document.getElementById("idconcept").value,e=document.getElementById("commasepidorganisers").value,a=[],b="",c="";if(d!=""){$("#organiserscheckboxdiv :checked").each(function(){a.push(this.id)});$.ajax({type:"GET",url:cDomain+"/ajax/ajaxpartyadd.p",data:{email:d,idparty:g,idconcept:f,commasepidorganisers:e,scope:"emailchanged"},dataType:"xml",success:function(d){$(d).find("result").each(function(){var d="checked";c=$("message",this).text();b=$("error",this).text();if(b!="")alert(b);else{$("#organiserscheckboxdiv").html(c);$("#organiserscheckboxdiv input").each(function(){$("#"+this.id).attr(d,"")});for(var e=0;e<a.length;e++)$("#"+a[e]).attr(d,d);getComboConcepts();focusNextField("email")}})},error:function(){alert("Something went wrong (emailChanged)")}})}}function refreshLocation(t){var a="",v=document.getElementById("date").value,f,n=a,c=a,i=a,e=a,r=a,s=a,p=a,q=a,o=a,k=a,u=a,l=a,h=a,m=a,d=a,j=false,g=[],b;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxxml.p",data:{idlocation:t,dateparty:v,scope:"refreshlocation"},dataType:"xml",success:function(t){$(t).find("result").each(function(){var v="commasepidorganisers",t="#locationmessagediv",w="location";f=$(this).find("message");if($(f).length>0){n=$(f).text();i=$(f).attr("type");if(i!="succes")showmessage(document.getElementById(w),i,n,true);else{b=$(this).find("locations");e=$(b).attr(w);r=$(b).attr("street");s=$(b).attr("city");p=$(b).attr("timefrom");q=$(b).attr("timetill");o=$(b).attr("province");k=$(b).attr("countrycode");u=$(b).attr("idlocation");l=$(b).attr("eventname");h=$(b).attr("iditemparty");m=$(b).attr("date");d=$(b).attr("idorganiserevent");$("#location").val(e);$("#street").val(r);$("#city").val(s);$("#timefrom").val(p);$("#timetill").val(q);$("#province").val(o);$("#countrycode").val(k);if(h!==undefined){c='<a class="showaslinkonhover" href="/partytoevoegen.p?id='+h+"&amp;language="+cLanguage+'">';if(cLanguage=="en")c=c+"Event on this date in "+e+" already exist, click here to modify: ";else c=c+"Er bestaat al een evenement op deze datum in "+e+" , klik hier om te wijzigen: ";c=c+m+" "+l+"</a>";$(t).html(c);$(t).css({display:"block"})}else{$(t).html(a);$(t).css({display:"none"})}if(d!==undefined&&d>"0"){g=document.getElementById("possibleorganisers").value.split(",");j=false;for(var x=0;x<g.length;x++)if(g[x]==d){j=true;break}if(j===false){if(document.getElementById(v).value==a)document.getElementById(v).value+=d;else document.getElementById(v).value+=","+d;handleEmailChanged()}}}}})},error:function(){alert("Something went wrong (refreshLocation)")}})}function refreshConcept(){var a="",b,f=a,d=a,c=a,i=a,g=a,l=$("#idconcept").val(),e,h=a,k=a,j=a;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxxml.p",data:{idconcept:l,scope:"refreshconcept"},dataType:"xml",success:function(l){$(l).find("result").each(function(){var l="#location",n="#citysearch",m="partyconcept";b=$(this).find(m);if($(b).length>0){b=$(this).find(m);f=$(b).attr("locationname");d=$(b).attr("defcity");c=$(b).attr("deflocation");i=$(b).attr("nameconcept");g=$(b).attr("idlocation");j=$(n).val();if(d>a&&d!=j){$(n).val(d);handleCitySearchChanged()}f=$(l).val();c>a&&c!=f&&$(l).val(c);$("#name").val(i);g>0&&refreshLocation(g)}e=$(this).find("message");if($(e).length>0){h=$(e).text();k=$(e).attr("type");h!=a&&showmessage($(l).get(0),k,h,true)}})},error:function(){alert("Something went wrong (refreshConcept)")}})}function publishparty(){var a="directlive",g=$("#rowiddbnewparty").val(),d="",f="",c,b,e;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxpartyadd.p",data:{scope:a,rowiddb:g},dataType:"xml",success:function(g){if(g===undefined){alert("no data");return}$(g).find("result").each(function(){b=$(this).find("message");if(b.length>0){d=b.text();f=b.attr("type");d!=""&&showmessage(document.getElementById("btndirectlive"),f,d,true)}c=$(this).find(a);if(c.length>0){e=c.attr("url");if(e!==undefined)window.location.href=e}})},error:function(){alert("Something went wrong (publish live)")}})}function submitForm(j){var a="#partyform",k=$(a),e="",i="",g="",c,d,f="",h="",b;g=k.serialize();$.post(cDomain+"/ajax/ajaxpartyadd.p",g,function(g){if(g===undefined){alert("no data");return}$(g).find("result").each(function(){var g="invalidinput";$(a).find("select").removeClass(g);$(a).find("input").removeClass(g);$("#partyform div.invalidmessage").remove();$(this).find("error").each(function(){f=$(this).attr("field");h=$(this).text();b=$("#"+f);if(b.length===0)b=$("input[name='"+f+"']");b.addClass(g);b.parent(".form-row").after('<div class="invalidmessage form-row"><div class="label">'+(cLanguage=="en"?"Error:":"Fout:")+"</div>"+h+"</div>")});c=$(this).find("message");d=$(this).find("partysaved");if(d.length>0){ScrollToElement(document.getElementById("partyformcontainer"));$("#partyformcontainer").html(d.text());$("#btndirectlive").click(function(){publishparty()})}else if($(c).length>0){e=c.text();i=c.attr("type");e!=""&&showmessage(j,i,e,true)}})},"xml");return false}function openFormUploadFlyer(d,c){var b="option",a="#dialogcontainer";$(a).dialog(b,"title","Upload flyer");$(a).dialog(b,"height",260);$(a).dialog(b,"width",500);$.get(cDomain+"/ajax/ajaxpartyflyerupload.p",{act:"showform",iditem:d,rnewparty:c,language:cLanguage},function(b){if(b===undefined){alert("no data");return}$(a).html(b);$(a).dialog("open");$('#dialogcontainer input[value=""]:first').focus();$("#dialogcontainer form").submit(function(){$("#dialogcontainer input[type=submit]:first").replaceWith("Uploading...")})});return false};
