
var obs={};obs.callback={};obs.config={};obs.init=function(jq){obs.jq=jq;obs.div=document.createElement("div");obs.jq(obs.div).attr("id",obs.config.id);obs.jq('body').append(obs.div);obs.jq(obs.div).hide();obs.bg=document.createElement("div");obs.jq(obs.bg).attr("id",obs.config.id+'-bg');obs.jq('body').append(obs.bg);obs.jq(obs.bg).hide();obs.css=document.createElement("link");obs.jq(obs.css).attr("type","text/css").attr("rel","stylesheet");obs.attach();obs.jq(window).resize(function(){var page_size=___getPageSize();var page_scroll=___getPageScroll();obs.jq(obs.bg).css({"width":page_size[0],"height":page_size[1]});obs.top_offset=page_scroll[1]+70;obs.left_offset=(page_size[0]-obs.jq(obs.div).width())/2;obs.jq(obs.div).css({"top":obs.top_offset,"left":obs.left_offset});});obs.jq('link[@href*=obs-print.css]').each(function(){this.disabled=true;});};obs.attach=function(){for(var i=0;i<obs.config.buttons.length;i++){obs.jq(obs.config.buttons[i]).attr("href","javascript:void(0);");obs.jq(obs.config.buttons[i]).removeAttr("onclick");obs.jq(obs.config.buttons[i]).unbind("click");obs.jq(obs.config.buttons[i]).click(function(){obs.load();});}};obs.load=function(url,data){var page_size=___getPageSize();var page_scroll=___getPageScroll();obs.jq(obs.bg).css({"width":page_size[0],"height":page_size[1],"opacity":"0.7","filter":"alpha(opacity=30)","position":"absolute","top":"0","left":"0","background":"#000","z-index":"999"});obs.jq(obs.bg).show();if(!url){url=obs.config.url;}
var load_div=document.createElement("div");var load_txt=document.createElement("h3");var load_logo=document.createElement("img");var load_img=document.createElement("img");obs.jq(load_txt).text("LOADING...");obs.jq(load_div).css({"text-align":"center","margin":"100px 0 0 0"}).append(obs.jq(load_logo)).append(obs.jq(load_txt)).append(obs.jq(load_img));obs.jq(load_img).attr("src","/images-2008/obs/loading-bar.gif");obs.jq(load_logo).attr("src","/images-2008/obs/logo-spaced.gif");obs.jq(obs.div).empty().append(load_div).load(url,data,obs.stage_callback).show();if(obs.top_offset===undefined||obs.left_offset===undefined){obs.top_offset=page_scroll[1]+30;obs.left_offset=(page_size[0]-obs.jq(obs.div).width())/2;}
obs.jq(obs.div).css({"top":obs.top_offset,"left":obs.left_offset});if(obs.jq.browser.msie){obs.jq('#cta select').hide();}
obs.jq('link[@href*=obs-print.css]').each(function(){this.disabled=false;});};obs.unload=function(){obs.jq(obs.bg).hide();obs.jq(obs.div).hide();obs.jq('#cta select').show();obs.jq('link[@href*=obs-print.css]').each(function(){this.disabled=true;});if(Get("my_appointments-content")){WidgetObj['my_appointments'].Pull(WidgetObj['my_appointments'].InitURL,'my_appointments');}};obs.stage_callback=function(){obs.jq(obs.config.form_selector).submit(function(){if(obs.jq('input[@name=postcode]').attr("value")=="Enter your postcode"){obs.jq('input[@name=postcode]').attr("value","");}
obs.load(obs.config.url+"?"+obs.jq(this).serialize());return false;});obs.jq("a[@href*=obs_controller]").each(function(){var href=obs.jq(this).attr("href");obs.jq(this).attr("href","javascript:void(0);");obs.jq(this).click(function(){obs.load(href);});});obs.jq("#obs-close-window").add("#obs-close a").each(function(){obs.jq(this).attr("href","javascript:void(0);").unbind("click").click(function(){obs.load(obs.config.exit_url);});});obs.jq("input[@type=button][@rel]").each(function(){var url=obs.jq(this).attr("rel");obs.jq(this).unbind("click");obs.jq(this).click(function(){var form=obs.jq(obs.config.form_selector).serialize();if(form&&url.match("\\?")){url=url+'&'+form;}
else if(form){url=url+'?'+form;}
obs.load(url);});});var stage=obs.jq("#stage-ident").attr("rel");if(stage&&obs.callback.dt[stage]!=undefined){obs.callback.dt[stage]();}};obs.callback.obs_pre_filter=function(){obs.jq(obs.div).attr("class","").addClass("stage-1");obs.jq("select[@name=preferred_clinic] option").each(function(){var v=obs.jq(this).attr("value");var mapped_v;if(obs.config.clinic_map[v]!=undefined){mapped_v=obs.config.clinic_map[v];}
else{mapped_v=obs.config.clinic_map._default(v);}
obs.jq(this).attr("value",mapped_v);});obs.jq("select[@name=preferred_clinic]").attr("name","event_location");__prefill();obs.jq("input[@name=postcode][@value=]").attr("value","Enter your postcode");obs.jq("input[@name=postcode]").focus(function(){obs.jq("input[@name=postcode][@value^=Enter]").attr("value","");});obs.jq("#lenses-type").hide();obs.jq("#lenses-warning").hide();if(!(obs.jq("input[@name=lenses_type][@value=soft]").attr('checked'))&&!(obs.jq("input[@name=lenses_type][@value=extended]").attr('checked'))&&!(obs.jq("input[@name=lenses_type][@value=hard]").attr('checked'))){obs.jq("input[@name=lenses_wearer][@value=yes]").attr('checked','');}
obs.jq("input[@name=lenses_wearer][@value=yes]").click(function(){obs.jq("#lenses-wearer").fadeOut(10,function(){obs.jq("#lenses-type").fadeIn();});});obs.jq("input[@name=lenses_type]").click(function(){obs.jq("#lenses-warning").empty().append(obs.config.lenses_warnings[obs.jq(this).attr('value')]);obs.jq("#lenses-warning").show();});};obs.callback.obs_select_event=function(){obs.jq(obs.div).attr("class","").addClass("stage-2");obs.jq('.day-events').hide();obs.jq('.event-count > a').attr('href','javascript:void(0);');obs.jq('.event-count').parent().hover(function(){obs.jq(this).find('.day-events').show();obs.jq(this).css({"z-index":1060});},function(){obs.jq(this).find('.day-events').hide();obs.jq(this).css({"z-index":1050});});obs.jq('.day-events').parent().parent().hover(function(){if(obs.jq.browser.msie){obs.jq('.booking-info').hide();}},function(){if(obs.jq.browser.msie){obs.jq('.booking-info').show();}});obs.jq('.promo').hide();obs.jq("p.explanation").hide();};obs.callback.obs_post_filter=function(){obs.jq(obs.div).attr("class","").addClass("stage-3");obs.jq('.promo').hide();obs.jq("p.explanation").hide();};obs.callback.obs_complete=function(){obs.jq(obs.div).attr("class","").addClass("stage-4");obs.jq('.previous-clinic').hide();obs.jq('.next-clinic').hide();obs.jq('#change-event').hide();obs.jq('.booking-info').append('<a class="print-booking" href="javascript:window.print();">Print Booking</a>');obs.jq("#obs-close-window").add("#obs-close a").each(function(){obs.jq(this).attr("href","javascript:void(0);").unbind("click").click(function(){obs.unload();});});obs.jq('.promo').hide();obs.jq("p.explanation").hide();};obs.callback.obs_early_exit=function(){var w=420;var h=430;var page_size=___getPageSize();var _w=obs.jq(obs.div).css("width");var _h=obs.jq(obs.div).css("height");var _left=obs.jq(obs.div).css("left");obs.jq(obs.div).css({"width":w+"px","height":h+"px","left":(page_size[0]-w)/2});obs.jq("#obs-close-window").add("#obs-close a").each(function(){obs.jq(this).attr("href","javascript:void(0);").unbind("click").click(function(){obs.unload();obs.jq(obs.div).css({"width":_w,"height":_h,"left":_left});});});}
obs.callback.dt={obs_pre_filter:obs.callback.obs_pre_filter,obs_select_event:obs.callback.obs_select_event,obs_post_filter:obs.callback.obs_post_filter,obs_complete:obs.callback.obs_complete,obs_early_exit:obs.callback.obs_early_exit}
