// flash interface and other utility functions


// provides the proper address for the movie depending on browser
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}


// make flash call back
function cb_flash(flashid, swf_id, ret_value) {
	//alert('swf_id:' + swf_id + ' ret_value:' + ret_value);
	if (flashid == "ad120") {
		getFlashMovie(swf_id).flashCallback120(ret_value);
	} else if (flashid == "ad300") {
		getFlashMovie(swf_id).flashCallback300(ret_value);
	} else if (flashid == "ad728") {
		getFlashMovie(swf_id).flashCallback728(ret_value);
	} else {
		//alert('Incorrect ID passed.');
	}
}


// check iframe for content
function getIframeHasContent(thisid) {
	var frameID = "";
	frameID = thisid;
	var myIFrame = document.getElementById(frameID);
	//alert("start content");
	var getIFrameContent = myIFrame.contentWindow.document.body.innerHTML;
	//alert("end content");
	if (getIFrameContent == "") {
		return false;
	} else {
		return true;
	}
}


// wrapper which checks iframe content and runs flash callback
function cbIframe(id) {
	var tempID = "";
	tempID = id;
	var swf_id = "myAlternativeContent";
	var framecontent = "";
	//alert("start frame content for " + id + " :: current ID");
	framecontent = getIframeHasContent(tempID);
	cb_flash(tempID, swf_id, framecontent);
	//showAd() do this?
}
function cbIframe120() {
	//alert("Start cbIframe120");
	cbIframe('ad120');
}
function cbIframe300() {
	//alert("Start cbIframe300");
	cbIframe('ad300');
}
function cbIframe728() {
	//alert("Start cbIframe728");
	cbIframe('ad728');
}


function callRefresh(id) {
	document.getElementById(id).contentWindow.location.reload(true);
}


function showAd(id) {
	var obj = document.getElementById(id)
	obj.style.display = "block";
}


function hideAd(id) {
	var obj = document.getElementById(id)
	obj.style.display = "none";
}


function openMusicPlayer() {
	window.open("pages/musicPlayer/dcmusicplayer.html","HotTracks","width=450,height=460,scrollbars=no,resizable=no,toolbar=no,location=no");
}


function mp_onload(id) {
	var content = getIframeHasContent(id);
	if (content) {
		showAd(id);
	}
}
