var popup_exists = 0;

function img_click_close(path, img, x, y){
    if(x > screen.availWidth)
    {
        x = screen.availWidth - 20;
    }

    if(y > screen.availHeight)
    {
        y = screen.availHeight - 30;
    }

    url = path + '/popup.php?img=' + img;

    if(popup_exists)
    {
        popup_exists.close();
    }

    popup_exists = window.open(url, 'Image', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + x + ',height=' + y);

    if(window.focus)
    {
        popup_exists.focus();
    }
}

function check_change(prefixe){
    var input= document.getElementsByTagName('INPUT');

    for(var i = input.length - 1; i >= 0; --i)
    {
        if(input[i].type == 'checkbox' && input[i].name.indexOf(prefixe) != -1)
        {
            input[i].checked = !input[i].checked;
        }
    }
}

function warning1(value,texte){
    if(confirm(texte))
    {
        location = value;

        return true;
    }
    else
    {
        return false;
    }
}

function zappeimgmodo(){
    var statusimg = document.getElementById('zappeimg').checked;
    var compteur = 0;

    if(statusimg == true)
    {
        while(document.getElementById('contenumodA' + compteur))
        {
            document.getElementById('contenumodA' + compteur).style.display = 'none';
            document.getElementById('contenumodB' + compteur).style.display = 'block';
            document.getElementById('zappeimgone' + compteur).checked = true;
            compteur++;
        }
    }
    else
    {
        while(document.getElementById('contenumodA' + compteur))
        {
            document.getElementById('contenumodA' + compteur).style.display = 'block';
            document.getElementById('contenumodB' + compteur).style.display = 'none';
            document.getElementById('zappeimgone' + compteur).checked = false;
            compteur++;
        }
    }

    return true;
}

function zappeoneimgmodo(nolig){
    var statusimg = document.getElementById('zappeimgone' + nolig).checked;
	var compteur = 0;

	if(statusimg == true)
	{
        document.getElementById('contenumodA' + nolig).style.display = 'none';
        document.getElementById('contenumodB' + nolig).style.display = 'block';
	}
	else
	{
        document.getElementById('contenumodA'+nolig).style.display = 'block';
        document.getElementById('contenumodB'+nolig).style.display = 'none';
	}

	return true;
}

function deplihidequote(noquote, action, img_path){
    if(action == 1)
    {
        document.getElementById('paraquotedep' + noquote).style.display = 'block';
        document.getElementById('actionquotehide' + noquote).innerHTML = '<a href="#1" onclick="deplihidequote(' + noquote + ', 2, \'' + img_path + '\');"><img src="' + img_path + '/icones/reply.gif" alt="" /></a>';
    }
    else
    {
        document.getElementById('paraquotedep' + noquote).style.display = 'none';
        document.getElementById('actionquotehide' + noquote).innerHTML = '<a href="#1" onclick="deplihidequote(' + noquote + ', 1, \'' + img_path + '\')"><img src="' + img_path + '/icones/deply.gif" alt="" /></a>';
    }
}

function writeCookie(){
    var today = new Date();
    var the_date = new Date('December 31, 2023');
    var the_cookie_date = the_date.toGMTString();
    var the_cookie = 'users_res=' + screen.width + 'x' + screen.height;
    var the_cookie = the_cookie + ';expires=' + the_cookie_date + ';path=/';

    document.cookie = the_cookie
}

function validMoveThreads(value, action){
	if(value && value == 1){
		$('form1').action = decodeURIComponent(action);
	}
}