

/******* this has nothing to do with menu  -- just combining javascript into 1 file ***********/
function getQuerystringDeprecated(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}


function getQuerystring(key, default_)
{
    if (default_==null)
    {
        default_="";
    }
    var search = unescape(location.search);
    if (search == "")
    {
        return default_;
    }
    search = search.substr(1);
    var params = search.split("&");
    for (var i = 0; i < params.length; i++)
    {
        var pairs = params[i].split("=");
        if(pairs[0] == key)
        {
            return pairs[1].replace('+', ' ');
        }
    }
    return default_;
}




/*  Browser Detection */
var b_supported = true
var ua = navigator.userAgent.toLowerCase();
idx1 = ua.indexOf('msie');
idx2 = ua.indexOf('5.2');
if(idx1>-1 && idx2>-1){
  b_supported = false;
}


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for Basics Menu
var basics_menu=new Array();
basics_menu[0]='<a href="http://www.spe1031.com/basics">1031 Basics</a>';
basics_menu[1]='<a href="http://www.spe1031.com/basics/why-exchange">Why Exchange</a>';
basics_menu[2]='<a href="http://www.spe1031.com/basics/qualified-intermediary">Qualified Intermediary</a>';
basics_menu[3]='<a href="http://www.spe1031.com/basics/what-can-be-exchanged">What Can Be Exchanged</a>';
basics_menu[4]='<a href="http://www.spe1031.com/basics/financial-and-tax-reporting">Financial and Tax Reporting</a>';
basics_menu[5]='<a href="http://www.spe1031.com/basics/types-of-exchanges">Types of Exchanges</a>';

// About Us Menu
var about_menu = new Array();
about_menu[0]='<a href="http://www.spe1031.com/about-us">About Us</a>';
about_menu[1]='<a href="http://www.spe1031.com/about-us/guaranteed-services">Guaranteed Services</a>';

//Why SPE? Menu
var why_spe_menu=new Array()
why_spe_menu[0]='<a href="http://www.spe1031.com/why-spe">Why SPE<sup>X</sup>?</a>';
why_spe_menu[1]='<a href="http://www.spe1031.com/why-spe/testimonials">Testimonials</a>';

//Contents for Newsletters Menu
var newsletters_menu=new Array()
newsletters_menu[0]='<a href="http://www.spe1031.com/newsletters/1031-insights">1031 Insights</a>';
newsletters_menu[1]='<a href="http://www.spe1031.com/newsletters/1031-advisor">1031 Advisor</a>';
newsletters_menu[2]='<a href="http://www.spe1031.com/newsletters/business-asset-exchange-advisor">Business Asset Exchange</a>';
newsletters_menu[3]='<nobr><a href="http://www.spe1031.com/newsletters/intangible-asset-exchange-advisor">Intangible Asset Exchange</a></nobr>'
newsletters_menu[4]='<a href="http://www.spe1031.com/newsletters/collectible-exchange-advisor">Collectible Exchange</a>';
newsletters_menu[5]='<a href="http://www.spe1031.com/newsletters/reverse-exchange-advisor">Reverse Exchange</a>';

//Contents for Tools Menu
var tools_menu=new Array()
tools_menu[0]='<a href="http://www.allstates1031.com/1031-exchanges/useful-links.php">Useful Links</a>';
tools_menu[1]='<a href="http://www.allstates1031.com/capital-gains-calculator.php">Capital Gains Calculator</a>';
tools_menu[2]='<a href="http://www.allstates1031.com/1031-exchanges/glossary-of-terms.php">Glossary of Terms</a>';
tools_menu[3]='<a href="http://www.allstates1031.com/1031-exchanges/state-homepages.php">State Homepages</a>';
tools_menu[4]='<a href="http://www.allstates1031.com/1031-exchanges/state-tax-sites.php">State Tax Sites</a>';
tools_menu[5]='<a href="http://www.allstates1031.com/1031-exchanges/cpa-societies.php">CPA Societies for States</a>';
tools_menu[6]='<a href="http://www.spe1031.com/tools/45-180">45/180 Day Calculator</a>';
tools_menu[7]='<a href="http://spe1031.com/tools/1031-exchange-calculation">1031 Exchange Calculator</a>';


//Contents for Links Menu
var links_menu=new Array()
links_menu[0]='<a href="http://www.spe1031.com/newsroom">Newsroom</a>';
links_menu[1]='<a href="http://www.spe1031.com/newsroom/upcoming-seminars">Upcoming Events</a>';
links_menu[2]='<a href="http://www.spe1031.com/links">Helpful Resources</a>';
links_menu[3]='<a href="http://www.spe1031.com/links/link-to-us">Link to Us</a>';
links_menu[4]='<a href="http://www.spe1031.com/links/site-map">Site Map</a>';


//Contents for Contact Menu
var contact_menu=new Array()
contact_menu[0]='<a href="http://www.spe1031.com/contact">Contact Information</a>';
//contact_menu[1]='<a href="http://www.spe1031.com/contact/online-form">Online Question Form</a>';



		
//var menuwidth='190px' //default menu width
var menuwidth='260px' //default menu width
//var menubgcolor='#669A2F'  //menu bgcolor
var menubgcolor='#888'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?




/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background:#777" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
//document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background:url(/images/trans_grey.png)background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : 

window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : 

window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

// added by jmf
function clear_top_menu_links(){
   $("#top-menu-2010 a").removeClass('gray-back-link'); 
}

function dropdownmenu(obj, e, menucontents, menuwidth){
  if(b_supported==false){
    return;
  }
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

/// added by JMF
clear_top_menu_links();
/*if($("//div[@id='top-menu']/a")){
  $(obj).addClass('green-back-link');
} else {
  $(obj).addClass('gray-back-link');
}*/
$(obj).addClass('gray-back-link');

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
clear_top_menu_links(); // added by jmf
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
  if(b_supported==false){
    return;
  }
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


