// JavaScript Document


document.write("<style type='text/css'>#thephoto {visibility:hidden;}</style>");




/*************************** portfolio image fade **************************/
function portfolioImageFade(newImage, newCaption) {
	imageId='thephoto';
	image = document.getElementById(imageId);
	
	captionId = 'imageCaption';
	caption = document.getElementById(captionId);
	caption.innerHTML=newCaption;
	image.alt=newCaption;
	
	newCaption=newCaption.replace(/"/g,"*q*");
	
	document.getElementById('fullSizeLink').innerHTML='<a href=\'javascript:void(0);\' onMouseDown=\'fullSizeImageFade("'+newImage+'", "'+newCaption+'");\'>View Full Size</a>';
	
	setOpacity(image, 0);
	document.getElementById('thephoto').src=newImage;
	
	var newImg = new Image();
	newImg.src = newImage;
	var myheight = newImg.height;
	var mywidth = newImg.width;
	
	var maxWidth=355;
	var maxHeight=223;
	var x=parseInt(newImg.width);
	  var y=parseInt(newImg.height);
	
	if (mywidth>maxWidth) {
	
		y=(myheight*maxWidth)/mywidth;
		x=maxWidth;
	  }
	   if (myheight>maxHeight) {
			
		x=(mywidth*maxHeight)/myheight;
		y=maxHeight;
	  }
	
 	 image.width=x;
	 image.height=y;
	image.style.visibility = "visible";
	fadeIn(imageId,0);
}
/*************************** fullsize image fade **************************/
function fullSizeImageFade(newfullImage, newCaption) {
	
	/*myPostion=document.getElementById("portfolioDetails").offsetTop;
	alert(myPostion);*/
	
	fullimageId='thefullsizephoto';
	fullimage = document.getElementById(fullimageId);
	document.getElementById("fullSize").style.display="block";
	captionId = 'fullSizeCaption';
	caption = document.getElementById(captionId);
	newCaption=newCaption.replace(/*q*/,"hi");
	caption.innerHTML=newCaption;
	setOpacity(fullimage, 0);
	document.getElementById('thefullsizephoto').src=newfullImage;
	fullimage.alt=newCaption;
	
	var newfullImg = new Image();
	newfullImg.src = newfullImage;
	var myfullheight = newfullImg.height;
	var myfullwidth = newfullImg.width;
	var fullmaxWidth=550;
	var fullmaxHeight=450;
	var fullx=parseInt(fullimage.width);
	  var fully=parseInt(fullimage.height);
	
	if (myfullwidth>fullmaxWidth) {
		fully=(myfullheight*fullmaxWidth)/myfullwidth;
		fullx=fullmaxWidth;
	  }
	  else
	  {
		fully=myfullheight;
		fullx=myfullwidth;
	  }
	   if (myfullheight>fullmaxHeight) {
		fullx=(myfullwidth*fullmaxHeight)/myfullheight;
		fully=fullmaxHeight;
	  }
	  else
	  {
		fully=myfullheight;
		fullx=myfullwidth;
	  }
	
 	 fullimage.width=fullx;
	  fullimage.height=fully;
	fullimage.style.visibility = "visible";
	fadeIn(fullimageId,0);
}

/*************************** Handles fade in **************************/
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 80);
		}
	}
}
/*************************** Handles gradual opacity fade **************************/
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;
}


/*************************** Changes div states on fly **************************/
function changeState(divName, styleType, newStyle){
	document.getElementById(divName).style[styleType]=newStyle;
}