function IR_IsDateMinorOrEqual(IR_cDate, IR_cThresholdDate)
{
	var IR_bResult;
	var IR_nYear;
	var IR_nDay;
	var IR_nMonth;
	var IR_nThresholdYear;
	var IR_nThresholdDay;
	var IR_nThresholdMonth;
	var IR_cThresholdDateAsString;

	IR_bResult = false;

	IR_cThresholdDateAsString = IR_cThresholdDate;
	IR_nYear = IR_cDate.substr(6,4);
	IR_nThresholdYear = IR_cThresholdDateAsString.substr(6,4);

	if(IR_nYear <= IR_nThresholdYear)
	{
		IR_bResult = true;

		if(IR_nYear == IR_nThresholdYear)
		{
			IR_bResult = false;

			IR_nMonth = IR_cDate.substr(3,2);
			IR_nThresholdMonth = IR_cThresholdDateAsString.substr(3,2);

			if(IR_nMonth <= IR_nThresholdMonth)
			{
				IR_bResult = true;

				if(IR_nMonth == IR_nThresholdMonth)
				{
					IR_bResult = false;

					IR_nDay = IR_cDate.substr(0,2);
					IR_nThresholdDay = IR_cThresholdDateAsString.substr(0,2);

					if(IR_nDay <= IR_nThresholdDay)
						IR_bResult = true;
				}
			}
		}
	}

	return IR_bResult;
}



function IR_IsDateMinor(IR_cDate, IR_cThresholdDate)
{
	var IR_bResult;
	var IR_nYear;
	var IR_nDay;
	var IR_nMonth;
	var IR_nThresholdYear;
	var IR_nThresholdDay;
	var IR_nThresholdMonth;
	var IR_cThresholdDateAsString;

	IR_bResult = false;

	IR_cThresholdDateAsString = IR_cThresholdDate;
	IR_nYear = IR_cDate.substr(6,4);
	IR_nThresholdYear = IR_cThresholdDateAsString.substr(6,4);

	if(IR_nYear < IR_nThresholdYear)
		IR_bResult = true;
	else
	{
		if(IR_nYear == IR_nThresholdYear)
		{
			IR_bResult = false;

			IR_nMonth = IR_cDate.substr(3,2);
			IR_nThresholdMonth = IR_cThresholdDateAsString.substr(3,2);

			if(IR_nMonth < IR_nThresholdMonth)
				IR_bResult = true;
			else
			{
				if(IR_nMonth == IR_nThresholdMonth)
				{
					IR_bResult = false;

					IR_nDay = IR_cDate.substr(0,2);
					IR_nThresholdDay = IR_cThresholdDateAsString.substr(0,2);

					if(IR_nDay < IR_nThresholdDay)
						IR_bResult = true;
					else
					{
						if(IR_nDay == IR_nThresholdDay)
							IR_bResult = false;
					}
				}
			}
		}
	}
//alert("ret da minor : " + IR_bResult);
	return IR_bResult;
}



function IR_fcgGetComboBoxSelectedItemValue(IR_oComboBox)
{
	var IR_cValue = '';

	if(IR_oComboBox.selectedIndex != -1)
		IR_cValue = IR_oComboBox.options[IR_oComboBox.selectedIndex].value;
			
	return IR_cValue;
}

function IR_fcgGetRadioButtonSelectedItemValue(IR_oRadioButton)
{
	var IR_x;
	var IR_cValue = '';

	for(IR_x = 0; IR_x < IR_oRadioButton.length; IR_x++)
	{
		if(IR_oRadioButton[IR_x].checked == true)
			IR_cValue = IR_oRadioButton[IR_x].value;
	}

	return IR_cValue;
}

function IR_fcgGetComboBoxSelectedItemText(IR_oComboBox)
{
	var IR_cValue = '';

	if(IR_oComboBox.selectedIndex != -1)
		IR_cValue = IR_oComboBox.options[IR_oComboBox.selectedIndex].text;
		
	return IR_cValue;
}

function IR_LeftTrimExtended(IR_cString, IR_cChar)
{
	var IR_x;
	var IR_nLength;
  var IR_cTrimmed;

	IR_x = 0;
	IR_cTrimmed = '';

	IR_nLength = IR_cString.length;

	while((IR_x < IR_nLength) && (IR_cString.charAt(IR_x) == IR_cChar))
		IR_x++;

	if(IR_x < IR_nLength)
		IR_cTrimmed = IR_cString.substring(IR_x, IR_nLength);

	return IR_cTrimmed;
}

function IR_IsValidString(IR_cString, IR_nFrom, IR_nTo, IR_cMask)
{
	var IR_i;
	var IR_j;
	var IR_ch;
  var IR_bIsValid;
	IR_bIsValid = true;
	for(IR_i = IR_nFrom;  IR_i < IR_nTo;  IR_i++)
	{
		IR_ch = IR_cString.charAt(IR_i);
		for(IR_j = 0;  IR_j < IR_cMask.length;  IR_j++)
		{
			if(IR_ch == IR_cMask.charAt(IR_j))
				break;
		}
		if(IR_j == IR_cMask.length)
		{
			IR_bIsValid = false;
			break;
		}
	}
	return IR_bIsValid;
}

function IR_IsStringOfDigits(IR_cString, IR_nFrom, IR_nTo)
{
	return IR_IsValidString(IR_cString, IR_nFrom, IR_nTo, '1234567890');
}


function IR_IsValidDate(IR_cDate)
{
	var IR_bIsValid;
	var IR_cStr;
	var IR_nDay;
	var IR_nMonth;
	var IR_nYear;
	var IR_nMaximumDays;

	IR_bIsValid = false;
	
	if(IR_cDate.length == 10)
	{
		IR_bIsValid = IR_IsStringOfDigits(IR_cDate, 0, 2);

		if(IR_bIsValid)
			IR_bIsValid = IR_IsValidString(IR_cDate, 2, 3, '/-');

		if(IR_bIsValid)
			IR_bIsValid = IR_IsStringOfDigits(IR_cDate, 3, 5);

		if(IR_bIsValid)
			IR_bIsValid = IR_IsValidString(IR_cDate, 5, 6, '/-');

		if(IR_bIsValid)
			IR_bIsValid = IR_IsStringOfDigits(IR_cDate, 6, 10);

		if(IR_bIsValid)
		{
			IR_bIsValid = false;

			IR_cStr = IR_LeftTrimExtended(IR_cDate.substring(6, 10), '0');
			IR_nYear = parseInt(IR_cStr, 10);

			if(IR_nYear > 1899)
			{
				IR_cStr = IR_LeftTrimExtended(IR_cDate.substring(3, 5), '0');
				IR_nMonth = parseInt(IR_cStr, 10);

				if((IR_nMonth > 0) && (IR_nMonth < 13))
				{
					IR_cStr = IR_LeftTrimExtended(IR_cDate.substring(0, 2), '0');
					IR_nDay = parseInt(IR_cStr, 10);

					if(IR_nDay > 0)
					{
						switch(IR_nMonth)
						{
							case 2:
								if(IR_IsLeapYear(IR_nYear))
									IR_nMaximumDays = 29;
								else
									IR_nMaximumDays = 28;
							break;
							case 4:
							case 6:
							case 9:
							case 11:
								IR_nMaximumDays = 30;
							break;
							default:
								IR_nMaximumDays = 31;
							break;
						}

						if(IR_nDay <= IR_nMaximumDays)
							IR_bIsValid = true;
					}
				}
			}
		}
	}

	return IR_bIsValid;
}

function IR_IsLeapYear(IR_nYear)
{
	var IR_bIsLeapYear;

	IR_bIsLeapYear = false;

  if((IR_nYear % 4) == 0)
  {
    IR_bIsLeapYear = true;

    if((IR_nYear % 100) == 0)
    {
      if(IR_nYear % 400)
      {
        IR_bIsLeapYear = false;
      }
    }
  }

  return IR_bIsLeapYear;
}


function IR_IsNumericString(IR_cString, IR_nFrom, IR_nTo)
{
	return IR_IsValidString(IR_cString, IR_nFrom, IR_nTo, '1234567890');
}


function IR_fngGetRadioButtonSelectedItemIndex(IR_oRadioButton)
{
	var IR_x;
	var IR_nIndex = -1;

	for(IR_x = 0; IR_x < IR_oRadioButton.length; IR_x++)
	{
		if(IR_oRadioButton[IR_x].checked == true)
			IR_nIndex = IR_x;
	}

	return IR_nIndex;
}

function IR_fcgGetRadioButtonSelectedItemValue(IR_oRadioButton)
{
	var IR_x;
	var IR_cValue = '';

	for(IR_x = 0; IR_x < IR_oRadioButton.length; IR_x++)
	{
		if(IR_oRadioButton[IR_x].checked == true)
			IR_cValue = IR_oRadioButton[IR_x].value;
	}

	return IR_cValue;
}

function doAggiornaCheck(x) {
  var id;
  var idElenco=document.frmCerca.idSelez.value;
  id=x.name.substring(6,x.name.length);
  pos=idElenco.indexOf(';'+id+';');
  if(pos>=0){
    //alert('trovato '+pos);
	var str1, str2;
	str1=idElenco.substring(0,pos);
	str2=idElenco.substring((pos+id.length+1),idElenco.length);
	//alert(str1+' '+id+' '+str2);
	document.frmCerca.idSelez.value=str1+str2;
	//alert(document.frmCerca.idSelez.value);
  }
  else{
    //alert('non trovato');
	document.frmCerca.idSelez.value=document.frmCerca.idSelez.value+id+';';
  }
  //alert(x.name);
}

function validate_required(field,alerttxt) {
  with (field)
  {
  if (value==null||value=="")
    {alert(alerttxt);return false}
  else {return true}
  }
}

function validate_form(thisform) {
  with (thisform)
  {
  if (validate_required(userID,"Inserisci il tuo username!")==false)
    {userID.focus();return false}
  else if (validate_required(passID,"Inserisci la tua password!")==false)
    {passID.focus();return false}
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function show(x) {
	hideAll();
	document.getElementById(x).style.display='inline';
}
                
function hideAll() {
	document.getElementById('mybazar_menu').style.display='none';
	document.getElementById('favourite_menu').style.display='none';
	document.getElementById('account_menu').style.display='none';
}

