function Zorrino_Web_Dialog_Init() {
	if (typeof Zorrino_Web_Dialog_Data != "undefined") {
		document.write("<div id='__dialog' class='dropshadow' style='position: absolute; left: 0; top: 0; display: none'><iframe id='__frame'	 src='https://mentor.zorrino.com/Dialog/Blank.aspx' frameborder='0' scrolling='no'></iframe></div>");

		
		for (var i=0; i<Zorrino_Web_Dialog_Data.length; i++) {
			var properties = Zorrino_Web_Dialog_Data[i];
			
			if (properties.Control.length == 0) {
				Zorrino_Web_Dialog_DoShow(properties.Url, properties.Width, properties.Height);
			}
			else {
				var control = document.getElementById(properties.Control);
			
				properties.Window = properties.Window == "True" ? true : false;
				
				if (control) {
					if (control.hasChildNodes() == false && control.tagName != "IMG") 
						control.style.display = "none";
					else {
						control.onclick = Zorrino_Web_Dialog_Show;
						
						control.Url = properties.Url;
						control.Width = properties.Width;
						control.Height = properties.Height;
						control.Window = properties.Window;
						
						control.href = "javascript: void(0);";
						control.style.cursor = "pointer";
					} 
				}
			}
		}	
	}
}

function Zorrino_Web_Dialog_Close() {
	document.getElementById("__dialog").style.display = "none";
	document.getElementById("__frame").src = "http://www.zorrino.com/General/Blank.aspx";
}

function Zorrino_Web_Dialog_Show() {
	Zorrino_Web_Dialog_DoShow(this.Url, this.Width, this.Height, this.Window);
}

function Zorrino_Web_Dialog_DoShow(url, width, height, inWindow) {
	if (inWindow) {
		var left = (window.innerWidth ? (window.innerWidth - width) / 2 : (document.documentElement.clientWidth - width) / 2);
		var top = (window.innerHeight ? (window.innerHeight - height) / 2 : (document.documentElement.innerHeight - height) / 2);
		var win = window.open(url, "_blank", "resizable=yes,height=" + height + ",width=" + width + ",top=" + top + ",left=" + left);
	}
	else {
		var dialog = document.getElementById("__dialog");
		var frame = document.getElementById("__frame");
		
		frame.src = url;
		
		if (width > 0 && height > 0) Zorrino_Web_Dialog_Resize(width, height);
	}	
}

function Zorrino_Web_Dialog_Resize(width, height) {
	var dialog = document.getElementById("__dialog");
	var frame = document.getElementById("__frame");
	
	dialog.style.left = (window.innerWidth ? (window.innerWidth - width) / 2 : ((document.documentElement.clientWidth - width) / 2)) + "px";
	dialog.style.top = (window.innerHeight ? (window.innerHeight - height) / 2 : ((document.documentElement.clientHeight - height) / 2)) + 
						(window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop) + "px";
	
	if (Zorrino_Web_Dialog_ReadCookie("style") == "800") {
		width = width / 3 * 2; 
		height = height / 3 * 2;
	}
	
	dialog.style.display = "block";
	
	frame.width = width + "px";
	frame.height = height + "px";
	
	frame.Width = width;
	frame.Height = height;
	
	dialog.style.left = (window.innerWidth ? (window.innerWidth - width) / 2 : ((document.documentElement.clientWidth - width) / 2)) + "px";
	dialog.style.top = (window.innerHeight ? (window.innerHeight - height) / 2 : ((document.documentElement.clientHeight - height) / 2)) + 
						(window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop) + "px";
}

function Zorrino_Web_Dialog_ReadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//window.onresize = Zorrino_Web_Dialog_Move;

function Zorrino_Web_Dialog_Move(width, height) {
	var dialog = document.getElementById("__dialog");
	var frame = document.getElementById("__frame");
	
	dialog.style.left = (window.innerWidth ? (window.innerWidth - frame.Width) / 2 : (document.documentElement.clientWidth - frame.Width) / 2) + "px";
	dialog.style.top = (window.innerHeight ? (window.innerHeight - frame.Height) / 2 : (document.documentElement.innerHeight - frame.Height) / 2) + 
						(window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop) + "px";
}


