/*
(c) 2009 KonteStacja.com
 ver. 1.5
	Kalin tu byl! o!
*/

AudioPlayer.setup("scripts/player.swf", {  
    width: 320,  
	autostart: "no",
	animation: "yes",
    transparentpagebg: "yes",  
	bg: "303030",
	leftbg: "333333",
	lefticon: "666666", 
	voltrack: "666666",
	volslider: "cccccc",
	rightbg: "555555",
	rightbghover: "666666",
	righticon: "cccccc",
	righticonhover: "ededed",
	loader: "7dae1a",
	track: "303030",
	tracker: "111111",
	border: "444444",
	skip: "303030",
	text: "efefef"
});

$(document).ready(function() {

	$("div.box div.title.arrow").each(function() {
		var name = $(this).parent().attr("id");
		if(name != "") {	
			cookie = readCookie(name);
			if(cookie == "no") {
				$(this).children("span.arrow").toggleClass("hide");
				$(this).nextAll().hide();
				createCookie(name, "no", 365);
			}	
		}
	}).click(function() {
		$(this).children("span.arrow").toggleClass("hide");
		$(this).nextAll().slideToggle("fast");
		var name = $(this).parent().attr("id");
		if(name != "") {
			cookie = readCookie(name);
			if(!cookie || cookie == "yes")
				createCookie(name, "no", 365);
			else
				createCookie(name, "yes", 365);
		}
	});
	
	$("input[type=text], input[type=password]").not(".select").each(function () {
        $(this).attr("default", $(this).val())
    }).focus(function () {
        if ($(this).val() == $(this).attr("default")) $(this).val("")
    }).blur(function () {
        if ($(this).val() == "") $(this).val($(this).attr("default"))
    });

	$("input[type=text].select, input[type=password].select").focus(function() {
		$(this).select();
	}).click(function() {
		$(this).select();
	});
	
	$("div.box a.slider").click(function() {
		$(this).prev("ul.hide").slideToggle();
		if( $(this).text() == "∨ więcej ∨" )
			$(this).text("∧ mniej ∧");
		else
			$(this).text("∨ więcej ∨");
	});

	if ($("#config-dialog").length && $("#config").length)
	{
		$("#config-dialog").dialog({
			autoOpen: false,
			modal: true,
			buttons: {
				'Anuluj': function() {
					$(this).dialog("close");
				},
				'Zapisz': function() {
					$(this).children("form").submit();
				}
			}
		});
		$("#config").click(function() {
				$("#config-dialog").dialog("open");
		});
	}

		$("div[id^='ramowka-dialog']").dialog({
			autoOpen: false,
			modal: true,
			buttons: {
				'Anuluj': function() {
					$(this).dialog("close");
				},
				'Ustaw': function() {
					$(this).children("form").submit();
				}
			}
		});
});

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
