function setElementsVisibility(show) {
	var v = show ? "visible" : "hidden";
	var d = show ? "" : "none";
	//document.getElementById("header_foto_div").style.visibility = v;
	//document.getElementById("stars_slot_1").style.visibility = v;
	//document.getElementById("banner").style.visibility = v;
	//document.getElementById("banner_frame").style.display = d;
	if (document.getElementById("PlayVideo")) 
	{
		document.getElementById("PlayVideo").style.visibility = v;		
	}	
}

function siteOnload() {
	document.getElementById("preload_block").style.display = "none";
	document.getElementById("preload_block").style.visibility = "hidden";
	setElementsVisibility(true);
	var s = document.location.search ? document.location.search + "&" : "?";
	document.getElementById("rich_media_frame").src = "RichMediaPage.aspx" +
		s + "bannerFilePath=" + document.location.pathname +
		"&now=" + (new Date()).getTime();
}

function hiddenPostOnload() {
	var d = window.frames['hidden_post'].document;
	var poll = d.getElementById('cw_pool_block');
	if (poll) {
		document.getElementById('cw_pool_block').innerHTML = poll.innerHTML;
	}
	var events = d.getElementById("events_block");
	if (events) {
		var inputs = events.getElementsByTagName("input");
		if (inputs && inputs.length > 0) {
			var input = inputs[0];
			document.getElementById(input.id).value = input.value;
		}
	}
}

var staff = {
	activeImage: null,
	activeDiv: null,
	open: function(index) {
		var img = document.getElementById("staff_cat_image_" + (index ? index : 0));
		if (img) {
			img.onclick();
		}
	},
	onclick: function(img, index, activeSrc) {
		if (this.activeImage) {
			this.activeImage.src = this.activeImage.passiveSrc;
		}
		img.passiveSrc = img.src;
		img.src = activeSrc;
		this.activeImage = img;
		
		if (this.activeDiv) {
			this.activeDiv.style.display = "none";
		}
		this.activeDiv = document.getElementById("staff_cat_" + index);
		this.activeDiv.style.display = "";
		
		return false;
	}
};

var gallery = {
	div: null,
	imageDiv: null,
	image: null,
	label: null,
	showing: 0,
	isIE: (navigator.userAgent.indexOf("Opera") < 0) && (navigator.userAgent.indexOf("Gecko") < 0),
	init: function(src) {
		var self = this;
		var hideFunc = function() {self.hide();};
		
		this.div = document.createElement("div");
		this.div.style.position = "absolute";
		this.div.style.zIndex = 50;
		this.div.style.left = 0;
		this.div.style.top = 0;
		if (this.isIE) {
			this.div.style.background = "#000000";
		} else {
			var imgOp20 = document.createElement("img");
			imgOp20.src = "imgs/page_inner/opacity20.png";
			var imgOp40 = document.createElement("img");
			imgOp40.src = "imgs/page_inner/opacity40.png";
			var imgOp60 = document.createElement("img");
			imgOp60.src = "imgs/page_inner/opacity60.png";
		}
		this.div.onclick = hideFunc;
		document.body.appendChild(this.div);

		this.imageDiv = document.createElement("div");
		this.imageDiv.style.position = "absolute";
		this.imageDiv.style.zIndex = 51;
		this.imageDiv.style.textAlign = "center";
		this.imageDiv.style.color = "#ffffff";
		this.imageDiv.style.fontFamily = "Tahoma";
		this.imageDiv.style.fontSize = "9pt";
		this.imageDiv.style.fontWeight = "bold";
		this.imageDiv.style.cursor = "pointer";
		this.imageDiv.onclick = hideFunc;
		document.body.appendChild(this.imageDiv);
		
		this.image = document.createElement("img");
		this.image.src = src;
		this.image.style.border = "solid 3px #FFFFFF";
		this.image.style.MozBorderRadius = "3px";
		this.imageDiv.appendChild(this.image);
		
		this.imageDiv.appendChild(document.createElement("br"));
		this.imageDiv.appendChild(document.createTextNode("close"));

		if (!window.onresize) {
			window.onresize = function() {self.setPosition();};
		}
	},
	processShowing: function(s) {
		if (this.showing > 0) {
			if (this.showing <= 3) {
				if (this.isIE) {
					this.div.style.filter = "alpha(opacity=" + (this.showing * 20) + ")";
					//this.div.style.MozOpacity = this.showing / 5;
					this.imageDiv.style.filter = "alpha(opacity=" + (this.showing * 33.3) + ")";
					//this.imageDiv.style.MozOpacity = this.showing / 3;
				} else {
					this.div.style.backgroundImage = "url(imgs/page_inner/opacity" + (this.showing * 20) + ".png)";
				}
			}
			this.showing++;
			var self = this;
			window.setTimeout(function() {self.processShowing();}, 100);
			this.setPosition();
		}
	},
	setPosition: function() {
		if (this.div) {
			this.div.style.width = document.documentElement.scrollWidth + "px";
			this.div.style.height = document.documentElement.scrollHeight + "px";
			var w = window.innerWidth || document.documentElement.clientWidth;
			this.imageDiv.style.left = (document.documentElement.scrollLeft + (w - this.imageDiv.offsetWidth) / 2) + "px";
			var h = window.innerHeight || document.documentElement.clientHeight;
			this.imageDiv.style.top = (document.documentElement.scrollTop + (h - this.imageDiv.offsetHeight) / 2) + "px";
		}
	},
	show: function(src) {
		setElementsVisibility(false);
		this.init(src);
		this.showing = 1;
		this.processShowing();
		this.setPosition();
	},
	hide: function() {
		this.showing = 0;
		document.body.removeChild(this.imageDiv);
		document.body.removeChild(this.div);
		setElementsVisibility(true);
	}
};
