function gif_over(img) {
	img.src=img.src.replace('.gif','r.gif');
};
function gif_out(img) {
	img.src=img.src.replace('r.gif','.gif');
};

function bg_main_over(td) {
	td.style.backgroundImage="url('../../img/tdbgr.gif')";
}

function bg_main_out(td) {
	td.style.backgroundImage="url('../../img/tdbg.gif')";
}

function showLayer(layerName) {
	eval('document.all'+'["'+layerName+'"]'+'.style'+'.display=""');
 	//document.layerName.visibility="visible"';
}

function openPopup(url) {
    var insert_div = '<div id="popup" style="display:block; position:fixed; *position: absolute; z-index:99; top:50%; left:50%;"><img src="/img/preloader.gif" alt="" onclick="closePopup();" /></div><div id="backgroundPopup" style="display:none; position:absolute; height:100%; width:100%; top:0; left:0; background:#000000; z-index:50;" onclick="closePopup();"></div>';
    $("body").append(insert_div);
    centerPopup();
	$("#popup").fadeIn("slow");
    $("#backgroundPopup").css({
	   "opacity": "0.7"
	});
    $("#backgroundPopup").fadeIn("slow");
    $("#popup").load(url,function(){
        centerPopup();
        if($("#player").html() != null){
            flowplayer("player", "/img/flash/flowplayer-3.1.1.swf", { clip: { autoPlay:true } });
        }
    });
}

function closePopup() {
	$("#popup").fadeOut("fast",function(){
	   $("#popup").remove();
	});
    $("#backgroundPopup").fadeOut("slow",function(){
	   $("#backgroundPopup").remove();
	});
}

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};


function centerPopup(){
	var popupHeight = $("#popup").height();
	var popupWidth = $("#popup").width();
	$("#popup").css({
        "margin-top": -popupHeight/2,
		"margin-left": -popupWidth/2
	});	
    var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var arrPageSizes = ___getPageSize();
	$("#backgroundPopup").css({
		width:arrPageSizes[0],
		height:arrPageSizes[1]
	});
}