// modelData deve essere DD-MM-AAAA
function getAge(modelData)
{
//alert(modelData.length);
    var bday= parseInt(modelData.substring(0,2));
    var bmonth= parseInt(modelData.substring(3,5));
    var byear= parseInt(modelData.substring(6,modelData.length)); 

    //alert("bday: "+bday+"   bmonth:"+bmonth+"    byear:"+byear);
    var age;
    var now = new Date();
    var tday=now.getDate();
    var tmonth=(now.getMonth());
    var tyear=(now.getFullYear());
    if ((tmonth > bmonth)||(tmonth==bmonth & tday>=bday)) age=byear
    else age=byear+1;

    modelAge= tyear-age;
    return (modelAge);

}

function makeImgNumber (i,maxLen)
{
var x=i.toString();
     var len=maxLen-x.length;
     for (h=0;h<len;h++)
       {
       x="0"+x;
       }
return x;
}

//-------non va-------
function countImages(thisPath) { 
var myImg = new Image();
var imgName;
for (j=1;j<10;j++)
  {
  imgName = makeImgNumber (j,4);
  imgPath = thisPath+"/"+imgName+".jpg";
  myImg.src=imgPath;
  alert(myImg.src+" - "+myImg.width+" - "+myImg.height+" - "+myImg.fileSize);
  //if(myImg.complete) alert("ok");
  //if (myImg.width<30 && myImg.width>1) return (j-1);
  }
}

function makeCell (thisImg, thisDir, thisAuthor, thisTitle)
{
  var myImgPath = thisDir+"/"+thisImg+".jpg";
  var myString  = "";
  var thisWidth = 100/numCols;
  myString=myString+'<td width="'+thisWidth+'%" align="center" valign="bottom">';
  myString=myString+'<a href="'+myImgPath+'" rel="lightbox[view]" title="'+thisTitle+'"><img border="0" height="'+heightThumbs+'" src="'+myImgPath+'" ></a>';
  if(thisAuthor.length!=0)
    myString=myString+'<br><font color="#FFCC66"><i>'+thisAuthor+'</i></font>';
  myString=myString+'</td>';

  return myString;
}

function makeEmptyCell ()
{
  var myString="";
  var thisWidth = 100/numCols;
  myString=myString+'<td width="'+thisWidth+'%" align="center" valign="bottom">&nbsp;</td>';
  return myString;
}

function makeRow (indx,myDir)
{
  
  var myString="<tr>";
  var myParam= numCols+indx;
  for (i=indx;i<myParam;i++)
    {
      var myImg    = makeImgNumber (i,4); 
      if (myImg.toString()<=numFoto)
         myString=myString+makeCell(myImg,myDir,"","");
      else
         myString=myString+makeEmptyCell();
    }
  myString=myString+'</tr>';
  return myString;
}

function makeRowByArray (indx, myDir, thisArray)
{
  var myString="<tr>";
  var myParam= numCols+indx;
  for (i=indx;i<myParam;i++)
    {
    if (thisArray[i])
      {
      var myImg    = thisArray[i][0];
      var myAuthor = thisArray[i][1];
      var myTitle  = myAuthor+' - '+gallery[i][2];

      myString=myString+makeCell(myImg ,myDir, myAuthor, myTitle);
      }
    else myString=myString+makeEmptyCell();
    }
  myString=myString+'</tr>';
  return myString;
}

//-----funzioni slideshow immagini in webportfolio------
var webportfolioLink = "webportfolio/index.htm";
var webportfolioPath = "webportfolio/images/";
//Specify the slider's width (in pixels)
var sliderwidth="450px";
//Specify the slider's height
var sliderheight="120px";
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2;
//configure background color:
slidebgcolor="#333333";
//Specify gap between each image (use HTML):
var imagegap=" "
//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=5;

function fillup(){
if (iedom){//alert("iedom");
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){//alert("document.layers");
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}


function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap

if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}


//------- funzioni per slideshow eurossworks
var eurossworksPath = "eurossworks/images/";
var eurossworksLink = "eurossworks/index.htm";
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000
// Duration of crossfade (seconds)
var crossFadeDuration = 4

function runSlideShow(myImgName,myAuthor){
//alert(document.getElementById(myImgName).name);
   if (document.all){
      document.images[myImgName].style.filter="blendTrans(duration=2)"
      document.images[myImgName].style.filter="blendTrans(duration=crossFadeDuration)"
      document.images[myImgName].filters.blendTrans.Apply()  
      }
   document.images[myImgName].src = preLoad[j].src;
   document.getElementById(myAuthor).innerHTML=gallery[j][1];
   if (document.all){
     document.images[myImgName].filters.blendTrans.Play()
      }
   j = j + 1
   if (j > (numFotoERW-1)) j=0
    setTimeout('runSlideShow("'+myImgName+'","'+myAuthor+'")', slideShowSpeed);
}
