function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;	
}

function toggleDiv(id) {
	var divname = "videoPlayer" + id;
	var contentname= "innerDiv1" + id;
	var div = document.getElementById(divname);
	if(div.style.display == "none"){
		callExternalInterface("callPlay", id);
		div.style.display = "";
		document.documentElement.style.width = screen.width + "px";
		document.documentElement.style.overflow = "hidden";
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		var contentElement = document.getElementById(contentname);
		var contentHeight = contentElement.offsetHeight;
		var contentWidth = contentElement.offsetWidth;
		contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
		contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
	} else {
		callExternalInterface("callClose", id);
		div.style.display = "none";
		document.documentElement.style.width = "";
		document.documentElement.style.overflow = "";
	}
}
function callExternalInterface(method, id) {
	var moviename = id+"index";
	if(getMovieName(moviename)[method] != undefined) {
		// alert("callExternalInterface: "+ method + " " + id + ".");
		getMovieName(moviename)[method]();
	}
}
function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}else if(document[movieName].length != undefined){
		return document[movieName][1];
	}else{
		return document[movieName];
	}
}

