

function changeClass(pays){
    var element = document.getElementById(pays);
    element.className = 'liens-active';
}

function addback(folder, idimage,lookbook)
{

	if (lookbook == null)
		lookbook = false;

	if(lookbook)
		$('#lookbook_map_image').hide();

	NewImage = generate_item(folder, idimage,lookbook);
    $(document.getElementById('background')).append(NewImage); 
}


function addbacken(folder, idimage,lookbook)
{
	if (lookbook == null)
		lookbook = false;

	if(lookbook)
		$('#lookbook_map_image').hide();

		NewImage = generate_item_en(folder, idimage,lookbook);
    $(document.getElementById('background')).append(NewImage);
}


function generate_item(folder, idimage,lookbook)
{
	if(lookbook == false)
	{
		NewImage = '<div id="' + idimage + 'ID" style="top: 223px; left: 11px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '.php" style="width: 1082px; height: 488px;" frameborder="0"> </iframe><div style=";top: 381px; left: 653px; margin: 0; position: absolute;">';
	}
	else
	{
		NewImage = '<div id="' + idimage + 'ID" style="top: 0px; left: 0px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '.php" style="width: 1082px; height: 657px;padding-top:185px;" frameborder="0"> </iframe><div style="top: 553px; left: 653px; margin: 0; position: absolute;">';
	
	}
	
	if(lookbook == false)
	{
		if (findprev(idimage, folder)[0] != '') 
			NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="nextprev(\'' + findprev(idimage, folder)[1] + '\',\'' + idimage + '\',findprev(\'' + idimage + '\',\'' + folder + '\')[0]);"><</a>&nbsp;&nbsp;';
		else
			NewImage = NewImage + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

    }

	
    NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="removeback(\'' + idimage + '\',true);">x</a>';
    
	if(lookbook == false)
	{
		if (findnext(idimage, folder)[0] != '') 
			NewImage = NewImage + '&nbsp;&nbsp;<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="nextback(\'' + findnext(idimage, folder)[1] + '\',\'' + idimage + '\',findnext(\'' + idimage + '\',\'' + folder  + '\')[0]);">></a></div></div>';
    }	
    return NewImage;
}


function generate_item_en(folder, idimage,lookbook)
{
	if(lookbook == false)
	{
		NewImage = '<div id="' + idimage + 'ID" style="top: 223px; left: 11px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '_en.php" style="width: 1082px; height: 488px;" frameborder="0"> </iframe><div style="top: 381px; left: 653px; margin: 0; position: absolute;">';
	}
	else
	{
		NewImage = '<div id="' + idimage + 'ID" style="top: 0px; left: 0px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '_en.php" style="width: 1082px; height: 657px;padding-top:185px;" frameborder="0"> </iframe><div style="top: 583px; left: 653px; margin: 0; position: absolute;">';
	
	}
	
	if(lookbook == false)
	{
		if (findprev(idimage, folder)[0] != '') 
			NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="nextpreven(\'' + findprev(idimage, folder)[1] + '\',\'' + idimage + '\',findprev(\'' + idimage + '\',\'' + folder + '\')[0]);"><</a>&nbsp;&nbsp;';
		else
			NewImage = NewImage + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

    }

	
    NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="removeback(\'' + idimage + '\',true);">x</a>';
    
	if(lookbook == false)
	{
		if (findnext(idimage, folder)[0] != '') 
			NewImage = NewImage + '&nbsp;&nbsp;<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="nextbacken(\'' + findnext(idimage, folder)[1] + '\',\'' + idimage + '\',findnext(\'' + idimage + '\',\'' + folder  + '\')[0]);">></a></div></div>';
    }	
    return NewImage;
}




function removeback(idimage,close)
{
    $(document.getElementById(idimage + 'ID')).remove();
	if(close)
		$('#lookbook_map_image').show();
}




function next_tissu(folder, idimage, idimagenext){
    removeback(idimage);
    addtissu(folder, idimagenext);
}

function prev_tissu(folder, idimage, idimageprev){
    removeback(idimage);
    addtissu(folder, idimageprev);
}

function next_tissu_en(folder, idimage, idimagenext){
    removeback(idimage);
    addtissu_en(folder, idimagenext);
}

function prev_tissu_en(folder, idimage, idimageprev){
    removeback(idimage);
    addtissu_en(folder, idimageprev);
}




function addtissu(folder, idimage){
    NewImage = '<div id="' + idimage + 'ID" style="top: 153px; left: 11px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '.php?keepThis=true&amp;" style="width: 935px; height: 587px;padding-top:70px;" frameborder="0"> </iframe><div style="top: 431px; left: 589px; margin: 0; position: absolute;">';
    
    
    if (find_prev_tissu(idimage) != '') 
        NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="prev_tissu(\'' + folder + '\',\'' + idimage + '\',find_prev_tissu(\'' + idimage + '\'));"><</a>&nbsp;&nbsp;';
    else 
        NewImage = NewImage + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    
    NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="removeback(\'' + idimage + '\');">x</a>';
    
    if (find_next_tissu(idimage) != '') 
        NewImage = NewImage + '&nbsp;&nbsp;<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="next_tissu(\'' + folder + '\',\'' + idimage + '\',find_next_tissu(\'' + idimage + '\'));">></a></div></div>';
    
    $(document.getElementById('background')).append(NewImage);
}

function addtissu_en(folder, idimage){

    NewImage = '<div id="' + idimage + 'ID" style="top: 153px; left: 11px; margin: 0; position: absolute;	background: #ffffff; "><iframe hspace="0" src="../' + folder + '/' + idimage + '_en.php?keepThis=true&amp;" style="width: 935px; height: 587px;padding-top:70px" frameborder="0"> </iframe><div style="top: 431px; left: 589px; margin: 0; position: absolute;">';
    
    
    if (find_prev_tissu(idimage) != '') 
        NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="prev_tissu_en(\'' + folder + '\',\'' + idimage + '\',find_prev_tissu(\'' + idimage + '\'));"><</a>&nbsp;&nbsp;';
    else 
        NewImage = NewImage + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		    
    NewImage = NewImage + '<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="removeback(\'' + idimage + '\');">x</a>';
    
    if (find_next_tissu(idimage) != '') 
        NewImage = NewImage + '&nbsp;&nbsp;<a href="#" style=" text-decoration:none;font-size:18px;" OnClick="next_tissu_en(\'' + folder + '\',\'' + idimage + '\',find_next_tissu(\'' + idimage + '\'));">></a></div></div>';
    
    $(document.getElementById('background')).append(NewImage);
}


function find_next_tissu(idimage)
{
	if(idimage == '60_9')
		return '60_10';
	if(idimage == '60_10')
		return '170_2';
	if(idimage == '170_2')
		return '330_8';
	if(idimage == '330_8')
		return '330_9';
	if(idimage == '330_9')
		return '801_2';
	if(idimage == '801_2')
		return '805';
	if(idimage == '805')
		return '1001';
	if(idimage == '1001')
		return '1002';
	if(idimage == '1002')
		return '1003';
	if(idimage == '1003')
		return '1004';
	if(idimage == '1004')
		return '1005';
	if(idimage == '1005')
		return '1006';
	if(idimage == '1006')
		return '1007';
	if(idimage == '1007')
		return '1008';
	if(idimage == '1008')
		return '1010';
	if(idimage == '1010')
		return '1011';
	if(idimage == '1011')
		return '1012';
	if(idimage == '1012')
		return '1013';
	if(idimage == '1013')
		return '1014';
	if(idimage == '1014')
		return '1015';
	if(idimage == '1015')
		return '1016';
	if(idimage == '1016')
		return '1020';
	if(idimage == '1020')
		return '1021';
	if(idimage == '1021')
		return '1022';
	if(idimage == '1022')
		return '1023';
	if(idimage == '1023')
		return '1025';
	if(idimage == '1025')
		return '1026';
	if(idimage == '1026')
		return '1027';
	if(idimage == '1027')
		return '1030';
	if(idimage == '1030')
		return '1031';
	if(idimage == '1031')
		return '1032';
	if(idimage == '1032')
		return '1033';
	if(idimage == '1033')
		return '1035';
	if(idimage == '1035')
		return '1036';
	if(idimage == '1036')
		return '1037';
	if(idimage == '1037')
		return '1040';
	if(idimage == '1040')
		return '1041';
	if(idimage == '1041')
		return '1042';
	if(idimage == '1042')
		return '1043';
	if(idimage == '1043')
		return '1045';
	if(idimage == '1045')
		return '1046';
	if(idimage == '1046')
		return '1047';
	if(idimage == '1047')
		return '1051';
	if(idimage == '1051')
		return '1061';
	if(idimage == '1061')
		return '1062';
	if(idimage == '1062')
		return '1063';
	if(idimage == '1063')
		return '1064';
	if(idimage == '1064')
		return '1065';
	if(idimage == '1065')
		return '1066';
	if(idimage == '1066')
		return '1067';
	if(idimage == '1067')
		return '1068';
	if(idimage == '1068')
		return '1070_10';
	if(idimage == '1070_10')
		return '1071';
	if(idimage == '1071')
		return '1072';
	if(idimage == '1072')
		return '1073';
	if(idimage == '1073')
		return '1074';
	if(idimage == '1074')
		return '1075';
	if(idimage == '1075')
		return '1076';
	if(idimage == '1076')
		return '1077';
	if(idimage == '1077')
		return '1078';
	if(idimage == '1078')
		return '1079';
	if(idimage == '1079')
		return '1081';
	if(idimage == '1081')
		return '1082';
	if(idimage == '1082')
		return '1091';
	if(idimage == '1091')
		return '';
}

function find_prev_tissu(idimage)
{
	if(idimage == '1091')
		return '1082';
	if(idimage == '1082')
		return '1081';
	if(idimage == '1081')
		return '1079';
	if(idimage == '1079')
		return '1078';
	if(idimage == '1078')
		return '1077';
	if(idimage == '1077')
		return '1076';
	if(idimage == '1076')
		return '1075';
	if(idimage == '1075')
		return '1074';
	if(idimage == '1074')
		return '1073';
	if(idimage == '1073')
		return '1072';
	if(idimage == '1072')
		return '1071';
	if(idimage == '1071')
		return '1070_10';
	if(idimage == '1070_10')
		return '1068';
	if(idimage == '1068')
		return '1067';
	if(idimage == '1067')
		return '1066';
	if(idimage == '1066')
		return '1065';
	if(idimage == '1065')
		return '1064';
	if(idimage == '1064')
		return '1063';
	if(idimage == '1063')
		return '1062';
	if(idimage == '1062')
		return '1061';
	if(idimage == '1061')
		return '1051';
	if(idimage == '1051')
		return '1047';
	if(idimage == '1047')
		return '1046';
	if(idimage == '1046')
		return '1045';
	if(idimage == '1045')
		return '1043';
	if(idimage == '1043')
		return '1042';
	if(idimage == '1042')
		return '1041';
	if(idimage == '1041')
		return '1040';
	if(idimage == '1040')
		return '1037';
	if(idimage == '1037')
		return '1036';
	if(idimage == '1036')
		return '1035';
	if(idimage == '1035')
		return '1033';
	if(idimage == '1033')
		return '1032';
	if(idimage == '1032')
		return '1031';
	if(idimage == '1031')
		return '1030';
	if(idimage == '1030')
		return '1027';
	if(idimage == '1027')
		return '1026';
	if(idimage == '1026')
		return '1025';
	if(idimage == '1025')
		return '1023';
	if(idimage == '1023')
		return '1022';
	if(idimage == '1022')
		return '1021';
	if(idimage == '1021')
		return '1020';
	if(idimage == '1020')
		return '1016';
	if(idimage == '1016')
		return '1015';
	if(idimage == '1015')
		return '1014';
	if(idimage == '1014')
		return '1013';
	if(idimage == '1013')
		return '1012';
	if(idimage == '1012')
		return '1011';
	if(idimage == '1011')
		return '1010';
	if(idimage == '1010')
		return '1008';
	if(idimage == '1008')
		return '1007';
	if(idimage == '1007')
		return '1006';
	if(idimage == '1006')
		return '1005';
	if(idimage == '1005')
		return '1004';
	if(idimage == '1004')
		return '1003';
	if(idimage == '1003')
		return '1002';
	if(idimage == '1002')
		return '1001';
	if(idimage == '1001')
		return '805';
	if(idimage == '805')
		return '801_2';
	if(idimage == '801_2')
		return '330_9';
	if(idimage == '330_9')
		return '330_8';
	if(idimage == '330_8')
		return '170_2';
	if(idimage == '170_2')
		return '60_10';
	if(idimage == '60_10')
		return '60_9';
	if(idimage == '60_9')
		return '';
}





function menuinfo(top, left){


    /*init undefined var */
    if (typeof(top) == "undefined") 
        top = '268';
    if (typeof(left) == "undefined") 
        left = '175';
    
    info = document.createElement("div");
    info.innerHTML = '<div id="infoID" style="top:' + top + 'px; left:' + left + 'px; margin: 0; position: absolute;	background: #ffffff; text-align:left;"><a href="http://ketiketa.com/blog/index.php?wptheme=Ketiketa"><img src="http://ketiketa.com/fr/menu/news.png" alt="News/Blog"/></a><div style="margin-top:8px;"><a href="http://ketiketa.com/fr/apropos.php" alt="A propos de Ketiketa"><img src="http://ketiketa.com/fr/menu/apropos.png" /></a><div style="margin-top:8px;"><a href="http://ketiketa.com/fr/makingof.php"><img src="http://ketiketa.com/fr/menu/makingof.png" alt="Making of"/></a></div><div style="margin-top:6px;"><a href="http://ketiketa.com/fr/lavage.php"><img src="http://ketiketa.com/fr/menu/lavage.png" alt="Instructions de lavage"/></a></div></div>';
    
    if (!document.getElementById("infoID")) {
        document.getElementById("background").appendChild(info);
    }
    else {
        var Old = document.getElementById("infoID");
        Old.parentNode.removeChild(Old);
    }
}

function menuinfoen(top, left){
    /*init undefined var */
    if (typeof(top) == "undefined") 
        top = '268';
    if (typeof(left) == "undefined") 
        left = '175';
    
    info = document.createElement("div");
    info.innerHTML = '<div id="infoID" style="top: ' + top + 'px; left: ' + left + 'px; margin: 0; position: absolute;	background: #ffffff; text-align:left;"><a href="http://ketiketa.com/blog/index.php?wptheme=ketiketa-english"><img src="http://ketiketa.com/fr/menu/news.png" alt="News/Blog"/></a><div style="margin-top:8px;"><a href="http://ketiketa.com/en/about.php" alt="About Ketiketa"><img src="http://ketiketa.com/fr/menu/about.png" /></a><div style="margin-top:8px;"><a href="http://ketiketa.com/en/makingof.php"><img src="http://ketiketa.com/fr/menu/makingof.png" alt="Making of"/></a></div><div style="margin-top:8px;"><a href="http://ketiketa.com/en/washing.php"><img src="http://ketiketa.com/fr/menu/washing.png" alt="Washing instructions"/></a></div></div> ';
    
    if (!document.getElementById("infoID")) {
        document.getElementById("background").appendChild(info);
    }
    else {
        var Old = document.getElementById("infoID");
        Old.parentNode.removeChild(Old);
    }
}


function menuinfoblog(){
    info = document.createElement("div");
    info.innerHTML = '<div id="infoID" style="top: 268px; left: 185px; margin: 0; position: absolute;	background: #ffffff; text-align:left;"><a href="http://ketiketa.com/blog/index.php?wptheme=Ketiketa"><img src="http://ketiketa.com/fr/menu/news.png" alt="News/Blog"/></a><div style="margin-top:8px;"><a href="http://ketiketa.com/fr/apropos.php" alt="A propos de Ketiketa"><img src="http://ketiketa.com/fr/menu/apropos.png" /></a></div><div style="margin-top:8px;"><a href="http://ketiketa.com/fr/makingof.php"><img src="http://ketiketa.com/fr/menu/makingof.png" alt="Making of"/></a></div><div style="margin-top:6px;"><a href="http://ketiketa.com/fr/lavage.php"><img src="http://ketiketa.com/fr/menu/lavage.png" alt="Instructions de lavage"/></a></div></div>';
    
    if (!document.getElementById("infoID")) {
        document.getElementById("background").appendChild(info);
    }
    else {
        var Old = document.getElementById("infoID");
        Old.parentNode.removeChild(Old);
    }
}

function menuinfoblogen(){
    info = document.createElement("div");
    info.innerHTML = '<div id="infoID" style="top: 285px; left: 185px; margin: 0; position: absolute;	background: #ffffff; text-align:left;"><a href="http://ketiketa.com/blog/index.php?wptheme=ketiketa-english"><img src="http://ketiketa.com/fr/menu/news.png" alt="News/Blog"/></a><div style="margin-top:8px;"><a href="http://ketiketa.com/en/about.php" alt="About Ketiketa"><img src="http://ketiketa.com/fr/menu/about.png" /></a></div><div style="margin-top:8px;"><a href="http://ketiketa.com/en/makingof.php"><img src="http://ketiketa.com/fr/menu/makingof.png" alt="Making of"/></a></div><div style="margin-top:8px;"><a href="http://ketiketa.com/en/washing.php"><img src="http://ketiketa.com/fr/menu/washing.png" alt="Washing instructions"/></a></div></div>';
    
    if (!document.getElementById("infoID")) {
        document.getElementById("background").appendChild(info);
    }
    else {
        var Old = document.getElementById("infoID");
        Old.parentNode.removeChild(Old);
    }
}


function pop_up(id){
    url = '../../tissus/' + id + '.html';
    window.open(url, id, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=292,height=292,left = 509,top = 381');
}


/* JavaScript Tooltip Michael Leigeber (c) 
 URL : http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/
 */
var tooltip = function(){
    var id = 'tt';
    var top = 3;
    var left = 3;
    var maxw = 300;
    var speed = 10;
    var timer = 20;
    var endalpha = 95;
    var alpha = 0;
    var tt, t, c, b, h;
    var ie = document.all ? true : false;
    return {
        show: function(v, w){
            if (tt == null) {
                tt = document.createElement('div');
                tt.setAttribute('id', id);
                t = document.createElement('div');
                t.setAttribute('id', id + 'top');
                c = document.createElement('div');
                c.setAttribute('id', id + 'cont');
                b = document.createElement('div');
                b.setAttribute('id', id + 'bot');
                tt.appendChild(t);
                tt.appendChild(c);
                tt.appendChild(b);
                document.body.appendChild(tt);
                tt.style.opacity = 0;
                tt.style.filter = 'alpha(opacity=0)';
                document.onmousemove = this.pos;
            }
            tt.style.display = 'block';
            c.innerHTML = v;
            tt.style.width = w ? w + 'px' : 'auto';
            if (!w && ie) {
                t.style.display = 'none';
                b.style.display = 'none';
                tt.style.width = tt.offsetWidth;
                t.style.display = 'block';
                b.style.display = 'block';
            }
            if (tt.offsetWidth > maxw) {
                tt.style.width = maxw + 'px'
            }
            h = parseInt(tt.offsetHeight) + top;
            clearInterval(tt.timer);
            tt.timer = setInterval(function(){
                tooltip.fade(1)
            }, timer);
        },
        pos: function(e){
            var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
            var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
            tt.style.top = (u - h) + 'px';
            tt.style.left = (l + left) + 'px';
        },
        fade: function(d){
            var a = alpha;
            if ((a != endalpha && d == 1) || (a != 0 && d == -1)) {
                var i = speed;
                if (endalpha - a < speed && d == 1) {
                    i = endalpha - a;
                }
                else 
                    if (alpha < speed && d == -1) {
                        i = a;
                    }
                alpha = a + (i * d);
                tt.style.opacity = alpha * .01;
                tt.style.filter = 'alpha(opacity=' + alpha + ')';
            }
            else {
                clearInterval(tt.timer);
                if (d == -1) {
                    tt.style.display = 'none'
                }
            }
        },
        hide: function(){
            clearInterval(tt.timer);
            tt.timer = setInterval(function(){
                tooltip.fade(-1)
            }, timer);
        }
    };
}();



