// cufon config
function initCufon() {
Cufon.replace('.col-box h2', { fontFamily: 'Fedra Medium' });
Cufon.replace('.center .article h1', { fontFamily: 'Fedra bold' });
Cufon.replace('.center .article h2:not(.nocufon)', { fontFamily: 'Fedra Medium' });
Cufon.replace('.center .article h3', { fontFamily: 'Fedra Medium' });
Cufon.replace('.center .article h4', { fontFamily: 'Fedra Medium' });
Cufon.replace('.center .latest-news h2', { fontFamily: 'Fedra Medium' });
Cufon.replace('#sidebar .sb-box h2', { fontFamily: 'Fedra Medium' });
Cufon.replace('.col-auctions h2', { fontFamily: 'Fedra Medium' });
Cufon.replace('.intyg_center .article h2', { fontFamily: 'Fedra Medium' });
Cufon.replace('.intyg_center .article h3', { fontFamily: 'Fedra Medium' });
}

function frameResize(frame, height) {
	try {
		var _height = false;
		if (height != undefined) {
			_height = height;
		} else {
			var f = frame.get(0);
			var w = f.contentWindow ? f.contentWindow : f.contentDocument.defaultView;
			if (w.innerHeight && w.scrollMaxY) {
				// webkit har inte scrollMaxY, så den hamnar inte här
				// IE har inte innerHeight
				_height = w.innerHeight+w.scrollMaxY;
			} else {
				// borde vara webkit o IE här då
				var b = frame.contents().find('body').get(0);
				// ibland funkar clientHeight (ta den om den funkar)
				if (b.clientHeight) {
					_height = b.clientHeight;
				// ibland funkar scrollHeight
				} else if (b.scrollHeight) {
					_height = b.scrollHeight;
				}
			}
		}
		if (_height) {
			frame.height(_height);
		}
	} catch (err) {
		if (window.console) {
			console.error(err);
		}
	}
}

document.domain = 'bilpriser.se';
//page init code
$(document).ready(function(){
	$('#resizeFrame').load(function(){
		frameResize($(this));
	});
	// just to be sure, trigger it in case the load-event has already happened
	try {
		var rf = $('#resizeFrame');
		if (rf.size()) {
			frameResize(rf);
		}
	} catch(err) { }
});