//create breadcrumb objects
var arrAffiliate = new Object();
var arrVertical = new Object();

var promoURL = 'http://www.nationallampoon.com/';
var promoText = 'NationalLampoon.com';

//turn promotion link on/off on NL.com
var nlShowPromo = 'on';

//browser version padding variable
var searchPadding = '3px';

//get browser name and version
var browserName = navigator.appName;
var browserVersion = parseInt(navigator.appVersion);

//set promotion URL, Text, and follow?
var varPromoFollow = 'follow';

// generate random number -- last number = number of promo ads
var n = Math.floor(Math.random()*2);

switch(n)
{
case 0:
  promoURL = 'http://twitter.com/nationallampoon';
  promoText = 'Check out NatLamp on twitter';
  break;    
case 1:
  promoURL = 'http://facebook.com/nationallampoon';
  promoText = 'Check out NatLamp on bookface';
  break;
case 2:
  promoURL = 'http://youtube.com/nationallampoon';
  promoText = 'Check out NatLamp on YouTube';
  break;
}

//Site List	
arrVertical['humor'] = 'Humor';
arrAffiliate['humor'] = new Object();
arrAffiliate["humor"]["DrunkUniversity"] = 'http://www.drunkuniversity.com';
arrAffiliate["humor"]["NationalLampoon"] = 'http://www.nationallampoon.com';

function createBar()
{
	document.write('<form action="http://nationallampoon.com/search-results" id="cse-search-box">');
	document.write('<table id="nlHatTable" align="center" border="0" cellspacing="0" cellpadding="0" width="'+nlWidth+'" height="27" style="background-image: url(http://www.nationallampoon.com/nlhat/bg.gif); background-repeat: repeat-x">');
	document.write('	<tr>');
	document.write('		<td>');
	document.write('<style type="text/css">');
	document.write('	body {');
	document.write('		margin-top:0px;');
	document.write('		margin-left:'+nlMarginLeft+';');
	document.write('		margin-right:'+nlMarginRight+';');
	document.write('	}');
	document.write('	#natlamphat_mainbar {');
	document.write('		background-image: url(http://www.nationallampoon.com/nlhat/bg.gif);');
	document.write('		width: 100%;');
	document.write('		height: 27px;');
	document.write('		font-family: Arial;');
	document.write('		font-size: 13px;');
	document.write('		font-weight: bold;');
	document.write('	}');
	document.write('	#natlamphat_mainbar a {');
	document.write('		color: #'+nlTextColor+';');
	document.write('		text-decoration: none;');
	document.write('	}');
	document.write('	#natlamphat_mainbar a:hover {');
	document.write('		color: #'+nlTextColor+';');
	document.write('		text-decoration: none;');
	document.write('	}');
	document.write('	#natlamphat_logo {');
	document.write('		width: 95px;');
	document.write('		float: left;');
	document.write('		margin-top:3px;');
	document.write('		margin-left: 10px;');
	document.write('		margin-right: 8px;');
	document.write('	}');
	document.write('	#natlamphat_gator {');
	document.write('		width: auto;');
	document.write('		height: 27px;');
	document.write('		line-height: 27px;');
	document.write('		float: left;');
	document.write('		color: #'+nlTextColor+';');
	document.write('		margin-left: 5px;');
	document.write('		margin-right: 5px;');
	document.write('		font-size: 16px;');
	document.write('	}');
	document.write('	#natlamphat_text {');
	document.write('		line-height: 27px;');
	document.write('		width:auto;');
	document.write('		height: 27px;');
	document.write('		float: left;');
	document.write('		font-size: 11px;');
	document.write('		color: #'+nlTextColor+';');
	document.write('		text-decoration: none;');
	document.write('	}');
	document.write('	#natlamphat_news {');
	document.write('		line-height: 27px;');
	document.write('		width:auto;');
	document.write('		height: 27px;');
	document.write('		float: right;');
	document.write('		margin-right: 25px;');
	document.write('		font-size: 13px;');
	document.write('		color: #'+nlTextColor+';');
	document.write('		text-decoration: none;');
	document.write('	}');
	document.write('</style>');
	document.write('		<div id="natlamphat_mainbar">');
	document.write('			<div id="natlamphat_logo"><a href="http://www.nationallampoon.com"><img src="http://www.nationallampoon.com/nlhat/nllogo.png" border="0" /></a></div>');
	//check to see if current site is already listed in the bar
	if(nlSiteName != 'National Lampoon' && nlSiteName != 'Drunk University' && nlSiteName != 'The Zaz' && nlSiteName != 'Splog' && nlSiteName != 'Gamers' && nlSiteName != 'Jerkass Clothing') {
	document.write('			<div id="natlamphat_text"><a href="'+nlSiteURL+'">'+nlSiteName+'</a></div>');
	document.write('			<div id="natlamphat_gator">|</div>');
	}
	document.write('			<div id="natlamphat_text"><a href="http://www.drunkuniversity.com/" target="_blank">Drunk U</a></div>');
	document.write('			<div id="natlamphat_gator">|</div>');
	document.write('			<div id="natlamphat_text"><a href="http://splog.nationallampoon.com" target="_blank">Splog!</a></div>');
	document.write('			<div id="natlamphat_gator">|</div>');
	document.write('			<div id="natlamphat_text"><a href="http://www.nationallampoon.com/thezaz" target="_blank">The Zaz</a></div>');
	document.write('			<div id="natlamphat_gator">|</div>');
	document.write('			<div id="natlamphat_text"><a href="http://www.nationallampoon.com/movies" target="_blank">Movies</a></div>');
	document.write('			<div id="natlamphat_gator">|</div>');
	document.write('			<div id="natlamphat_text"><a href="http://www.jerkassclothing.com" target="_blank">Jerkass Clothing</a></div>');
	if(nlShowPromo === 'on') {
	document.write('			<div id="natlamphat_news"><a href="'+promoURL+'" rel="'+varPromoFollow+'" target="_blank">'+promoText+'</a></div>');
	}
	document.write('			</div>');
	document.write('		</div>');
	document.write('	</td>');
	document.write('	<td height="27" class="search-bg" width="300" align="left" style="position:relative; padding-top:'+searchPadding+'" valign="top" nowrap>');
	if(nlSiteName != 'Drunk University') {
	document.write('		<input type="hidden" name="cx" value="partner-pub-4497377835859405:olb645-46vt" />');
    document.write('		<input type="hidden" name="cof" value="FORID:10" />');
	document.write('		<input type="hidden" name="ie" value="ISO-8859-1" />');
	document.write('		<input type="text" name="q" size="31" />');
	document.write('		<input type="submit" name="sa" value="Search" />');
	document.write('<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>');
	};
	document.write('	</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</form>');
	document.write('<A HREF="http://ad.doubleclick.net/jump/N3828.NationalLampoon/B3730888;sz=1x1;ord=[timestamp]?"><IMG SRC="http://ad.doubleclick.net/ad/N3828.NationalLampoon/B3730888;sz=1x1;ord=[timestamp]?" BORDER=0 WIDTH=1 HEIGHT=1 ALT="Click Here"></A>');
}

// check browser version and set search bar padding accordingly
if(browserName === 'Microsoft Internet Explorer') { searchPadding = '0px'; }

// hacky way of fixing CSS issue on NL.com (3px top padding issue)
if(nlSiteName === 'National Lampoon') { searchPadding = '4px'; }

// hacky way of fixing CSS issue on thezaz
if(nlSiteName === 'The Zaz') { searchPadding = '2px'; }

// dont show promo link on micro sites
if(nlSiteName === 'Micro') { nlShowPromo = 'off'; }

// bread crumbs (mostly disabled)
if(typeof(nlChannel) === 'undefined' || typeof(nlChannel) === 'number' || nlChannel === '') { var nlChannel = arrVertical[nlVertical]; }
if(typeof(nlChannelUrl) === 'undefined' || typeof(nlChannelUrl) === 'number' || nlChannelUrl === '') { var nlChannelUrl = arrAffiliate[nlVertical]['NationalLampoon']; }
if(typeof(nlSiteName) === 'undefined' || typeof(nlSiteName) === 'number' || nlSiteName === '') { var nlSiteName = 'National Lampoon'; }
if(typeof(nlSiteURL) === 'undefined' || typeof(nlSiteURL) === 'number' || nlSiteURL === '') { var nlSiteURL = 'http://www.nationallampoon.com'; }

// set to default?
if(typeof(nlWidth) === 'undefined' || typeof(nlWidth) === 'number' || nlWidth === '') { var nlWidth = '100%'; }
if(typeof(nlVertical) === 'undefined' || typeof(nlVertical) === 'number' || nlVertical === '') { var nlVertical = 'show all'; }

// text color default check
if(typeof(nlTextColor) === 'undefined' || typeof(nlTextColor) === 'number' || nlTextColor === '') { var nlTextColor = 'CCCCCC'; }
if(typeof(nlTextColor) === 'undefined' || typeof(nlTextColor) === 'number' || nlTextColor === '') { var nlTextColor = 'FFFFFF'; }

createBar();