var AdvancedFormCheck = {
    timer : 333,
    timelimit : 15000,
    doit : function() {
        if ( typeof(document.getElementById("lan2")) == 'undefined' || !document.getElementById("lan2") || (typeof(file_all_js) == 'undefined') ) {
            if (AdvancedFormCheck.timelimit > 0) {
                setTimeout('AdvancedFormCheck.doit()', AdvancedFormCheck.timer);
                AdvancedFormCheck.timelimit = AdvancedFormCheck.timelimit - AdvancedFormCheck.timer;
            }
        } else {
            AdvancedFormCheck.check_stored_values();
        }
    },
    check_stored_values: function()
    {
        // cookie_value = this.decode(this.readCookie('search_params'));
        cookie_value = getCookieValue('search_params');
        search_params = cookie_value.split(';');
        for(var i=0;i < search_params.length;i++) {
            if (search_params[i]) {
                settings = search_params[i].split(':');
                values = settings[1].split(',');
                for(var j=0;j < values.length;j++) {
                    if (settings[0]!='k') {
                        element = document.getElementById(settings[0] + values[j]);
                        if (element) element.checked = true;
                    }
                }
            }
        }

        languages_update_selector_label();
        sectors_update_selector_label();
        locations_update_selector_label();
        if (employments_update_selector_label) employments_update_selector_label();
        if (salary_update_selector_label) salary_update_selector_label();
    },
    readCookie : function(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
    },
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}

setTimeout('AdvancedFormCheck.doit()', AdvancedFormCheck.timer);



