// JavaScript Document

function banner_obj( lnk, img_path, alt_title) {
	this.lnk = lnk;
	this.img_path = img_path;
	this.alt_title = alt_title;
}

var banners_120 = [
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/hp4-120x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/120x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/wahm-120x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.kqzyfj.com/sr119nmvsmu9DEAHDAE9ICIGEDF?sid=sblunarp', 'http://www.awltovhc.com/hp121g04tzxIMNJQMJNIRLRPNMO', 'Huge savings on website hosting!' ),
	new banner_obj ( 'http://www.marketingtips.com/t.cgi/1429266/', 'http://images2.marketingtips.com/Course120x600_StartNow.gif', 'Internet Marketing Course' ),
    new banner_obj ( 'http://www.marketingtips.com/t.cgi/1429266/', 'http://images2.marketingtips.com/Course120x600_EasierBlue.gif', 'Internet Marketing Course' ),
	new banner_obj ( 'http://www.dpbolvw.net/ah81tenkem156295261327956B2?sid=sbterapeak2', 'http://www.lduhtrp.net/eg108wquiom7BC8FB8C798DFBCH8', 'Know when to sell on eBay' ),
	new banner_obj ( 'http://www.anrdoezrs.net/6f102nmvsmu9DEAHDAE9CIDCCDA?sid=sbconstantc3', 'http://www.ftjcfx.com/8998h48x20MQRNUQNRMPVQPPQN', 'Emails for Small Business with Constant Contact' ),
	new banner_obj ( 'http://www.seobook.com/5776-1-1-18.html', 'http://www.seobook.com/rf/banners/seobook120x600.gif', '' ),
	new banner_obj ( 'http://www.pntrs.com/t/RD1CR0FHPUNBQURDPUNFQg', 'http://www.pntrs.com/b/RD1CR0FHPUNBQURDPUNFQg', 'SEOmoz.org - Learn From SEO Experts. Become an Expert.' )
];			   

var banners_160 = [
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/160x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://videotour.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/tour-160x600.jpg', 'SBI Video Tour!' ),
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/hp2-160x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/hp4-160x600.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://services.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/services-160x600.jpg', 'SiteSell Services' ),
	new banner_obj ( 'http://affiliatemarketing.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/aff-market-160x600.jpg', 'Affiliate Marketing' ),
	new banner_obj ( 'http://workfromhome.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/home-160x600.jpg', 'Site Build It!' ),
	// the following are actually 250px wide:
	new banner_obj ( 'http://videotour.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/tour-250x250.jpg', 'SBI Video Tour!' ),
	new banner_obj ( 'http://buildit.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/buildit2-250x250.jpg', 'Site Build It!' ),
	// the following are actually 120px or 125px wide:
	new banner_obj ( 'http://www.anrdoezrs.net/6g77nmvsmu9DEAHDAE9BAECAADE?sid=sbprostore', 'http://www.tqlkg.com/8f116ltxlrpAEFBIEBFACBFDBBEF', 'Free trial' ),
	new banner_obj ( 'http://www.anrdoezrs.net/6g77nmvsmu9DEAHDAE9BAECAADE?sid=sbprostore', 'http://www.tqlkg.com/8f116ltxlrpAEFBIEBFACBFDBBEF', 'Free trial' ),
	new banner_obj ( 'http://www.dpbolvw.net/82108efolfn2673A637243978A48?sid=sbdeliverywatch', 'http://www.lduhtrp.net/23100bosgmk59A6D96A576CABD7B', 'Do your email campaigns get through?' ),
	new banner_obj ( 'http://www.anrdoezrs.net/6f102nmvsmu9DEAHDAE9CIDCCDA?sid=sbconstantc3', 'http://www.ftjcfx.com/8998h48x20MQRNUQNRMPVQPPQN', 'Emails for Small Business with Constant Contact' ),
	new banner_obj ( 'http://www.seobook.com/5776-1-1-18.html', 'http://www.seobook.com/rf/banners/seobook120x600.gif', '' )
];

var banners_468 = [
	new banner_obj ( 'http://buildit.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/hp4-468x60.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.marketingtips.com/t.cgi/1429266/', 'http://www.marketingtips.com/images/imc-52.gif', 'Internet Marketing Course' ),
	new banner_obj ( 'http://www.dpbolvw.net/jr75vpyvpxCGHDKGDHCLFMELHK?sid=sblunarp2', 'http://www.tqlkg.com/ao104fz2rxvGKLHOKHLGPJQIPLO', 'Unlimited Storage and Bandwidth for $4.95/mo!' ),
	new banner_obj ( 'http://www.marketingtips.com/bebiz/special/t/1429266', 'http://images.marketingtips.com/bebiz_banner_01.gif', 'Create your Online Business' ),
	new banner_obj ( 'http://www.marketingtips.com/backstage-pass/t/1429266', 'http://images.marketingtips.com/seoLab_banner_1.gif', 'Create your Online Business' ),
	new banner_obj ( 'http://services.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/services-468x60.jpg', 'SiteSell Services' ),
	new banner_obj ( 'http://affiliatemarketing.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/aff-market-468x60.jpg', 'Affiliate Marketing' ),
	new banner_obj ( 'http://videotour.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/tour-468x60.jpg', 'SBI Video Tour!' ),
	new banner_obj ( 'http://passion.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/passion2-468x60.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://passion.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/passion-468x60.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://buildit.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/468x60.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://blogorbuild.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/blog-or-build-468x60.jpg', 'Blog or Build an SBI! Site' ),
	new banner_obj ( 'http://ctpm.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/process-468x60.jpg', 'SBI! CTPM Process' ),
	new banner_obj ( 'http://workfromhome.sitesell.com/sidebuck.html', 'http://graphics.sitesell.com/snippet/home2-468x60.jpg', 'Site Build It!' ),
	new banner_obj ( 'http://www.marketingtips.com/bebiz/special/t/1429266', 'http://images.marketingtips.com/bebiz_banner_01.gif', 'Create your Online Business!' ),
	new banner_obj ( 'http://www.marketingtips.com/backstage-pass/t/1429266', 'http://images.marketingtips.com/seoLab_banner_1.gif', 'SEO Course' ),
	new banner_obj ( 'http://www.dpbolvw.net/dh108wktqks7BC8FB8C798C8GF9B?sid=sbprostore2', 'http://www.ftjcfx.com/pi105z15u-yJNOKRNKOJLKOKSRLN', 'ProStores 1 Month Free Trial' ),
	new banner_obj ( 'http://www.dpbolvw.net/dh108wktqks7BC8FB8C798C8GF9B?sid=sbprostore2', 'http://www.ftjcfx.com/pi105z15u-yJNOKRNKOJLKOKSRLN', 'ProStores 1 Month Free Trial' ),
	new banner_obj ( 'http://www.dpbolvw.net/dh108wktqks7BC8FB8C798C8GF9B?sid=sbprostore2', 'http://www.ftjcfx.com/pi105z15u-yJNOKRNKOJLKOKSRLN', 'ProStores 1 Month Free Trial' ),
	new banner_obj ( 'http://www.jdoqocy.com/83102ar-xrzEIJFMIFJENGJILMG?sid=sbconstantc', 'http://www.lduhtrp.net/3074bosgmk59A6D96A5E7A9CD7', 'Emails for Small Business with Constant Contact' ),
	new banner_obj ( 'http://www.seobook.com/5776-1-1-3.html', 'http://www.seobook.com/rf/banners/468-60.gif', '' ),
	new banner_obj ( 'http://www.pjtra.com/t/RD1CR0JFPUNBQURDPUNFQg', 'http://www.pjtra.com/b/RD1CR0JFPUNBQURDPUNFQg', 'SEOmoz.org - Learn From SEO Experts. Become an Expert.' )
];

function imgset( element ) { // adjust too small and too large images inside articles content
	with( element ) {
		if( getWidth() > 538 ) setStyle( { width: '512px' } ); // adjust images wider than containing frame
		else if( getWidth() <= 10 && getHeight() <= 10 ) remove(); // hide any images smaller than 10x10 px from inside articles content
	}
}

document.observe( 'dom:loaded', function() { // initiate page
	 // preload rollover images:
	MM_preloadImages( 
		'/images/nav-back-over.gif',
		'/images/page_arrow-left-over.gif',
		'/images/page_arrow-right-over.gif',
		'/images/tab-back-over.gif',
		'/images/tab-home-back-over.gif',
		'/images/home_icon-on.gif',
		'/images/calltoaction_back-over.gif'
	);
	$$( '.content_txt a', '.article_preview_txt a' ).each( function( element ) { element.writeAttribute( "target", "_blank" ); } ); // open articles links in new pages
	$$( '.content_txt a > img' ).each( function( element ) { element.up( 'a' ).setStyle( { border: 'none' } ); } ); // clear dashed underline from linkable images inside content
	$$( '#article_txt a > img', '.article_preview_txt a > img' ).each( function( element ) { element.up( 'a' ).replace( element ); } ); // eliminate links from linkable images inside articles content
	$$( '#article_txt img', '.article_preview_txt img' ).each( function( element ) { // adjust too small and too large images inside articles content 
		imgset( element );
		element.writeAttribute( "onLoad", "imgset( this )" ); // schedule the same set of actions on images unloaded yet
	} );
	$$( '.feedflare' ).each( function( element ) { element.hide(); } ); // hide feedburner bar from inside articles content
	[ '120', '160', '468' ].each( function( element ) { // choose random banners
		var obj_name = $( 'banner_' + element );
		if( obj_name != null ) {
			var banner_array = eval( 'banners_' + element );
			var random_banner = banner_array[ Math.floor( Math.random() * banner_array.size() ) ];
			obj_name.innerHTML = '<a href=\"#null\" title=\"' + random_banner.alt_title + '\" onClick=\"ext_lnk(\'' + random_banner.lnk + '\');return false\"><img src=\"' + random_banner.img_path + '\" border=\"0\" alt=\"' + random_banner.alt_title + '\" width=\"' + element + '\"></a>';
		}
	} );
} );

function init_articles_list() { // format articles list 
	var lst = $$( '#side_hdlines_content_navbar > div' );
	var lst_in = new Array(); // array to reference list HTML in reversed order
	lst.each( function( element ) { lst_in[ lst.size() - 1 - lst.indexOf( element ) ] = element.innerHTML; } )
 	.each( function( element ) { element.update( lst.indexOf( element ) + 1 + ' - ' + lst_in[ lst.indexOf( element ) ] ); } ) // add ordered numbers to articles headlines list items and reverse list order
	.first().setStyle( { border: 'none' } ); // clear top border line of first item
}

function init_featured_list() { // format featured articles list 
	$$( '#side_featured_content_navbar > div' ).first().setStyle( { border: 'none' } ); // clear top border line of first item
}

function chg_cls( obj ) { // change object class on mouseover and mouseout
	var hover_class = $( obj ).readAttribute( 'class' ) + '_over';
	obj.addClassName( hover_class ).observe( 'mouseout', function() { this.removeClassName( hover_class ); } );
}

function ext_lnk( address ) { // link to outside provider
	pageTracker._trackPageview( address );
	MM_openBrWindow( address, '', '' );
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
