// gScripts.js ver 1.00

scriptName = '';
startParams = '?';
divParams = '&';

function compose(PathInfo, Title) {
	window.open(scriptName + "/" + PathInfo, Title, "width=620,height=570,status=no,location=no,resizable=yes,toolbar=no,menubar=no,scrollbars=no");
}

function openPopup(PathInfo, Title, width, height) {
	window.open(scriptName + "/" + PathInfo, Title, "width="+width+",height="+height+",status=no,location=no,resizable=yes,toolbar=no,menubar=no,scrollbars=no");
}

function LaunchLogin(aForm) {
	aForm.action = scriptName + '/dologin';
	aForm.submit;
}

function LaunchForm(aForm, action) {
	if (action > '') {
		action = '/' + action;
	}
	aForm.action = scriptName + action;
	aForm.submit;
}

function LaunchFormURL(aForm, URL) {
	aForm.action = '';
	aForm.submit;
}

function LaunchMenu(action, href, params) {
	if (href > '') {
		window.location = href;
	}
	else
	{
		if (action > '') {
			action = '/' + action;
		}
		window.location = scriptName + action;
	}
}

function LaunchForm(aForm, action) {
	if (action > '') {
		action = '/' + action;
	}
	aForm.action = scriptName + action;
	aForm.submit;
}

function LaunchURL(action, params) {
	if (action > '') {
		action = '/' + action
	}
	window.location = scriptName + action + startParams + divParams + params;
}

function Show(tabArray, divArray, aTab, aDiv) {
	for (i=0; i < tabArray.length; i++) {
		if (tabArray[i] == aTab) {
			ShowTab(tabArray[i]);
		}
		else {
			HideTab(tabArray[i]);
		}
		if (divArray[i] == aDiv) {
			ShowDiv(divArray[i]);
		}
		else {
			HideDiv(divArray[i]);
		}
	}
}

function Hide(tabArray, aTab, aDiv) {
	for (i=0; i < tabArray.length -1 ; i++) {
		if (tabArray[i] == aTab) {
			HideTab(tabArray[i]);
		}
		else {
			ShowTab(tabArray[i]);
		}
		if (divArray[i] == aDiv) {
			HideDiv(divArray[i]);
		}
		else {
			ShowDiv(divArray[i]);
		}
	}
}

function ShowTab(aTab) {
	var el;

	if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
	{
		el = document.getElementById(aTab);
		el.className = 'tabSelected';
	}
}

function HideTab(aTab) {
	var el;

	if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
	{
		el = document.getElementById(aTab);
		el.className = 'tab';
	}
}

function ShowDiv(aDiv) {
	var el;

	if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
	{
		el = document.getElementById(aDiv);
		el.style.display = 'block';
		el.style.visibility = 'visible';
	}
	else if (document.all)	 // IE4+
	{
		el = document.all[aDiv];
		el.style.display = 'block';
		el.style.visibility = 'visible';
	}
}

function HideDiv(aDiv) {
	var el;

	if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
	{
		el = document.getElementById(aDiv);
		el.style.display = 'none';
		el.style.visibility = 'hidden';
	}
	else if (document.all)	 // IE4+
	{
		el = document.all[aDiv];
		el.style.display = 'none';
		el.style.visibility = 'hidden';
	}
}

function ModifyCell(aCell, theValue) {
	var el;

	if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
	{
		el = document.getElementById(aCell);
		el.width = theValue;
	}
	else if (document.all)	 // IE4+
	{
		el = document.all[aCell];
		el.width = theValue;
	}
}

function VerifyData(aForm) {

	if(aForm.Nome.value == "" || aForm.Nome.value == ' ')
	{ alert("Inserire il nome!");
		aForm.Nome.focus();
		return false; }

	if(aForm.Cognome.value == "" || aForm.Cognome.value == ' ')
	{ alert("Inserire il Cognome!");
		aForm.Cognome.focus();
		return false; }

	if(aForm.email.value == "")
	{ alert("Inserire l'indirizzo email!");
		aForm.email.focus();
		return false; }

	if(aForm.email.value.indexOf('@') == -1 || aForm.email.value.indexOf('.',0)==-1)
	{ alert("Questo indirizzo email non e' valido!\n\n Reinserirlo!");
		aForm.email.focus();
		return false; }
}

function JumpTo(newURL) {
  document.location = newURL;
}

var hLayer = false;

function sLayer(aDiv, aShow)
{
  var el;
  var aDisplay, aVisibility
  if (aShow) {
    aDisplay = 'block';
    aVisibility = 'visible';
  }
  else {
    aDisplay = 'none';
    aVisibility = 'hidden'; 
  }


  if (document.getElementById) // IE5+, NS6+, Mozilla/Gecko
  {
    el = document.getElementById(aDiv);
    el.style.display = aDisplay;
    el.style.visibility = aVisibility;
  }
  else if (document.all) // IE4+
  {
    el = document.all[aDiv];
    el.style.display = aDisplay;
    el.style.visibility = aVisibility;
  }
  else if (document.layers) // NS4
  {
    el = document.layers[aDiv];
    el.visibility = aVisibility;
  }
}

function sethomepage (itemid)
{
   document.frm_homepage.newsid.value = itemid;
}

function submitForm(aForm) {
  var s = '';
  for (var i = 0; i<aForm.elements.length; i++) {
    if ((aForm.elements[i].type == 'text') || (aForm.elements[i].type == 'hidden'))
      s = s + aForm.elements[i].name + ':' + aForm.elements[i].value + ';';
  }
  aForm.action = aForm.action + s;
  aForm.submit;
}



