// JavaScript Document

function page(thePage) {
	

	if(document.getElementById('p3d_home').style.display == 'inherit' && thePage != 'p3d_home')
	{
		opacity('p3d_home', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_home').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_about').style.display == 'inherit' && thePage != 'p3d_about')
	{
		opacity('p3d_about', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_about').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_3d').style.display == 'inherit' && thePage != 'p3d_3d')
	{
		opacity('p3d_3d', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_3d').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_video').style.display == 'inherit' && thePage != 'p3d_video')
	{
		opacity('p3d_video', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_video').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_web').style.display == 'inherit' && thePage != 'p3d_web')
	{
		opacity('p3d_web', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_web').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_art').style.display == 'inherit' && thePage != 'p3d_art')
	{
		opacity('p3d_art', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_art').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_comp').style.display == 'inherit' && thePage != 'p3d_comp')
	{
		opacity('p3d_comp', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_comp').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_dj').style.display == 'inherit' && thePage != 'p3d_dj')
	{
		opacity('p3d_dj', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_dj').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_gallery').style.display == 'inherit' && thePage != 'p3d_gallery')
	{
		opacity('p3d_gallery', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_gallery').style.display = 'none';}, 501);
	}
	else if(document.getElementById('p3d_contact').style.display == 'inherit' && thePage != 'p3d_contact')
	{
		opacity('p3d_contact', 100, 0, 500);
		setTimeout(function(){document.getElementById('p3d_contact').style.display = 'none';}, 501);
	}


	if(document.getElementById(thePage).style.display == 'none')
	{
		setTimeout(function(){document.getElementById(thePage).style.opacity = 0;}, 502);
		setTimeout(function(){document.getElementById(thePage).style.display = 'inherit';}, 502);
		setTimeout(function(){opacity(thePage, 0, 100, 500);}, 502);
	}

}

function menu(id) {
	
    var object = document.getElementById(id).style; 
	var objHeader = document.getElementById(id + "h").style; 
	
	//Determain the current state
	if(object.display == "none"){
		if(id == 'p3d') {
			document.getElementById('p3d1').style.opacity = 0;
			document.getElementById('p3d2').style.opacity = 0;
			document.getElementById('p3d3').style.opacity = 0;
			document.getElementById('p3d4').style.opacity = 0;
			document.getElementById('p3d5').style.opacity = 0;
			document.getElementById('p3d6').style.opacity = 0;
			document.getElementById('p3d7').style.opacity = 0;
			document.getElementById('p3d8').style.opacity = 0;
			
			object.display = "inherit";
			
			setTimeout(function(){opacity('p3d1', 0, 100, 200);}, 100);
			setTimeout(function(){opacity('p3d2', 0, 100, 200);}, 200);
			setTimeout(function(){opacity('p3d3', 0, 100, 200);}, 300);
			setTimeout(function(){opacity('p3d4', 0, 100, 200);}, 400);
			setTimeout(function(){opacity('p3d5', 0, 100, 200);}, 500);
			setTimeout(function(){opacity('p3d6', 0, 100, 200);}, 600);
			setTimeout(function(){opacity('p3d7', 0, 100, 200);}, 700);
			setTimeout(function(){opacity('p3d8', 0, 100, 200);}, 800);
			
		}else if(id == 'c105')
		{
			document.getElementById('c1051').style.opacity = 0;
			document.getElementById('c1052').style.opacity = 0;
			document.getElementById('c1053').style.opacity = 0;
			document.getElementById('c1054').style.opacity = 0;
			
			object.display = "inherit";
			
			setTimeout(function(){opacity('c1051', 0, 100, 200);}, 100);
			setTimeout(function(){opacity('c1052', 0, 100, 200);}, 200);
			setTimeout(function(){opacity('c1053', 0, 100, 200);}, 300);
			setTimeout(function(){opacity('c1054', 0, 100, 200);}, 400);
		}
		else
		{
			document.getElementById('vex1').style.opacity = 0;
			document.getElementById('vex2').style.opacity = 0;
			document.getElementById('vex3').style.opacity = 0;
			
			object.display = "inherit";
			
			setTimeout(function(){opacity('vex1', 0, 100, 200);}, 100);
			setTimeout(function(){opacity('vex2', 0, 100, 200);}, 200);
			setTimeout(function(){opacity('vex3', 0, 100, 200);}, 300);
		}
		objHeader.listStyleImage = "url(images/a/menu/m.png)";
		
	}else{
			if(id == 'p3d'){

			document.getElementById('p3d1').style.opacity = 100;
			document.getElementById('p3d2').style.opacity = 100;
			document.getElementById('p3d3').style.opacity = 100;
			document.getElementById('p3d4').style.opacity = 100;
			document.getElementById('p3d5').style.opacity = 100;
			document.getElementById('p3d6').style.opacity = 100;
			document.getElementById('p3d7').style.opacity = 100;
			document.getElementById('p3d8').style.opacity = 100;
			
			setTimeout(function(){opacity('p3d1', 100, 0, 100);}, 50);
			setTimeout(function(){opacity('p3d2', 100, 0, 100);}, 100);
			setTimeout(function(){opacity('p3d3', 100, 0, 100);}, 150);
			setTimeout(function(){opacity('p3d4', 100, 0, 100);}, 200);
			setTimeout(function(){opacity('p3d5', 100, 0, 100);}, 250);
			setTimeout(function(){opacity('p3d6', 100, 0, 100);}, 300);
			setTimeout(function(){opacity('p3d7', 100, 0, 100);}, 350);
			setTimeout(function(){opacity('p3d8', 100, 0, 100);}, 400);
			
			setTimeout(function(){object.display = "none";}, 400);
			setTimeout(function(){objHeader.listStyleImage = "url(images/a/menu/p.png)";}, 400);
			
		}else if(id == 'c105')
		{
			document.getElementById('c1051').style.opacity = 100;
			document.getElementById('c1052').style.opacity = 100;
			document.getElementById('c1053').style.opacity = 100;
			document.getElementById('c1054').style.opacity = 100;
			
			setTimeout(function(){opacity('c1051', 100, 0, 100);}, 50);
			setTimeout(function(){opacity('c1052', 100, 0, 100);}, 100);
			setTimeout(function(){opacity('c1053', 100, 0, 100);}, 150);
			setTimeout(function(){opacity('c1054', 100, 0, 100);}, 200);
			
			setTimeout(function(){object.display = "none";}, 200);
			setTimeout(function(){objHeader.listStyleImage = "url(images/a/menu/p.png)";}, 200);
			
		}else{
			
			document.getElementById('vex1').style.opacity = 100;
			document.getElementById('vex2').style.opacity = 100;
			document.getElementById('vex3').style.opacity = 100;
			
			setTimeout(function(){opacity('vex1', 100, 0, 100);}, 50);
			setTimeout(function(){opacity('vex2', 100, 0, 100);}, 100);
			setTimeout(function(){opacity('vex3', 100, 0, 100);}, 150);
			
			setTimeout(function(){object.display = "none";}, 150);
			setTimeout(function(){objHeader.listStyleImage = "url(images/a/menu/p.png)";}, 200);
		}
	}
	//Change header symbol
	
	//if
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
}
