if(!window.EVENTSNOW)window.EVENTSNOW={};
(function(){if(!window.EVENTSNOW.Widget){EVENTSNOW.Widget=function(o){this.options=o;this.currentPageNo=0;this.checkVarExists=function(){};this.getParams=function(a,e){params="?client="+encodeURI(this.options.client);params+="&pd="+encodeURI(this.options.password);if(a=="listing"){params+="&cb="+this.options.varName+".showListCallback";params+="&out=json";if(this.options.listing.keywords)params+="&kw="+encodeURI(this.options.listing.keywords);if(this.options.listing.period)params+="&per="+encodeURI(this.options.listing.period);
if(this.options.listing.regions)params+="&rg="+encodeURI(this.options.listing.regions);if(this.options.listing.categories)params+="&cat="+encodeURI(this.options.listing.categories);if(this.options.listing.tourismAreas)params+="&ta="+encodeURI(this.options.listing.tourismAreas);if(this.options.listing.paging&&this.options.listing.paging.enabled){this.currentPageNo=e||0;params+="&pg="+encodeURI(this.currentPageNo);params+="&rpp="+encodeURI(this.options.listing.paging.resultsPerPage)}if(this.options.listing.summary&&
this.options.listing.summary.enabled){params+="&sl="+encodeURI(this.options.listing.summary.maxLength);params+="&sc="+encodeURI(this.options.listing.summary.cut);params+="&sa="+encodeURI(this.options.listing.summary.appendText)}}else if(a=="details"){params+="&cb="+this.options.varName+".showDetailsCallback";params+="&out=jsonitem";params+="&eid="+encodeURI(e)}return params};this.init=function(){if(this.options.varName)if(eval("typeof "+this.options.varName)=="undefined")this.options.debug&&alert('varName is incorrect!\nMust be the name of this instance.\nvar eventsWidget = new EVENTSNOW.Widget({\n\tvarName: "eventsWidget",\n\t ...\n})\n');
else if(eval("typeof "+this.options.varName+".checkVarExists")!="function")this.options.debug&&alert('varName is incorrect!\nMust be on type EVENTSNOW.Widget.\nvar eventsWidget = new EVENTSNOW.Widget({\n\tvarName: "eventsWidget",\n\t ...\n})\n');else if(!this.options.password||!this.options.password.length>0)this.options.debug&&alert("password is a required field!");else if(!this.options.client||!this.options.client.length>0)this.options.debug&&alert("client is a required field!");else if(!this.options.listing&&
!this.options.details)this.options.debug&&alert("listing or details is a required field!");else{if(this.options.listing){if(!this.options.listing.targetDiv||!this.options.listing.targetDiv.length>0){this.options.debug&&alert("targetDiv is a required field within listings!");return}if(!document.getElementById(this.options.listing.targetDiv)){this.options.debug&&alert("listings - targetDiv does not exist!");return}if(this.options.listing.paging)if(this.options.listing.paging.enabled){if(!this.options.listing.paging.resultsPerPage||
!this.options.listing.paging.resultsPerPage>0){this.options.debug&&alert("resultsPerPage is a required field within listings - paging when paging is enabled!");return}}else{this.options.debug&&alert("enabled is a required field within listings - paging!");return}if(this.options.listing.clickThru){if(!this.options.listing.clickThru.URL||!this.options.listing.clickThru.URL.length>0){this.options.debug&&alert("URL is a required field within listings - clickThru!");return}if(!this.options.listing.clickThru.FieldName||
!this.options.listing.clickThru.FieldName.length>0){this.options.debug&&alert("FieldName is a required field within listings - clickThru!");return}}if(this.options.listing.summary)if(this.options.listing.summary.enabled){if(!this.options.listing.summary.maxLength||!this.options.listing.summary.maxLength>0){this.options.debug&&alert("maxLength is a required field within listings - summary when summary is enabled!");return}}else{this.options.debug&&alert("enabled is a required field within listings - paging!");
return}}if(this.options.details){if(!this.options.details.targetDiv||!this.options.details.targetDiv.length>0){this.options.debug&&alert("targetDiv is a required field within details!");return}if(!document.getElementById(this.options.details.targetDiv)){this.options.debug&&alert("details - targetDiv does not exist!");return}}var a=document.createElement("link");a.href="http://www.eventsnow.co.za/widget/stylesheet/widget.css";a.type="text/css";a.rel="stylesheet";document.getElementsByTagName("head")[0].appendChild(a);
if(this.options.customCSS){a=document.createElement("link");a.href=this.options.customCSS;a.type="text/css";a.rel="stylesheet";document.getElementsByTagName("head")[0].appendChild(a)}}else this.options.debug&&alert("varName is a required field!")};this.showListCallback=function(a){var e=Math.ceil(parseInt(a.totalCount)/this.options.listing.paging.resultsPerPage);document.getElementById("ewid_miniresult");var b=document.getElementById("ewid_topbox");b.innerHTML="";if(this.options.listing.paging.enabled){var c=
b.appendChild(document.createElement("div"));c.className="ewid_pagin";if(a.pageNo==null||a.pageNo>0){var d=c.appendChild(document.createElement("a"));d.href="javascript: "+this.options.varName+".prevPage()";d.className="ewid_arrow";d.innerHTML="&laquo;"}var f=a.pageNo-2;if(f<0)f=0;d=f+5;if(d>=e){d=e;if(e>5)f=d-5}for(pg=f;pg<d;pg++){f=c.appendChild(document.createElement("a"));f.href="javascript: "+this.options.varName+".gotoPage("+pg+")";f.appendChild(document.createTextNode(pg+1));if(pg==a.pageNo)f.className=
"ewid_page_here"}if(a.pageNo==null||a.pageNo<e-1){d=c.appendChild(document.createElement("a"));d.href="javascript: "+this.options.varName+".nextPage()";d.className="ewid_arrow";d.innerHTML="&raquo;"}}d=b.appendChild(document.createElement("div"));d.id="ewid_search";d.appendChild(document.createTextNode("Results"));d=document.getElementById("ewid_miniresultitemlist");d.innerHTML="";for(res=0;res<a.results.length;res++){b=a.results[res];c=d.appendChild(document.createElement("div"));c.className="ewid_miniresultitem";
if(this.options.details&&this.options.details.targetDiv)c.onclick=new Function(this.options.varName+".getDetailsById("+b.EventID+")");else if(this.options.listing&&this.options.listing.clickThru&&this.options.listing.clickThru.URL){f=this.options.listing.clickThru.URL;f+=f.indexOf("?",0)>0?"&":"?";f+=this.options.listing.clickThru.FieldName+"="+b.EventID;c.onclick=new Function('document.location = "'+f+'"')}f=c.appendChild(document.createElement("div"));f.className="ewid_mri_image";f.appendChild(document.createElement("img")).src=
b.Image;f=c.appendChild(document.createElement("div"));f.className="ewid_mri_name";f.appendChild(document.createTextNode(b.EventName));f=c.appendChild(document.createElement("div"));f.className="ewid_mri_date";var h=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),i=new Date(b.Dates[0].StartDate*1E3);i=i.getDate()+" "+h[i.getMonth()]+" "+(i.getFullYear()+"").substr(2,2);var j=new Date(b.Dates[0].EndDate*1E3);h=j.getDate()+" "+h[j.getMonth()]+" "+(j.getFullYear()+
"").substr(2,2);f.appendChild(document.createTextNode(i==h?i:i+" - "+h));if(b.Dates.length>1){f.appendChild(document.createElement("br"));f.appendChild(document.createTextNode("(more dates)"))}f=c.appendChild(document.createElement("div"));f.className="ewid_mri_location";f.appendChild(document.createTextNode(b.City));if(this.options.listing.summary&&this.options.listing.summary.enabled){f=c.appendChild(document.createElement("div"));f.className="ewid_d_whygo";f.appendChild(document.createElement("p")).appendChild(document.createTextNode(b.WhyGo))}c.appendChild(document.createElement("div")).className=
"ewid_clear"}b=document.getElementById("ewid_bottombox");b.innerHTML="";if(this.options.listing.paging.enabled){c=b.appendChild(document.createElement("div"));c.className="ewid_pagin";if(a.pageNo==null||a.pageNo>0){d=c.appendChild(document.createElement("a"));d.href="javascript: "+this.options.varName+".prevPage()";d.className="ewid_arrow";d.innerHTML="&laquo;"}f=a.pageNo-2;if(f<0)f=0;d=f+5;if(d>=e){d=e;if(e>5)f=d-5}for(pg=f;pg<d;pg++){f=c.appendChild(document.createElement("a"));f.href="javascript: "+
this.options.varName+".gotoPage("+pg+")";f.appendChild(document.createTextNode(pg+1));if(pg==a.pageNo)f.className="ewid_page_here"}if(a.pageNo==null||a.pageNo<e-1){a=c.appendChild(document.createElement("a"));a.href="javascript: "+this.options.varName+".nextPage()";a.className="ewid_arrow";a.innerHTML="&raquo;"}}b.appendChild(document.createElement("img")).src="http://www.eventsnow.co.za/widget/images/eventsnow_logo110px.png"};this.showDetailsCallback=function(a){var e=document.getElementById("enDetails_"+
this.options.varName);e.innerHTML="";e=e.appendChild(document.createElement("div"));e.id="ewid_details";var b=e.appendChild(document.createElement("div"));b.className="ewid_d_eventname";b.appendChild(document.createElement("h2")).appendChild(document.createTextNode(a.EventName));b=e.appendChild(document.createElement("div"));b.className="ewid_d_dates";for(dt=0;dt<a.Dates.length;dt++){var c=b.appendChild(document.createElement("div"));c.className="ewid_d_date";var d=c.appendChild(document.createElement("div"));
d.className="ewid_d_day";d.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Date"));var f=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),h=new Date(a.Dates[dt].StartDate*1E3),i=h.getDate()+" "+f[h.getMonth()]+" "+(h.getFullYear()+"").substr(2,2);h=h.getHours()!=0&&h.getMinutes()!=0?h.getHours()+"H"+h.getMinutes():"";var j=new Date(a.Dates[dt].EndDate*1E3);f=j.getDate()+" "+f[j.getMonth()]+" "+(j.getFullYear()+"").substr(2,2);j=j.getHours()!=
0&&j.getMinutes()!=0?j.getHours()+"H"+j.getMinutes():"";var n="";n=i==f?i:i+" - "+f;timeStr="";if(h!=""&&j!=""&&h==j)timeStr=h;else if(h!=""&&j!="")timeStr=h+" - "+j;else if(h!="")timeStr="Starts at "+h;else if(j!="")timeStr="Ends at "+j;d.appendChild(document.createElement("p")).appendChild(document.createTextNode(n));if(timeStr!=""){c=c.appendChild(document.createElement("div"));c.className="ewid_d_time";c.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Time"));c.appendChild(document.createElement("p")).appendChild(document.createTextNode(timeStr))}}b=
e.appendChild(document.createElement("div"));b.className="ewid_d_image";b.appendChild(document.createElement("img")).src=a.Image;b=e.appendChild(document.createElement("div"));b.className="ewid_d_price";b.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Price"));c="";if(a.IsFree==1)c="FREE";else if(a.MinPrice!=""&&a.MaxPrice!="")c=a.Symbol+""+a.MinPrice+" - "+a.Symbol+""+a.MaxPrice;else if(a.MinPrice==""&&a.MaxPrice=="")c="TBC";else if(a.MinPrice!="")c="Min Price "+a.Symbol+
a.MinPrice;else if(a.MaxPrice!="")c="Max Price "+a.Symbol+a.MaxPrice;b.appendChild(document.createElement("p")).appendChild(document.createTextNode(c));b.appendChild(document.createElement("p")).appendChild(document.createTextNode(a.PriceInfo));b=e.appendChild(document.createElement("div"));b.className="ewid_d_whygo";b.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Why Go"));b.appendChild(document.createElement("p")).appendChild(document.createTextNode(a.WhyGo));b=
e.appendChild(document.createElement("div"));b.className="ewid_d_usefull";b.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Usefull Information"));b.appendChild(document.createElement("p")).appendChild(document.createTextNode(a.UsefulInfo));b=e.appendChild(document.createElement("div"));b.className="ewid_d_venueinfo";b.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Venue Information"));c=b.appendChild(document.createElement("div"));c.className=
"ewid_d_venuename";c.appendChild(document.createTextNode(a.VenueName));c=b.appendChild(document.createElement("div"));c.className="ewid_d_address";d=c.appendChild(document.createElement("div"));d.className="ewid_d_addr1";d.appendChild(document.createTextNode(a.Address_1));d=c.appendChild(document.createElement("div"));d.className="ewid_d_addr2";d.appendChild(document.createTextNode(a.Address_2));c.appendChild(document.createElement("div")).className="ewid_d_addr3";d.appendChild(document.createTextNode(a.Address_3));
d=c.appendChild(document.createElement("div"));d.className="ewid_d_city";d.appendChild(document.createTextNode(a.City));d=c.appendChild(document.createElement("div"));d.className="ewid_d_province";d.appendChild(document.createTextNode(a.ProvinceName));c=c.appendChild(document.createElement("div"));c.className="ewid_d_country";c.appendChild(document.createTextNode("South Africa"));c=b.appendChild(document.createElement("div"));c.className="ewid_d_geocode";d=c.appendChild(document.createElement("div"));
d.className="ewid_d_lat";d.appendChild(document.createTextNode(a.Latitude));c=c.appendChild(document.createElement("div"));c.className="ewid_d_log";c.appendChild(document.createTextNode(a.Longitude));b=b.appendChild(document.createElement("div"));b.className="ewid_d_tarea";b.appendChild(document.createTextNode(a.TourismAreaName));b=e.appendChild(document.createElement("div"));b.className="ewid_d_booking";b.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Booking Information"));
if(a.BookCompany!=""){c=b.appendChild(document.createElement("div"));c.className="ewid_d_book_name";c.appendChild(document.createTextNode(a.BookCompany))}if(a.BookContact!=""){c=b.appendChild(document.createElement("div"));c.className="ewid_d_org_contact";c.appendChild(document.createTextNode(a.BookContact))}if(a.BookURL!=""){c=b.appendChild(document.createElement("div"));c.className="ewid_d_org_url";c.appendChild(document.createTextNode(a.BookURL))}if(a.BookEmail!=""){c=b.appendChild(document.createElement("div"));
c.className="ewid_d_org_email";c.appendChild(document.createTextNode(a.BookEmail))}if(a.BookPhone!=""){c=b.appendChild(document.createElement("div"));c.className="ewid_d_org_phone";c.appendChild(document.createTextNode(a.BookPhone))}if(a.BookFax!=""){c=b.appendChild(document.createElement("div"));c.className="ewid_d_org_fax";c.appendChild(document.createTextNode(a.BookFax))}if(a.BookCell!=""){b=b.appendChild(document.createElement("div"));b.className="ewid_d_org_fax";b.appendChild(document.createTextNode(a.BookCell))}e=
e.appendChild(document.createElement("div"));e.className="ewid_d_organiser";e.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Organiser Information"));if(a.OrgCompany!=""){b=e.appendChild(document.createElement("div"));b.className="ewid_d_org_company";b.appendChild(document.createTextNode(a.OrgCompany))}if(a.OrgContact!=""){b=e.appendChild(document.createElement("div"));b.className="ewid_d_org_contact";b.appendChild(document.createTextNode(a.OrgContact))}if(a.OrgURL!=
""){b=e.appendChild(document.createElement("div"));b.className="ewid_d_org_url";b.appendChild(document.createTextNode(a.OrgURL))}if(a.OrgEmail!=""){b=e.appendChild(document.createElement("div"));b.className="ewid_d_org_email";b.appendChild(document.createTextNode(a.OrgEmail))}if(a.OrgPhone!=""){b=e.appendChild(document.createElement("div"));b.className="ewid_d_org_phone";b.appendChild(document.createTextNode(a.OrgPhone))}if(a.OrgFax!=""){b=e.appendChild(document.createElement("div"));b.className=
"ewid_d_org_fax";b.appendChild(document.createTextNode(a.OrgFax))}if(a.OrgCell!=""){e=e.appendChild(document.createElement("div"));e.className="ewid_d_org_cell";e.appendChild(document.createTextNode(a.OrgCell))}};this.getList=function(a){var e=document.getElementById("enList_"+this.options.varName);if(e){b=document.getElementById("ewid_miniresultitemlist");b.innerHTML=""}else{e=document.getElementById(this.options.listing.targetDiv);if(!e)return;e=e.appendChild(document.createElement("div"));e.id=
"enList_"+this.options.varName;e=e.appendChild(document.createElement("div"));e.id="ewid_miniresult";e.appendChild(document.createElement("div")).id="ewid_topbox";var b=e.appendChild(document.createElement("div"));b.id="ewid_miniresultitemlist";e.appendChild(document.createElement("div")).id="ewid_bottombox"}e=b.appendChild(document.createElement("div"));e.id="ewid_loading";e.style.display="block";this.currentPageNo=a||0;e=document.createElement("script");e.type="text/javascript";e.id="text/javascript";
e.src=a?"http://www.eventsnow.co.za/widget/out_v2.php"+this.getParams("listing",a):"http://www.eventsnow.co.za/widget/out_v2.php"+this.getParams("listing");document.getElementsByTagName("head")[0].appendChild(e)};this.getDetailsById=function(a){var e=document.getElementById("enDetails_"+this.options.varName);if(e)e.innerHTML="";else{e=document.getElementById(this.options.details.targetDiv);if(!e)return;e=e.appendChild(document.createElement("div"));e.id="enDetails_"+this.options.varName}e=e.appendChild(document.createElement("div"));
e.id="ewid_loading";e.style.display="block";if(a)a=a;else if(this.options.details.eventId)a=this.options.details.eventId;else{this.options.debug&&alert("Event ID is required!");return}e=document.createElement("script");e.type="text/javascript";e.id="text/javascript";e.src=a?"http://www.eventsnow.co.za/widget/out_v2.php"+this.getParams("details",a):"http://www.eventsnow.co.za/widget/out_v2.php"+this.getParams("details");document.getElementsByTagName("head")[0].appendChild(e)};this.start=function(){this.options.listing&&
this.getList();this.options.details&&this.options.details.eventId&&this.getDetailsById()};this.dealWithError=function(a){document.write(a)};this.nextPage=function(){this.getList(this.currentPageNo+1)};this.prevPage=function(){this.getList(this.currentPageNo-1)};this.gotoPage=function(a){this.getList(a)}};(function(){var o,a,e={'"':'"',"\\":"\\","/":"/",b:"\u0008",f:"\u000c",n:"\n",r:"\r",t:"\t"},b,c=function(g){throw{name:"SyntaxError",message:g,at:o,text:b};},d=function(g){g&&g!==a&&c("Expected '"+
g+"' instead of '"+a+"'");a=b.charAt(o);o+=1;return a},f=function(){var g;g="";if(a==="-"){g="-";d("-")}for(;a>="0"&&a<="9";){g+=a;d()}if(a===".")for(g+=".";d()&&a>="0"&&a<="9";)g+=a;if(a==="e"||a==="E"){g+=a;d();if(a==="-"||a==="+"){g+=a;d()}for(;a>="0"&&a<="9";){g+=a;d()}}g=+g;if(isNaN(g))c("Bad number");else return g},h=function(){var g,k,l="",p;if(a==='"')for(;d();)if(a==='"'){d();return l}else if(a==="\\"){d();if(a==="u"){for(k=p=0;k<4;k+=1){g=parseInt(d(),16);if(!isFinite(g))break;p=p*16+g}l+=
String.fromCharCode(p)}else if(typeof e[a]==="string")l+=e[a];else break}else l+=a;c("Bad string")},i=function(){for(;a&&a<=" ";)d()},j=function(){switch(a){case "t":d("t");d("r");d("u");d("e");return true;case "f":d("f");d("a");d("l");d("s");d("e");return false;case "n":d("n");d("u");d("l");d("l");return null}c("Unexpected '"+a+"'")},n;n=function(){i();switch(a){case "{":var g;a:{var k,l={};if(a==="{"){d("{");i();if(a==="}"){d("}");g=l;break a}for(;a;){k=h();i();d(":");Object.hasOwnProperty.call(l,
k)&&c('Duplicate key "'+k+'"');l[k]=n();i();if(a==="}"){d("}");g=l;break a}d(",");i()}}c("Bad object")}return g;case "[":a:{g=[];if(a==="["){d("[");i();if(a==="]"){d("]");k=g;break a}for(;a;){g.push(n());i();if(a==="]"){d("]");k=g;break a}d(",");i()}}c("Bad array")}return k;case '"':return h();case "-":return f();default:return a>="0"&&a<="9"?f():j()}};return function(g,k){var l;b=g;o=0;a=" ";l=n();i();a&&c("Syntax error");return typeof k==="function"?function p(s,t){var q,r,m=s[t];if(m&&typeof m===
"object")for(q in m)if(Object.hasOwnProperty.call(m,q)){r=p(m,q);if(r!==undefined)m[q]=r;else delete m[q]}return k.call(s,t,m)}({"":l},""):l}})()}})();