﻿function Sh(theDiv,how){  
  document.getElementById(theDiv).style.display = how;  
}  

function popup(url) {
	newwindow=window.open(url,'name','height=600,width=600');
	if (window.focus) {newwindow.focus()}
	return false;
}

function showp(){  
  document.getElementById('searchb2').style.display = 'block';  
}  

function hidep(){  
  document.getElementById('searchb2').style.display = 'none';  
} 


$.growl.settings.dockTemplate = '<div></div>';
$.growl.settings.dockCss = {
    position: 'absolute',
    top: '10px',
    right: '10px',
    width: '300px'
  };

$(function() {
		$('#txtSearch').autocomplete({
		minLength: 1,
			source: function(request, response) {
							$.ajax({
								url: "the-includes/searchSuggest.php",
								dataType: "json",
								data: {
								search: request.term
								},
								success: function(data) {
										response($.map(data, function(item) {
										return {
											value: item.name
										}
									}));
								}
					        });
				},
		});
	});

window.onbeforeunload = function () {
checkVars();
}	

function set_activeto(id,active,n){
    	$.ajax({
   		beforeSend: function(){
   		},
		
		type: "GET",
		url: "templates/set_active.php",
		data: 'id='+id+'&active='+active,
		success: function(html){
		$.growl(n, 'ustawiona domyślną Playlistą');
		}
	});	
}
function set_active(id,active){
 $.ajax({
   		beforeSend: function(){
   		},
		
		type: "GET",
		url: "templates/get_active_name.php",
		data: '&active='+active,
		success: function(data){
		var n = data;
		set_activeto(id,active,n);
		}
	});
}	
	

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function checkVars(obj)
{
var flaga = 'url';
var q = getUrlVars()['q'];
var p = getUrlVars()['p'];
var m = getUrlVars()['m'];
var rl = getUrlVars()['rl'];
var c = getUrlVars()['c'];
var pl = getUrlVars()['pl'];
var hp = getUrlVars()['hp'];
var l = getUrlVars()['l'];
var ps = getUrlVars()['ps'];
var pbs = getUrlVars()['pbs'];
	if (q){
	q3 = q.replace(/\+/g," ");
	document.getElementById('txtSearch').value = q3;
	}
    if (m){
	
    	$.ajax({
   		beforeSend: function(){
   		},
		
		type: "GET",
		url: "file.php",
		data: 'id='+m+'',
		success: function(html){
		var info = html;
		var it = info.split(",");
		if (!q) res2(it[2]);
	    if (!q) document.getElementById('txtSearch').value = it[2];
		//tekst2(it[2],it[3]);
		inject_player(it[0],it[1],it[2],it[3],it[4],it[5],it[6],it[7],it[8],it[9]);
		document.getElementById("logo").style.display = "block";
		}
	});
	}
	
	if (rl) {
	radio_lista(rl,rl,flaga);
	}
	if (pl && !hp) {
	top_lista(pl,pl,flaga);
	}
	if (pl && hp) {
	myplayer(pl,hp,flaga);
	}
	if (l) {
	alles2(l);
	}
	if (l == 'random') {
	rand_pl();
	}
    if (q && p){
	document.getElementById('txtSearch').value = q;
	res(q,p);
    }
	if (ps) {
	play_similar(ps,flaga);
	}
	if (pbs) {
	play_bestsimilar(pbs,flaga);
	}
}

function play_random(){
$.growl('Czy wiesz że..', 'Losowy utwór zostanie odtworzony gdy przy pustym polu wyszukiwania naciśniesz ENTER');
var random = Math.floor(Math.random()*2000000);
window.location= '#m='+random;
checkVars();
}

function play_random_enter(){
var random = Math.floor(Math.random()*2000000);
window.location= '#m='+random;
checkVars();
}

var tb_pathToImage = "images/loading.gif";

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(o).2S(9(){1u(\'a.18, 3n.18, 3i.18\');1w=1p 1t();1w.L=2H});9 1u(b){$(b).s(9(){6 t=X.Q||X.1v||M;6 a=X.u||X.23;6 g=X.1N||P;19(t,a,g);X.2E();H P})}9 19(d,f,g){3m{3(2t o.v.J.2i==="2g"){$("v","11").r({A:"28%",z:"28%"});$("11").r("22","2Z");3(o.1Y("1F")===M){$("v").q("<U 5=\'1F\'></U><4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}n{3(o.1Y("B")===M){$("v").q("<4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}3(1K()){$("#B").1J("2B")}n{$("#B").1J("2z")}3(d===M){d=""}$("v").q("<4 5=\'K\'><1I L=\'"+1w.L+"\' /></4>");$(\'#K\').2y();6 h;3(f.O("?")!==-1){h=f.3l(0,f.O("?"))}n{h=f}6 i=/\\.2s$|\\.2q$|\\.2m$|\\.2l$|\\.2k$/;6 j=h.1C().2h(i);3(j==\'.2s\'||j==\'.2q\'||j==\'.2m\'||j==\'.2l\'||j==\'.2k\'){1D="";1G="";14="";1z="";1x="";R="";1n="";1r=P;3(g){E=$("a[@1N="+g+"]").36();25(D=0;((D<E.1c)&&(R===""));D++){6 k=E[D].u.1C().2h(i);3(!(E[D].u==f)){3(1r){1z=E[D].Q;1x=E[D].u;R="<1e 5=\'1X\'>&1d;&1d;<a u=\'#\'>2T &2R;</a></1e>"}n{1D=E[D].Q;1G=E[D].u;14="<1e 5=\'1U\'>&1d;&1d;<a u=\'#\'>&2O; 2N</a></1e>"}}n{1r=1b;1n="1t "+(D+1)+" 2L "+(E.1c)}}}S=1p 1t();S.1g=9(){S.1g=M;6 a=2x();6 x=a[0]-1M;6 y=a[1]-1M;6 b=S.z;6 c=S.A;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}13=b+30;1a=c+2G;$("#8").q("<a u=\'\' 5=\'1L\' Q=\'1o\'><1I 5=\'2F\' L=\'"+f+"\' z=\'"+b+"\' A=\'"+c+"\' 23=\'"+d+"\'/></a>"+"<4 5=\'2D\'>"+d+"<4 5=\'2C\'>"+1n+14+R+"</4></4><4 5=\'2A\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4>");$("#Z").s(G);3(!(14==="")){9 12(){3($(o).N("s",12)){$(o).N("s",12)}$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1D,1G,g);H P}$("#1U").s(12)}3(!(R==="")){9 1i(){$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1z,1x,g);H P}$("#1X").s(1i)}o.1h=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}n 3(I==3k){3(!(R=="")){o.1h="";1i()}}n 3(I==3j){3(!(14=="")){o.1h="";12()}}};16();$("#K").C();$("#1L").s(G);$("#8").r({Y:"T"})};S.L=f}n{6 l=f.2r(/^[^\\?]+\\??/,\'\');6 m=2p(l);13=(m[\'z\']*1)+30||3h;1a=(m[\'A\']*1)+3g||3f;W=13-30;V=1a-3e;3(f.O(\'2j\')!=-1){1E=f.1B(\'3d\');$("#15").C();3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4></4><U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\' > </U>")}n{$("#B").N();$("#8").q("<U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\'> </U>")}}n{3($("#8").r("Y")!="T"){3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\'>1l</a> 1k 1j 1s</4></4><4 5=\'F\' J=\'z:"+W+"p;A:"+V+"p\'></4>")}n{$("#B").N();$("#8").q("<4 5=\'F\' 3c=\'3b\' J=\'z:"+W+"p;A:"+V+"p;\'></4>")}}n{$("#F")[0].J.z=W+"p";$("#F")[0].J.A=V+"p";$("#F")[0].3a=0;$("#1H").11(d)}}$("#Z").s(G);3(f.O(\'37\')!=-1){$("#F").q($(\'#\'+m[\'26\']).1T());$("#8").24(9(){$(\'#\'+m[\'26\']).q($("#F").1T())});16();$("#K").C();$("#8").r({Y:"T"})}n 3(f.O(\'2j\')!=-1){16();3($.1q.35){$("#K").C();$("#8").r({Y:"T"})}}n{$("#F").34(f+="&1y="+(1p 33().32()),9(){16();$("#K").C();1u("#F a.18");$("#8").r({Y:"T"})})}}3(!m[\'1A\']){o.21=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}}}}31(e){}}9 1m(){$("#K").C();$("#8").r({Y:"T"})}9 G(){$("#2Y").N("s");$("#Z").N("s");$("#8").2X("2W",9(){$(\'#8,#B,#1F\').2V("24").N().C()});$("#K").C();3(2t o.v.J.2i=="2g"){$("v","11").r({A:"1Z",z:"1Z"});$("11").r("22","")}o.1h="";o.21="";H P}9 16(){$("#8").r({2U:\'-\'+20((13/2),10)+\'p\',z:13+\'p\'});3(!(1V.1q.2Q&&1V.1q.2P<7)){$("#8").r({38:\'-\'+20((1a/2),10)+\'p\'})}}9 2p(a){6 b={};3(!a){H b}6 c=a.1B(/[;&]/);25(6 i=0;i<c.1c;i++){6 d=c[i].1B(\'=\');3(!d||d.1c!=2){39}6 e=2a(d[0]);6 f=2a(d[1]);f=f.2r(/\\+/g,\' \');b[e]=f}H b}9 2x(){6 a=o.2M;6 w=1S.2o||1R.2o||(a&&a.1Q)||o.v.1Q;6 h=1S.1P||1R.1P||(a&&a.2n)||o.v.2n;1O=[w,h];H 1O}9 1K(){6 a=2K.2J.1C();3(a.O(\'2I\')!=-1&&a.O(\'3o\')!=-1){H 1b}}',62,211,'|||if|div|id|var||TB_window|function||||||||||||||else|document|px|append|css|click||href|body||||width|height|TB_overlay|remove|TB_Counter|TB_TempArray|TB_ajaxContent|tb_remove|return|keycode|style|TB_load|src|null|unbind|indexOf|false|title|TB_NextHTML|imgPreloader|block|iframe|ajaxContentH|ajaxContentW|this|display|TB_closeWindowButton||html|goPrev|TB_WIDTH|TB_PrevHTML|TB_iframeContent|tb_position||thickbox|tb_show|TB_HEIGHT|true|length|nbsp|span|Math|onload|onkeydown|goNext|Naciśnij|lub|Kliknij Zamknij|tb_showIframe|TB_imageCount|Close|new|browser|TB_FoundURL|Esc|Image|tb_init|name|imgLoader|TB_NextURL|random|TB_NextCaption|modal|split|toLowerCase|TB_PrevCaption|urlNoQuery|TB_HideSelect|TB_PrevURL|TB_ajaxWindowTitle|img|addClass|tb_detectMacXFF|TB_ImageOff|150|rel|arrayPageSize|innerHeight|clientWidth|self|window|children|TB_prev|jQuery|frameborder|TB_next|getElementById|auto|parseInt|onkeyup|overflow|alt|unload|for|inlineId||100||unescape|1000|round|hspace|TB_closeAjaxWindow|TB_title|undefined|match|maxHeight|TB_iframe|bmp|gif|png|clientHeight|innerWidth|tb_parseQuery|jpeg|replace|jpg|typeof|which|keyCode|event|tb_getPageSize|show|TB_overlayBG|TB_closeWindow|TB_overlayMacFFBGHack|TB_secondLine|TB_caption|blur|TB_Image|60|tb_pathToImage|mac|userAgent|navigator|of|documentElement|Prev|lt|version|msie|gt|ready|Next|marginLeft|trigger|fast|fadeOut|TB_imageOff|hidden||catch|getTime|Date|load|safari|get|TB_inline|marginTop|continue|scrollTop|TB_modal|class|TB_|45|440|40|630|input|188|190|substr|try|area|firefox'.split('|'),0,{}))


/* when the DOM is ready */  
window.addEvent('domready', function() {  
    /* create sortables */  
    var sb = new Sortables('sortable-list', {  
        /* set options */  
        clone:true,  
        revert: true,  
        /* initialization stuff here */  
        initialize: function() {   
  
        },  
        /* once an item is selected */  
        onStart: function(el) {  
            el.setStyle('background','#add8e6');  
        },  
        /* when a drag is complete */  
        onComplete: function(el) {  
            el.setStyle('background','#ddd');  
            //build a string of the order  
            var sort_order = '';  
            $$('#sortable-list li').each(function(li) { sort_order = sort_order +  li.get('rel')  + '|'; });  
            $('sort_order').value = sort_order;  
  
            //autosubmit if the checkbox says to  
            if($('auto_submit').checked) {  
                //do an ajax request  
                var req = new Request({  
                    url:'',  
                    method:'post',  
                    autoCancel:true,  
                    data:'sort_order=' + sort_order + '&ajax=' + $('auto_submit').checked + '&do_submit=1&byajax=1',  
                    onRequest: function() {  
                        $('message-box').set('text','Updating the sort order in the database.');  
                    },  
                    onSuccess: function() {  
                        $('message-box').set('text','Database has been updated.');  
                    }  
                }).send();  
            }  
        }  
    });  
});


function visible_off() {
                document.getElementById('txtSearch').focus();
				checkVars();
				if (window.location == 'http://joogle.pl/') $.growl('Witamy!', 'Zapraszamy do zapoznania się z nowymi funkcjami w serwisie');
				}		
				

   			
			
function visible() {
/*
                document.getElementById('myplaylist').style.display = "block";
                document.getElementById('logintpl').style.display = "block";
				document.getElementById('loginh3').style.display = "block";
				document.getElementById('sugester').style.display = "block";
				mint.fx.Fade("dedykacja", 100, 1, 500);
				mint.fx.Fade("loginh3", 100, 1, 500);
				mint.fx.Fade("jhr_h1", 100, 1, 500);
				mint.fx.Fade("sugester", 100, 1, 500);
				mint.fx.Fade("logintpl", 100, 1, 500);
*/				
				
			}	

			

function mark(schema) {

   schema.focus();
   schema.select();
 }
 



			

function ColorIn() {
    mint.fx.Color("cell", "Color", null, "B22222", 20, 500);
    mint.fx.Color("cell", "Color", null, "000000", 20, 500);
}


function StartFX() {
    mint.fx.Style("tekst1", "marginLeft", null, 4, 1, 1);
    mint.fx.Style("tekst1", "width", null,  970, 0, 1);
	StartFX2();
	FadeIn3()
	
}  

function StartFX2() {
    mint.fx.Style("tekst2", "fontSize", null, 50, 1, 1);
    mint.fx.Style("tekst2", "marginLeft", null, 4, 1, 1);
    mint.fx.Style("tekst2", "width", null,  970, 5, 1);
} 

function StartFX3() {
    mint.fx.Style("tekst1", "marginLeft", null, 510, 1, 1);
    mint.fx.Style("tekst1", "width", null,  470, 1, 1);
	StartFX4();
	FadeIn2();
	document.getElementById("tekst1").innerHTML ='';
	
}  

function StartFX4() {
    mint.fx.Style("tekst2", "fontSize", null, 16, 1, 1);
    mint.fx.Style("tekst2", "marginLeft", null, 0, 1, 1);
    mint.fx.Style("tekst2", "width", null,  470, 1, 1);
} 
 
function StartFXc3() {
    mint.fx.Style("tekst1", "marginLeft", null, 510, 1, 1);
    mint.fx.Style("tekst1", "width", null,  470, 1, 1);
	StartFXc4();
	
}  

function StartFXc4() {
    mint.fx.Style("tekst2", "fontSize", null, 16, 1, 1);
    mint.fx.Style("tekst2", "marginLeft", null, 0, 1, 1);
    mint.fx.Style("tekst2", "width", null,  470, 1, 1);
} 
 


 
 function Movetxt() {
				mint.fx.Move("search_field", 50,72, 1, 1);
			}

function move_for_player() {
			mint.fx.Move("latestsearch", 0,370, 1, 1);
			mint.fx.Move("tekst1", 520,430, 1, 1);
			mint.fx.Move("similar", 20,800, 1,1 );
			document.getElementById("player2").style.display = "none";
			document.getElementById("playlist_player").style.display = "block";
			document.getElementById("logo").style.display = "block";
			document.getElementById("dedykacja").style.display = "none";
			}		

function move_for_inject() {
			mint.fx.Move("latestsearch", 0,160, 1, 1);
			mint.fx.Move("tekst1", 520,220, 1, 1);
			mint.fx.Move("similar", 20,600, 1,1 );
			document.getElementById("playlist_player").style.display = "none";
			document.getElementById("player2").style.display = "block";
			document.getElementById("dedykacja").style.display = "none";
			}				
			
function Movetekst() {
				mint.fx.Move("tekst1", 583,210, 20, 10);
			}
			
			
 function Movesuggest() {
				mint.fx.Move("search_suggest", 220,140, 20, 10);
			}			
			
 function FadeOut() {
				mint.fx.Fade("logo2", 0, 20, 500);
				document.getElementById("logo2").style.display="none";
				
			}
			
function Fadelogin() {
				mint.fx.Fade("loginh", 0, 20, 500);
			}
			
function FadeOut2() {
				mint.fx.Fade("tekst1", 0, 20, 500);
				StartFXc3()
				
			}			
			
 function FadeIn() {
				mint.fx.Fade("logo", 100, 1, 20);
			}	

			

 function FadeIn2() {
				mint.fx.Fade("tekst1", 100, 1, 1);
			}

function FadeIn3() {
				mint.fx.Fade("tekst1", 90, 1, 5);
			}			
 
 function enter()
 
      {
	  
      return res(document.getElementById('txtSearch').value);
   
      }
	

function check(e){
    var s_search = document.getElementById("txtSearch");
    if (!e) var e = window.event;
	var shift = e.shiftKey;
	if (e.keyCode) code = e.keyCode;
	if(code == 13){
		if (s_search.value == "" || s_search.value == "coś"){
			rand_pl();
		}
		else if (shift || e.ctrlKey) {
		alles2(s_search.value);
		var all = 1;
		}
		else if (all != 1){
			res(s_search.value);
		}	
    code = '';		
	}
	else if (code == 78){
		if (shift || e.ctrlKey) {
		play_similar(s_search.value);
		}	
    code = '';		
	}
	else if(code == 80){
		if (shift || e.ctrlKey) {
		play_bestsimilar(s_search.value);
		}
		code = '';	
		}	
	else if(code == 95){
		if (shift || e.ctrlKey) {
		rand_pl();
		}
		code = '';	
		}	
}
	   
	  

 function check2(e){
    var code;
      if (!e) var e = window.event;
      if (e.keyCode) code = e.keyCode;
      else if (e.which) code = e.which;
      if(code == 13){
        return on_login();;
      }
  }
   


function checkInp()
{
	s_search = document.getElementById("txtSearch");
	s_submit = document.getElementById("cmdSearch");

	if(s_search.value == ""){
		alert("Musisz wpisać jakieś słowo w pole wyszukiwania!");
		s_search.focus();
		return false;
	}

	s_submit.disabled = true;
	s_submit.value = "Process...";
	return true;
}

 function enter()
 
      {
      return res(document.getElementById('txtSearch').value);
   
      }

function restrictChars(myfield, e)
{
	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
   		return true;	

	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
   	return true;
	// numbers + alphabetic chars
	else if ((("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZęółśążźćńĄĘÓŁŚŻŹĆŃ-.,\"' ").indexOf(keychar) > -1))
   		return true;
	else
		alert("Dozwolone są znaki - . , \" ' i spacje");
		return false;
}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function inject_player(url, name, n, s, i, ile, src, link_id, name1,name2)
{
	$.ajax({
   		beforeSend: function(){
   		},
		type: "GET",
		url: "mp3_player.php",
		data: 'url='+url+'&name='+name+'&src='+src+'&like='+link_id,
		success: function(html){
		$.growl('Słuchasz:', name2);
		document.title = name2;
		window.location='#m='+link_id;
			    var j;
				if (i != 'link'){
					for (j=1;j<ile;j++){
					document.getElementById('cell'+j).style.borderColor="#000000";				
				}
				}
				move_for_inject();
				if (i != 'link') {document.getElementById('cell'+i).style.borderColor="#444444";}
                document.getElementById('player2').innerHTML = html;
			
			//if (i != 'link') tekst(n,s);
			if (i == 'link') similar2(n,s);
			
		}

	});
}

function similar(n,s)
{
	$.ajax({
   		beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/similar.php",
		data: 'n='+n+'&s='+s+'',
		success: function(html){
			document.getElementById('similar').innerHTML = html;
		}
	});
}

function play_similar(np)
{
		$.ajax({
   		beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/play_similar.php",
		data: '&np='+np+'',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&ps='+np;
		if (!q) window.location = '#ps='+np;
		move_for_player();
		document.getElementById('dedykacja').innerHTML = '';
        Movetxt();
		document.getElementById("logo2").style.display="none";
		document.getElementById("logo").style.display="block";
	    document.getElementById('playlist_player').innerHTML = html;
		$.growl('Tworzę Playlistę', 'Zawierającą najlepsze utwory wykonawcy: '+np);
			
		}
	});
}

function play_bestsimilar(np)
{
		$.ajax({
   		beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/play_bestsimilar.php",
		data: '&np='+np+'',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&pbs='+np;
		if (!q) window.location = '#pbs='+np;
		move_for_player();
		document.getElementById('dedykacja').innerHTML = '';
        Movetxt();
		document.getElementById("logo2").style.display="none";
		document.getElementById("logo").style.display="block";
		document.getElementById('playlist_player').innerHTML = html;
		$.growl('Tworzę Playlistę', 'Zawierającą najlepsze utwory wykonawców podobnych do: '+np);
			
		}
	});
}

function play_similar_one(np)
{
	$.ajax({
   		beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/play_similar_one2.php",
		data: '&np='+np+'',
		success: function(html){
		    move_for_player();
			document.getElementById('playlist_player').innerHTML = html;
		}
	});
}

function similar2(q)
{
	$.ajax({
   		beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/similar.php",
		data: 'q='+q+'',
		success: function(html){
			document.getElementById('similar').innerHTML = html;
		}
	});
}

function send_image(image)
{

	$.ajax({
   		beforeSend: function(){
		document.getElementById('playlist_player').innerHTML = 'Ładuję playlistę...';
   		},
		type: "GET",
		url: "templates/image2.php",
		data: 'image='+image+'',
		success: function(html){
			document.getElementById('myaccount').innerHTML = html;
		}
	});
	
	
	$.ajax({
   		beforeSend: function(){
			document.getElementById('myaccount').innerHTML = '<img src="images/loadingmp3.gif" alt="Loading..." />';
   		},
		type: "GET",
		url: "templates/myaccount2.php",
		data: '',
		success: function(html){
			document.getElementById('myaccount').innerHTML = html;
		}
	});
	
	
}

function info(n,s)
{
	$.ajax({
   		beforeSend: function(){
   		},
		type: "GET",
		url: "templates/info.php",
		data: 'n='+n+'&s='+s+'',
		success: function(html){
		document.getElementById('info').innerHTML = html;
		//tekst(n,s);
		}
	});
}

function res2(q,p)
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('latestsearch').style.opacity = 0.80;
   		},
   		type: "GET",
		url: "display.php",
		data: 'q='+q+'&page='+p+'&t=audio',
		success: function(html){
		if (!p) {
		p = 1;
		var res = 1;
		}
		var q2 = q.replace(/%20/g,"+");	
		q2 = q2.replace(/\s/g,'+');
		var m = getUrlVars()['m'];
		var rl = getUrlVars()['rl'];
		var pl = getUrlVars()['pl'];
		var l = getUrlVars()['l'];
		var c = getUrlVars()['c'];
		if (m) window.location='#q='+q2+'&p='+p+'&m='+m;
		if (rl) window.location='#q='+q2+'&p='+p+'&rl='+rl;
		if (pl) window.location='#q='+q2+'&p='+p+'&pl='+pl;
		if (l) window.location='#q='+q2+'&p='+p+'&l='+l;
		if (c) window.location = window.location+'&c='+c;
		if (!m && !rl && !pl && !l) window.location='#q='+q2+'&p='+p;
		document.getElementById('dedykacja').style.display = "none";
		document.getElementById('latestsearch').style.opacity = 1;
		document.getElementById('dedykacja').innerHTML = '';
        Movetxt();
		document.getElementById("logo2").style.display="none";
		document.getElementById("logo").style.display="block";
		document.getElementById('latestsearch').innerHTML = html;
		//tekst2(q);
		}
	});
}

function res(q,p)
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('latestsearch').style.opacity = 0.80;
   		},
   		type: "GET",
		url: "display.php",
		data: 'q='+q+'&page='+p+'&t=audio',
		success: function(html){
		if (!p) {
		p = 1;
		var res = 1;
		}
		var q2 = q.replace(/%20/g,"+");	
		q2 = q2.replace(/\s/g,'+');
		var m = getUrlVars()['m'];
		var rl = getUrlVars()['rl'];
		var pl = getUrlVars()['pl'];
		var l = getUrlVars()['l'];
		var c = getUrlVars()['c'];
		if (m) window.location='#q='+q2+'&p='+p+'&m='+m;
		if (rl) window.location='#q='+q2+'&p='+p+'&rl='+rl;
		if (pl) window.location='#q='+q2+'&p='+p+'&pl='+pl;
		if (l) window.location='#q='+q2+'&p='+p+'&l='+l;
		if (c) window.location = window.location+'&c='+c;
		if (!m && !rl && !pl && !l) window.location='#q='+q2+'&p='+p;
		document.getElementById('dedykacja').style.display = "none";
		document.getElementById('latestsearch').style.opacity = 1;
		document.getElementById('dedykacja').innerHTML = '';
        Movetxt();
		document.getElementById("logo2").style.display="none";
		document.getElementById("logo").style.display="block";
		document.getElementById('latestsearch').innerHTML = html;
		similar2(q);
		//tekst2(q);
		}
	});
}



function toplisty()
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('toplisty').innerHTML = '';
		
   		},
   		type: "GET",
		url: "templates/toplisty.php",
		data: '',
		success: function(html){
		document.getElementById('mojaplaylista').style.display = "none";
		document.getElementById('radio').style.display = "none";
		//if (document.getElementById('toplisty').style.display == "block") document.getElementById('toplisty').style.display = "none";
		document.getElementById('toplisty').style.display = "block";
		document.getElementById('toplisty').innerHTML = html;
		}
	});
}

function radio()
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('radio').innerHTML = '';
		
   		},
   		type: "GET",
		url: "templates/radio.php",
		data: '',
		success: function(html){
		document.getElementById('toplisty').style.display = "none";
		document.getElementById('mojaplaylista').style.display = "none";
		//if (document.getElementById('radio').style.display == "block") document.getElementById('radio').style.display = "none";
		document.getElementById('radio').style.display = "block";
		document.getElementById('radio').innerHTML = html;
		}
	});
}


function link_pl(link)
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('link_pl').innerHTML = '';
		
   		},
   		type: "GET",
		url: "templates/link_pl.php",
		data: 'link='+link+'',
		success: function(html){
		document.getElementById('link_embed').style.display = "none";
		if (document.getElementById('link_pl').style.display == "block") document.getElementById('link_pl').style.display = "none";
		else document.getElementById('link_pl').style.display = "block";
		document.getElementById('link_pl').innerHTML = html;
		}
	});
}

function link_embed(embed)
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('link_embed').innerHTML = '';
   		},
   		type: "GET",
		url: "templates/link_embed.php",
		data: 'embed='+embed+'',
		success: function(html){
		document.getElementById('link_pl').style.display = "none";
		if (document.getElementById('link_embed').style.display == "block") document.getElementById('link_embed').style.display = "none";
		else document.getElementById('link_embed').style.display = "block";
		document.getElementById('link_embed').innerHTML = html;
		}
	});
}

function mojaplaylista()
{
	$.ajax({
	    beforeSend: function(){
		document.getElementById('mojaplaylista').innerHTML = '';
		
   		},
   		type: "GET",
		url: "templates/mojaplaylista.php",
		data: '',
		success: function(html){
		document.getElementById('radio').style.display = "none";
		document.getElementById('toplisty').style.display = "none";
		if (document.getElementById('mojaplaylista').style.display == "block") document.getElementById('mojaplaylista').style.display = "none";
		else document.getElementById('mojaplaylista').style.display = "block";
		document.getElementById('mojaplaylista').innerHTML = html;
		}
	});
}

function logo()
{
	$.ajax({
	    beforeSend: function(){
		
   		},
		type: "GET",
		url: "templates/latest.php",
		data: 't=audio',
		success: function(html){
		document.getElementById('latestsearch').innerHTML = html;
		document.getElementById('search1').innerHTML ='';
		document.getElementById('tekst1').innerHTML ='';
		}
	});
}


function tekst(n,s)
{
	$.ajax({
	    beforeSend: function(){
   		},
   		type: "GET",
		url: "tekst.php",
		data: 'n='+n+'+&s='+s+'',
		success: function(html){
		document.getElementById('tekst1').style.display = "block";
		document.getElementById('tekst1').innerHTML = html;
		
		
		}
	});
}

function tekst2(n,s)
{
	$.ajax({
	    beforeSend: function(){
   		},
   		type: "GET",
		url: "tekst2.php",
		data: 'n='+n+'+&s='+s+'',
		success: function(html){
		FadeIn2();
		document.getElementById('tekst1').style.display = "block";
		document.getElementById('tekst1').innerHTML = html;
		
		
		}
	});
}

function tekst_pl(n)
{
	$.ajax({
	    beforeSend: function(){
   		},
   		type: "GET",
		url: "tekst2.php",
		data: 'n_pl='+n,
		success: function(html){
		document.getElementById('tekst1').style.display = "block";
		document.getElementById('tekst1').innerHTML = html;
		
		
		}
	});
}

function info2(n,s)
{
	$.ajax({
	    beforeSend: function(){
   		},
   		type: "GET",
		url: "templates/info2.php",
		data: 'n='+n+'+&s='+s+'',
		success: function(html){
		document.getElementById('info2').style.display = "block";
		document.getElementById('info2').innerHTML = html;
		
		
		}
	});
}

function close_player()
{
	$.ajax({
   		beforeSend: function(){
   		},
		complete: function(){
			document.getElementById('player1').innerHTML = '';
		}
	});
}

function close()
{
	$.ajax({
   		beforeSend: function(){
   		},
		complete: function(){
			document.getElementById('tekst2').innerHTML = '';
		}
	});
}

function mp3playlist()
{
	$.ajax({
	    beforeSend: function(){
   		},
   		type: "GET",
		url: "sort/index.php",
		data: '',
		success: function(html){
		document.getElementById('tekst1').style.display = "block";
        document.getElementById('tekst1').innerHTML = html;
		
		}
	});
}


function LoadContent(pf1, pf2, pf3)
{
	$.get("display.php", { q: pf1, src: pf2, page: pf3 },
		function(html){
			$('#' + pf2 + '').replaceWith(html);
		}
	);
}

function LoadContentVideo(pf1, pf2, pf3, pf4)
{
	$.get("display.php", { q: pf1, src: pf2, page: pf3, type: pf4 },
		function(html){
			$('#' + pf2 + '').replaceWith(html);
		}
	);
}

function alert_disable_dl()
{
	alert("Currently Disabled!");
}

function alert_disable_guest_dl()
{
	alert("Musisz się zalogować, aby pobrać ten utwór!");
}

function alert_add_playlist()
{
$.growl('Nie jesteś zalogowany', 'Musisz się zalogować, aby dodawać utwory do playlisty');
}

function alert_add_video()
{
	alert("Musisz się zalogować, aby dodać wideo do playlist`y!");
}

function deletemp3(remove)
{ 

$.ajax({
		beforeSend: function(){
		document.getElementById(remove).innerHTML = '<img src="images/time.png" alt="Dodawanie" width="16px" height="16px" class="cellicon" />';
		},
		type: "GET",
		url: "",
		data: '',
		async: false,
		success: function(msg){
		document.getElementById(remove).innerHTML = '<img src="images/action_check.png" alt="Dodane do playlisty" width="16px" height="16px" class="cellicon" />';
		}
	});
	
}

function addMP3to(link,n,active)
{

	$.ajax({
		beforeSend: function(){
		},
		type: "GET",
		url: "index.php?p=addsong",
		data: '&' + link + '',
		async: false,
		success: function(html){
		document.getElementById(link).innerHTML = '<img src="images/action_check.png" alt="Dodane do playlisty" width="16px" height="16px" class="cellicon" />';
		$.growl(n, 'dodano do Playlisty ' + active );
		document.getElementById('account').innerHTML = html;
		}
	});		
	
	
}

function addMP3(link,name){
 $.ajax({
   		beforeSend: function(){
   		},
		
		type: "GET",
		url: "templates/get_active_name.php",
		data: '',
		success: function(data){
		var active = data;
		addMP3to(link,name,active);
		}
	});
}

function addmp3_from_playlist(name,url)
{
	$.ajax({
		beforeSend: function(){
		},
		type: "GET",
		url: "index.php?p=addsong",
		data: '&url_pl='+url+'&name='+name,
		async: false,
		success: function(html){
		document.getElementById('tekst1').innerHTML = html;
		$.growl(name, 'dodano do Twojej aktywnej Playlisty');
		}
	});	
	
}


function top_lista(id_pl,name,flaga)
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/top_lista2.php",
		data: '&id_pl='+id_pl+'&name='+name+'',
		success: function(html){
		if (flaga != 'url'){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&pl='+id_pl;
		if (!q) window.location = '#pl='+id_pl;
		}
		move_for_player();
		document.getElementById("logo2").style.display="none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		document.getElementById("logo").style.display="block";
		
		}
	});
}

function radio_lista(id_pl,name,flaga)
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/radio_lista.php",
		data: '&id_pl='+id_pl+'.xml&name='+name+'',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&rl='+id_pl;
		if (!q) window.location = '#rl='+id_pl;
		if (flaga == 'url'){
			if (c) window.location = window.location + '&c='+c;
		}
        move_for_player();
		document.getElementById("logo2").style.display="none";
		document.getElementById("playlist_player").innerHTML = html;
		Movetxt();
		Movesuggest();
		document.getElementById("logo").style.display="block";
		}
	});
}


function alles(srch){
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/all.php",
	    data: '&srch='+srch+'',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&l='+srch;
		if (!q) window.location = '#l='+srch;	
		if (c) window.location = window.location+'&c='+c;
		move_for_player();
		document.getElementById('logo2').style.display = "none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		FadeOut();
		document.getElementById("logo").style.display="block";
		FadeIn();
		}
	});
	
}

function rand_pl(){
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/all.php",
	    data: '',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&l=random';
		if (!q) window.location = '#l=random';	
		if (c) window.location = window.location+'&c='+c;
		move_for_player();
		document.getElementById('logo2').style.display = "none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		FadeOut();
		document.getElementById("logo").style.display="block";
		FadeIn();
		}
	});
	
}

function alles2(srch,w){
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/all2.php",
	    data: '&srch='+srch+'',
		success: function(html){
		if (w) $.growl('Zamiast przycisku SŁUCHAJ', 'możesz użyć kombinacji: SHIFT+ENTER');
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&l='+srch;
		if (!q) window.location = '#l='+srch;	
		if (c) window.location = window.location+'&c='+c;
		move_for_player();
		document.getElementById('logo2').style.display = "none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		FadeOut();
		document.getElementById("logo").style.display="block";
		FadeIn();
		}
	});
	
}


function myplayer(active,pl,hp,flaga)
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/playlista.php",
		data: '&pl='+pl+'&hp='+hp,
		success: function(html){
		var p = getUrlVars()['p'];
		var q = getUrlVars()['q'];
		var c = getUrlVars()['c'];
		if (q) window.location='#q='+q+'&p='+p+'&pl='+active+'&hp='+hp;
		if (!q) window.location='#pl='+active+'&hp='+hp;
		if (flaga == 'url'){
		if (c) window.location = window.location+'&c='+c;
		}
		move_for_player();
		document.getElementById("logo2").style.display="none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		document.getElementById("logo").style.display="block";
		
		}
	});
}

function top_lista2(id_pl,name,flaga)
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/top_lista2.php",
		data: '&id_pl='+id_pl+'&name='+name+'',
		success: function(html){
		var c = getUrlVars()['c'];
		var q = getUrlVars()['q'];
		var p = getUrlVars()['p'];
		if (q) window.location = '#q='+q+'&p='+p+'&pl='+id_pl;
		if (!q) window.location = '#pl='+id_pl;
		if (flaga == 'url'){
			if (c) window.location = window.location + '&c='+c;
		}
		move_for_player();
		document.getElementById("logo2").style.display="none";
		document.getElementById('playlist_player').innerHTML = html;
		Movetxt();
		Movesuggest();
		document.getElementById("logo").style.display="block";
		
		}
	});
}



function srch_all(srch_all)
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/all.php",
		data: '&srch='+srch_all+'',
		success: function(html){
		document.getElementById('slideshow').style.display = "none";
		document.getElementById('playlist_player').innerHTML = html;
		document.getElementById('toplisty').innerHTML = '';
		}
	});
}

function myaccount()
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/myaccount2.php",
		data: '',
		success: function(html){
		document.getElementById('myaccount').innerHTML = html;
		}
	});
}

function add_playlist(name,check,pass)
{
	$.ajax({
		beforeSend: function(){
				},
		type: "GET",
		url: "templates/new_playlist.php",
		data: '&name=' + name + '&check='+check+'&pass='+pass,
		success: function(html){
		document.getElementById('process').innerHTML = html;
		}
	});
		$.ajax({
	    beforeSend: function(){
		document.getElementById('loginh2').innerHTML = '<img src="images/loading.gif" alt="Loading..." />';
		},
   		type: "GET",
		url: "templates/myaccount.php",
		data: '',
		success: function(html){
		$("#msgbox").fadeTo(200,0);
		var lol = document.getElementById('txtSearch').value;
		var url = window.location.href;
		document.getElementById('logintpl').innerHTML = '';
		document.getElementById('loginh2').innerHTML = html;
		if (lol){
		res(lol);
		}
		}
	});
	
}

function new_playlist_form()
{
	$.ajax({
	    beforeSend: function(){
		
   		},
   		type: "GET",
		url: "templates/show_form.php",
		data: '',
		success: function(html){
		document.getElementById('search_field').style.opacity= 0.3;
		document.getElementById('player2').style.opacity= 0.3;
		document.getElementById('playlist_player').style.opacity= 0.3;
		document.getElementById('latestsearch').style.opacity= 0.3;
		document.getElementById('tekst1').style.opacity= 0.3;
		document.getElementById('show_playlist_form').style.display = "block";
		document.getElementById('show_playlist_form').innerHTML = html;
		}
	});
}

function close_form()
{
document.getElementById('search_field').style.opacity= 1
		document.getElementById('player2').style.opacity= 1;
		document.getElementById('playlist_player').style.opacity= 1;
		document.getElementById('latestsearch').style.opacity= 1;
		document.getElementById('tekst1').style.opacity= 1;
		document.getElementById('show_playlist_form').style.display = "none";
}


function addVideo(add)
{
	$.ajax({
		beforeSend: function(){
			document.getElementById(add).innerHTML = '<img src="images/time.png" alt="Dodawanie" />';
		},
		type: "GET",
		url: "index.php?p=addvideo",
		data: '&' + add + '',
		async: false,
		success: function(msg){
			document.getElementById(add).innerHTML = '<img src="images/check.png" alt="Added" />';
			document.getElementById('player1').innerHTML = '';
		}
	});
			$.ajax({
	    beforeSend: function(){
		document.getElementById('search1').innerHTML = '<img src="images/loading.gif" alt="Loading..." />';
		
   		},
   		type: "GET",
		url: "templates/playlista.php",
		data: '',
		success: function(html){
		document.getElementById('search1').innerHTML = '';
		document.getElementById('player1').innerHTML = html;
		}
	});
}

function deleteVideo(remove)
{
	$.ajax({
		beforeSend: function(){
			document.getElementById(remove).innerHTML = 'Usuwanie';
		},
		type: "GET",
		url: "index.php?p=removevideo",
		data: '&id=' + remove + '',
		async: false,
		success: function(msg){
			document.getElementById(remove).innerHTML = 'Usunięto';
		}
	});
}

function on_login()
{
	uname_login = document.getElementById("username3");
	pass_login = document.getElementById("password3");
	uname_login.disabled = false;
	pass_login.disabled = false;
	$("#msgbox").addClass('messagebox').text('Sprawdzam').fadeIn(1000);
	$.post("index.php?p=do_login",{ username:$('#username3').val(),password:$('#password3').val(),rand:Math.random() } ,
		function(data)
		{
			if(data!='success')
			{
				$("#msgbox").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
				uname_login.disabled = false;
				pass_login.disabled = false;
			}
			else 
			{
				$("#msgbox").fadeTo(200,0.1,
					function()  //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html('Trwa logowanie').addClass('messageboxok').fadeTo(0,1,
							function()
							{ 
	
    
	$.ajax({
	    beforeSend: function(){
		document.getElementById('loginh2').innerHTML = '<img src="images/loading.gif" alt="Loading..." />';
		},
   		type: "GET",
		url: "templates/myaccount.php",
		data: '',
		success: function(html){
		$("#msgbox").fadeTo(200,0);
		var lol = document.getElementById('txtSearch').value;
		var url = window.location.href;
		location.replace('http://joogle.pl');
		document.getElementById('logintpl').innerHTML = '';
		document.getElementById('loginh2').innerHTML = html;
		if (lol){
		res(lol);
		}
		}
	});
	
	
	
	
							}
						);
					}
				);
			}		
		}
	);
	return false; 
}

function auto_login(login,pass)
{
	uname_login = login;
	pass_login = pass;
	uname_login.disabled = false;
	pass_login.disabled = false;
	$("#msgbox").addClass('messagebox').text('Sprawdzam').fadeIn(1000);
	$.post("index.php?p=do_login",{ username:$('#username3').val(),password:$('#password3').val(),rand:Math.random() } ,
		function(data)
		{
			if(data!='success')
			{
				$("#msgbox").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
				uname_login.disabled = false;
				pass_login.disabled = false;
			}
			else 
			{
				$("#msgbox").fadeTo(200,0.1,
					function()  //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html('Trwa logowanie').addClass('messageboxok').fadeTo(0,1,
							function()
							{ 
	
    
	$.ajax({
	    beforeSend: function(){
		document.getElementById('loginh2').innerHTML = '<img src="images/loading.gif" alt="Loading..." />';
		},
   		type: "GET",
		url: "templates/myaccount.php",
		data: '',
		success: function(html){
		$("#msgbox").fadeTo(200,0);
		var lol = document.getElementById('txtSearch').value;
		location.replace("http://joogle.pl/");
		document.getElementById('logintpl').innerHTML = '';
		document.getElementById('loginh2').innerHTML = html;
		if (lol){
		res(lol);
		}
		}
	});
	
	
	
	
							}
						);
					}
				);
			}		
		}
	);
	return false; 
}

function logout()

{ 
    	$.ajax({
		type: "GET",
		url: "templates/logout.php",
		data: '',
		success: function(html){
		document.getElementById('loginh3').innerHTML = html;
		location.replace("http://joogle.pl");
		}
	});

}


function on_editp()
{
	_email = document.getElementById("email");
	_fullname = document.getElementById("fullname");
	_site = document.getElementById("site");
	_country = document.getElementById("country");
	_city = document.getElementById("city");
	_tel = document.getElementById("tel");
	_profile = document.getElementById("profile");
	_email.disabled = true;
	_fullname.disabled = true;
	_site.disabled = true;
	_country.disabled = true;
	_city.disabled = true;
	_tel.disabled = true;
	_profile.disabled = true;
	//remove all the class add the messagebox classes and start fading
	$("#msgbox").removeClass().addClass('messagebox').text('Sprawdzam....').fadeIn(1000);
	//check the username exists or not from ajax
	$.post("index.php?p=do_editaccount",{ email:$('#email').val(),fullname:$('#fullname').val(),site:$('#site').val(),country:$('#country').val(),city:$('#city').val(),tel:$('#tel').val(),profile:$('#profile').val(),rand:Math.random() } ,
		function(data)
		{
			if(data!='success')
			{
				$("#msgbox").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
				_email.disabled = false;
				_fullname.disabled = false;
				_site.disabled = false;
				_country.disabled = false;
				_city.disabled = false;
				_tel.disabled = false;
				_profile.disabled = false;
			}
			else 
			{
				$("#msgbox").fadeTo(200,0.1,
					function()  //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html('Twoje informacje zostały zmienione.').addClass('messageboxok').fadeTo(900,1,
							function()
							{ 
								//redirect to secure page
								document.location='index.php?p=myaccount';
							}
						);
					}
				);
			}		
		}
	);
	return false; //not to post the  form physically
}

function on_changep()
{
	_old_pwd = document.getElementById("old_pwd");
	_new_pwd1 = document.getElementById("new_pwd1");
	_new_pwd2 = document.getElementById("new_pwd2");
	_old_pwd.disabled = true;
	_new_pwd1.disabled = true;
	_new_pwd2.disabled = true;
	//remove all the class add the messagebox classes and start fading
	$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
	//check the username exists or not from ajax
	$.post("index.php?p=do_changepwd",{ old_pwd:$('#old_pwd').val(),new_pwd1:$('#new_pwd1').val(),new_pwd2:$('#new_pwd2').val(),rand:Math.random() } ,
		function(data)
		{
			if(data!='success')
			{
				$("#msgbox").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
				_old_pwd.disabled = false;
				_new_pwd1.disabled = false;
				_new_pwd2.disabled = false;
			}
			else 
			{
				$("#msgbox").fadeTo(200,0.1,
					function()  //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html('Zamiana hasła została przeprowadzona pomyślnie.').addClass('messageboxok').fadeTo(900,1,
							function()
							{ 
								//redirect to secure page
								$.growl('Twoje hasło', 'Zostało zmienone. Zostałeś automatycznie wylogowany.');
								//logout();
							}
						);
					}
				);
			}		
		}
	);
	return false; //not to post the  form physically
}

function register()
{
	$.ajax({
   		beforeSend: function(){
   		},
		type: "GET",
		url: "templates/register.php",
		data: '',
		success: function(html){
		    document.getElementById('register').style.display = "block";
			mint.fx.Fade("latestsearch", 20, 1, 500);
			mint.fx.Fade("tekst1", 20, 1, 500);
			mint.fx.Fade("info", 10, 1, 500);
			mint.fx.Fade("register", 0, 1, 1);
			mint.fx.Fade("register", 100, 60, 400);
			mint.fx.Style("register", "width", null, 280, 1, 1);
			mint.fx.Style("register", "width", null, 300, 20, 100);	
            mint.fx.Style("register", "height", null, 470, 1, 1);
			mint.fx.Style("register", "height", null, 510, 20, 100);				
			mint.fx.Style("register", "marginTop", null, 320, 1, 1);
			mint.fx.Style("register", "marginTop", null, 280, 20, 100);
			mint.fx.Style("register", "marginLeft", null, 640, 1, 1);
			mint.fx.Style("register", "marginLeft", null, 600, 20, 100);
			mint.fx.Style("register", "width", null, 350, 20, 100);	
			document.getElementById('register').innerHTML = html;
		}
	});
}

function close_r()
{
           
			mint.fx.Fade("register", 0, 20, 500);
			document.getElementById('register').style.display = 'none';
			mint.fx.Fade("latestsearch", 100, 10, 500);
			mint.fx.Fade("tekst1", 60, 10, 500);
			mint.fx.Fade("info", 60, 10, 500);

}


function przewodnik()
{
	$.ajax({
   		beforeSend: function(){
			document.getElementById('przewodnik').innerHTML = '<img src="images/loadingmp3.gif" alt="Loading..." />';
   		},
		type: "GET",
		url: "templates/przewodnik.php",
		data: '',
		success: function(html){
		    document.getElementById('przewodnik').style.display = "block"; 
			document.getElementById('przewodnik').innerHTML = html;
		}
	});
}

function forgot_pwd()
{
	$.ajax({
   		beforeSend: function(){
   		},
		type: "GET",
		url: "templates/forgotpwd.php",
		data: '',
		success: function(html){
		document.getElementById('forgot_pwd').style.display = 'none';
		document.getElementById('forgot_pwd2').style.display = 'block';
		document.getElementById('forgot_pwd2').innerHTML = html;
		}
	});
}



function do_register()
{
	//remove all the class add the messagebox classes and start fading
	$("#msgbox2").removeClass().addClass('messagebox2').text('Sprawdzam....').fadeIn(1000);
	//check the username exists or not from ajax
	$.post("index.php?p=do_register",{ username:$('#username').val(), password:$('#password').val(), password2:$('#password2').val(), email:$('#email').val(), fullname:$('#fullname').val(), image:$('#image').val(), rand:Math.random() } ,
		function(data)
		{
			if(data!='register1' && data!='register2' && data!='register-1' && data!='register-2')
			{
				$("#msgbox2").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
			}
			else 
			{
				if(data=='register1')
				{
					$("#msgbox2").fadeTo(200,0.1,
						function() //start fading the messagebox
						{ 
							//add message and change the class of the box and start fading
							$(this).html("Rejestracja przebiegła pomyślnie.<br /> Możesz się już zalogować :)").addClass('messageboxok').fadeTo(900,1);
						}
					);
				}
				else if(data=='register2')
				{
					$("#msgbox2").fadeTo(200,0.1,
						function() //start fading the messagebox
						{ 
							//add message and change the class of the box and start fading
							$(this).html("Rejestracja przebiegła pomyślnie.<br /> Został wysłany do ciebie email w którym znajdziesz szczegóły jak aktywować konto.").addClass('messageboxok').fadeTo(900,1);
						}
					);
				}
				else if(data=='register-1')
				{
					$("#msgbox2").fadeTo(200,0.1,
						function() //start fading the messagebox
						{ 
							//add message and change the class of the box and start fading
							$(this).html("<font class=\"error\">Faild sending registration email,<br /> please report this to the webmaster</font><br /> Registration was successfull.<br /> you can now login.").addClass('messageboxok').fadeTo(900,1);
						}
					);
				}
				else
				{
					$("#msgbox2").fadeTo(200,0.1,
						function() //start fading the messagebox
						{ 
							//add message and change the class of the box and start fading
							$(this).html("<font class=\"error\">Faild sending registration email,<br /> please report this to the webmaster</font><br /> Registration was successfull.<br> Please go and check your email.<br> You'll find how to activate your account.").addClass('messageboxok').fadeTo(900,1);
						}
					);
				}
			}		
		}
	);
	return false; //not to post the  form physically
}




function on_forgotp()
{
	uname_forgotp = document.getElementById("username");
	pass_forgotp = document.getElementById("email");
	uname_forgotp.disabled = true;
	pass_forgotp.disabled = true;
	//remove all the class add the messagebox classes and start fading
	$("#msgbox").removeClass().addClass('messagebox').text('Sprawdzam').fadeIn(1000);
	//check the username exists or not from ajax
	$.post("index.php?p=do_forgotpwd",{ username:$('#username').val(),email:$('#email').val(),rand:Math.random() } ,
		function(data)
		{
			if(data!='success')
			{
				$("#msgbox").fadeTo(200,0.1,
					function() //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					}
				);
				uname_forgotp.disabled = false;
				pass_forgotp.disabled = false;
			}
			else 
			{
				$("#msgbox").fadeTo(200,0.1,
					function()  //start fading the messagebox
					{ 
						//add message and change the class of the box and start fading
						$(this).html('').addClass('messageboxok').fadeTo(900,1,
						
						function()
							{ 
								//redirect to secure page
								document.getElementById('forgot_pwd').style.display = 'none';
		                        document.getElementById('forgot_pwd2').style.display = 'none';
								$.growl('Nowe hasło', 'Zostało wysłane na Twój Email');
								window.location = 'http://joogle.pl/';
								
							}
						);
					}
				);
			}		
		}
	);
	return false; //not to post the  form physically
}


function onfocus_hide()
{
	$("#msgbox").hide("slow");
}

function popup(url, width, height)
{
    var left = parseInt((screen.width - width) / 2);
    var top = parseInt ((screen.height - height) / 2);

    popupWindow = window.open (url, '', 'toolbar=no,status=no,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
}

function closerefresh()
{
    window.close ();

    if (typeof (top.opener.document) == 'object')
        top.opener.location.reload();
}

function edit(artist, title)
{
	popup('http://www.lyricsplugin.com/edit/?artist=' + artist + '&title=' + title, 500, 300);
}

function edit2(artist, title)
{
	var urlartist = escape(artist);
	var urltitle = escape(title);
	var urlartist2 = urlartist.replace(/\+/ig, "%2B");
	var urltitle2 = urltitle.replace(/\+/ig, "%2B");
	popup('http://www.lyricsplugin.com/edit/?artist=' + escape(artist) + '&title=' + escape(title) + '&new=1', 500, 550);
}

function tellafriend()
{
	popup('http://www.lyricsplugin.com/tellafriend/', 500, 400);
}

function configure()
{
	popup('http://www.lyricsplugin.com/configure/', 500, 200);
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-11506204-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  
function current_song(obj)
{
  alert('State: ' + obj.state + '\nFile: ' + obj.file);
};

function clickclear(thisfield) {
thisfield.value = "";
} 

function showsimilar(div,tab){
document.getElementById('bestofartist').style.display = "none";
document.getElementById('similarartist').style.display = "none";
document.getElementById('similaruser').style.display = "none";
document.getElementById('boa_tab').style.color = "#ccc";
document.getElementById('sa_tab').style.color = "#ccc";
document.getElementById('su_tab').style.color = "#ccc";
document.getElementById(div).style.display = "block";
document.getElementById(tab).style.color = "#ffa200";
}
