function swapImg(img, src) {
	$(img).src = src;
}

function addtocart(pid) {
	jsf = new JSF(); 
	jsf.createField('action', 'addtocart'); 
	jsf.createField('pid', pid); 
	jsf.submitForm();
	return false;
}

function deletecart(pid) {
	jsf = new JSF(); 
	jsf.createField('action', 'deletecart'); 
	jsf.createField('pid', pid); 
	jsf.submitForm();
	return false;
}

function center_with_autoscroll() { 
	/*if(Prototype.Browser.IE) { 
		$('outergrid').style.display = ''; 
		return; 
	}*/
	
	$('outergrid').style.display = 'none';
	$('outergrid').style.position = 'absolute';
	
	if(document.viewport.getWidth() > 1020) {
		$('outergrid').style.left = (((document.viewport.getWidth() - 1020) / 2) - 8)+"px";
	} else {
		$('outergrid').style.left = "0px";
	}
	
	$('outergrid').style.display = '';
}

function float_footer(func) { 
	if($('footer')) 
		$('footer').remove();
		
	$(document.body).insert('<div id="footer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&copy; 2009 LadyB.com </div>');
	
	$('footer').style.position = 'absolute';
	$('footer').style.left = $('outergrid').style.left;
	
	var scrolloff = document.viewport.getScrollOffsets();
	
	if($('outergrid').getHeight() < document.viewport.getHeight()) {
		$('footer').style.top = (document.viewport.getHeight() + scrolloff[1] - 30)+"px";
	} else {
		
		$('footer').style.top = ($('outergrid').getHeight())+"px";
		$('footer').style.height = "30px";
	}
	
	//$('footer').insert($('outergrid').getHeight()+' < '+document.viewport.getHeight());
	//$('footer').insert($('footer').style.top); 
	//$('footer').style.border = "1px solid #ccc";
}

function iniZoomSWF(imgSmall, imgLarge) { 
   //alert( [imgSmall, imgLarge] );
		
	if( $('zoomSWF') ) {
		$('zoomSWF').innerHTML = '';
		
		
		if (AC_FL_RunContent == 0) {
				alert("This page requires AC_RunActiveContent.js.");
		} else {
			var acswf = AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
				'width', '256',
				'height', '460',
				'src', 'swf/zoomv3?small='+imgSmall+'&large='+imgLarge,
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'window',
				'devicefont', 'false',
				'id', 'swf_zoomv3',
				'bgcolor', '#ffffff',
				'name', 'swf_zoomv3',
				'menu', 'true',
				'allowFullScreen', 'false',
				'allowScriptAccess','sameDomain',
				'movie', 'includes/swf/zoomv3?small='+imgSmall+'&large='+imgLarge,
				'salign', ''
			); //end AC code
		}
		
		//alert(acswf);
		$('zoomSWF').insert( acswf ); //$('zoomSWF').innerHTML = acswf;
	}
	
	return false;
}

window.onload = function () {
	center_with_autoscroll();
	float_footer('onload');
	
	if( $('zoomSWF') ) { // grab src of init-image and pass as param to start zoomSWF
		iniZoomSWF($('zoomSWF').down().src, $('zoomSWF').down().src.replace(/\/out\//, '/in/'));
	}
};



window.onresize = function () {
	center_with_autoscroll();
	float_footer('onresize');
};