var activated;activated=false;var showdebug;showdebug=false;var poppages;poppages=new Array("basket.asp","shipping.asp","payment.asp","shopper_lookup.asp","shopper_new.asp");var coupon;coupon="exit10";var gotopage;gotopage="/austads/Survey_new.asp?sur=78&";var popuppage;popuppage="/austads/Survey_new.asp?sur=78&";var newwindowconfig;newwindowconfig="menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=520,height=500,top=30,left=30";var alreadyopen;alreadyopen=false;var locallink;locallink=false;var onclickfunc;var onsubmitfunc;var q_jump_func;var bill_to_country_func;var ship_to_country_func;var ShipOptions_func;function shouldIncludePopup(){var b_result;b_result=false;for(var i=0;i<poppages.length&&b_result==false;i++){if(window.location){if(window.location.href){if(window.location.href.toLowerCase().indexOf("/"+poppages[i])!=-1){b_result=true}}}}if(showdebug==true){if(b_result==true){alert("Debug: Current page should include popup.")}}if(activated==false){b_result=false}return b_result}function confirmLeave(){if(shouldIncludePopup()==true){if(locallink==false){popWindow(popuppage,"_blank",newwindowconfig)}else{if(showdebug==true){alert("Debug: Local link, do not show popup.")}}}}function popWindow(theURL,theName,theOptions){var newWin;if(showdebug==true){alert("Debug: Open the popup window.")}newWin=window.open(theURL,theName,theOptions);if(newWin){if(showdebug==true){alert("Debug: Open window successful.  Focus on it.")}newWin.focus()}}function reopen(){if(activated==true){if(!window.opener){if(showdebug==true){alert("Debug: The parent window was closed, open a new one for the user to '"+gotopage+"'.")}popWindow(gotopage,"_blank","")}else{if(!window.opener.closed){if(showdebug==true){alert("Debug: The parent window is still open, redirect it to '"+gotopage+"'.")}opener.location=gotopage}else{if(showdebug==true){alert("Debug: Cannot fully determine the state of the windows, just try opening a new one to '"+gotopage+"'.")}popWindow(gotopage,"_blank","")}}}window.close()}function prepareOnClickOnSubmit(){if(shouldIncludePopup()==true){onclickfunc=new Array(window.document.links.length);for(var i=0;i<window.document.links.length;i++){onclickfunc[i]=extractFunction(window.document.links[i].onclick,i);window.document.links[i].onclick=function(){var i;var returnval;var b_has_return;b_has_return=false;i=findMeLink(this);locallink=true;if(onclickfunc[i].length>0){if(onclickfunc[i].indexOf("return ")!=-1||onclickfunc[i].indexOf("return(")!=-1){b_has_return=true}eval(onclickfunc[i].replace("return ","returnval = ").replace("return(","returnval = ("))}else{if(showdebug==true){alert("Debug: Link did not have a previous onclick function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}}}onsubmitfunc=new Array(window.document.forms.length);for(var i=0;i<window.document.forms.length;i++){onsubmitfunc[i]=extractFunction(window.document.forms[i].onsubmit,i);window.document.forms[i].onsubmit=function onsubmit(event){var i;var returnval;var b_has_return;b_has_return=false;i=findMeForm(this);locallink=true;if(onsubmitfunc[i].length>0){if(onsubmitfunc[i].indexOf("return ")!=-1||onsubmitfunc[i].indexOf("return(")!=-1){b_has_return=true}eval(onsubmitfunc[i].replace("return ","returnval = ").replace("return(","returnval = ("))}else{if(showdebug==true){alert("Debug: Form did not have a previous onsubmit function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}};if(window.document.forms[i].q_jump){if(showdebug==true){alert("Debug: The q_jump Function is...\n\n"+window.document.forms[i].q_jump.onchange)}q_jump_func=extractFunction(window.document.forms[i].q_jump.onchange,0);window.document.forms[i].q_jump.onchange=function onchange(event){var returnval;var b_has_return;b_has_return=false;locallink=true;if(q_jump_func.length>0){if(q_jump_func.indexOf("return ")!=-1||q_jump_func.indexOf("return(")!=-1){b_has_return=true}eval(q_jump_func.replace("return ","returnval = ").replace("return(","returnval = (").replace("[selectedIndex]","[this.selectedIndex]"))}else{if(showdebug==true){alert("Debug: q_jump did not have a previous onchange function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}}}if(window.document.forms[i].bill_to_country){if(showdebug==true){alert("Debug: The bill_to_country Function is...\n\n"+window.document.forms[i].bill_to_country.onchange)}bill_to_country_func=extractFunction(window.document.forms[i].bill_to_country.onchange,0);window.document.forms[i].bill_to_country.onchange=function onchange(event){var returnval;var b_has_return;b_has_return=false;locallink=true;if(bill_to_country_func.length>0){if(bill_to_country_func.indexOf("return ")!=-1||bill_to_country_func.indexOf("return(")!=-1){b_has_return=true}eval(bill_to_country_func.replace("return ","returnval = ").replace("return(","returnval = (").replace("[selectedIndex]","[this.selectedIndex]"))}else{if(showdebug==true){alert("Debug: bill_to_country did not have a previous onchange function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}}}if(window.document.forms[i].ship_to_country){if(showdebug==true){alert("Debug: The ship_to_country Function is...\n\n"+window.document.forms[i].ship_to_country.onchange)}ship_to_country_func=extractFunction(window.document.forms[i].ship_to_country.onchange,0);window.document.forms[i].ship_to_country.onchange=function onchange(event){var returnval;var b_has_return;b_has_return=false;locallink=true;if(ship_to_country_func.length>0){if(ship_to_country_func.indexOf("return ")!=-1||ship_to_country_func.indexOf("return(")!=-1){b_has_return=true}eval(ship_to_country_func.replace("return ","returnval = ").replace("return(","returnval = (").replace("[selectedIndex]","[this.selectedIndex]"))}else{if(showdebug==true){alert("Debug: ship_to_country did not have a previous onchange function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}}}if(window.document.forms[i].ShipOptions){if(showdebug==true){alert("Debug: The ShipOptions Function is...\n\n"+window.document.forms[i].ShipOptions.onchange)}ShipOptions_func=extractFunction(window.document.forms[i].ShipOptions.onchange,0);window.document.forms[i].ShipOptions.onchange=function onchange(event){var returnval;var b_has_return;b_has_return=false;locallink=true;if(ShipOptions_func.length>0){if(ShipOptions_func.indexOf("return ")!=-1||ShipOptions_func.indexOf("return(")!=-1){b_has_return=true}eval(ShipOptions_func.replace("return ","returnval = ").replace("return(","returnval = (").replace("[selectedIndex]","[this.selectedIndex]"))}else{if(showdebug==true){alert("Debug: ShipOptions did not have a previous onchange function.")}}if(b_has_return==true){if(showdebug==true){alert("Debug: Function has return value: "+returnval)}return returnval}}}}}}function findMeLink(me){var done;done=false;for(var i=0;i<window.document.links.length&&done==false;i++){if(me==window.document.links[i]){done=true;me_index=i}}if(showdebug==true){if(done==true){alert("Debug: Index of link found: "+me_index)}else{alert("Debug: Index of link not found.")}}return me_index}function findMeForm(me){var done;done=false;for(var i=0;i<window.document.forms.length&&done==false;i++){if(me==window.document.forms[i]){done=true;me_index=i}}if(showdebug==true){if(done==true){alert("Debug: Index of link found: "+me_index)}else{alert("Debug: Index of link not found.")}}return me_index}function extractFunction(p_codestr,p_index){var codestr;codestr="";if(p_codestr){codestr=""+p_codestr;codestr=codestr.substring(codestr.indexOf("{")+1,codestr.length);codestr=reverseText(codestr);codestr=codestr.substring(codestr.indexOf("}")+1,codestr.length);codestr=reverseText(codestr);if(showdebug==true){alert("Debug: Function extracted ("+p_index+"): "+codestr)}codestr=codestr.replace("\n","");codestr=codestr.replace("\r","")}return codestr}function reverseText(p_str){var text;var str;var i;str=p_str;text="";i=0;while(i<str.length){text=str.substring(i,i+1)+text;i++}return text}function getCookie(NameOfCookie){if(document.cookie.length>0){begin=document.cookie.indexOf(NameOfCookie+"=");if(begin!=-1){begin+=NameOfCookie.length+1;end=document.cookie.indexOf(";",begin);if(end==-1){end=document.cookie.length}return unescape(document.cookie.substring(begin,end))}}return null}function setCookie(NameOfCookie,value,expiredays){var ExpireDate=new Date();ExpireDate.setTime(ExpireDate.getTime()+(expiredays*24*3600*1000));document.cookie=NameOfCookie+"="+escape(value)+((expiredays==null)?"":"; expires="+ExpireDate.toGMTString())}function delCookie(NameOfCookie){if(getCookie(NameOfCookie)){document.cookie=NameOfCookie+"=; expires=Thu, 01-Jan-70 00:00:01 GMT"}}function checkCookie(){var theGender=getCookie("gender");if(theGender==null){setCookie("gender","women",365)}};