function loadScript(url, callback) { // add script to head var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; //bind to callback script.onreadystatechange = callback; script.onload = callback; // kick off the script head.appendChild(script); } var rnClientLoaded = function() { var getStr = ""; if (typeof chat_id != 'undefined') { var en_chat_id = encodeURIComponent(chat_id); getStr += "i=" + en_chat_id; } else { getStr = "i=w"; } if (typeof wd_first != 'undefined') { var en_first = encodeURIComponent(wd_first); getStr += "&f=" + en_first; } if (typeof wd_last != 'undefined') { var en_last = encodeURIComponent(wd_last); getStr += "&l=" + en_last; } if (typeof wd_email != 'undefined') { var en_email = encodeURIComponent(wd_email); getStr += "&e=" + en_email; } if (typeof wd_postal_code != 'undefined') { var en_postal_code = encodeURIComponent(wd_postal_code); getStr += "&z=" + en_postal_code; } if (typeof wd_phone != 'undefined') { var en_phone = encodeURIComponent(wd_phone); getStr += "&p=" + en_phone; } if (typeof wd_pet_name != 'undefined') { var en_pet_name = encodeURIComponent(wd_pet_name); getStr += "&n=" + en_pet_name; } if (typeof wd_pet_type != 'undefined') { if (wd_pet_type.toLowerCase()=="dog") { en_pet_type="Dog"; } else if (wd_pet_type.toLowerCase()=="cat") { en_pet_type="Cat"; } else { en_pet_type="Other"; } getStr += "&t=" + en_pet_type; } if (typeof wd_pet_breed != 'undefined') { var en_pet_breed = wd_pet_breed.split('%20').join('_'); en_pet_breed = encodeURIComponent(en_pet_breed); getStr += "&b=" + en_pet_breed; } if (typeof wd_pet_age != 'undefined') { var en_pet_age = encodeURIComponent(wd_pet_age); getStr += "&a=" + en_pet_age; } if (typeof wd_pet_gender != 'undefined') { if (wd_pet_gender.toLowerCase()=="female") { en_pet_gender="Female"; } else if (wd_pet_gender.toLowerCase()=="male") { en_pet_gender="Male"; } else { en_pet_gender="Male"; } getStr += "&g=" + en_pet_gender; } if (typeof wd_pet_fixed != 'undefined') { if (wd_pet_fixed.toLowerCase()=="yes") { en_pet_fixed="Yes"; } else if (wd_pet_fixed.toLowerCase()=="no") { en_pet_fixed="No"; } else { en_pet_fixed="No"; } getStr += "&x=" + en_pet_fixed; } if (typeof wd_pet_number != 'undefined') { var en_pet_number = encodeURIComponent(wd_pet_number); getStr += "&u=" + en_pet_number; } if (typeof wd_ident_number != 'undefined') { var en_ident_number = encodeURIComponent(wd_ident_number); getStr += "&d=" + en_ident_number; } getStr += "&st=1"; var chat_login_page = "https://www.whiskerdocs.com/saas/chat/chatlogin31.php?en=" + encodeURIComponent(btoa(getStr)); RightNow.Client.Controller.addComponent( { chat_login_page_height: 630, chat_login_page_width: 330, chat_login_page: chat_login_page, container_element_id: "wdChatLinkContainer", label_available_immediately_template: "CHAT NOW", label_unavailable_busy_template: "All whiskerDocs vet experts are busy.", label_unavailable_hours: "We're sorry, chat is currently unavailable.", ignore_preroute: true, min_sessions_avail: 0, wait_threshold: 86400, info_element_id: "wdChatLinkInfo", link_element_id: "wdChatLink", instance_id: "sccl_0", module: "ConditionalChatLink", type: 7 }, "https://whiskerdocs.widget.custhelp.com/ci/ws/get" ); //Widget loaded callback RightNow.Client.Event.evt_widgetLoaded.subscribe(function (type, args) { //Register event to watch for when avail is checked RightNow.Client.Event.evt_conditionalChatLinkAvailabilityResponse.subscribe(function(type, args, instance) { var result = args[0].data; var scope = args[1].scope; var eventScope = args[1]; //Overwrite the base_url to be blank so that we can open absolute URL's from the chat_login_page attribute if(scope && scope.data && scope.data.base_url) { scope.data.base_url = ""; } }); }); function objToString (obj) { var str = ''; for (var p in obj) { if (obj.hasOwnProperty(p)) { str += p + '::' + obj[p] + '\n'; } } return str; } }; loadScript("https://whiskerdocs.widget.custhelp.com/euf/rightnow/RightNow.Client.js", rnClientLoaded);