// functions generiche
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function stringToInteger (inputString)
{
  return parseInt(inputString);
}

function numberToString(inputNumber,base)
{
  var prefix = '';
  if (!base) base = 10;
  if (base=8) prefix = '0';
	if (base=16) prefix = '0x'
  return (prefix + inputNumber.toString(base));
}


// functions gMenu

// * Dependencies * 
// this function requires the following snippet:
// JavaScript/readable_MM_functions/findObj
function setGMenuBgOver(thisObj)
{
  thisId = thisObj.id;
  // es: thisId = item_3 -> num = 3
  numId = stringToInteger(thisId.substring(5,thisId.length));
  prevNum = numId - 1;
  nextNum = numId + 1;
  
  div_left_id  = 'div_' + numId;
  div_right_id = 'div_' + nextNum;
  
  div_left_obj  = findObj(div_left_id);
  div_right_obj = findObj(div_right_id); 
  

  //scambio img a sx 
  switch (div_left_obj.className) {
	case 'gmenu_div_start_normal': 
	  div_left_obj.className = 'gmenu_div_start_over';
	  break;
	case 'gmenu_div_start_out': 
	  div_left_obj.className = 'gmenu_div_start_over';
	  break;
	case 'gmenu_div_an_normal': 
	  div_left_obj.className = 'gmenu_div_an_over';
	  break;
	case 'gmenu_div_an_out': 
	  div_left_obj.className = 'gmenu_div_an_over';
	  break;
	default:
	  div_left_obj.className = 'gmenu_div_nn_right_over';
	  break;	
  }
  
  //scambio img a dx 
  switch (div_right_obj.className) {
	case 'gmenu_div_end_normal': 
	  div_right_obj.className = 'gmenu_div_end_over';
	  break;
	case 'gmenu_div_end_out': 
	  div_right_obj.className = 'gmenu_div_end_over';
	  break;
	case 'gmenu_div_na_normal': 
	  div_right_obj.className = 'gmenu_div_na_over';
	  break;
	case 'gmenu_div_na_out': 
	  div_right_obj.className = 'gmenu_div_na_over';
	  break;
	default:
	  div_right_obj.className = 'gmenu_div_nn_left_over';
	  break;	
  }

  // scambio img fond
  thisObj.className = 'gmenu_item_over';

}




// * Dependencies * 
// this function requires the following snippet:
// JavaScript/readable_MM_functions/findObj
function setGMenuBgOut(thisObj)
{
  thisId = thisObj.id;
  // es: thisId = item_3 -> num = 3
  numId = stringToInteger(thisId.substring(5,thisId.length));
  prevNum = numId - 1;
  nextNum = numId + 1;
  
  div_left_id  = 'div_' + numId;
  div_right_id = 'div_' + nextNum;
  
  div_left_obj  = findObj(div_left_id);
  div_right_obj = findObj(div_right_id); 
  

  //alert('div_left_obj.className  -->  '+div_left_obj.className);
  //scambio img a sx 
  switch (div_left_obj.className) {
	case 'gmenu_div_start_over': 
	  div_left_obj.className = 'gmenu_div_start_out';
	  break;
	case 'gmenu_div_an_over': 
	  div_left_obj.className = 'gmenu_div_an_out';
	  break;
	default:
	  div_left_obj.className = 'gmenu_div_nn_right_out';
	  break;	
  }
  
  
  //scambio img a dx 
  switch (div_right_obj.className) {
	case 'gmenu_div_end_over': 
	  div_right_obj.className = 'gmenu_div_end_out';
	  break;
	case 'gmenu_div_na_over': 
	  div_right_obj.className = 'gmenu_div_na_out';
	  break;
	default:
	  div_right_obj.className = 'gmenu_div_nn_left_out';
	  break;	
  }

  // scambio img fond
  thisObj.className = 'gmenu_item_out';

}
