//'@Project: WebSite	@Type: Libreria
//'Common - © 2005 - 2009 KinderSoft
//'v.1.10.r.29.11.07

var ie = (navigator.userAgent.indexOf("MSIE")!=-1);
var ns = (document.layers ? true : false);
var w3 = (navigator.userAgent.indexOf("Firefox")!=-1);
if (!ie && !ns && !w3) w3=true;

var fsubmit_exec;

var globalStopTab = false;
var globalStopEsc = true;

function _CloseOnEsc(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if (globalStopEsc) {
		if (code == 27) window.close();
	}
	if (globalStopTab) {
		if (code == 9) {
			e.cancelBubble = true;
			if (e.stopPropagation) e.stopPropagation();
			if (e.preventDefault) e.preventDefault()
			return false;
		}
	}
}


function log(){	document.forms[0].submit();}

function fsubmit(){
	var Ok = true;
	if (fsubmit_exec) {
		if (fsubmit_exec.length>0) {
			var v = fsubmit_exec;
			fsubmit_exec = '';
			Ok = eval(v);
		}
	}
	if (Ok) document.forms[0].submit();
}

function shownews(n){
	u = "newshow.asp?n="+ n
	sn = window.open(u,'wnews','location=0,resizable=0,scrollbars=1,toolbar=0,menubar=0,width=500,height=480,left=20,top=20;');
	sn.focus();
}

function showevents(n){
	u = "eventshow.asp?n="+ n
	sn = window.open(u,'wevents','location=0,resizable=0,scrollbars=1,toolbar=0,menubar=0,width=500,height=480,left=20,top=20;');
	sn.focus();
}

function PopUpX(u,x,y,l,t){
	var wPopUpX = window.open(u,'wPopUpX','location=0,resizable=0,scrollbars=1,toolbar=0,menubar=0,width='+x+',height='+y+',left='+l+',top='+'t;');
	wPopUpX.focus();
}

function PopUpXCenter(u,x,y,w){
	var DoNotCenterVertical=false;
	if (x==0) {x=(screen.width -80)}
	if (y==0) {y=(screen.height -130);DoNotCenterVertical=true;}
	var a_int_windowWidth=x;
	var a_int_windowHeight=y;
	var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
	var int_windowTop = (screen.height - a_int_windowHeight) / 2;
	if (DoNotCenterVertical) {int_windowTop=40}
	if (arguments.length<4) w = 'wPopUpXCenter';
	var wPopUpXCenter = window.open(u,w,'location=0,resizable=0,status=0,scrollbars=0,toolbar=0,menubar=0,width='+a_int_windowWidth+',height='+a_int_windowHeight+',left='+int_windowLeft+',top='+int_windowTop+';');
	wPopUpXCenter.focus();
}

function PopUpXCenterBar(u,x,y,w){
	var DoNotCenterVertical=false;
	if (x==0) {x=(screen.width -80)}
	if (y==0) {y=(screen.height -130);DoNotCenterVertical=true;}
	var a_int_windowWidth=x;
	var a_int_windowHeight=y;
	var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
	var int_windowTop = (screen.height - a_int_windowHeight) / 2;
	if (DoNotCenterVertical) {int_windowTop=40}
	if (arguments.length<4) w = 'wPopUpXCenterBar';
	var wPopUpXCenterBar = window.open(u,w,'location=0,resizable=0,status=0,scrollbars=1,toolbar=0,menubar=0,width='+a_int_windowWidth+',height='+a_int_windowHeight+',left='+int_windowLeft+',top='+int_windowTop+';');
	wPopUpXCenterBar.focus();
}

function BOX_DIV_PM_swap(d) {
	var img1=document.getElementById(d+'_img');
	var div2=document.getElementById(d+'_div');
	var status=div2.style.display;
	if (status=='none') {
		status='block';
		img1.src='../img/BoxMinus.gif'
	}
	else {
		status='none'
		img1.src='../img/BoxPlus.gif'
	}
	div2.style.display=status;
	SetCookie(d,status,1000)
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function OpenSpeedWin(o) {
	o.blur();
	if (o.value.length > 0) {
		var sw = window.open(o.value, 'w', 'location=1, border=1, resizable=1, status=1, scrollbars=1, toolbar=1, menubar=1, locationbar=1, top=0, left=0, width='+(screen.availWidth-100)+', height='+(screen.availHeight-200)+';');
		sw.focus(); 
		o.value='';
	}
}

function OpenBlankWin(u) {
	if (u.length > 0) {
		var sw = window.open(u, 'w', 'location=1, border=1, resizable=1, status=1, scrollbars=1, toolbar=1, menubar=1, locationbar=1, top=0, left=0, width='+(screen.availWidth-100)+', height='+(screen.availHeight-200)+';');
		sw.focus(); 
	}
}

function kPageClick(id,n) {
	var oLnk, oUpTab, oDiv;

	//all off
	for (var i=1;i<=n;i++) {
		oLnk = document.getElementById('kPageTabLnk'+i);
		oUpTab = document.getElementById('kPageTabUpTab'+i);
		oDiv = document.getElementById('kPageTabDiv'+i);
		oLnk.className='kPageTabLnk';
		oUpTab.className='kPageTabUpTab';
		oDiv.className='kPageTabInnerDiv';
	}
	//id on
	oLnk = document.getElementById('kPageTabLnk'+id);
	oUpTab = document.getElementById('kPageTabUpTab'+id);
	oDiv = document.getElementById('kPageTabDiv'+id);
	oLnk.className='kPageTabLnkSel';
	oUpTab.className='kPageTabUpTabSel';
	oDiv.className='kPageTabInnerDivSel';
	oLnk.blur();
}

function ImgFilterOn(t){
	if (w3)	t.style.opacity='1.0'
	else t.filters.alpha.opacity='100'
}
function ImgFilterOff(t){
	if (w3)	t.style.opacity='0.5'
	else t.filters.alpha.opacity='50'
}

function IsDate(dateStr)
{
	var datePat = /^((3[01]|[12]\d|0?[1-9])\/(0?[13578]|10|12)\/(\d\d)?\d\d|(30|[12]\d|0?[1-9])\/(0?[469]|11)\/(\d\d)?\d\d|(2[0-8]|[01]\d|0?[1-9])\/(0?2)\/(\d\d)?\d\d|29\/(0?2)\/(1200|1600|2000|2400|2800|00)|29\/(0?2)\/(\d\d)?(0[48]|[2468][048]|[13579][26]))$/;
    var matchArray = dateStr.match(datePat); 
	return !(matchArray == null)
}

