var _currentFill = "fill:#d4213d";
var p_red = 'fill:#d4213d';
var p_yellow = 'fill:#ffe131';
var p_green = 'fill:#80ce1b';
var p_violet = 'fill:#6d2bed';
var p_blue = 'fill:#339eff';
var p_orange = 'fill:#f28d20';
var p_brown = 'fill:#843617';
var p_pink = 'fill:#ff5cae';
var p_white = 'fill:#e9e8e7';

$("#svg_MW_I_1_3").click(function (event) {
    var task = 'MW_I_1_3';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('style') != 'fill:#000000') {
		$(event.target).attr('style', _currentFill);
	}
    var elements = $(event.target).parent().children();
    var yellow = false;
    var green = false;
    var violet = false;
    var other = true;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if (fill == p_yellow) {
			yellow = true;
		} else if (fill == p_green) {
			green = true;
		} else if (fill == p_violet) {
			violet = true;
		}
    }

    if (yellow && green && violet) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})
$("#svg_MW_I_5_2").click(function (event) {
    var task = 'MW_I_5_2';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('style') != 'fill:#000000') {
		$(event.target).attr('style', _currentFill);
	}
    var elements = $(event.target).parent().children();
    var red = false;
    var blue = false;
    var yellow = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if (fill == p_red) {
			red = true;
		} else if (fill == p_blue) {
			blue = true;
		} else if (fill == p_yellow) {
			yellow = true;
		}
    }

    if (red && blue && yellow) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})

$("#svg_MW_I_9_4").click(function (event) {
    var task = 'MW_I_9_4';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var elements = $(event.target).parent().children();
    var red = false;
    var orange = false;
    var brown = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'dab' && fill == p_red) {
			red = true;
		}
        if ($(elements[i]).attr('id') == 'kasztanowiec' && fill == p_orange) {
			orange = true;
		}
        if ($(elements[i]).attr('id') == 'klon' && fill == p_brown) {
			brown = true;
		}
    }

    if (red && orange && brown) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})
$("#svg_MW_I_10_2").click(function (event) {
    var task = 'MW_I_10_2';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var elements = $(event.target).parent().children();
    var tak = 0;
    var nie = 0;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'tak' && fill != "fill:#ffffff") {
			tak++;
		}
        if ($(elements[i]).attr('id') == 'nie' && fill == "fill:#ffffff") {
			nie++;  
		}
    }
    if (tak == 5 && nie == 1) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})
$("#svg_OS_I_1_8").click(function (event) { 
    var task = 'OS_I_1_8';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var elements = $(event.target).parent().children();
    var rect = 0;
    var circle = 0;
    var triangle = 0;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {

        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'trojkat' && fill == p_red) {
			triangle++;
		}
        if ($(elements[i]).attr('id') == 'trojkat' && fill != p_red) {
			triangle--;
		}
        if ($(elements[i]).attr('id') == 'kwadrat' && (fill == p_blue || fill == p_violet)) {
			rect++;
		}
        if ($(elements[i]).attr('id') == 'kwadrat' && fill != p_blue && fill != p_violet) {
			rect--;
		}
        if ($(elements[i]).attr('id') == 'kolo' && fill == p_yellow) {
			circle++;
		}
        if ($(elements[i]).attr('id') == 'kolo' && fill != p_yellow) {
			circle--;
		}
    }
    if (rect == 4 && circle == 6 && triangle == 5) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})
$("#svg_OS_I_3_1").click(function (event) { 
    var task = 'OS_I_3_1';
    var elements = $(event.target).parent().children();
	
    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var polska = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {

        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'polska' && fill != '') {
			polska = true;
			console.log("Polska zaznaczona");
		}
        if ($(elements[i]).attr('id') == 'polska' && fill == '') {
			polska = false;
			console.log("Polska niezaznaczona");
		}
    }

    if (polska) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_MW_I_3_1").click(function (event) {
    var task = 'MW_I_3_1';
    var elements = $(event.target).parent().children();
	
    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var polska = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'polska' && fill != '') {
			polska = true;
		}
        if ($(elements[i]).attr('id') == 'polska' && fill == '') {
			polska = false;
		}
    }

    if (polska) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_OS_I_3_2").click(function (event) {
    var task = 'OS_I_3_2';
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var elements = $(event.target).parent().children();
    var yellow = 0;
    var red = 0;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
        }
        if ($(elements[i]).attr('id') == 'path7' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path9' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path11' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path13' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path15' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path17' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path19' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path21' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path23' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'path25' && fill == p_yellow) {
			yellow++;
			console.log("yellow = "+yellow);
		}
        if ($(elements[i]).attr('id') == 'rect36' && fill == p_red) {
			red++;
			console.log("red = "+red);
		}
        if ($(elements[i]).attr('id') == 'path5' && fill == p_red) {
			red++;
			console.log("red = "+red);
		}
    }

    if (yellow >= 10 && red >= 2) {
        document.getElementById('vs_' + task).innerHTML = "1";
    }
})
var detektor = navigator.userAgent.toLowerCase();
var is_ie = detektor.indexOf('msie');
var is_ienew = detektor.indexOf('trident');
var yellow = 0, red = 0, green = 0, brown = 0, white = 0, pink = 0, orange = 0;
var europe = false, asia = false, africa = false, australia = false, north_america = false, south_america = false, antarctica = false;
$("#svg_OS_I_3_7").click(function (event) {
    var task = 'OS_I_3_7';
	
	if(is_ienew > -1 || is_ie > -1){
		console.log("Wykryto przeglądarkę IE");
		if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
			$(event.target).attr('style', _currentFill);
		}
		var elements = $(event.target).parent().children();
		var fill = '';

		for (var i = 0; i < elements.length; i++) {
			if ($(elements[i]).attr('style') !== undefined) {
				fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
			}
			else {
				fill = '';
			}
			if ($(event.target).parent().attr('id') == 'europe' && fill == p_red) {
				red = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'europe' && fill == '') {
				red = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'asia' && fill == p_yellow) {
				yellow = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'asia' && fill == '') {
				yellow = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'africa' && fill == p_green) {
				green = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'africa' && fill == '') {
				green = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'australia' && fill == p_brown) {
				brown = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'australia' && fill == '') {
				brown = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'antarctica' && fill == p_white) {
				white = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'antarctica' && fill == '') {
				white = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'south_america' && fill == p_pink) {
				pink = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'south_america' && fill == '') {
				pink = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'north_america' && fill == p_orange) {
				orange = 1;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			if ($(event.target).parent().attr('id') == 'north_america' && fill == '') {
				orange = 0;
				console.log("red = "+red+", yellow = "+yellow+", green = "+green+", brown = "+brown+", white = "+white+", pink = "+pink+", orange = "+orange);
			}
			var inner = $(event.target).parent().children();
        
			for (var j = 0; j < inner.length; j++) {
				$(inner[j]).attr('style', _currentFill);
			}
		}

		if (red == 1 && yellow == 1 && green == 1 && brown == 1 && white == 1 && pink == 1 && orange == 1) {
			document.getElementById('vs_' + task).innerHTML = "1";
		}
		else {
			document.getElementById('vs_' + task).innerHTML = "0";
		}
	} else {
		console.log("Wykryto przeglądarkę inną niż IE");
		var elements = $(event.target).parent();
		var fill = '';

		for (var i = 0; i < elements.length; i++) {
			if ($(elements[i]).attr('style') !== undefined) {
				fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
			} else {
				fill = '';
			}
			if ($(event.target).parent().attr('id') == 'europe' && _currentFill == p_red) 
			{
				europe = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'europe' && _currentFill != p_red) 
			{
				europe = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'asia' && _currentFill == p_yellow)
			{
				asia = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'asia' && _currentFill != p_yellow)
			{
				asia = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'africa' && _currentFill == p_green)
			{
				africa = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'africa' && _currentFill != p_green)
			{ 
				africa = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'australia' && _currentFill == p_brown)
			{
				australia = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'australia' && _currentFill != p_brown) 
			{
				australia = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'north_america' && _currentFill == p_orange) 
			{
				north_america = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'north_america' && _currentFill != p_orange)
			{ 
				north_america = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'south_america' && _currentFill == p_pink)
			{
				south_america = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'south_america' && _currentFill != p_pink)
			{ 
				south_america = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'antarctica' && _currentFill == p_white) 
			{
				antarctica = true;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			if ($(event.target).parent().attr('id') == 'antarctica' && _currentFill != p_white) 
			{
				antarctica = false;
				console.log("europa = "+europe+", azja = "+asia+", afryka = "+africa+", australia = "+australia+", antarktyda = "+antarctica+", south_america = "+south_america+", north_america = "+north_america);
			}
			var inner = $(event.target).parent().children();
        
			for (var j = 0; j < inner.length; j++) {
				$(inner[j]).attr('style', _currentFill);
			}
       
		}

		if (europe && asia && africa && australia && north_america && south_america && antarctica) {
			document.getElementById('vs_' + task).innerHTML = "1";
		} else {
			document.getElementById('vs_' + task).innerHTML = "0";
		}
	}
})
$("#svg_OS_I_4_2").click(function (event) {
    var task = 'OS_I_4_2';
    var elements = $(event.target).parent().children();

    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var wielka_brytania = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {

        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'wielka_brytania' && fill != '') {
			wielka_brytania = true;
		}
        if ($(elements[i]).attr('id') == 'wielka_brytania' && fill == '') {
			wielka_brytania = false;
		}
    }

    if (wielka_brytania) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_OS_I_5_1").click(function (event) {
    var task = 'OS_I_5_1';
    var elements = $(event.target).parent().children();

    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}

    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var hiszpania = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'hiszpania' && fill != '') {
			hiszpania = true;
		}
        if ($(elements[i]).attr('id') == 'hiszpania' && fill == '') {
			hiszpania = false;
		}
    }

    if (hiszpania) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_OS_I_6_3").click(function (event) {
    var task = 'OS_I_6_3';
    var elements = $(event.target).parent().children();

    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var grecja = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'grecja' && fill != '') {
			grecja = true;
		}
        if ($(elements[i]).attr('id') == 'grecja' && fill == '') {
			grecja = false;
		}
    }

    if (grecja) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_OS_I_8_7").click(function (event) {
    var task = 'OS_I_8_7';
    var elements = $(event.target).parent().children();
	
    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var rumunia = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'rumunia' && fill != '') {
			rumunia = true;
		}
        if ($(elements[i]).attr('id') == 'rumunia' && fill == '') {
			rumunia = false;
		}
    }

    if (rumunia) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_OS_I_9_3").click(function (event) {
    var task = 'OS_I_9_3'; 
    var elements = $(event.target).parent().children();

    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var francja = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'francja' && fill != '') {
			francja = true;
		}
        if ($(elements[i]).attr('id') == 'francja' && fill == '') {
			francja = false;
		}
    }

    if (francja) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
$("#svg_ZIP_I_9_8").click(function (event) {
    var task = 'ZIP_I_9_8';
    var elements = $(event.target).parent().children();

    for (var i = 0; i < elements.length; i++) {
		$(elements[i]).removeAttr("style");
	}
	
    if ($(event.target).attr('id') != 'svg_' + task && $(event.target).attr('id') != undefined) {
        $(event.target).attr('style', _currentFill);
    }
    var polska = false;
    var fill = '';

    for (var i = 0; i < elements.length; i++) {
        if ($(elements[i]).attr('style') !== undefined) {
			fill = $(elements[i]).attr('style').replace(" ", "").replace(";", "");
		}
        else {
			fill = '';
		}
        if ($(elements[i]).attr('id') == 'polska' && fill != '') {
			polska = true;
		}
        if ($(elements[i]).attr('id') == 'polska' && fill == '') {
			polska = false;
		}
    }

    if (polska) {
		document.getElementById('vs_' + task).innerHTML = "1";
	}
    else {
		document.getElementById('vs_' + task).innerHTML = "0";
	}
})
var $swatches = $(".swatches");
$swatches.click(function (event) {
    $swatch = $(event.target);
    loc = [parseInt($swatch.attr('x'), 10), parseInt($swatch.attr('y'), 10)]
    if (loc[0] > -1) {
		$("#selection", $swatches).attr('x', loc[0]);
	}
    if (loc[1] > -1) {
		$("#selection", $swatches).attr('y', loc[1]);
	}
    _currentFill = $swatch.attr('style');
})