function createDivBg (which) {
	var divWhich = $(which);
	var divWrapper      = new Element ('div', {'id' : which+'Wrapper'});
	var divBg           = new Element ('div', {'id' : which+'Bg'});
	var divBgContent    = new Element ('div', {'id' : which+'BgContent'});
	var divBgTop        = new Element ('div', {'id' : which+'BgTop'});
	
	if (aBgVertSizing [which]) {
		var divBgBottom     = new Element ('div', {'id' : which+'BgBottom'});
		var divBgBottomLeft = new Element ('div', {'id' : which+'BgBottomLeft'});
	}
	
	divWhich       .setStyle  ('background-color' , 'transparent');

	var bgFileURL = 'url(' + aBgImages[which] + ')';
	divBgContent   .setStyles({'background-image' : bgFileURL, 'position' : 'absolute', 'background-position' : 'top right'});
	divBgTop       .setStyles({'background-image' : bgFileURL, 'position' : 'absolute', 'background-position' : 'top left'});
	if (aBgVertSizing [which]) {
		divBgBottom    .setStyles({'background-image' : bgFileURL, 'position' : 'absolute', 'background-position' : 'bottom right'});
		divBgBottomLeft.setStyles({'background-image' : bgFileURL, 'position' : 'absolute', 'background-position' : 'bottom left'});
	}

	var offset = 0;
	(which=='container_div' | which=='bigBanner_div') ? offset = 0 : offset = 3;
	divWrapper .setStyles ({'position' : 'absolute', 'z-index' : 1 + offset});
	divBg      .setStyles ({'position' : 'absolute', 'z-index' : 2 + offset});
	divWhich   .setStyles ({'position' : 'absolute', 'z-index' : 3 + offset});
	
	divWrapper     .inject (divWhich,     'before');
	divWhich       .inject (divWrapper,   'top');
	divBg          .inject (divWrapper,   'top');
	divBgContent   .inject (divBg,        'top');
	divBgTop       .inject (divBgContent, 'top');
	if (aBgVertSizing [which]) {
		divBgBottom    .inject (divBgContent, 'after');
		divBgBottomLeft.inject (divBgBottom,  'bottom');
	}
}

function updateDiv(which){

	var bottomHeight = aBgVertSizing[which] ? 15 : 0;

	switch (which) {
		
		case 'container_div':
			var w=container.width;
			var h=container.height;
			var l=container.left;
			var t=container.top;
			break;
			
		case 'bigBanner_div':
			var w=winCoords.width;
			var h=200;
			var l=0;
			var t=0;
			break;
			
		case 'player_div':
			var w = 234;
			var grow = (playerType == 'v') ? 120 : 0;
			var h = 195 + grow;
			var t = 200;
//			var l = popupOpen ? winCoords.width+5 : container.width - 264;
			var l = container.width - 264;
			bottomHeight = 80;
			
			var playerLeft = (winCoords.width > 980) ? parseInt((winCoords.width - container.width) / 2) + l + 1 :
													   parseInt((980 - container.width) / 2) + l + 1;
			
			$('flashAudioPlayer_div'  ).setStyles ( { left : playerLeft, top : t + 28 } );
			$('flashYoutubePlayer_div').setStyles ( { left : playerLeft, top : t + 28 } );
			
			break;
			
	}
	var leftSliceWidth = parseInt (w / 2);
//	if (!($(which + 'Wrapper'))) alert ('no ' + which + ', currentPage=' + currentPage);
	$(which+'Wrapper')     .setStyles({'width' : w,    'height' : h,    'left'   : l,       'top' : t});
	$(which+'Bg')          .setStyles({'width' : w,    'height' : h});
	$(which+'BgContent')   .setStyles({'width' : w-leftSliceWidth, 'height' : h-bottomHeight, 'right' : 0,        'top' : 0});
	$(which+'BgTop')       .setStyles({'left'  : -leftSliceWidth,  'top'    : 0,    'width'  : leftSliceWidth,   'height' : h-bottomHeight});

	if (aBgVertSizing [which]) {
		$(which+'BgBottom')    .setStyles({'right' : 0,    'bottom' : 0,    'width'  : w-leftSliceWidth, 'height' : bottomHeight});
		$(which+'BgBottomLeft').setStyles({'left' : -leftSliceWidth,   'bottom' : 0,    'width'  : leftSliceWidth,   'height' : bottomHeight});
	}

	$(which)               .setStyles({'left'  : 0,    'top'    : 0,    'width' : w,    'height' : h});

	if (which == 'player_div') $('playerContents_div').tween('height', 70+grow);
}
		
function changeSlColumnWidth (column, width) {
	$$('.'+column).setStyle('width', width);
}

function resized() {
//			if (!avoidRedraw) {

	if (iPhone) {
		container.left = 20;
		container.top =  0; // was 20
		container.width = 940;
		container.height = 670; // was 1050
	} else {
		container.resize();
	}
	
//	updateDiv('container_div');

	aObjs['dbgDiv']['res'].init("Screen: "+winCoords.width + " x " + winCoords.height + ", NN: " + container.width + "x" + container.height);
}

function fnHideDivs() {
	for (var i=0; i<aHiddenDivs.length; i++) {
		which=aHiddenDivs[i];
		$(which).fade('hide');
		$(which).setStyle ('display', 'inline');		
	}
}

function displayBanners() {
	$('topBanner1_div'  ).set('html', bannersObj.t1.html);
	$('topBanner2_div'  ).set('html', bannersObj.t2.html);
	$('leftBanner1_div' ).set('html', bannersObj.l1.html);
	$('leftBanner2_div' ).set('html', bannersObj.l2.html);
	$('leftBanner3_div' ).set('html', bannersObj.l3.html);
	$('rightBanner1_div').set('html', bannersObj.r1.html);
	$('rightBanner2_div').set('html', bannersObj.r2.html);
	$('rightBanner3_div').set('html', bannersObj.r3.html);
	
	$('rightBanner1_div').setStyles( { 'right'  : (30 + parseInt((234 - bannersObj.r1.width) / 2)) + 'px',
 									   'width'  : bannersObj.r1.width + 'px',
									   'border' : bannersObj.r1.border_style + ' ' +
									              bannersObj.r1.border_width + 'px ' +
												  bannersObj.r1.border_color } );
	
	$('rightBanner2_div').setStyles( { 'right'  : (30 + parseInt((234 - bannersObj.r2.width) / 2)) + 'px',
 									   'width'  : bannersObj.r2.width + 'px',
									   'border' : bannersObj.r2.border_style + ' ' +
									              bannersObj.r2.border_width + 'px ' +
												  bannersObj.r2.border_color } );
	
	$('rightBanner3_div').setStyles( { 'right'  : (30 + parseInt((234 - bannersObj.r3.width) / 2)) + 'px',
 									   'width'  : bannersObj.r3.width + 'px',
									   'border' : bannersObj.r3.border_style + ' ' +
									              bannersObj.r3.border_width + 'px ' +
												  bannersObj.r3.border_color } );
}

function fnRotateSlogan() {
	currentSlogan++;
	if (currentSlogan >= aSloganText.length) currentSlogan = 0;

	if (currentSloganDiv == 1) {
		$('sloganDiv2Line1_span').innerHTML = aSloganText[currentSlogan][0];
		$('sloganDiv2Line2_span').innerHTML = aSloganText[currentSlogan][1];
		sloganDiv1Fade.start ('opacity', 0);
		sloganDiv2Fade.start ('opacity', 1);
		currentSloganDiv = 2;
	} else {
		$('sloganDiv1Line1_span').innerHTML = aSloganText[currentSlogan][0];
		$('sloganDiv1Line2_span').innerHTML = aSloganText[currentSlogan][1];
		sloganDiv1Fade.start ('opacity', 1);
		sloganDiv2Fade.start ('opacity', 0);
		currentSloganDiv = 1;
	}
}
