// WineCountry.com
// Main Menu JavaScript
/***********************************************
* Ver $ 1.0 $
* - To change the actual menu look and feel, refer to "menu_vertDrop_std.css"
***********************************************/


/***********************************************
* 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
***********************************************/

//menu 1 Travel
var menu1=new Array()
menu1[0]='<a href="/regions/">Cities</a>'
menu1[1]='<a href="/lodging/">Lodging</a>'
menu1[2]='<a href="/wineries/">Wineries</a>'
menu1[3]='<a href="/thingstodo/spas/">Spas</a>'
menu1[4]='<a href="/thingstodo/dining/">Restaurants</a>'
menu1[5]='<a href="/about/archive/">Articles</a>'
menu1[6]='<a href="/events.html">Event Calendar</a>'
menu1[7]='<a href="/eventplanning/">Meeting &amp; Event Planning</a>'
menu1[8]='<a href="/visitorsinfo/">Visitor Info</a>'
menu1[9]='<a href="/thingstodo/">Things To Do</a>'
menu1[10]='<a href="/freestuff/freestuff.html">Discounts &amp; Promotions</a>'
menu1[11]='<a href="http://www.winecountry.com/photogallery/winecountry/">Photo Gallery</a>'
menu1[12]='<a href="http://www.winecountry.com/forms/news.html">Newsletters</a>'
menu1[13]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 2 Food & Wine
var menu2=new Array()
menu2[0]='<a href="/thingstodo/dining/">Restaurants</a>'
//menu2[1]='<a href="http://www.winecountry.com/reviews-and-news">Restaurant Reviews and News</a>'
//menu2[2]='<a href="http://www.winecountry.com/recipes/">Recipes</a>'
menu2[3]='<a href="/wineries/">Wineries</a>'
menu2[4]='<a href="http://discover.winecountry.com/food/">Food Blog</a>'
menu2[5]='<a href="http://discover.winecountry.com/wine/">Wine Blog</a>'
menu2[6]='<a href="http://www.winecountry.com/forms/news.html">Newsletters</a>'
menu2[7]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 3 Things To Do - needs to be dynamic
var menu3=new Array()
menu3[0]='<a href="/thingstodo/">All Activities</a>'
menu3[1]='<a href="/thingstodo/wineries/">Wine Tasting / Wineries</a>'
menu3[2]='<a href="/thingstodo/dining/">Dining</a>'
menu3[3]='<a href="/thingstodo/tours/featured.html">Tours / Sightseeing</a>'
menu3[4]='<a href="/thingstodo/spas/index.html">Spas / Day Spas</a>'
menu3[5]='<a href="/thingstodo/gourmet_sampling/featured.html">Gourmet Sampling</a>'
menu3[6]='<a href="/thingstodo/golf/featured.html">Golf</a>'
menu3[7]='<a href="/thingstodo/recreational_sports/featured.html">Recreational Sports</a>'
menu3[8]='<a href="/thingstodo/antiques/featured.html">Antiques</a>'
menu3[9]='<a href="/thingstodo/nightlife/featured.html">Nightlife</a>'
menu3[11]='<a href="/thingstodo/historical_attractions/featured.html">Attractions</a>'
menu3[12]='<a href="/thingstodo/ballooning_skydiving/featured.html">Ballooning &amp; Skydiving</a>'
menu3[13]='<a href="/thingstodo/ag-eco_tourism/listings.html">Ag-Eco Tourism</a>'
menu3[15]='<a href="/thingstodo/farmers_markets/listings.html">Farmer\'s Markets</a>'
menu3[16]='<a href="/thingstodo/parks_beaches/listings.html">Parks and Beaches</a>'
menu3[17]='<a href="/thingstodo/arts/featured.html">The Arts</a>'
menu3[18]='<a href="/thingstodo/shopping/index.html">Shopping</a>'
menu3[19]='<a href="/events.html">Events Calendar</a>'
menu3[20]='<a href="/whatsnew/whatsnew.html">What\'s New</a>'
menu3[21]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 4 Events
var menu4=new Array()
menu4[1]='<a href="/events.html">Event Calendar</a>'
menu4[2]='<a href="/eventplanning/">Meeting &amp; Event Planning</a>'
menu4[3]='<a href="/visitorsinfo/">Visitor Info</a>'
menu4[4]='<a href="http://www.winecountry.com/events/submitEvents/">Enter Your Events</a>'
menu4[5]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 5 Wine Regions
var menu5=new Array()
menu5[0]='<a href="http://goldcountry.winecountry.com/">Gold Country</a>'
menu5[1]='<a href="http://livermore.winecountry.com/">Livermore</a>'
menu5[2]='<a href="http://lodi.winecountry.com/">Lodi</a>'
menu5[3]='<a href="http://monterey.winecountry.com/">Monterey</a>'
menu5[4]='<a href="http://mendocino.winecountry.com/">Mendocino</a>'
menu5[5]='<a href="http://napavalley.winecountry.com/">Napa Valley</a>'
menu5[6]='<a href="http://sanluisobispo.winecountry.com/">SLO / Paso Robles</a>'
menu5[7]='<a href="http://santabarbara.winecountry.com/">Santa Barbara</a>'
menu5[8]='<a href="http://santacruz.winecountry.com/">Santa Cruz</a>'
menu5[9]='<a href="http://sonoma.winecountry.com/">Sonoma</a>'
menu5[10]='<a href="http://temecula.winecountry.com/">Temecula</a>'
menu5[11]='<a href="http://oregon.winecountry.com/">Oregon</a>'
menu5[12]='<a href="http://virginia.winecountry.com/">Virginia</a>'
menu5[13]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 6 Connect
var menu6=new Array()
menu6[0]='<a href="http://www.winecountry.com/cgi-bin/ubb/Ultimate.cgi">Message Boards</a>'
menu6[1]='<a href="http://www.winecountry.com/blogs/">Blogs</a>'
menu6[2]='<a href="/whatsnew/whatsnew.html">What\'s New</a>'
menu6[3]='<a href="http://download.winecountry.com/feeds/">RSS Feeds</a>'
menu6[4]='<a href="http://www.winecountry.com/forms/news.html/">Newsletter</a>'
menu6[5]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 7 Shopping
var menu7=new Array()
menu7[0]='<a href="/thingstodo/shopping/">Shop This Region</a>'
menu7[1]='<a href="http://www.valleyandvine.com/">Shop Valley and Vine</a>'
menu7[2]='<a href="http://www.mywinesdirect.com/" target="_blank">Wine and Gift Baskets</a>'
menu7[3]='<a href="https://commerce.winecountry.com/display/ee/">Exclusive Experiences</a>'
menu7[4]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 8 Weddings
var menu8=new Array()
menu8[0]='<a href="/eventplanning/weddings.html">Weddings</a>'
menu8[1]='<a href="/eventplanning/weddings/ceremonies_chapels.html">Locations</a>'
menu8[2]='<a href="/eventplanning/weddings/consultants_otherservices.html">Services</a>'
menu8[3]='<a href="/eventplanning/weddings/cateringlistings.html">Caterers</a>'
menu8[4]='<a href="/eventplanning/weddings/entertainmentlistings.html">Entertainment</a>'
menu8[5]='<a href="/eventplanning/weddings/transportation.html">Transportation</a>'
menu8[6]='<a href="/cgi-bin/lead_generator.cgi?class=wedding">Request Wedding Info</a>'
menu8[7]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//menu 9 Real Estate
var menu9=new Array()
menu9[0]='<a href="/realestate/">Real Estate</a>'
menu9[1]='<a href="/realestate/broker.html">Broker/Brokerage</a>'
//menu9[2]='<a href="/realestate/agent.html">Individual Agents</a>'
menu9[3]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'

//Contents for menu 10, and so on
var menu10=new Array()
menu10[0]='<a href="http://www.winecountry.com/forms/news.html">Sign Up Today!</a>'
menu10[1]='<a href="http://www.winecountry.com/newsletters/current/newsletter.html" target="_blank">Current Newsletter</a>'
menu10[2]='<a href="http://www.winecountry.com/newsletters/index.html" target="_blank">Past Newsletters</a>'
menu10[3]='<a href="http://www.winecountry.com/travel-planner/index.html?action=place;place=Santa%20Cruz;state=CA">Travel Planner</a>'


var menuwidth='165px' //default menu width
var menubgcolor='#034d66'  //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-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("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

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){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu
