﻿function Zorrino_Web_Panel_Init() {
	if (typeof Zorrino_Web_Panel_Data != 'undefined') {
		for(var i=0; i<Zorrino_Web_Panel_Data.length; i++) {
			var properties = Zorrino_Web_Panel_Data[i];
			var panel = document.getElementById(properties.Panel);
			var show = document.getElementById(properties.Show);
			var hide = document.getElementById(properties.Hide);
			
			if (show.style.display != "none") {
				show.Panel = panel;
				show.Hide = hide;
				hide.Panel = panel;
				hide.Show = show;
				
				panel.Show = show;
				
				if (show.className.indexOf("locked") == -1) {
					show.onclick = function(e) {
						this.Panel.style.display = "";
						this.style.display = "none";
						this.Hide.style.display = "";
						document.forms[0][this.Panel.id + "state"].value = true;
					}
				}
				else show.style.cursor = "default";
				
				show.href = "javascript: void(0);"

				hide.onclick = function(e) {
					this.Panel.style.display = "none";
					this.style.display = "none";
					this.Show.style.display = "";
					document.forms[0][this.Panel.id + "state"].value = false;
				}
				hide.href = "javascript: void(0);"
			
				hide.onclick();
				var href = window.location.href;
				if (href.substring(href.indexOf("#") + 1, href.length) == properties.ID)
					show.onclick();
			}
		}
			
		if (typeof Zorrino_Web_Panel_Show_Data != 'undefined') {
			for(var i=0; i<Zorrino_Web_Panel_Show_Data.length; i++) {
				document.getElementById(Zorrino_Web_Panel_Show_Data[i].Panel).Show.onclick();
			}
		}
	}

	if (typeof Zorrino_Web_Panel_All_Data != 'undefined') {
		for(var i=0; i<Zorrino_Web_Panel_All_Data.length; i++) {
			var properties = Zorrino_Web_Panel_All_Data[i];
			
			var show = document.getElementById(properties.Show);
			var hide = document.getElementById(properties.Hide);

			show.Hide = hide;
			hide.Show = show;

			show.onclick = function(e) {
				this.style.display = "none";
				this.Hide.style.display = "";
				for(var i=0; i<Zorrino_Web_Panel_Data.length; i++)
					document.getElementById(Zorrino_Web_Panel_Data[i].Show).onclick();
			}

			hide.onclick = function(e) {
				this.style.display = "none";
				this.Show.style.display = "";
				for(var i=0; i<Zorrino_Web_Panel_Data.length; i++)
					document.getElementById(Zorrino_Web_Panel_Data[i].Hide).onclick();
			}
		}
	}
}
