//	ggha_default.js
//	Portions (C) PyrusMalus, 2009.
//	www.pyrusmalus.com




// Email links

function pm_contact(inName, inDomain)
{
	address='mailto:' + inName + '@' + inDomain;
	location = (address);
}

var images = new Array();
var imageCount;
var currentImageIndex = 0;

//	need to do this because IE doesn't support indexOf...
if(!Array.indexOf){
  Array.prototype.indexOf = function(obj){
   for(var i=0; i<this.length; i++){
    if(this[i]==obj){
     return i;
    }
   }
   return -1;
  }
}


function pm_addImageToImageList(inImageUrl)
{
	images[images.length] = (inImageUrl);
}


function pm_setupImages()
{
	now = new Date();
	seed = now.getSeconds();
	
	copyImages = images;
	
	firstIndex = Math.floor(Math.random(seed) * copyImages.length);
	firstObject = document.getElementById('image_placeholder_1');
	firstObject.src = copyImages[firstIndex];
	copyImages.splice(firstIndex, 1);
	
	secondIndex = Math.floor(Math.random(seed) * copyImages.length);
	secondObject = document.getElementById('image_placeholder_2');
	secondObject.src = copyImages[secondIndex];
	copyImages.splice(secondIndex, 1);
	
	thirdIndex = Math.floor(Math.random(seed) * copyImages.length);
	thirdObject = document.getElementById('image_placeholder_3');
	thirdObject.src = copyImages[thirdIndex];
	copyImages.splice(thirdIndex, 1);
	
	fourthIndex = Math.floor(Math.random(seed) * copyImages.length);
	fourthObject = document.getElementById('image_placeholder_4');
	fourthObject.src = copyImages[fourthIndex];
	copyImages.splice(fourthIndex, 1);
	
	pm_fadeInImages(0, 1, 10);
	
}


function pm_setOpacity(object, opacity)
{
	if (opacity < 0)
	{
		opacity = 0;
	}
	if (opacity > 100)
	{
		opacity = 100;
	}
	
	if (object != null)
	{
		opacity = (opacity == 100 ? 99.999 : opacity);

		//	Safari 1.2, Firefox, Mozilla, CSS3...
		object.style.opacity = opacity / 100;

		//	Old Mozilla, Firefox...
		object.style.MozOpacity = opacity / 100;

		//	Old Safari, Konqueror...
		object.style.KHTMLOpacity = opacity / 100;

		//	IE/Win...
		object.style.filter = "alpha(opacity:"+opacity+")";
	}
}


function pm_setOpacityForId(objectId, opacity)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		pm_setOpacity(object, opacity);
	}
}


function pm_fadeInImages(inOpacity, inFadeIncrement, inFadeDelay)
{
	keepFading = true;
	for (var imageIndex = 1; imageIndex < 5; imageIndex++)
	{
		object = document.getElementById("image_placeholder_" + imageIndex);
		if (inOpacity <= 250)
		{
			//	fade up image...
			pm_setOpacity(object, inOpacity - (50 * (imageIndex - 1)));
		}
		else
		{
			keepFading = false;
		}
	}
	
	if (keepFading)
	{
		inOpacity += inFadeIncrement;
		window.setTimeout("pm_fadeInImages(" + inOpacity + ", " + inFadeIncrement + ", " + inFadeDelay + ")", inFadeDelay);
	}
}

function pm_clickedEventThumbnail(inImageUrl)
{
	object = document.getElementById("image_placeholder");
	object.src = inImageUrl;
}
