// these variables and the 4 scripts that follow are used to hide/show the DIV layer
var enableDropDowns = true; // globally enable/disable drop down menus
var mainNavHideMenu  = true; // our layer object is hidden by default, also via CSS
if (enableDropDowns) { var mainNavIs = new mainNavIs(); }
var mainNavHeight = 15; // vertical offset places menu under navigation element
	
/////////// functions ////////////////
function mainNavIs () {   // checks for IE, which if true needs some space adjusting in the DIV
    var agt=navigator.userAgent.toLowerCase();
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	this.gecko = (agt.indexOf('ecko') != -1);
	this.firefox = (agt.indexOf('irefox') != -1);
	this.mac    = (agt.indexOf("mac")!=-1);
	this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)));
	this.konq = (agt.indexOf('onqueror') != -1);
	this.linux = (agt.indexOf("inux")!=-1);
}

function mainNavSetLayer(clickTargetId,viz) {
	// obj: ID of object against which we do our relative positioning
	// lyr: our target DIV by ID
	// viz: what to do, hide or show
	// height: starting position for the DIV, usually the height of the target
	if (enableDropDowns) {
		var clickTarget = document.getElementById(clickTargetId);
		var menu = new mainNavGetObj(clickTargetId+'Menu');
		if (clickTarget) {
			// we position the hidden DIV just under the clicked object
			var targetX = mainNavFindPosX(clickTarget);
			var targetY = mainNavFindPosY(clickTarget);
			//alert('x='+targetX+' y='+targetY);
			
			// IE has a different idea of the 0,0 origin location when the object is in a table
			//    so this might break depending on if the target is in a table cell or not.
			if (mainNavIs.ie)  { targetY += mainNavHeight - 1; }
			else if (mainNavIs.gecko && mainNavIs.mac && !mainNavIs.firefox)  { targetY += mainNavHeight - 2; targetX += 0; }
			else if (mainNavIs.firefox)  { targetY += mainNavHeight - 1; targetX += 0; } 
			else if (mainNavIs.konq && mainNavIs.linux)  { targetY += mainNavHeight - 1; targetX += 0; }
			else { targetY += mainNavHeight; }
			// now position the DIV according to our predictions
			// change targetX if you want to indent or overhang the DIV relative to target
			menu.style.top = targetY + 'px';
			menu.style.left = targetX + 'px';
			//alert('x='+targetX+' y='+targetY);
		}
		// now do something, according to 'viz'
		// 'toggle' does what it says :)
		if (viz=='toggle') mainNavHideMenu = !mainNavHideMenu;
		if (viz=='hidden') mainNavHideMenu = true;
		if (viz=='visible') mainNavHideMenu = false;
		menu.style.visibility = (mainNavHideMenu) ? 'hidden' : 'visible';
	}
}

function mainNavFindPosX(obj) {
	// tricky bit to account for nested objects
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    } else if (obj.x) { curleft += obj.x; }
    return curleft;
}

function mainNavFindPosY(obj) {
	// tricky bit to account for nested objects
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    } else if (obj.y) { curtop += obj.y; }
    return curtop;
}

function mainNavGetObj(name) {
	//alert(name);
 // get an object reference in accordance with the rules of engagement
 if (document.getElementById) {
       this.obj = document.getElementById(name);
       this.style = document.getElementById(name).style;
 } else if (document.all) {
       this.obj = document.all[name];
       this.style = document.all[name].style;
 } else if (document.layers) {
       if (document.layers[name]) {
        this.obj = document.layers[name];
        this.style = document.layers[name];
       }
 }
}
/////////// drop-down menu defs ////////////////
var menuTmp = '';
menuTmp += '<DIV id="cjnav_connectMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_connect\',\'visible\') " onMouseOut="mainNavSetLayer(\'cjnav_connect\',\'hidden\')" ><div class="mainMenuLayer_item" style="">';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/contact.html">Contact Us</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
menuTmp += ' <a class="dn" href="http://www.carjunky.com/pit-stop/motorspeedway.html">Pit Stop</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/cgi-bin/exchange/index.shtml">Banner Exchange</a><br>';
	menuTmp += ' <a class="dn" href="http://carjunky.mail.everyone.net/email/scripts/loginuser.pl">Carjunky Email</a><br>';	
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/site/friend/friend.php" target="_blank">Email to Friend</a><br>';	
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/site/linktous.html">Link to Us</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/upload/CarPics/">Submit Pictures</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/cgi-bin/exec/admin.cgi?id=autopub&pw=autopub&login=1">Submit Article</a><br>';
menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_ecardMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_ecard\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_ecard\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/Antiques_and_Classics">Antiques &amp; Classics</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/Dallas-Auto-Shows">Dallas Car Shows</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/Exotic_Autos">Exotic Pics</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/Carjunky-Member-car-pictures">Member Pics</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/NJ-Auto-Expo-2004">NJ Auto Expo</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/NJ-Car-Shows">NJ Car Shows</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/AutoShowsandEvents">NY Auto Show</a><br>';
	menuTmp += ' <a class="dn" href="http://carpictures.carjunky.com/Detroit-Auto-Show-2003">Detroit Auto Show</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/classiccars/index.html">Classic Cars</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/upload/CarPics/">Submit Pictures</a><br>';
menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_shopMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_shop\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_shop\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += 'Discount Auto Parts:<br>';
	menuTmp += '<div style="padding-left: 7px;">';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/partstore/">Performance Parts</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/partstore/">Performance Brands</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/partstore/">Replacement Parts</a><br>';
	menuTmp += '</div>';	
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/site/automotive_books.html">Used Auto Books</a><br>';	
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/carinsurance/">Car Insurance Articles</a><br>';	
	menuTmp += '<a class="dn" href="http://www.netquote.com/auto/app?nqid=12183&status=111">Car Insurance Quotes</A><br>';	
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += '<div><a href="http://www.kqzyfj.com/8r97gv30v2IKPMMQMNISMMOQPK" target="_blank"><img src="http://www.tqlkg.com/9k122nswkqo9BGDDHDE9JDDFHGB" alt="" border="0"></a></div>';
menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_hlMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_hl\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_hl\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += '<a class="dn" href="http://classifieds.carjunky.com">Used Car Classifieds</a><br>';
menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_newsMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_news\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_news\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com">Car Articles</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/alternative_fuel_vehicles.shtml">Alt. Fuel Vehicles</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive.shtml">Automotive</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/car_buying_tips.shtml">Car Buying Tips</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/car_maintenance.shtml">Car Maintenance</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive_news_33.shtml">Car News</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/car_safety.shtml">Car Safety</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive_news_39.shtml">Driving Economically</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive_news_35.shtml">Garage Know How</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive_news_42.shtml">Road Trips</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/automotive_news_41.shtml">Traveling with Kids</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';	
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/carinsurance/Important_factors_to_consider_before_purchasing_car_insurance.shtml">Car Insurance</a><br>';	
    menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/cgi-bin/exec/search.cgi">Search Articles</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Automotive_News_Discussions_F39/">Discuss News</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/cgi-bin/exec/admin.cgi?id=autopub&pw=autopub&login=1">Submit Article</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/articlefeeds.shtml">Using our Articles</a><br>';
	menuTmp += ' <a class="dn" href="http://news.carjunky.com/articlefeeds.shtml">RSS Feeds</a><br>';
	menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_petMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_pet\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_pet\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += 'Car Troubles:<br>';
	menuTmp += '<div style="padding-left: 7px;">';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Electrical_and_Wiring_F6/">Electrical</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Engine_Troubles_F16/">Engine</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Heating_or_AC_Issues_F8/">Heating &amp; AC Issues</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Funny_Noises_F7/">Noises</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Car_Stereo_Repair_Advice_F28/">Car Radios</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Transmission_Troubles_F11/">Transmission</a><br>';
	menuTmp += '</div>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += 'Discussions:<br>';
	menuTmp += '<div style="padding-left: 7px;">';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Antique_Car_Talk_F40/">Antique Car Talk</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/General_Discussions_F18/">Automotive</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Car_Shows_and_Events_F21/">Car Shows</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Gasoline%2C_Motor_Oils%2C_Concept_Cars_and_Engines_F24/">Concept Cars</a><br>';	
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Auto_Insurance%2C_Financing%2C_Leases%2C_Warranties_F37/">Financing &amp; Leases</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Gasoline%2C_Motor_Oils%2C_Concept_Cars_and_Engines_F24/">Gas &amp; Motor oils</a><br>';	
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/General_Discussions_F5/">General</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Auto_Insurance%2C_Financing%2C_Leases%2C_Warranties_F37/">Insurance</a><br>';	
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Motorcycles_and_ATVs_C9/General_Discussions_F12/">Motorcycles &amp; ATVs</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Truck_Repair_C6/General_Discussions_F3/">Trucks</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Motor_Vehicle_Inspection_F30/">Vehicle Inspection</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Auto_Insurance%2C_Financing%2C_Leases%2C_Warranties_F37/">Warranties</a><br>';	
	menuTmp += '</div>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += 'Tips and Tricks:<br>';
	menuTmp += '<div style="padding-left: 7px;">';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_World_C11/Car_Care_Tips_F25/">Car Care</a><br>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/autoforums/Automotive_Repair_C1/Tricks_of_the_Trade_F31/">Tips</a><br>';
	menuTmp += '</div>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://autoforums.carjunky.com/cgi-bin/gforum.cgi?do=search;t=search_engine">Search Forums</a><br>';
menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
menuTmp += '<DIV id="cjnav_cjdMenu" class="mainMenuLayer" style="visibility: hidden;" onMouseOver="mainNavSetLayer(\'cjnav_cjd\',\'visible\')" onMouseOut="mainNavSetLayer(\'cjnav_cjd\',\'hidden\')" ><div class="mainMenuLayer_item">';
	menuTmp += 'Automotive Link Categories:<br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Auto_Classifieds/index.shtml">Auto Classifieds</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Auto_Auctions/index.shtml">Auto Auctions</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Information/Auto_Insurance/index.shtml">Auto Insurance</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Antique_N_Classic/index.shtml">Antique &amp; Classic</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Aviation/index.shtml">Aviation</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Boating/index.shtml">Boating</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Accessories/index.shtml">Car Accessory</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Information/index.shtml">Car Information</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Parts_and_Accessories/index.shtml">Car Parts &amp; Accessories</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Shows_and_Events/index.shtml">Car Shows and Events</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Collectibles___Memorabilia/index.shtml">Collectibles &amp; Memorabilia</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Concept_Cars/index.shtml">Concept Cars</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Exotic_Cars/index.shtml">Exotic Cars</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Hot_Rods/index.shtml">Hot Rods</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Import_Cars/index.shtml">Import Cars</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/LowRiders/index.shtml">LowRiders</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Manufacturers/index.shtml">Manufacturers</a><br>';
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Motorcycles/index.shtml">Motorcycles</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Motor_Sports/index.shtml">Motor Sports</a><br>';	
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Auto_Publications/index.shtml">Publications</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Recreation_Vehicles/index.shtml">Recreation Vehicles</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Car_Repair_Information/index.shtml">Repair Information</a><br>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/Trucks/index.shtml">Trucks</a><br>';	
	menuTmp += '<div class="navMenuDivider"></div>';
	menuTmp += ' <a class="dn" href="http://www.carjunky.com/cgi-bin/cars/search.cgi">Search Links</a><br>';		
	menuTmp += '</div><div class="navMenuBottom" align="right"><img src="http://www.carjunky.com/images/navDropMenu/spacer.gif" width="7" height="7" border="0" alt="" style="margin: 0 -7px 0 0;"></div></div>';
// now write the entire blob to the container
tmpObj = document.getElementById('menuDropdownContainer');
tmpObj.innerHTML = menuTmp;