﻿
var WindowTemp;
function popup_open(popupfile, popupname, popupwidth, popupheight, resize, status, scroll, tool, menu) {
	//titlebar=0;
	var winleft = (screen.width - popupwidth) / 2;
	var wintop = (screen.height - popupheight) / 2;
	var params = "width=" + popupwidth + ",height=" + popupheight + ",top=" + wintop + ",left=" + winleft + ",resizable=" + resize + ",status=" + status + ",scrollbars=" + scroll + ",toolbar=" + tool + ",location=0,directories=0,menubar=" + menu + "";
	if((navigator.appName.indexOf("Explorer")!=-1)&&(parseInt(navigator.appVersion.substring(0,1))<4)) {
		newwin = window.open(popupfile,popupname,params);
	}
	else {
		if(WindowTemp) {
			if(!WindowTemp.closed) {
				WindowTemp.close();
				WindowTemp="";
			}
		}

		newwin = window.open(popupfile,popupname,params);
		WindowTemp = newwin;
		WindowTemp.name = "WindowTemp";
		newwin="";
	}
}

function TransformEnterKpress(evt,myObj) {
	evt = (evt) ? evt : ((event) ? event : null);
	if (evt) {
		var charCode = (document.all) ? event.keyCode : evt.which;
		if (charCode == 13) {
			for (j = 0; j < document.forms[0].length; j++) {
				if (document.forms[0].elements[j].name == myObj.name) {
					document.forms[0].elements[j+1].focus();
					break;
				}
			}
			return false;
		}
	}
}

function BlockEnterKpress(evt,myObj) {
	evt = (evt) ? evt : ((event) ? event : null);
	if (evt) {
		var charCode = (document.all) ? event.keyCode : evt.which;
		if (charCode == 13) {
			return false;
		}
	}
}

/* scroller index magazine */
function movedownMagazineScroller() {
	if (parseInt(crossobj.style.top)>-(contentheight-containerHeight)) //l'altezza del contenitore
		crossobj.style.top=parseInt(crossobj.style.top)-speed + "px";

	movedownvarMgSc=setTimeout("movedownMagazineScroller()",100)
}
function moveupMagazineScroller() {
	if (parseInt(crossobj.style.top)<=0)
		crossobj.style.top=parseInt(crossobj.style.top)+speed+ "px";

	moveupvarMgSc=setTimeout("moveupMagazineScroller()",100)
}
function getcontent_height() {
	contentheight=crossobj.offsetHeight;
	if (contentheight<containerHeight) {
		var tableScroll=document.getElementById? document.getElementById("tblScroll") : document.all.content
		if (tableScroll) {
			tableScroll.style.visibility="hidden";
		}
	}
}
function GetOnMouseWheelMgSc(oEvent) {
	if (!oEvent)
		oEvent = window.event;

	var MouseWheelDelta = 0;
	if (IE) {
		MouseWheelDelta = oEvent.wheelDelta;
	}
	else {
		MouseWheelDelta = -(oEvent.detail);
	}
	if (MouseWheelDelta<0) {
		movedownMagazineScroller();
		clearTimeout(movedownvarMgSc);
	}
	else {
		moveupMagazineScroller();
		clearTimeout(moveupvarMgSc);
	}
}

/* free pages */
function viewFreePage(freePageId, hostId) {
	$(document).ready(function(){
		$("div#divFreePage").hide("fast");
		$("div#divFreePage").html("");
		$("div#divFreePage").load("/common/include/freepage.aspx?fpid=" + freePageId + "&hhid=" + hostId);
		$("div#divFreePage").show("slow");
	});
	return;
}
function hideFreePage() {
	$(document).ready(function(){
		$("div#divFreePage").html("");
		$("div#divFreePage").hide("slow");
	});
	return false;
}

function replaceHistoryContent(sFind, sReplace) {
	$('.css-cover-history-cont-bottom').each(function() {
		var thisItem = $(this);
		var thisHtml = thisItem.html();
		var newHtml = thisHtml.replace(sFind, sReplace);
		thisItem.html(newHtml);
	});
}
function replaceTitlePartContent(sFind, sReplace) {
	$('.css-sx-title-part-number').each(function() {
		var thisItem = $(this);
		var thisHtml = thisItem.html();
		var newHtml = thisHtml.replace(sFind, sReplace);
		thisItem.html(newHtml);
	});
}

