﻿// Developed By X402 Limited
// Screenshot load and effects

window.addEventListener?window.addEventListener("load",screenshot_init,false):window.attachEvent("onload",screenshot_init);

var d=document, imgs = new Array(), current=0;
var goalHeight=140, goalWidth=210, rate=20;

function screenshot_init() {
	if(!d.getElementById || !d.createElement)return;
	
	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	
	for(i=0;i<imgs.length;i++){
	    imgs[i].xOpacity = 0;
	    imgs[i].xHeight = 0;
	    imgs[i].xWidth = 0;
	    imgs[i].xGoalHeight = imgs[i].style.height.replace(/px/,"");
	    imgs[i].xGoalWidth = imgs[i].style.width.replace(/px/,"");
	    imgs[i].style.top = '0px';
	    imgs[i].style.left = '0px';
	    setObject(imgs[i]);
	}
	
	d.getElementById("imageContainer").style.display = "block";
	
	current=imgs.length-1;
	
	setTimeout(screenshot_phase1,1000);
}

function screenshot_phase1(){
    var cOpacity,cWidth,cHeight;
    
    cOpacity = imgs[current].xOpacity;
    cWidth = imgs[current].xWidth;
    cHeight = imgs[current].xHeight;
    
    cOpacity+=1/rate;
    cWidth+=imgs[current].xGoalWidth/rate;
    cHeight+=imgs[current].xGoalHeight/rate;
    
    //set objects height,width,opacity
    imgs[current].xOpacity=cOpacity;
    imgs[current].xWidth=cWidth;
    imgs[current].xHeight=cHeight;
    
    setObject(imgs[current]);
    
    if(cWidth==imgs[current].xGoalWidth){
        if(current>0)
            setTimeout(screenshot_phase2,1000);
    }else{
        setTimeout(screenshot_phase1,50);
    }
}

//start phase 1 for next obj
function screenshot_phase2(){
    if(current>0){
        current-=1;
        setTimeout(screenshot_phase1,50);
    }
}

//Set the objects properties
function setObject(obj){
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	obj.style.height = obj.xHeight+'px';
	obj.style.width = obj.xWidth+'px';
}
