var msec2=1;
var go2="";
var opacity = 0;
var timer = '';
var count = 0;
var current_image = 0;
var old_image = 0;
var youtubesplit = 0;
var image_viewed = new Array();

function check_image()
{
    if (document.getElementById('il_image').complete)
    { 
        clearInterval(img_timer) 
        opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 0, 100, 0.3); opacityTween.start();
    }
} 

function pop_image_amplification(id)
{
    if(navigator.appName == 'Firefox')
    {
        if(navigator.appVersion < 3.5)
        {
            var doorgaan = false;
        }
        else
        {
            var doorgaan = true;
        }
    }
    else
    {
        var doorgaan = true;
    }

    if(doorgaan == true)
    {
    	var xScroll, yScroll;
    	
    	if (window.innerHeight && window.scrollMaxY) {	
    		xScroll = document.body.scrollWidth;
    		yScroll = window.innerHeight + window.scrollMaxY;
    	} else if (document.body.scrollHeight > document.body.offsetHeight){
    		xScroll = document.body.scrollWidth;
    		yScroll = document.body.scrollHeight;
    	} else {
    		xScroll = document.body.offsetWidth;
    		yScroll = document.body.offsetHeight;
    	}
    	
    	var windowWidth, windowHeight;
    	if (self.innerHeight) {	// all except Explorer
    		windowWidth = self.innerWidth;
    		windowHeight = self.innerHeight;
    	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    		windowWidth = document.documentElement.clientWidth;
    		windowHeight = document.documentElement.clientHeight;
    	} else if (document.body) { // other Explorers
    		windowWidth = document.body.clientWidth;
    		windowHeight = document.body.clientHeight;
    	}	
    	if(yScroll < windowHeight){
    		pageHeight = windowHeight;
    	} else { 
    		pageHeight = yScroll;
    	}
        
        var image_root = 'http://www.factoryprices.nl/images/';
        var il_thumbnails = '';
        current_image = id;  
        
    	document.getElementById('darkbackground').style.height = pageHeight+10;
     	document.getElementById('darkbackground').style.visibility = "visible";
     	document.getElementById('il_background').style.visibility = "visible";
        
        if(vergrooturl.length > 1 || youtube != '' || threed != '')
        {
            if((youtube != '' || threed != '') && vergroot_image == 'nee')
            {
                if(youtube != '' && threed != '')
                {
                    
                }
                else
                {
                    document.getElementById('il_thumbnail_div').style.height = '0';
                    document.getElementById('il_thumbnail_div').style.display = 'none';
                    document.getElementById('il_background').style.height = '430px';
                }
            }
            else
            {
                for(var i = 0; i < vergrooturl.length; i++)
                {
                    il_thumbnails += '<img style="float: left;" id="il_thumbnail_'+i+'" class="il_thumbnail" src="'+image_root+vergrooturl[i]+'" onclick="il_thumbnail_action(\''+i+'\', \'click\')" onmouseover="il_thumbnail_action(this, \'over\')" onmouseout="il_thumbnail_action(this, \'out\')">';
                    
                    image_viewed[i] = false;
                }
            }
            image_viewed[i] = true;
            
            if(youtube != '')
            {
                if(youtubesplit[0] != '')
                il_thumbnails += '<img style="float: right;" id="il_thumbnail_5" onclick="il_youtube(0)" onmouseover="il_thumbnail_action(this, \'over\')" onmouseout="il_thumbnail_action(this, \'out\')" class="il_thumbnail" src="images/youtube_logo.png" style="height: 64px;">';
                if(youtubesplit[1] != undefined)
                il_thumbnails += '<img style="float: right;" id="il_thumbnail_6" onclick="il_youtube(1)" onmouseover="il_thumbnail_action(this, \'over\')" onmouseout="il_thumbnail_action(this, \'out\')" class="il_thumbnail" src="images/youtube_logo.png" style="height: 64px;">';
            }
                    
            if(threed != '')
            il_thumbnails += '<img style="float: right;" id="il_thumbnail_7" onclick="il_threed()" onmouseover="il_thumbnail_action(this, \'over\')" onmouseout="il_thumbnail_action(this, \'out\')" class="il_thumbnail" src="images/threed.png" style="height: 64px;">';

            document.getElementById('il_thumbnail_div').innerHTML = il_thumbnails;
            
            il_thumbnail_action(document.getElementById('il_thumbnail_'+id), 'over');
            
            document.getElementById('il_arrow_l').style.display = 'block';
            document.getElementById('il_arrow_r').style.display = 'block';
        }
        else
        {
            document.getElementById('il_thumbnail_div').style.height = '0';
            document.getElementById('il_background').style.height = '430px';
        }
        
        if(youtube != '')
        {
            document.getElementById('il_youtube_div').innerHTML = '<object id="il_youtube_object" width="694" height="380"><param name="movie" value="'+youtubesplit[0]+'rel=0&"></param><embed src="'+youtubesplit[0]+'rel=0&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="694" height="380"></embed></object>';
        }
        
        opacityTween = new OpacityTween(document.getElementById('darkbackground'),Tween.regularEaseIn, 0, 70, 0.1);
        opacityTween.start();
        
        setTimeout("opacityTween = new OpacityTween(document.getElementById('il_background'),Tween.regularEaseIn, 0, 100, 0.4); opacityTween.start();", 150);
       
        document.getElementById('il_image').src = 'http://www.factoryprices.nl/images/'+vergrootdir[id]+vergrooturl[id];
        document.getElementById('il_image_div').style.visibility = 'visible';
       
        img_timer = setInterval('check_image()', 1400);
        
        if(meer_images == 'nee')
        {
            display_arrows(0);
        }
    }
}

function display_arrows(display)
{
    if(display == 0)
    display = 'none';
    else
    display = 'block';
    
    document.getElementById('il_arrow_r').style.display = display;
    document.getElementById('il_arrow_l').style.display = display;
}
bah = false;
function il_thumbnail_action(thumbnail, action)
{
    switch(action)
    {
        case 'click':
        old_image = current_image;
        current_image = thumbnail;
        
        if(old_image != current_image)
        {
            if(bah == false)
            {
                bah = true;
            
                document.getElementById('il_youtube_div').style.visibility = 'hidden';
                document.getElementById('il_threed_div').style.visibility = 'hidden';
                document.getElementById('il_image_protect_div').style.visibility = 'visible';
                
                il_thumbnail_action(document.getElementById('il_thumbnail_'+old_image), 'out');
                il_thumbnail_action(document.getElementById('il_thumbnail_'+thumbnail), 'over');
                
                opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 100, 0, 0.1);
                opacityTween.start();
                
                if(image_viewed[current_image] == false)
                {
                    timeout_time = 400;
                    image_viewed[current_image] = true;
                }
                else
                timeout_time = 100;

                
                if(meer_images == 'ja')
                setTimeout("display_arrows(1);", timeout_time);
                
                setTimeout("document.getElementById('il_image_div').style.visibility = 'visible';", timeout_time);
                setTimeout("document.getElementById('il_image').src = 'http://www.factoryprices.nl/images/'+vergrootdir["+thumbnail+"]+vergrooturl["+thumbnail+"];", timeout_time);
                setTimeout("img_timer = setInterval('check_image()', 200);", timeout_time);
                setTimeout('bah = false;', (timeout_time+400));
            }
            

        }
        break;
        
        case 'over':

            thumbnail.style.opacity = '1';
        	thumbnail.style.MozOpacity = '1';
        	thumbnail.style.KhtmlOpacity = '1';
        	thumbnail.style.filter = 'alpha(opacity=100)';
        break;
        
        case 'out':
        if(thumbnail.id != 'il_thumbnail_'+current_image)
        {
            thumbnail.style.opacity = '0.8';
        	thumbnail.style.MozOpacity = '0.8';
        	thumbnail.style.KhtmlOpacity = '0.8';
        	thumbnail.style.filter = 'alpha(opacity=80)';
        }
        break;
    }
}

function il_youtube(yt)
{
    old_image = current_image;
    current_image = yt+5;
    
    document.getElementById('il_youtube_div').innerHTML = '<object id="il_youtube_object" width="694" height="380"><param name="movie" value="'+youtubesplit[yt]+'rel=0&"></param><embed src="'+youtubesplit[yt]+'rel=0&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="694" height="380"></embed></object>';
  
 
    il_thumbnail_action(document.getElementById('il_thumbnail_'+old_image), 'out');
    il_thumbnail_action(document.getElementById('il_thumbnail_'+current_image), 'over');
    
    opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 100, 0, 0.2);
    opacityTween.start();
    
    setTimeout("display_arrows(0);", 400);
    setTimeout("document.getElementById('il_image_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_image_protect_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_threed_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_youtube_div').style.visibility = 'visible';", 400);
}

function il_threed()
{
    old_image = current_image;
    current_image = 7;
    document.getElementById('il_threed').src = threed;
    il_thumbnail_action(document.getElementById('il_thumbnail_'+old_image), 'out');
    il_thumbnail_action(document.getElementById('il_thumbnail_'+current_image), 'over');
    
    opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 100, 0, 0.2);
    opacityTween.start();
    
    setTimeout("display_arrows(0);", 400);
    setTimeout("document.getElementById('il_image_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_image_protect_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_youtube_div').style.visibility = 'hidden';", 400);
    setTimeout("document.getElementById('il_threed_div').style.visibility = 'visible';", 400);
}

function il_arrow(arrow, action)
{
    switch(action)
    {
        case 'click': 
        var images_length = vergrooturl.length-1;
        old_image = current_image;
        if(bah == false)
        {
            bah = true;
            if(arrow.id == 'il_arrow_l')
            {
                if(old_image == 0)
                current_image = images_length;
                else
                current_image--;
            }
            else
            {
                if(old_image == images_length)
                current_image = 0;
                else
                current_image++;
            }
            
            document.getElementById('il_youtube_div').style.visibility = 'hidden';
            document.getElementById('il_threed_div').style.visibility = 'hidden';               
            
            il_thumbnail_action(document.getElementById('il_thumbnail_'+old_image), 'out');
            il_thumbnail_action(document.getElementById('il_thumbnail_'+current_image), 'over');
            
            opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 100, 0, 0.1);
            opacityTween.start();
            
            if(image_viewed[current_image] == false)
            {
                timeout_time = 400;
                image_viewed[current_image] = true;
            }
            else
            timeout_time = 100;
            
            setTimeout("document.getElementById('il_image_div').style.visibility = 'visible';", timeout_time);
            setTimeout("document.getElementById('il_image').src = 'http://www.factoryprices.nl/images/'+vergrootdir["+current_image+"]+vergrooturl["+current_image+"];", timeout_time);
            setTimeout("img_timer = setInterval('check_image()', 200);", timeout_time);
            setTimeout('bah = false;', (timeout_time+400));
        }
        
        break;
        
        case 'over':
        arrow.style.opacity = '1';
        arrow.style.MozOpacity = '1';
        arrow.style.KhtmlOpacity = '1';
        arrow.style.filter = 'alpha(opacity=100)';
        break;
        
        case 'out':
        arrow.style.opacity = '0.8';
        arrow.style.MozOpacity = '0.8';
        arrow.style.KhtmlOpacity = '0.8';
        arrow.style.filter = 'alpha(opacity=80)';
        break;
    }
}

function pop_image_amplification_out()
{
    opacityTween = new OpacityTween(document.getElementById('darkbackground'),Tween.regularEaseIn, 70, 0, 0.1);
    opacityTween.start();
    opacityTween = new OpacityTween(document.getElementById('il_background'),Tween.regularEaseIn, 100, 0, 0.1);
    opacityTween.start();
    opacityTween = new OpacityTween(document.getElementById('il_image_div'),Tween.regularEaseIn, 100, 0, 0.1);
    opacityTween.start();
    
    document.getElementById('il_youtube_div').style.visibility = 'hidden';
    document.getElementById('il_threed_div').style.visibility = 'hidden';
    
    setTimeout("document.getElementById('il_image_protect_div').style.visibility = 'hidden';", 200);
 	setTimeout("document.getElementById('il_image_div').style.visibility = 'hidden';", 200);
    setTimeout("document.getElementById('darkbackground').style.visibility = 'hidden';", 200);
    setTimeout("document.getElementById('il_background').style.visibility = 'hidden'", 200);
}

function button_effect(name, oo)
{
	var divs = document.getElementById(name);
	
	if(oo == 0)
	{
		divs.style.background = '#ee6d19';
	}
	else
	{
		divs.style.background = '#919191';
	}
}

function button_effect(name, oo)
{
	var divs = document.getElementById(name);
	
	if(oo == 0)
	{
		divs.style.background = '#ee6d19';
	}
	else
	{
		divs.style.background = '#919191';
	}
}
