// Code by Andrea Moi (IUX) - Mind srl - http://wwmind.com 

// COMMON JS CODE FOR FORM

var InternetExplorer=navigator.appName.indexOf("Microsoft")!=-1;
var NetscapeNavigator=navigator.appName.indexOf("Netscape")!=-1;
var Gecko=navigator.appName.indexOf("Gecko")!=-1;
var Safari=navigator.appName.indexOf("Safari")!=-1;
var browserVer=parseInt(navigator.appVersion);

var rootPath="";	// questa var deve essere inizializzata

// open a windows (custom parameters)
function newWinCust(url,wname,wparam)		{
	// new windows
	var siteWindowVar=open(url,wname,"directories=no"+wparam);
	if (NetscapeNavigator||browserVer>=4)	{	siteWindowVar.focus();	siteWindowVar.focus();	}
}

// get element by ID (with browser check)
function getObj(objID){
	if (!document.getElementById)	return null;	// not compatible
	//else
	return document.getElementById(objID);
}

// show and hide DIV
function alternateShow(divToShow,divToHide) {

	// hide
	if (divToHide!=null&&divToHide.style!=null) {
		divToHide.style.display = "none";
	}

	// show
	if (divToShow!=null&&divToShow.style!=null) {
		divToShow.style.display = "block";
	}
}


// select: autosubmit
function autoSubmitSelect (selObj,emptyAlso)	{
	var v=selObj[selObj.selectedIndex].value;
	if (v!=""||emptyAlso)	selObj.form.submit();
}


// pop up vari

// send a card
function inviaCard(idcard,startMode)	{
	newWinCust(rootPath+"cards/send/?id="+idcard+"&startMode="+startMode,"sendcard","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,location=no,width=550,height=400");
}

// send to friend
function send2friend(what,idrel,obj) {
	newWinCust(rootPath+"send2friend/?"+what+"="+escape(idrel)+"&obj="+escape(obj),"send2friend","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=500,height=330");
}

// invita un amico
function invitaUnAmico() {
	newWinCust(rootPath+"community/invitaunamico/","invitaUnAmico","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=500,height=330");
}

// msg - send
function newMessage(to,type,reply) {
	newWinCust(rootPath+"community/msg/send.php?to="+escape(to)+"&type="+escape(type)+"&reply="+escape(reply),"message","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=550,height=500");
}

// msg - read
function readMessage(msgid) {
	newWinCust(rootPath+"community/msg/read.php?msgid="+escape(msgid),"message","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=550,height=500");
}


// regolamento community
function regolamentoCommunity() {
	newWinCust(rootPath+"popup/regolamento.php","community","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=400,height=350");
}

// regolamento community associazione
function regolamentoCommunityAss() {
	newWinCust(rootPath+"popup/regolamentoasspc.php","community","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=400,height=350");
}

// faq community
function faqCommunity() {
	newWinCust(rootPath+"popup/faq.php","community","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=400,height=350");
}

// faq community associazione
function faqCommunityAss() {
	newWinCust(rootPath+"popup/faqasspc.php","community","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=400,height=350");
}

// diventare location
function divLocation() {
	newWinCust(rootPath+"popup/divlocation.php","community","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=400,height=320");
}

// privacy disclaimer
function privacy() {
	newWinCust(rootPath+"popup/privacy.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=350,height=300");
}

// privacy disclaimer associazione
function privacyAss() {
	newWinCust(rootPath+"popup/privacyasspc.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=350,height=300");
}

// copyright
function copyright() {
	newWinCust(rootPath+"popup/copyright.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=350,height=260");
}

// credits
function credits() {
	newWinCust(rootPath+"popup/credits.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=350,height=260");
}

// contacts
function contacts() {
	newWinCust(rootPath+"popup/contacts.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=350,height=280");
}

// privacy disclaimer
function jobsPrivacy() {
	newWinCust(rootPath+"popup/jobsPrivacy.php","information","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=550,height=450");
}
