jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


function getCookie(szName)
{
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{
       	var arr = 		  document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}




function css_effect(type,inpname,typ){

if($.cookie(''+type+'')){
$.cookie(""+type+"", "end", { expires: -1 });
}else{
$.cookie(''+type+'', 'true', { expires: 365});
}
$('.'+type+'').each(function() {
if($(this).css('display')=='none'){
$(this).animate({opacity: 'show'},400);

}else{
$(this).animate({opacity: 'hide'},400);

}
});
}


function cbox(typ,value){
if(typ=="man" || typ=="woman" || typ=="adult"){
var inpname = document.getElementById(typ).checked;

if(typ=="woman"){
css_effect('fiuk',inpname,typ);
}

if(typ=="man"){
css_effect('lanyok',inpname,typ);
}

if(typ=="adult"){
css_effect('adult',inpname,typ);
}

}
}

$(document).ready(function() {
	if ($.cookie('fiuk')){
	document.getElementById("woman").checked="true";
	$('.fiuk').each(function(index) {
	$(this).animate({opacity: 'show'});
	});
	}
	
	
	if ($.cookie('lanyok')){
	document.getElementById("man").checked="true";
	$('.lanyok').each(function(index) {
	$(this).animate({opacity: 'show'});
	});
	}
	
	if ($.cookie('adult')){
	document.getElementById("adult").checked="true";
	$('.adult').each(function(index) {
	$(this).animate({opacity: 'show'});
	});
	}


if($.cookie('fiuk') && $.cookie('lanyok') && $.cookie('adult')){console.log("Content filter active.")}else{
$('#filter').animate({opacity: 'show'});
}


	$('input:checkbox:not([safari])').checkbox();
				$('input[safari]:checkbox').checkbox({cls:'jquery-safari-checkbox'});
				$('input:radio').checkbox();


});

			displayForm = function (elementId)
			{
				var content = [];
				$('#' + elementId + ' input').each(function(){
					var el = $(this);
					if ( (el.attr('type').toLowerCase() == 'radio'))
					{
						if ( this.checked )
							content.push([
								'"', el.attr('name'), '": ',
								'value="', ( this.value ), '"',
								( this.disabled ? ', disabled' : '' )
							].join(''));
					}
					else
						content.push([
							'"', el.attr('name'), '": ',
							( this.checked ? 'checked' : 'not checked' ), 
							( this.disabled ? ', disabled' : '' )
						].join(''));
				});
				alert(content.join('\n'));
			}
			
			changeStyle = function(skin)
			{
				jQuery('#myform :checkbox').checkbox((skin ? {cls: skin} : {}));
			}
