var checkFunction=false;var currentIndex=0;function displayLayer(b,a){document.getElementById(b).style.visibility="hidden";document.getElementById(a).style.visibility="visible"}function clearForm(c){var b=c;for(var a=0;a<b.elements.length;a++){if(b.elements[a].type=="text"){b.elements[a].value=""}}}function clearFormNationwide(c){var b=c;if(checkFunction==false){for(var a=0;a<b.elements.length;a++){if(b.elements[a].type=="text"){b.elements[a].value=""}if(b.elements[a].type=="select-one"){b.elements[a].selectedIndex=0}}}checkFunction=true}function clearFormLocal(c){var b=c;if(checkFunction==false){for(var a=0;a<b.elements.length;a++){if(b.elements[a].type=="text"&&b.elements[a].id!="search_service_usa"&&b.elements[a].id!="search_service_can"){b.elements[a].value=""}if(b.elements[a].type=="select-one"&&b.elements[a].name!="select_location"){b.elements[a].selectedIndex=0}}}checkFunction=true}function allCategories(c){if(c.name=="form_usa"){if(document.getElementById("select_location_usa").selectedIndex==0){alert("Please select a location first. Thank you.");clearForm(c)}else{var a=document.getElementById("select_location_usa");location.href=a.options[a.selectedIndex].value}}else{if(document.getElementById("select_location_can").selectedIndex==0){alert("Please select a location first. Thank you.");clearForm(c)}else{var b=document.getElementById("select_location_can");location.href=b.options[b.selectedIndex].value}}}function checkSubmissionUSA(){var b=false;var a="";if(document.getElementById("search_merchant_usa").value!=""){document.getElementById("search_merchant_usa").name="q";selectOutputID("online_us",document.forms.form_usa);actionRequestUS();b=true}else{if(document.getElementById("select_merchant_usa").selectedIndex!=0){actionRequestUS();b=false}else{if(document.getElementById("search_service_usa").value!=""){if(document.getElementById("select_location_usa").selectedIndex==0){a="Please select a location first. Thank you."}else{document.getElementById("search_service_usa").name="q";selectOutputID("local_us",document.forms.form_usa);actionRequestUS();b=true}}else{if(document.getElementById("select_location_usa").selectedIndex!=0){if(document.getElementById("search_service_usa").value==""){a='Please enter a valid service into the "Search Service" field.  Thank you.'}else{b=true}}else{a="Please enter and/or select a value before submitting.  Thank you."}}}}if(b){return b}else{if(a!=""){alert(a)}return b}}function checkSubmissionCAN(){var b=false;var a="";if(document.getElementById("select_location_can").selectedIndex==0){a="Please enter and/or select a value before submitting.  Thank you."}else{if(document.getElementById("search_service_can").value==""){a='Please enter a valid service into the "Search Service" field.  Thank you.'}else{document.getElementById("search_service_can").name="q";selectOutputID("local_can",document.forms.form_canada);actionRequestCAN();b=true}}if(b){return b}else{if(a!=""){alert(a)}return b}}function actionRequestUS(){var b="/html/search_ofs.php";var a="/html/search.php";var c="";if(document.getElementById("search_merchant_usa").value!=""){document.form_usa.action=b}if(document.getElementById("search_service_usa").value!=""){document.form_usa.action=a}if(document.getElementById("select_merchant_usa").selectedIndex!=0){var d=document.getElementById("select_merchant_usa");c+=d.options[d.selectedIndex].value;location.href=c}}function actionRequestCAN(){var b="/html/search.php";var a="/html/search.php";var c="";if(document.getElementById("search_service_can").value!=""){document.form_canada.action=a}}function selectOutputID(b,e){var c;var a=e.getElementsByTagName("SPAN");if(b=="online_us"){c="<input type='hidden' name='cref' value='http://www.fabuloussavings.com/xml/online-usa-coupons.xml' />";c+="<input type='hidden' name='city_id' value='2' />"}if(b=="local_us"){var f=document.getElementById("select_location_usa");var g=f.options[document.getElementById("select_location_usa").selectedIndex].id;cityValue=f.value;cityValue=cityValue.substring(cityValue.indexOf("/")+1,cityValue.lastIndexOf("/"));if(typeof g!="undefined"){c="<input type='hidden' name='cref' value='http://www.fabuloussavings.com/xml/"+cityValue+".xml' />";c+="<input type='hidden' name='city_id' value='"+g+"' />"}}if(b=="local_can"){var f=document.getElementById("select_location_can");var g=f.options[document.getElementById("select_location_can").selectedIndex].id;cityValue=f.value;cityValue=cityValue.substring(cityValue.indexOf("/")+1,cityValue.lastIndexOf("/"));if(typeof g!="undefined"){c="<input type='hidden' name='cref' value='http://www.fabuloussavings.com/xml/"+cityValue+".xml' />";c+="<input type='hidden' name='city_id' value='"+g+"' />"}}for(var d=0;d<a.length;d++){if(a[d].id=="selectedOutput"){a[d].innerHTML=c}}}function clearName(){for(var b=0;b<document.forms.length;b++){for(var a=0;a<document.forms[b].elements.length;a++){if(document.forms[b].elements[a].type=="text"){document.forms[b].elements[a].name=""}}}}function setFlag(){checkFunction=false}function hasClass(b,a){return b.className.match(new RegExp("(\\s|^)"+a+"(\\s|$)"))}function addClass(b,a){if(!hasClass(b,a)){if(b.className===""||typeof b.className==="undefined"){b.className=a}else{b.className+=" "+a}}}function removeClass(b,a){if(hasClass(b,a)){var c=new RegExp("(\\s|^)"+a+"(\\s|$)");b.className=b.className.replace(c," ")}}function nextClick(){var a=collectHeaderText();var b=collectCellContent();removeClass(a[currentIndex],"bundleHeaderVisible");addClass(a[currentIndex],"bundleHeaderHidden");removeClass(a[currentIndex+1],"bundleHeaderHidden");addClass(a[currentIndex+1],"bundleHeaderVisible");removeClass(b[currentIndex],"display");addClass(b[currentIndex],"noDisplay");removeClass(b[currentIndex+1],"noDisplay");addClass(b[currentIndex+1],"display");currentIndex++;if((currentIndex+1)>=a.length){removeClass(document.getElementById("next"),"visible");addClass(document.getElementById("next"),"hidden")}removeClass(document.getElementById("back"),"hidden");addClass(document.getElementById("back"),"visible")}function backClick(){var a=collectHeaderText();var b=collectCellContent();removeClass(a[currentIndex],"bundleHeaderVisible");addClass(a[currentIndex],"bundleHeaderHidden");removeClass(a[currentIndex-1],"bundleHeaderHidden");addClass(a[currentIndex-1],"bundleHeaderVisible");removeClass(b[currentIndex],"display");addClass(b[currentIndex],"noDisplay");removeClass(b[currentIndex-1],"noDisplay");addClass(b[currentIndex-1],"display");currentIndex--;if((currentIndex-1)<0){removeClass(document.getElementById("back"),"visible");addClass(document.getElementById("back"),"hidden")}removeClass(document.getElementById("next"),"hidden");addClass(document.getElementById("next"),"visible")}function collectHeaderText(){var a=document.getElementById("second").getElementsByTagName("div").length,c=new Array();for(var b=0;b<a;b++){if(document.getElementById("second").getElementsByTagName("div")[b].className.indexOf("bundleHeader")!==-1){c.push(document.getElementById("second").getElementsByTagName("div")[b])}}return c}function collectCellContent(){var b=document.getElementById("cellBundles").childNodes.length,a=new Array();for(var c=0;c<b;c++){if(document.getElementById("cellBundles").childNodes[c].nodeName!="#text"){a.push(document.getElementById("cellBundles").childNodes[c])}}return a}function loadScript(b,a){var d=document.getElementsByTagName("head")[0];var c=document.createElement("script");c.setAttribute("type","text/javascript");if(a){if(c.addEventListener){c.addEventListener("load",a,false)}else{c.onreadystatechange=function(){if(this.readyState=="complete"||this.readyState=="loaded"){a()}}}}c.src=b;d.appendChild(c)}if(window.addEventListener){window.addEventListener("DOMContentLoaded",function(){window.removeEventListener("DOMContentLoaded",arguments.callee,false);if(collectHeaderText().length>1){removeClass(document.getElementById("next"),"hidden");addClass(document.getElementById("next"),"visible")}document.getElementById("next").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}nextClick()};document.getElementById("back").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}backClick()};var a="";var d=document.createElement("ul");d.setAttribute("id","twitter_update_list");var b=document.getElementById("twitterBox");var c=b.getElementsByTagName("a")[0];b.insertBefore(d,c);loadScript("http://twitter.com/statuses/user_timeline/fabuloussavings.json?callback=twitterCallback2&count=8")},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState=="interactive"||document.readyState=="complete"){document.detachEvent("onreadystatechange",arguments.callee);if(collectHeaderText().length>1){removeClass(document.getElementById("next"),"hidden");addClass(document.getElementById("next"),"visible")}document.getElementById("next").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}nextClick()};document.getElementById("back").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}backClick()};var a="";var d=document.createElement("ul");d.setAttribute("id","twitter_update_list");var b=document.getElementById("twitterBox");var c=b.getElementsByTagName("a")[0];b.insertBefore(d,c);loadScript("http://twitter.com/statuses/user_timeline/fabuloussavings.json?callback=twitterCallback2&count=8")}})}else{window.onload=function(){if(collectHeaderText().length>1){removeClass(document.getElementById("next"),"hidden");addClass(document.getElementById("next"),"visible")}document.getElementById("next").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}nextClick()};document.getElementById("back").getElementsByTagName("a")[0].onclick=function(f){if(!f){event.returnValue=false}else{f.preventDefault()}backClick()};var a="";var d=document.createElement("ul");d.setAttribute("id","twitter_update_list");var b=document.getElementById("twitterBox");var c=b.getElementsByTagName("a")[0];b.insertBefore(d,c);loadScript("http://twitter.com/statuses/user_timeline/fabuloussavings.json?callback=twitterCallback2&count=8")}}};
