DOMAIN = 'radio-proactive.net';
BASE_STATIC = 'http://static.'+DOMAIN+'/';
BASE_LINK = 'http://'+DOMAIN+'/';


//####################
//# NAWIGACJA NA STRONIE   #
//###################
$(document).ready(function(){
		$("#nav-one li").hover(
			function(){ $("ul", this).fadeIn("fast"); }, 
			function() { } 
		);
		if (document.all) {
			$("#nav-one li").hoverClass ("sfHover");
		}
	//Osadzanie obiektu flash !!
	var flashvars = {
		host: BASE_LINK,
	};
	var params = {
		menu: "false",
		wmode: "transparent"
	};
	var attributes = {};
	var randomnumber=Math.floor(Math.random()*1000)
	   swfobject.embedSWF(BASE_LINK  + "stale.swf?"+ randomnumber, "animacja", "922", "240", "8", BASE_LINK  + "expressInstall.swf", flashvars, params, attributes);

	odswiez_shout();
	setInterval("odswiez_shout();", 16000);
	setInterval("odswiez_panel();", 8000);
//mini_menu	
var Image1= new Image(160,45);
Image1.src = BASE_STATIC + "image/nav_over.png";

//enter w Szukaj na PROfeel
	$('#szukajProfeel').keypress(function(event) {
	  if (event.keyCode == '13') {
		 szukajProfeel();
	   }
	});
//enter w shoutbox
	$('#shout .dodaj').keypress(function(event) {
	  if (event.keyCode == '13') {
		 dodaj_shout();
	   }
	});

//profeelActionClick
	$('.wizPokaz').click(function(e){e.preventDefault();});
	
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});

};

function playWWW() {
var day = new Date();
var id = day.getTime();
eval("page" + id + " = window.open(BASE_LINK+'wwwplayer/', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=465,height=330,left = 302,top = 134');");
}
function imprezy(id) {
	var wizLink = BASE_LINK + "imprezy/"+id+"/.jpg";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Impreza w Radio PROactive');
	$('#wizytowka').click();
}

function wizytowka(id, link) {
	//var tmpLink = $(link).attr('href');
	//$(link).attr('href','javascript:void(null);');
	var wizLink = BASE_LINK + "wizytowka/"+id+".html?keepThis=true&TB_iframe=true&height=292&width=632";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Wiza PROfilaktyka');
	$('#wizytowka').click();
	//$(link).attr('href', tmpLink);
}

function pokazProfeel(id) {
	var wizLink = BASE_LINK + "profeel/"+id+"/";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", '');
	$('#wizytowka').click();
}

function zapiszAvatar() {
	if($('input[name="Filedata"]').val() !='')
	{	
		var wizLink = BASE_STATIC + "image/loadingAnimation.gif";
		$('#wizytowka').attr("href", wizLink);
		$('#wizytowka').attr("title", 'Wysyłanie avatara na serwer...');
		$('#wizytowka').click();
		$('#sendAvatar').attr('action', '/profeel/zapisz/');
		$('#sendAvatar').submit();
	}
}
function szukajProfeel() {
var kto = $('input[name="szukajProfilaktyka"]').val();
	if(kto != '')
	{
		$('#szukajProfeel').attr('action', '/profil.php');
		$('#szukajProfeel').submit();
	}
}
function zapiszProfeel() {
	var wizLink = BASE_STATIC + "image/loadingAnimation.gif";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Trwa akutalizacja danych...');
	$('#wizytowka').click();
	$('#twojeKonto').attr('action', '/profeel/zapisz/');
	$('#twojeKonto').submit();
}
/* 
Code Highlighting 
Courtesy of Dean Edwards star-light 
http://dean.edwards.name/my/behaviors/#star-light.htc
	- with jQuery methods added, of course

########################
# SHOUTBOX I ZDARZENIA #
########################
*/
/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function odswiez_shout() {
		$.ajax({
			type: "POST",
			url: BASE_LINK + 'shoutbox.php',
			data: "show=true",
			success: function(responseText) {
				$("#shout ul").html(responseText);
				while($("#shout ul").height() > $(".wypowiedzi").height())
						$("#shout ul li:last").remove();
				
				$('.wizPokaz').click(function(e){e.preventDefault();});
			}
		});
}

function dodaj_shout() {
	if($("#shout_tresc").val() != "") {
		$.ajax({
			type: "POST",
			url: BASE_LINK + 'shoutbox.php',
			data: "show=true&tresc=" + $("#shout_tresc").val(),
			success: function(responseText) {
				$("#shout ul").html(responseText);
				while($("#shout ul").height() > $(".wypowiedzi").height())
						$("#shout ul li:last").remove();
				$("#shout_tresc").val('');
				$('.wizPokaz').click(function(e){e.preventDefault();});
			}
		});
	}
}
/*
########################
# KOMENTARZE I ZDARZENIA #
########################
*/
function dodaj_komentarz(strona, id) {
	if($("#komentarz_tresc").val() != "") {
		$.ajax({
			type: "POST",
			url: BASE_LINK+'comments.php',
			data: "akcja=dodaj&strona=" + strona + "&indeks=" + id + "&tresc=" + $("#komentarz_tresc").val(),
			success: function(responseText) {
				$("ul.komentarze").html(responseText);
				$("#komentarz_tresc").val('');
				ile = $(".ileKomentarzy").html()*1 + 1;
				$(".ileKomentarzy").html(ile);
				$('.wizPokaz').click(function(e){e.preventDefault();});	
			}
		});
	}
}

function usun_komentarz(ktory) {
	$("#kom-"+ktory).remove();
		$.ajax({
			type: "POST",
			url: BASE_LINK + 'comments.php',
			data: "akcja=usun&kom=" + ktory,
			success: function() {
				ile = $(".ileKomentarzy").html()*1 - 1;
				$(".ileKomentarzy").html(ile);
			}
		});
}

//###########
//# ZNAJOMI #
//###########
function wizytowkaPW(kto) {
	setTimeout("wyslijPW("+kto+");", 300);
}

function wyslijPW(kto)
{
	var wizLink = BASE_LINK+"poczta/"+kto+".html?keepThis=true&TB_iframe=true&height=470&width=480";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Nowa wiadomosc');
	$('#wizytowka').click();
}

function dodajZnajomego(kto) {
	$.ajax({
		type: "GET",
		url: BASE_LINK+'znajomi.php?dodajZnajomego='+kto,
		success: function() {
			parent.location.reload(1);
		}
	});	

}

function odswiez_panel() {
		$.ajax({
			type: "POST",
			url: BASE_LINK + 'user.php',
			data: "refreshUserPanel=newMessages",
			success: function(responseText) {
				$("#newMessages").html(responseText);
			}
		});
		
		$.ajax({
			type: "POST",
			url: BASE_LINK + 'user.php',
			data: "refreshUserPanel=onZnajomi",
			success: function(responseText) {
				$("#onZnajomi").html(responseText);
			}
		});
}

function pokazKodPromuj(id) {
	var wizLink = BASE_LINK + "program_partnerski/"+id+".html?keepThis=true&TB_iframe=true&height=292&width=632";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Kod do wklejenia na Twoja strone');
	$('#wizytowka').click();
}

function pokazKodDemota(id) {
	var wizLink = BASE_LINK + "demotywujemy_nude/"+id+".html?keepThis=true&TB_iframe=true&height=372&width=632";
	$('#wizytowka').attr("href", wizLink);
	$('#wizytowka').attr("title", 'Kod do wklejenia na Twoja strone');
	$('#wizytowka').click();
}