function showImage(sImageName)
{
	var oPopup = window.createPopup();
	var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "lightyellow";
	oPopupBody.style.border = "solid black 1px";    
	//oPopupBody.style.margin = "10px";
	oPopupBody.innerHTML = "<img src='" + sImageName + "'>";
	oPopup.show(200, 200, 200, 200, null);
}


function isDate (year, month, day)
{
	// Original post: Dan Osborne <dano@specialist.co.uk>
	//                4/26/1999
	//                JavaScript <javascript@LaTech.edu>
	// Modified by:   Walter Torres <walter@torres.ws>
	//                4/29/2001

	// This is an interesting way to do validation of dates!

	// First, decrement the given month;
	// since humans think in base ONE and
	// JavaScript dates for months think in base ZERO.
	//      Human month range : 1 - 12
	// JavaScript month range : 0 - 11
	month--;  

	// Then, create a new JS Date Object based upon given values.
	// NOTICE: This will convert 2/32/2000 to 3/3/2000
	//         JavaScript 'helps' you like this.
	var objTempDate = new Date(year,month,day);

	// Now, tear that new Data Object apart and see if the
	// values it gives back matches what we gave it.
	return	( ( objTempDate.getFullYear() == year  ) &&
			  ( objTempDate.getMonth()    == month ) &&
			  ( objTempDate.getDate()     == day)  )  ? true : false

	// Very nice method Dan!
}

function isTime (intHour, intMinute, intSecond)
{
	// Baased upon:   Dan Osborne <dano@specialist.co.uk>
	//                4/26/1999
	//                JavaScript <javascript@LaTech.edu>
	// Modified by:   Walter Torres <walter@torres.ws>
	//                4/29/2001

	// This is an interesting way to do validation of Time!

	// Create a new JS Date Object based upon given values.
	var objTempTime = new Date( 0, 0, 1, intHour, intMinute, intSecond );

	// Now, tear that new Data Object apart and see if the
	// values it gives back matches what we gave it.
	return	( ( objTempTime.getHours()   == intHour   )  &&
			  ( objTempTime.getMinutes() == intMinute ) &&
			  ( objTempTime.getSeconds() == intSecond ) ) ? true : false
}



function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("L'indirizzo e-mail non sembra essere corretto (verifica @ e .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("Lo username non sembra essere valido.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("L'indirizzo IP di destinazione non è valido!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Il nome del dominio non sembra essere corretto.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("L'indizzo deve terminare con un nome di dominio a tre lettere, oppure con una sigla di Paese con due lettere.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="L'indizzo non include un hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


function getEditPage(className)
{
	switch (className)
	{
	case "Process":
		return "ProcessAdmin.asp";
	default:
		return "FolderAdmin.asp";
	}
}

function checkEmpty(ctrl, msg)
{
	if (ctrl.value.length == 0)
	{
		alert(msg);
		return false;
	}
	
	return true;
}

function checkSelect(ctrl, msg, bad_index)
{
	if (ctrl.selectedIndex == bad_index)
	{
		alert(msg);
		return false;
	}
	
	return true;
}

function getKindDisplayName(kind)
{
	switch (kind)
	{
	case "folder":
		return "Cartella";
	case "process":
		return "Processo";
	case "news":
		return "News";
	case "task":
		return "Task";
	default:
		return null;
	}
}

function canHaveChildren(kind)
{
	return kind == "folder";
}

function downloadFile(id)
{
	//var skey = location.search.substr(6, 38);
	location.href = "../DownloadFile.asp?id=" + id;
}

function showEditPage(className, id, cont_id)
{
	var contentPane = parent.document.all("contentpane");
	var skey = location.search.substr(6, 38);



	switch (className)
	{
		case "Object/Process":
			contentPane.src = "Process.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/PrivateFileCategory":
			contentPane.src = "PrivateFileCategory.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Provider":
			contentPane.src = "Provider.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Thread":
			contentPane.src = "Thread.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Reference":
			contentPane.src = "Reference.asp?skey=" + skey + "&id=" + id;
			break;
			
		case "Object/ProcessPerCustomer":
			contentPane.src = "ProcessPerCustomer.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/ProcessPerProvider":
			contentPane.src = "ProcessPerProvider.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/ProviderProject":
			contentPane.src = "ProviderProject.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/CustomerProject":
			contentPane.src = "CustomerProject.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/CustomerEstimate":
			contentPane.src = "CustomerEstimate.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/CustomerTask":
			contentPane.src = "CustomerTask.asp?skey=" + skey + "&id=" + id + "&container_id=" + cont_id;
			break;

		case "Object/Event":
			contentPane.src = "Event.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Contact":
			contentPane.src = "Contact.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/News":
			contentPane.src = "News.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/WebLink":
			contentPane.src = "WebLink.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Task":
			contentPane.src = "Task.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/EditablePage":
			contentPane.src	= "EditablePage.asp?skey=" + skey + "&id=" + id;
			break;
			
		case "Object/Financing":
			contentPane.src	= "Financing.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Link/NewsLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/NewsLink&id=" + id;
			break;

		case "Object/Link/WebLinkLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/WebLinkLink&id=" + id;
			break;

		case "Object/Link/EventLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/EventLink&id=" + id;
			break;

		case "Object/Link/LearningLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/LearningLink&id=" + id;
			break;

		case "Object/Link/FaqLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/FaqLink&id=" + id;
			break;

		case "Object/Link/ProcessLink":
			contentPane.src	= "Link.asp?skey=" + skey + "&link_class_name=Object/Link/ProcessLink&id=" + id;
			break;

		case "Object/File":
			contentPane.src	= "File.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Faq":
			contentPane.src	= "Faq.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Learning":
			contentPane.src	= "Learning.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/SiteInfo":
			contentPane.src	= "SiteInfo.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/SimpleUserImport":
			contentPane.src	= "SimpleUserImport.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/CustomInfoDef":
			contentPane.src	= "CustomInfoDef.asp?skey=" + skey + "&id=" + id;
			break;

		//case "NewsLinkFolder":
		//	contentPane.src	= "NewsLinkFolder.asp?skey=" + skey + "&id=" + id;
		//	break;

		case "Object/Folder/PageEditorFolder":
			contentPane.src = "Folder.asp?skey=" + skey + "&readonly=1&static=1&id=" + id;
			break;

		case "Object/Info":
			contentPane.src = "Info.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Customer":
			contentPane.src = "Customer.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/CalendarItem":
			contentPane.src = "CalendarItem.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/File/PrivateFile":
			contentPane.src = "PrivateFile.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/File/PublicFile":
			contentPane.src = "PublicFile.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/AccessorTable":
			contentPane.src = "AccessorTable.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/SimpleUser":
			contentPane.src = "SimpleUser.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/ReferenceCategory":
			contentPane.src = "ReferenceCategory.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/LearningTipologia":
			contentPane.src = "LearningTipologia.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/LearningDestinatario":
			contentPane.src = "LearningDestinatario.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/LearningArgomento":
			contentPane.src = "LearningArgomento.asp?skey=" + skey + "&id=" + id;
			break;

		case "Object/Folder/SimpleUserFolder":
			contentPane.src = "Folder.asp?skey=" + skey + "&readonly=1&xls=SimpleUserList.xsl&get_sp=ListSimpleUsers&id=" + id;
			break;

		default:
			if (id == 347 || id == 1719)
				contentPane.src = "Folder.asp?skey=" + skey + "&readonly=1&static=1&id=" + id;
			else
				contentPane.src = "Folder.asp?skey=" + skey + "&readonly=1&id=" + id;
			break;
	}
}

