
var DirectImports = {
	init: function(){
		DirectImports.setups();
		DirectImports.rewriteLinks();
		if ($('serps')) DirectImports.limitResults();
		if ($('enews-next-mi')) DirectImports.signPopupMI();
		if ($('enews-next-ce')) DirectImports.signPopupCE();
		if (typeof(banners) != 'undefined') DirectImports.rotator(banners);
	},
	setups: function(){
		if ($('search-box')) {
			$('search-box').addEvent('focus', function(){ if (this.value == 'Search Direct Imports') this.value = '' });
			$('search-box').addEvent('blur', function(){ if ($('search-box').value == '') $('search-box').value = 'Search Direct Imports' });
		}

//		if ($('side').getStyle('height').toInt() < 200) $('side').setStyle('height', '250px');
//		if ($('side').getStyle('height').toInt() < $('food').getStyle('height').toInt() + 50) $('side').setStyle('height', ($('food').getStyle('height').toInt() + 50) + 'px');
		if ($('supp') && $('supp').getStyle('height').toInt() < 50) $('supp').setStyle('display', 'none');
//		if ($('side').getStyle('height').toInt() < $('food').getStyle('height').toInt() + 50) $('side').setStyle('height', ($('food').getStyle('height').toInt()) + 'px');
	},
	rewriteLinks: function(){
		var a = $$('a');

		for (var i=0; i < a.length; i++) {
			if (a[i].rel == 'external') a[i].target = '_blank';
		}
	},
	rotator: function(banners){
		diShow = new Slideshow('feat', {
			type: 'combo',
			duration: [1500, 4500],
			width: 850, height: 200,
			images: banners,
			hu: 'http://directimports.creativeweb.co.nz'
		});
	},
	limitResults: function(){
		which = $('category').getValue();

		$$('div.mi, div.ce').each(function(elHide, i) {
			elHide.setStyle('display','block');
		});

		if (which != 'all'){
			$$('div.' + which).each(function(elHide, i) {
				elHide.setStyle('display','none');
			});
		}
	}
};

window.addEvent('load', DirectImports.init);

function popup() {
	dipopup = window.open('', 'dipopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=380,top='+(screen.height-550)/2+',left='+(screen.width-380)/2);
	return true;
}
