/*
	js..

*/

showimg = 1;
tspeed = 7000;


function timedCount(imgarr) {
	var imgs = eval("myimgs_"+imgarr);
	var imgslinks = eval("myimgslinks_"+imgarr);
	var imgstext = eval("myimgstext_"+imgarr);	
	t=setTimeout("timedCount('"+imgarr+"')",tspeed);
	if (eval("showimg_"+imgarr) == imgs.length) {
		//showimg = 0;
		eval("showimg_"+imgarr + "=0;");		
	}		
	initImage(imgs[eval("showimg_"+imgarr)],imgslinks[eval("showimg_"+imgarr)],"thephoto_"+imgarr,"thephotodiv_"+imgarr,"thephototext_"+imgarr,imgstext[eval("showimg_"+imgarr)]);
	//showimg = showimg + 1;
	eval("showimg_"+imgarr + "+=1;");		
}	


function initImage(img,imglink,imageId,imageDivId,imageDivText,imageText) {		
  //imageId = 'thephoto';  
  imageText = imageText.replace(/'/g,"");  	
  
  fadeOut(img,imglink,imageId,imageDivId,imageDivText,imageText,100);

}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,imageDivId,imageDivText,imageText,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(imageDivId);
    obj.style.display = '';
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 2;
      window.setTimeout("fadeIn('"+objId+"','"+imageDivId+"','"+imageDivText+"','"+imageText+"',"+opacity+")", 10);
    }
  }
}

function fadeOut(img,imglink,objId,imageDivId,imageDivText,imageText,opacityOut) {	
  if (document.getElementById) {
    obj = document.getElementById(imageDivId);
    if (opacityOut >= 0) {
      setOpacity(obj, opacityOut);
      opacityOut-= 2;
      window.setTimeout("fadeOut('"+img+"','"+imglink+"','"+objId+"','"+imageDivId+"','"+imageDivText+"','"+imageText+"',"+opacityOut+")", 10);                  
      //window.setTimeout("fadeOut('"+img+"','"+objId+"',"+opacityOut+")", 10);
    } else {
      image = document.getElementById(objId);
//      image.style.display='hidden';      //
      image.src = img;
    	image.parentNode.href=imglink;
    	imageText =(imageText=="")?"":"<div class='photoholdertext'>"+imageText+"</div>";
    	imageText = imageText.replace(/'/g,"\"");  	
    	document.getElementById(imageDivText).innerHTML=imageText;
      fadeIn(objId,imageDivId,imageDivText,imageText,0);	
    }
  }
}


