
function mqToggleSTC(evt,popupContainerId)
{fEventData=getEventData(evt);var eventId=(fEventData.id.indexOf("-close")>0)?fEventData.id.substring(0,fEventData.id.indexOf("-close")):fEventData.id;var eventType=fEventData.type;var stcObj=getElementById("stcpopup");if(!stcObj){stcObj=createSTCPopup(fEventData.id);stcObj.style.display="block";}
else if(!getElementById("stcac")){getElementById("stcpopup").parentNode.removeChild(getElementById("stcpopup"));stcObj=createSTCPopup(fEventData.id);stcObj.style.display="block";}
else{getElementById("stcac").value="";getElementById("stcpfx").value="";getElementById("stcsfx").value="";getElementById("stcfrom").value="";getElementById("mqstc-errmsg").innerHTML="";getElementById("mqstc-errmsg").style.display="";}
popuplateDefaultPhoneNum();var reclick=stcObj.popupOpener==eventId&&stcObj.style.display=="block";if(!reclick){stcObj.popupOpener=eventId;stcObj.style.display="block";if(eventId=="mqstc-0"||eventId.indexOf("mqstc-AC")>=0){var container;if(typeof(popupContainerId)!='undefined'&&popupContainerId){container=getElementById(popupContainerId);}else{container=getElementById("popupcontainer");}
container.style.width=container.style.height="";var topOffset=container.clientHeight;var leftOffset=40;stcObj.style.top=topOffset+"px";stcObj.style.left=leftOffset+"px";stcObj.style.zIndex="";container.appendChild(stcObj);}
else{var ele=getElementById(eventId);var left=0;var top=0;while(ele)
{left+=ele.offsetLeft;top+=ele.offsetTop;ele=ele.offsetParent;}
stcObj.style.top=(top+13)+"px";stcObj.style.left=(left-91)+"px";stcObj.style.zIndex="9999";if((fEventData.id.indexOf("dirs")>0)&&(window.attachEvent))
{if(getElementById("locselect"))getElementById("locselect").style.visibility="hidden";}
document.body.appendChild(stcObj);}
addResultToSTCPopup(eventId);}
else{stcObj.style.display="none";if((fEventData.id.indexOf("dirs")>0)&&(window.attachEvent))
{getElementById("locselect").style.visibility="";}}}
function createSTCPopup(evtid)
{var oRoot=getElementById("stcpopup");if(!oRoot)
{oRoot=createSTCShell();if(evtid=="mqstc-0")
document.body.appendChild(oRoot);else
getElementById("mqcontent").appendChild(oRoot);}
var str="";if(getElementById("dirman-options")&&getElementById("dirman-options").className.indexOf("avoids")>=0)
{str+="<div class='stc-alert-sorry'>";str+="    <img src='http://img.mqcdn.com/mqsite2/icon-frowny-yellow-emoticon.gif' alt='Sorry' />Sorry! Send to Cell does not currently support advanced routing options. The route sent to your phone will use MapQuest's default route settings.";str+="</div>";}
str+="<h3 id='mqstc-errmsg' class='alertwarning disn'></h3>";str+="<form id='mqstc-form' action='' onsubmit=\"mqSubmitSTC();return false;\"><div id='tofrom'><div style='padding-bottom:5px;'><input type='hidden' id='stceid' value='"+evtid+"' />";str+="<div style='float:left;border:0px solid green;width:50px;'><span class='label'>To:</span></div>";str+="<div class='alttext'>(<input type='text' id='stcac' name='stcac' tabindex='0' maxlength='3' style='width:33px;' value='' />) <input type='text' id='stcpfx' name='stcpfx' tabindex='0' maxlength='3' style='width:34px;' value='' /> - <input type='text' id='stcsfx' name='stcsfx' tabindex='0' maxlength='4' style='width:58px;' value='' />";str+="<div class='alttext' style='margin-left:52px;margin-top:-2px;'>e.g., (717) 555-1212</div>";str+="</div></div>";str+="<div style='padding-bottom:5px;'>";str+="<div style='float:left;width:50px;height:14px;'><span class='label'>From:</span></div>";str+="<div class='greytext'><input type='text' id='stcfrom' name='stcfrom' style='width:160px;' value='' /><div class='alttext' style='margin-left:52px;margin-top:-2px;'>Your email address (required)</div>";str+="</div></div></div>";str+="<div id='mqstc-resultcontent'></div>";str+="<div class='textc'><input type='submit' id='mqstc-button' value='Send' class='submit' style='background:#ecebe6; width:60px;' /></div></form>";str+="<div class='stcbottom'><div class='alttext'>NOTE: ";if(evtid.indexOf("dirs")>0)
{str+="The directions will be sent to your <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a> application on your cell phone. By signing up for <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a>, you will have on-the-go access to color maps, step-by-step driving directions, and personalized address information.";}
else
{str+="Your wireless carrier may charge a small fee for receiving text messages, usually a few cents.  Information collected here will be used only to send a one-time message on your behalf. <a style='position:relative;' href='/features/main.adp?page=help_sendtocell'>More help</a>.";}
str+="<a href='http://pr.atwola.com/promoclk/100223980x1097751692x1076229873/aol?redir=http://www.windowsmobile.com' target='_blank'><img src='http://pr.atwola.com/promoimp/100223980xx1076229873/aol' height='1' width='1' /><br /><img src='http://img.mqcdn.com/mqmobile/logo-windowsmobile.png' width='220' height='50' alt='Windows Mobile - windowsmobile.com' style='margin-top:4px;' /></a>";str+="</div></div>";getElementById("stcinfocontainer").innerHTML=str;return oRoot;}
function createSTCShell()
{var oRoot=document.createElement("DIV");oRoot.id="stcpopup";oRoot.className="mqpopup-small";var str="<div class='stctitle'><span class='label'>Send To Cell</span><img id='stcclose' src='"+artUrl+"stc-close' onclick='closeSTCPopup();' /></div>"
str+="<div id='stctop' class='mqtop'></div>"
str+="<div id='stccenter' class='mqcenter'><div id='stcinfocontainer'></div></div>";str+="<div id='stcbottom' class='mqbottom'></div>";oRoot.innerHTML=str;var browser=getBrowserInfo();if(browser.name=='msie'&&browser.version<7)
{oRoot.childNodes[2].style.height="10px";if(browser.version>=5.5)
{oRoot.childNodes[1].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+artUrl+"frmp-bg-smallboxtop.png', sizingMethod='scale')";oRoot.childNodes[2].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+artUrl+"frmp-bg-smallboxcntr.png', sizingMethod='scale')";oRoot.childNodes[3].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+artUrl+"frmp-bg-smallboxbtm.png', sizingMethod='scale')";}
else
{oRoot.childNodes[1].style.background="transparent url("+artUrl+"frmp-bg-smallboxtop) no-repeat left";oRoot.childNodes[2].style.background="transparent url("+artUrl+"frmp-bg-smallboxcntr) 0 100% repeat-y";oRoot.childNodes[3].style.background="transparent url("+artUrl+"frmp-bg-smallboxbtm) no-repeat left";oRoot.childNodes[3].style.height="13px";}}
else
{oRoot.childNodes[1].style.background="transparent url("+artUrl+"frmp-bg-smallboxtop.png) no-repeat left";oRoot.childNodes[2].style.background="transparent url("+artUrl+"frmp-bg-smallboxcntr.png) 0 100% repeat-y";oRoot.childNodes[3].style.background="transparent url("+artUrl+"frmp-bg-smallboxbtm.png) no-repeat left";}
return oRoot;}
function popuplateDefaultPhoneNum()
{var stcPhone=stcAc=stcPfx=stcSfx="";if(readCookie("settings"))
{var stcPhoneSetting=readCookie("settings").split("|")[6];if(stcPhoneSetting.length>0)
{for(var i=0,l=stcPhoneSetting.length;i<l;i++)
{if((stcPhoneSetting.charAt(i)>="0")&&(stcPhoneSetting.charAt(i)<="9"))
{stcPhone+=stcPhoneSetting.charAt(i);}}
getElementById("stcac").value=stcPhone.substring(0,3);getElementById("stcpfx").value=stcPhone.substring(3,6);getElementById("stcsfx").value=stcPhone.substring(6,10);}}}
function mqSubmitSTC()
{var mqStcURL="/apart/mqmobile.adp?";var eidVal=getElementById("stceid").value;mqStcURL+=getElementById(eidVal).rel;var stcPhone=new Array("stcac","stcpfx","stcsfx");for(var nv=0;nv<stcPhone.length;nv++)
{var stcPhoneElem=getElementById(stcPhone[nv]);if(!(stcPhoneElem&&stcPhoneElem.value))
{showSTCStatusMsg("0","phone");return;}
var stcPhoneValue=stcPhoneElem.value;for(var i=0,n=stcPhoneValue.length;i<n;i++)
{if(((nv<2)&&(n!=3))||((nv==2)&&(n!=4)))
{showSTCStatusMsg("0","phone");return;}
var c=stcPhoneValue.charAt(i);if((c<"0")||(c>"9"))
{showSTCStatusMsg("0","phone");return;}}
mqStcURL+="&"+stcPhone[nv]+"="+stcPhoneValue;}
var stcFromValue=getElementById("stcfrom").value;if((stcFromValue.indexOf(".")<1)&&(stcFromValue.indexOf("@")<0))
{showSTCStatusMsg("0","email");return;}
mqStcURL+="&stcfrom="+stcFromValue+"&rand="+(Math.round((Math.random()*10000)));var mqXMLHttp=mqXMLHttpRequest();if(mqXMLHttp==null)
{loadJS(mqStcURL+"&stcjs=1","mqstc-js","body");}
else
{mqXMLHttp.open("GET",mqStcURL,true);mqXMLHttp.onreadystatechange=function()
{if(mqXMLHttp.readyState==4)
{if(mqXMLHttp.status==200)
{var stcResponse=mqXMLHttp.responseText.split("|");showSTCStatusMsg(stcResponse[1],stcResponse[2]);return;}
else
{loadJS(mqStcURL+"&stcjs=1","mqstc-js","body");}}}
mqXMLHttp.send(null);}}
function showSTCStatusMsg(retval,retdata)
{var strStatusMsg;var htmlCaption="<span class='statusmsg'><b>Congratulations!</b></span><br />";var htmlClose="<div class='textc' style='padding:10px 0px;'>";htmlClose+="<input type='submit' id='stc-close' value='Close' class='submit' onclick='closeSTCPopup();return false;' style='width:60px;' tabindex='0'/></div>";switch(retval)
{case"0":strStatusMsg="<img src='"+artUrl+"icon-alert-warning-20' height='20' width='20' alt='warning' />";if(retdata=="phone")
{strStatusMsg+=" Invalid Phone Number.";}
else if(retdata=="email")
{strStatusMsg+=" Invalid Email Address.";}
else if(retdata.indexOf("http:")<0)
{strStatusMsg+=retdata;}
var errorObj=getElementById("mqstc-errmsg");errorObj.style.display="block";errorObj.innerHTML=strStatusMsg;break;case"1":case"5":case"7":strStatusMsg="<div class='statusmsg'>A text message has been sent to your cell phone.</div>";break;case"2":case"6":case"8":strStatusMsg="<p class='statusmsg'>A map has been sent to your <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a> application on your cell phone.</p><p class='statusmsg'>Please launch <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a> and click on Web Downloads to view your results.</p>";break;case"3":window.location=retdata;return;break;case"4":strStatusMsg="<p class='statusmsg'>The directions have been sent to your <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a> application on your cell phone.  By signing up for <a style='position:relative;' href='http://www.mapquest.com/features/main.adp?page=help_mqm'>MapQuest Mobile</a>, you will have on-the-go access to interactive color maps, step-by-step driving directions, and personalized address information.</p>";break;}
strStatusMsg=htmlCaption+strStatusMsg+htmlClose;if(retval!='0'){getElementById("stcinfocontainer").innerHTML=strStatusMsg;}
if(getElementById("stc-close")){getElementById("stc-close").focus();}}
function addResultToSTCPopup(evtid)
{var stcPage=evtid.split("-")[1];var mapSummary=getElementById("mapsummary");if(document.body.id=='dirs')
{var temp=getElementById(evtid);while(temp.id&&temp.id.indexOf("poi-")<0)
{temp=temp.parentNode;}
if(temp&&temp.id.indexOf("poi-")>=0)
{var stcAddress="<div id='stcresult'>";stcAddress+=(MQ.poi.curDataObj.name!='')?("<b>"+MQ.poi.curDataObj.name+"</b>"):"";var addressStr=(MQ.poi.curDataObj.address=='')?'':((MQ.poi.curDataObj.name=='')?("<b>"+MQ.poi.curDataObj.address+"</b>, "):(MQ.poi.curDataObj.address+", "));var cityStr=(MQ.poi.curDataObj.city=='')?'':(MQ.poi.curDataObj.city+", ");var addCityStateZip=addressStr+cityStr+MQ.poi.curDataObj.stateProvince+" "+MQ.poi.curDataObj.postalCode+" "+MQ.poi.curDataObj.country;stcAddress+=(MQ.poi.curDataObj.name==''&&MQ.poi.curDataObj.address=='')?("<div><b>"+addCityStateZip+"</b></div>"):("<div>"+addCityStateZip+"</div>");stcAddress+=(MQ.poi.curDataObj.phone!='')?("<div>"+MQ.poi.curDataObj.phone+"</div>"):"";stcAddress+="</div>";getElementById("mqstc-resultcontent").innerHTML=stcAddress;}
else
{var startObj=getElementById("mqaddress-start");var endObj=getElementById("mqaddress-end");var output="<div class='clear'>";output+="<img border='0' src='"+artUrl+"icon-dirs-start' width='32' height='17' alt='Start' />";output+="<p>";output+=startObj.getElementsByTagName("span")[0].innerHTML;output+="</p></div>";output+="<div class='clear'>";output+="<img border='0' src='"+artUrl+"icon-dirs-end' width='32' height='17' alt='End' />";output+="<p>";output+=endObj.getElementsByTagName("span")[0].innerHTML;output+="</p></div>";getElementById("mqstc-resultcontent").innerHTML=output;}}
else if(mapSummary)
{var temp=getElementById(evtid);while(temp.id&&temp.id.indexOf("poi-")<0)
{temp=temp.parentNode;}
if(temp.id.indexOf("-poi-AC")>0)
{var dataObj=MQ.poi.data.goldRush.aerial["location"+temp.id.charAt(temp.id.length-1)];var stcAddress="<div id='stcresult'>";stcAddress+=(typeof(dataObj.name)!="undefined"&&dataObj.name!='')?("<b>"+dataObj.name+"</b>"):"";var addressStr=(typeof(dataObj.address)=="undefined"||dataObj.address=='')?'':((dataObj.name=='')?("<b>"+dataObj.address+"</b>, "):(dataObj.address+", "));var cityStr=(typeof(dataObj.city)=="undefined"||dataObj.city=='')?'':(dataObj.city+", ");var addCityStateZip=addressStr+cityStr+dataObj.stateProvince+" "+dataObj.postalCode+" "+dataObj.country;stcAddress+=(dataObj.name==''||dataObj.address=='')?("<div><b>"+addCityStateZip+"</b></div>"):("<div>"+addCityStateZip+"</div>");stcAddress+=(typeof(dataObj.phone)!="undefined"&&dataObj.phone!='')?("<div>"+dataObj.phone+"</div>"):"";stcAddress+="</div>";getElementById("mqstc-resultcontent").innerHTML=stcAddress;}
else
{var stcAddress=mapSummary.getElementsByTagName("span")[0].innerHTML;getElementById("mqstc-resultcontent").innerHTML=stcAddress;}}
else
{var resultCount=parseFloat(stcPage);var oLI=getElementById("mqresult-"+resultCount);if(oLI)
{oLI=oLI.cloneNode(true);oLI.style.background="white";oLI.id="stcresult";oHLinks=oLI.getElementsByTagName("UL");var len=oHLinks.length;for(var i=(len-1);i>=0;i--)
{oLI.removeChild(oHLinks.item(i));}
if(oLI.lastChild.className=='cat')oLI.removeChild(oLI.lastChild);var oUL=document.createElement("UL");oUL.className="results";oUL.style.listStyle="none";oUL.style.paddingLeft="0";oUL.style.marginLeft="4px";oUL.appendChild(oLI);var oDiv=document.createElement("DIV");oDiv.appendChild(oUL);getElementById("mqstc-resultcontent").innerHTML=oDiv.innerHTML;}}}
function closeSTCPopup()
{if(document.getElementById("stcpopup")){if((fEventData.id.indexOf("dirs")>0)&&(window.attachEvent))
{if(getElementById("locselect"))getElementById("locselect").style.visibility="";}
document.getElementById("stcpopup").style.display="none";}}
function mqInitSTC()
{var stcPrefix="mqstc-";var stcObj;if(getElementById(stcPrefix+"maps"))
{stcObj=getElementById(stcPrefix+"maps");stcObj.parentNode.style.display="inline";addEvent(stcObj,"click",mqToggleSTC);}
else if(getElementById(stcPrefix+"dirs"))
{stcObj=getElementById(stcPrefix+"dirs");stcObj.parentNode.style.display="inline";addEvent(stcObj,"click",mqToggleSTC);}
else
{var start=1;if(getElementById("mqsearchresult"))
start=getElementById("mqsearchresult").start;for(var stcCount=start;stcCount<(start+10);stcCount++)
{stcObj=getElementById(stcPrefix+stcCount);if(stcObj)
{stcObj.parentNode.style.display="inline";addEvent(stcObj,"click",mqToggleSTC);}}}
preLoadSTCImages();}
mqInitSTC();function preLoadSTCImages(){img1=new Image();img1.src=artUrl+"stc-close";img2=new Image();img2.src=artUrl+"frmp-bg-smallboxtop.png";img3=new Image();img3.src=artUrl+"frmp-bg-smallboxbtm.png";img4=new Image();img4.src=artUrl+"frmp-bg-smallboxcntr.png";}