var VIDEO1_popup;
$(document).ready(VIDEO1_init);

function VIDEO1_init(){
	$("a.VIDEO1").click(function(event){
		event.preventDefault();
		this.blur();
		VIDEO1_show(this.href);
		VIDEO1_open_popup();
	});
}

function VIDEO1_open_popup() {
	
	if (VIDEO1_popup == undefined || VIDEO1_popup.closed) {	
		var width = 500;
		var height = 600;
		var features = '';
		var x, y;
		x = (640 - width)/2, y = (480 - height)/2;
		if (screen) {
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		if (screen.availWidth > 1800) { 
			x = ((screen.availWidth/2) - width)/2; 
		} 
		VIDEO1_popup = window.open('video1.php','VIDEO1','scrollbars=no,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+','+features);
	}
	VIDEO1_popup.focus();
}	

function VIDEO1_close_remote() {
	var opener = window.opener;
	if (opener) {
		this.close();
		opener.focus();
		opener.VIDEO1_remove();
	}
}		

function VIDEO1_show(url) {
//	if ( !$("#VIDEO1_HideSelect").length ) {
//		$("body").append("<iframe id='VIDEO1_HideSelect'></iframe><div id='VIDEO1_overlay'></div><div id='VIDEO1_window'></div>");
//		$("#VIDEO1_overlay").click(VIDEO1_remove);
//	}
//	$(window).scroll(VIDEO1_position);
//	VIDEO1_overlaySize();
}

function VIDEO1_remove() {
 	$("#VIDEO1_imageOff").unbind("click");
	$("#VIDEO1_overlay").unbind("click");
	$("#VIDEO1_closeWindowButton").unbind("click");
	$("#VIDEO1_window").fadeOut("fast",function(){$('#VIDEO1_window,#VIDEO1_overlay,#VIDEO1_HideSelect').remove();});
	$("#VIDEO1_load").remove();
	return false;
}

function VIDEO1_position() {
	var pagesize = VIDEO1_getPageSize();	
	var arrayPageScroll = VIDEO1_getPageScrollTop();
	var style = {width: VIDEO1_WIDTH, left: (arrayPageScroll[0] + (pagesize[0] - VIDEO1_WIDTH)/2), top: (arrayPageScroll[1] + (pagesize[1]-VIDEO1_HEIGHT)/2)};
	$("#VIDEO1_window").css(style);
}

function VIDEO1_overlaySize(){
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} else { 
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  	}
	$("#VIDEO1_overlay").css({"height": yScroll, "width": xScroll});
	$("#VIDEO1_HideSelect").css({"height": yScroll,"width": xScroll});
}

function VIDEO1_getPageScrollTop(){
	var yScrolltop;
	var xScrollleft;
	if (self.pageYOffset || self.pageXOffset) {
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	} else if (document.body) {
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

function VIDEO1_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}
