jQuery(function() {
	var sLoc = location.search;
	if (sLoc.length == 0) {
		return;
	}
	var aArgs = sLoc.substring(1).split('&');
	for (var i = 0; i < aArgs.length; i++) {
		var aSplit = aArgs[i].split('=');
		if (aSplit[0] == 'print') {
			if (aSplit[1] == 'true') {
				setupPrinterFriendly();
			}
			return;
		}
	}
});

function setupPrinterFriendly() {
	jQuery('head > style').each(function(i, oElem) {
		oElem.parentNode.removeChild(oElem);
	});
	jQuery('head > link').each(function(i, oElem) {
		if (oElem.getAttribute('type') == 'text/css') {
			oElem.parentNode.removeChild(oElem);
		}
	});
	jQuery('<link media="screen" href="/bmw/css/print.css" type="text/css" rel="stylesheet">').appendTo('head');
	setTimeout(window.print, 500);
}
