// ustaw jako stronę startową
function UstawJakoStartowa(Obj)
{ 
	Obj.style.behavior = 'url(#default#homepage)'; 
	Obj.setHomePage('http://www.muzyka.pl');
	
	return false;
}

// dodaj do ulubionych
function DodajDoUlubionych()
{
	window.external.addFavorite('http://www.muzyka.pl', 'Muzyka.pl - muzyka, teksty piosenek, teledyski, mp3');
	
	return false;
}

/*
	name - name of the cookie
	value - value of the cookie
	[expires] - expiration date of the cookie (defaults to end of current session)
	[path] - path for which the cookie is valid (defaults to path of calling document)
	[domain] - domain for which the cookie is valid (defaults to domain of calling document)
	[secure] - Boolean value indicating if the cookie transmission requires a secure transmission
	* an argument defaults when it is assigned null as a placeholder
	* a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

/*
	name - name of the desired cookie
	return string containing value of specified cookie or null if cookie does not exist
*/

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if(begin == -1)
	{
    	begin = dc.indexOf(prefix);
		if(begin != 0) return null;
	}
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if(end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

/*
	name - name of the cookie
	[path] - path of the cookie (must be same as path used to create cookie)
	[domain] - domain of the cookie (must be same as domain used to create cookie) path and domain default if assigned null or omitted if no explicit argument proceeds
*/

function deleteCookie(name, path, domain) {
	if(getCookie(name))
	{
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if(skew > 0) date.setTime(date.getTime() - skew);
}

// pobierz obiekt
function _f(objName)
{
	return document.getElementById(objName);
}

// obsluga list dzien - miesiac - rok
function CheckDateSelect(dd, mm, yy, curr, extra_items) {
	var _dd = document.getElementById(dd);
	var _mm = document.getElementById(mm);
	var _yy = document.getElementById(yy);
	var _curr = document.getElementById(curr);
	
	var d_ind  = _dd.selectedIndex;
	var m_ind  = _mm.selectedIndex;
	var r_ind  = _yy.selectedIndex;
	var ind2   = _curr.selectedIndex;

	var dzien   = _dd.options[d_ind];
	var miesiac = _mm.options[m_ind];
	var rok     = _yy.options[r_ind];
	var zazn    = _curr.options[ind2];
	
	date = new Date();
	var d_dzien = date.getDate();
	var d_miesiac = date.getMonth()+1;
	var d_rok = date.getYear();
	if (d_rok<=110) {d_rok+=1900;}
	d_rok -= 1999;
			
	if (miesiac.value == '1' || miesiac.value == '3' || miesiac.value == '5' || miesiac.value == '7' || miesiac.value == '8' || miesiac.value == '12')
	{
		if (_dd.options.length < 29+extra_items)
			_dd.options[28+extra_items] = new Option('29','29');
		if (_dd.options.length < 30+extra_items)
			_dd.options[29+extra_items] = new Option('30','30');
		if (_dd.options.length < 31+extra_items)
			_dd.options[30+extra_items] = new Option('31','31');
	}
	else if (miesiac.value == '4' || miesiac.value == '6' || miesiac.value == '9' || miesiac.value == '11')
	{
		if (_dd.options.length < 29+extra_items)
			_dd.options[28+extra_items] = new Option('29','29');
		if (_dd.options.length < 30+extra_items)
			_dd.options[29+extra_items] = new Option('30','30');
		if(d_ind == 30+extra_items) _dd.options[0+extra_items].selected = true;
		_dd.options[30+extra_items] = null;
	}
	else if (miesiac.value == '2')
	{		
		if (rok.text == '2000' || rok.text == '2004' || rok.text == '2008' || rok.text == '2012' || rok.text == '2016')
		{
			if(d_ind >= 29+extra_items) _dd.options[0+extra_items].selected = true;
			_dd.options[30+extra_items] = null;
			_dd.options[29+extra_items] = null;
			if (_dd.options.length < 29+extra_items) _dd.options[28+extra_items] = new Option('29','29');
		}
		else
		{
			if(d_ind >= 28+extra_items) _dd.options[0+extra_items].selected = true;
			_dd.options[28+extra_items] = null;
			_dd.options[28+extra_items] = null;
			_dd.options[28+extra_items] = null;
		}
	}
	
	if( (zazn.value != 'none') && ((dzien.value == 'none') || (miesiac.value == 'none') || (rok.value == 'none')) )
	{
		if(curr != dd) _dd.options[d_dzien].selected = true;
		if(curr != mm) _mm.options[d_miesiac].selected = true;
		if(curr != yy) _yy.options[d_rok].selected = true;
	}
	else if(zazn.value == 'none')
	{
		if(curr != dd) _dd.options[0].selected = true;
		if(curr != mm) _mm.options[0].selected = true;
		if(curr != yy) _yy.options[0].selected = true;
	}
}

function ShowGaleria(id)
{
	window.open('/galeria/'+id+'.html', 'w'+id, 'toolbar=no, location=no, status=no, menubar=yes, scrollbars=yes, resizable=no, width=760, height=550, left='+(screen.width-760)/2+', top=20');
}

function PrintPage(url)
{
	window.open(url, 'printwnd', 'toolbar=yes, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width=560, height=450, left='+(screen.width-560)/2+', top=20');
}

function SendMessage(url)
{
	window.open('/powiadom_znajomego'+url, 'sendwnd', 'toolbar=yes, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width=400, height=350, left='+(screen.width-400)/2+', top=40');
}

function ShowImage(img_name, width, height)
{
	window.open('/zdjecie/'+img_name, 'imgview', 'toolbar=no, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function ShowText(text_name)
{
	width = 300;
	height = 220;
	window.open('/tekst/'+text_name, 'textview', 'toolbar=no, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function ShowMovie(url)
{
	width = 500;
	height = 420;	
	window.open('/film/'+url, 'filmview', 'toolbar=no, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function Teledysk(id)
{
	width = 366;
	height = 329;	
	window.open('/teledysk/'+id+'.html', 'video', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function TeledyskY(id)
{
	width = 425;
	height = 355;	
	window.open('/teledysk/'+id+'.html', 'video', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function ShowAudio(url)
{
	width = 366;
	height = 100;	
	window.open('/dzwiek/'+url, 'audioview', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function ShowPDF(url)
{
	width = 600;
	height = 500;	
	window.open('/pdf/'+url, 'pdfview', 'toolbar=no, location=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function RegulaminWnd(id)
{
	width = 400;
	height = 500;	
	window.open('/regulamin/'+id+'.html', 'regulamin', 'toolbar=yes, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width='+width+', height='+height+', left='+(screen.width-width)/2+', top=40');
}

function SendAnkieta(id)
{
	var sonda_obj = document.getElementById('Sonda_'+id);
	var sonda_form = document.getElementById('sonda_form_'+id);
	if(!sonda_obj || !sonda_form) return false;
	
	var o = 0;
	var i = 0;
	while(true)
	{
		i++;
		var odp = document.getElementById('sonda_odp_'+id+'_odp_'+i);
		if(!odp) break;
		if(odp.checked) o = i;
	}
	
	if(o == 0)
	{
		alert('Wybierz odpowiedz.');
		return false;	
	}
	
	advAJAX.get({
  		url: '/sonda.php',
		parameters : {
			"id" : id,
			"odp" : o	
		},
		onLoading : function(obj) { sonda_obj.innerHTML = '<div align="center" id="Sonda" style="padding: 10px;"><img src="/img/loading.gif"></div>'; },
	    onSuccess : function(obj) { sonda_obj.innerHTML = obj.responseText; },		
    	onError : function(obj) { alert("Wystąpił błąd podczas pobierania danych."); sonda_obj.innerHTML = ''; }
	});
	
	return false;
}

