// JavaScript Document
/* $Id: resize_iframe.js,v 1.4 2007/09/17 16:33:08 paul Exp $ */
var getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox')).split('/')[1];
var FFextraHeight = (parseFloat(getFFVersion) >= 0.1 ? 16 : 0);
var FFextraWidth = (parseFloat(getFFVersion) >= 0.1 ? 16 : 0);
var body_is_loaded = false;
var cart_max_height = '0';
function resize_cart_iframe() {	
	if(document.getElementById) {
		var cart_iframe = document.getElementById('w2bo_aff_content');
		var measuring_stick = document.getElementById('measuring_stick');
		if(cart_iframe && !window.opera) {
			if(measuring_stick && !window.opera) {
				measuring_stick.style.display = 'block';
				if(measuring_stick.contentDocument && measuring_stick.contentDocument.body.offsetHeight) {
					measuring_stick.height = measuring_stick.contentDocument.body.offsetHeight + FFextraHeight;
					cart_max_height = measuring_stick.height;
				} else if(measuring_stick.Document && measuring_stick.Document.body.scrollHeight) {
					measuring_stick.height = measuring_stick.Document.body.scrollHeight;
					cart_max_height = measuring_stick.height;
				}
				measuring_stick.style.display = 'none';
			}
			if(cart_iframe.contentDocument && cart_iframe.contentDocument.body.offsetHeight) {
				if(must_resize == '1') {
					cart_iframe.height = cart_iframe.contentDocument.body.offsetHeight + FFextraHeight;
					cart_iframe.addEventListener('load',resize_loaded_cart_iframe,false);
				}
			} else if(cart_iframe.Document && cart_iframe.Document.body.scrollHeight) {
				if(must_resize == '1') {
					cart_iframe.height = cart_iframe.Document.body.scrollHeight;
					cart_iframe.attachEvent('onload',resize_loaded_cart_iframe);
				}
			}
			if(cart_iframe.contentDocument && cart_iframe.contentDocument.body.offsetWidth) {
				if(must_resize == '1') {
					cart_iframe.width = cart_iframe.contentDocument.body.offsetWidth + FFextraWidth;
				}
			} else if(cart_iframe.Document && cart_iframe.Document.body.scrollWidth) {
				if(must_resize == '1') {
					cart_iframe.width = cart_iframe.Document.body.scrollWidth;
				}
			}
			body_is_loaded = true;
		}
	}	
}
function resize_loaded_cart_iframe() {
	if(body_is_loaded) {
		var cart_iframe = document.getElementById('w2bo_aff_content');
		if(cart_iframe) {
			cart_iframe.height = cart_max_height;
		}
	}
}
if(window.addEventListener) {
	window.addEventListener('load',resize_cart_iframe,false);
} else if(window.attachEvent) {
	window.attachEvent('onload',resize_cart_iframe);
} else {
	window.onload = resize_cart_iframe;
}
