/*
	FILE : ulmer.js
	DATE : 7.3.2007.dave
	COPY : Copyright 2007 David A Striegel
*/

function destroyZoomer() {
	if ($('zoomer')) document.body.removeChild($('zoomer'));
}

function initZoomer(srcElm,dirpath,filename,w,h,max) {
	var i = new Image();
	i.src = '/_mods/resize.php?max='+max+'&imgURL='+dirpath+filename;

	if (i.complete) showZoomer(srcElm,dirpath,filename,w,h,max);
	i.onload = function () { showZoomer(srcElm,dirpath,filename,w,h,max); };
}

function showZoomer(srcElm,dirpath,filename,w,h,max) {
	destroyZoomer();

	tmpW = (w>h)?max:(w*max/h);
	tmpH = (w<h)?max:(h*max/w);

	w = (tmpW>w || tmpH>h)?w:tmpW;
	h = (tmpW>w || tmpH>h)?h:tmpH;

	var curWindowDim = getWindowDim();
	var scrollXY = getScrollOffset();
	var xy = [scrollXY[0] + ((curWindowDim[0] - w) / 2), scrollXY[1] + ((curWindowDim[1] - h) / 2)];

	newDiv = document.createElement("div");
	newDiv.id = 'zoomer';
	newDiv.style.width = w + 'px';
	newDiv.style.height = h + 'px';
	newDiv.style.left = xy[0] + 'px';
	newDiv.style.top = xy[1] + 'px';
	newDiv.style.backgroundImage = 'url(\'/_mods/resize.php?max='+max+'&imgURL='+dirpath+filename+'\')';
	newDiv.style.backgroundColor = '#ffffff';
	newDiv.style.backgroundRepeat = 'no-repeat';
	newDiv.style.backgroundPosition = 'top left';
	
	addEvent(newDiv, 'click', destroyZoomer);
	
	document.body.appendChild(newDiv);

	newDiv2 = document.createElement("div");
	newDiv2.className = 'fileDetails';
	newDiv2.innerHTML = '<a href="javascript:destroyZoomer();"><img src="/_css/images/close.gif" alt="Close" border="0"></a>';

	$('zoomer').appendChild(newDiv2);
}

var toggleShipping = function(elm) {
	$('S_FIRST_NAME').value = '';		$('S_FIRST_NAME').disabled = elm.checked;	$('S_FIRST_NAME').className = (elm.checked)?'disabled':'';
	$('S_MI').value = '';				$('S_MI').disabled = elm.checked;			$('S_MI').className = (elm.checked)?'disabled':''
	$('S_LAST_NAME').value = '';		$('S_LAST_NAME').disabled = elm.checked;	$('S_LAST_NAME').className = (elm.checked)?'disabled':''
	$('S_STREET_1').value = '';			$('S_STREET_1').disabled = elm.checked;		$('S_STREET_1').className = (elm.checked)?'disabled':''
	$('S_STREET_2').value = '';			$('S_STREET_2').disabled = elm.checked;		$('S_STREET_2').className = (elm.checked)?'disabled':''
	$('S_CITY').value = '';				$('S_CITY').disabled = elm.checked;			$('S_CITY').className = (elm.checked)?'disabled':''
	$('S_STATE_ID').selectedIndex = 0;	$('S_STATE_ID').disabled = elm.checked;		$('S_STATE_ID').className = (elm.checked)?'disabled':''
	$('S_ZIP').value = '';				$('S_ZIP').disabled = elm.checked;			$('S_ZIP').className = (elm.checked)?'disabled':''
}

var toggleHelp = function(elmID) {
	if ($(elmID) && $(elmID).style.display == 'none')
		$(elmID).show();
	else if ($(elmID))
		$(elmID).hide();
}
