var tk_slideshow = false;

function display_menu()
{
    var hoofdmenu_elm = document.getElementById('menu');
    if(hoofdmenu_elm.style.display == 'none')
    {
        hoofdmenu_elm.style.display = 'block';
    }
    else
    {
        hoofdmenu_elm.style.display = 'none';
    }
}

function change_content_width()
{
    var max_width = screen.width-350;

    if(window.innerWidth)
    {
        max_width = window.innerWidth-350;
    }

    var content_elm = document.getElementById('foto_kader');

    content_elm.style.width = max_width+'px';
}

function display_winkel(url)
{
    var winkel = document.getElementById('winkel');

    if(winkel.style.display == 'block')
    {
        winkel.style.display = 'none';
    }
    else
    {
        winkel.style.display = 'block';
        toggle_slideshow_2(url, false);
    }
}

function toggle_slideshow_img(url)
{
    setTimeout('next_slide("'+url+'")',5000);
}

function toggle_slideshow(url)
{
    if(tk_slideshow == true)
    {
        toggle_slideshow_2(url, false);
    }
    else
    {
        toggle_slideshow_2(url, true);
    }
}

function toggle_slideshow_2(url, slideshow)
{
    var start_stop_elm = document.getElementById('start_stop');

	jQuery.ajax(
	{
		type: "POST",
		url: SITE_URL+"foto/ajax_set_slideshow",
		data: 'slideshow='+slideshow,
		dataType: "json",
		async: false
	});

    if(slideshow == false)
    {
        tk_slideshow = false;
        start_stop_elm.src = SITE_APP_URL+'images/webshop/start.gif';
    }
    else
    {
        tk_slideshow = true;
        next_slide(url);
        start_stop_elm.src = SITE_APP_URL+'images/webshop/stop.png';
    }
}

function next_slide(url)
{
    if(tk_slideshow == true)
    {
        window.location = url;
    }
}

function go_to_home(url)
{
    window.opener.location = url;
    window.opener.focus();
    window.close();
}

function go_to_winkelwagen(url)
{
    window.opener.location = url;
    window.opener.focus();
    window.close();
}

function close_popup()
{
    window.opener.location.reload(true);
    window.opener.focus();
    window.close();
}

function resize_image(img)
{
    var new_img = new Image();
    new_img.src = img.src;

    var width = img.width;
    var height = img.height;

    if(width <= 0)
    {
        width = new_img.width;
        height = new_img.height;
    }

    var max_width = screen.width-50;
    var max_height = screen.height-145;

    if(window.innerHeight)
    {
        max_width = window.innerWidth-50;
        max_height = window.innerHeight-50;
    }

    var img_width = width;
    var img_height = height;

    var verhouding = width/height;

    if(width > max_width)
    {
        img_width = max_width;
        img_height = img_width/verhouding
    }

    if(img_height > max_height)
    {
        img_height = max_height;
        img_width = img_height*verhouding;
    }

    var verticaal = window.document.getElementById('verticaal');

    verticaal.style.height = img_height+'px';
    verticaal.style.lineHeight = img_height+'px';
    verticaal.style.width = img_width+'px';
    img.style.width = img_width+'px';
    img.style.height = img_height+'px';
    img.style.display = 'block';
}
