// Placed in the frame
var baseURL = "http://www2.chrysler.se/js/iframeresize/";

function swfMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		 return window[movieName];
	} else {
		 return document[movieName];
	}
}

function getBodyHeight() {
    var height;
    var scrollHeight;
    var offsetHeight;

    if (document.height) {
        height = document.height;
    } else if (document.body) {
        if (document.body.scrollHeight) {
            height = scrollHeight = document.body.scrollHeight;
        }
        if (document.body.offsetHeight) {
            height = offsetHeight = document.body.offsetHeight;
        }

        if (scrollHeight && offsetHeight) {
            height = Math.max(scrollHeight, offsetHeight);
        }
    }

    return height;
}

// Load UFO
try {
	if(typeof UFO == "undefined") {
		var fileref=document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src", baseURL + "ufo.js");
		document.getElementsByTagName("head")[0].appendChild(fileref);
	}
} catch(e) { }

// ADD DIVS/HTML
var icload = setInterval(function() {
	if ((document.getElementsByTagName("body")[0] != null || document.body != null)) {
		clearInterval(icload);
		document.body.style.margin = "0";

		var icDiv=document.createElement("div");
		icDiv.style.position = "absolute";
		icDiv.style.top = "0";
		icDiv.style.left = "0";
		icDiv.id = "iframeconnect";
		document.body.appendChild(icDiv);

		var icfload = setInterval(function() {
			if ((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById("iframeconnect") != null) {
				clearInterval(icfload);						 
				var icFO = { movie: baseURL + "crossdomainLink.swf", width:"1", height:"1", majorversion:"8", build:"0", wmode: "transparent", flashvars: "thisId=sender01&otherId=reciever01", id: "icF", name: "icF", allowscriptaccess: "always" };
				try{
					UFO.create(icFO, "iframeconnect");
				} catch(e) { }
				
				var icfs = setInterval(function() {
					if(swfMovie('icF') && swfMovie('icF').executeJS) {
						clearInterval(icfs);
						swfMovie('icF').executeJS('FrameManager.setHeight(' + getBodyHeight() + ');');
					}
				}, 250);
			}
		 }, 1);
	}
}, 50);
