function SongsPreviewHome(subtask,home,participant){
	var aj = new Ajax.Updater('songs_preview_ajax_'+subtask+participant,'?site=karaokes&task=songspreviewhome',{  
		 	method:'get',   
		 	parameters: {'subtask': subtask, 'home': home, 'participant': participant} ,
	 		onSuccess: function(transport)
	 						{setTimeout("new Carousel($('carousel-wrapper'),$('carousel-content').select('.slide'),null,{auto:true,frequency:6,duration:0.4,effect:'fade',wheel:false})", 1000);}
		    });
}

function resize_userst(direction,id,task)
{
switch(direction)
	{
	case 'show' : 
		$(id).style.height = '260px';
		$('songs_preview_div_'+task).style.display = 'block';
		$("hide_"+id).style.cursor = "pointer";	
		$("show_"+id).style.cursor = "default";
	break;
	case 'hide' : 
		$(id).style.height = '25px';
		$('songs_preview_div_'+task).style.display = 'none';
		$("hide_"+id).style.cursor = "default";	
		$("show_"+id).style.cursor = "pointer";
	break;
	default : $(id).style.height = '260px'; break;
	}
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
document.cookie = id + "=" + direction + "; expires=" + d.toGMTString() + "; path=/";
}


function PostFeatured(data)
	{  
	var aj = new Ajax.Request('?site=karaokes&action=makefeatured',{  
	 	method:'post',   
	 	parameters: data 
	 	}  
		);
	}
	

function PostVideaLink(data)
	{  
	var aj = new Ajax.Request('?site=karaokes&action=videalink',{  
	 	method:'post',   
	 	parameters: data 
	 	}  
		);
	}
// Get singers preview song
function GetSongsPreviewSong(task){
	new Ajax.Updater('songs_preview_d_'+task, '?site=karaokes&task=getsongpreview&subtask='+task, {
	  method: 'get'  
	});
}

function RateSong(r,ksid,participant){
	new Ajax.Request('?site=karaokes&action=ratekaraokesong&ksid='+ksid+'&participant='+participant,{
		method:'post',
		parameters: {rate: r},
		onCreate: function(){$('pollstxtx1').update('<img src="http://91.120.21.217/img/silbgal.gif" style="width:16px;height:16px;margin:0 25px 10px 0" alt="...">');},
		onSuccess: function(t){
			$('pollstxtx1').setStyle({'visibility':'hidden'});
			g=t.responseText.evalJSON();
			if(g.m){alert(g.m)}
			if(g.nr){$('starrate').update('<div style="width:' + (g.nr*20) + '%" class="voted"></div>')}
			if(g.avg){$('avg').update(g.avg)}
			if(g.ksp){$('kspoints').update(g.ksp)}
			if(g.comp){
				if(g.comp.star){$('compsrate').update('<div style="width:'+(g.comp.star*20)+'%"></div>')}
				if(g.comp.scs){$('compscore').update(g.comp.scs)}
			}
		}
	});
}

function AddToFavorities(songid) 
	{
	new Ajax.Request('?site=karaokes&action=addtofavorities&songid='+songid,
		{
	    method:'post',
	    parameters: {songid: songid},
	    onSuccess: function(transport)
	    	{
	      	var response = transport.responseText;
	      	$('favorite_title').update(response);
	    	}
		});
	}

function DeleteFavoritySong(songid) 
	{
	new Ajax.Request('?site=karaokes&action=deletefavoritysong&songid='+songid,
		{
	    method:'post',
	    parameters: {songid: songid},
	    onSuccess: function(transport)
	    	{ document.location='?site=previewkaraokes&subtask=myfavorities&limit=all';
	    	// no response - always OK
	    	}
		});
	}

function ShareSong(sid,status){
	var szam;
	if (status == ''){ szam = sid;}  else {szam = sid +9999;}
	new Ajax.Request('?site=karaokes&action=sharesong',
		{
	    method:'post',
	    parameters: {songid: sid, status: status},
	    onSuccess: function(transport){
	    				if(transport.responseText){alert (transport.responseText);document.location='?site=sms&task=smsactive&display=sms_shere_song_f';}
	    				else {$('song_'+szam).style.display = 'none';}
			    	}
	});
}
	
function ToggleDelete(sid)
	{
	new Ajax.Request('?site=karaokes&action=toggledelete',
		{
	    method:'post',
	    parameters: 
	    	{
	    	songid: sid
	    	},
	    onSuccess: function(transport)
	    	{
	    	$('admin_delete').update(transport.responseText);
	    	}
		});
	}
	
function ApplyToCompetition(sid, cid, i)
	{
	new Ajax.Request('competition/competitionmanager.php?task=applycompetition',
		{
	    method:'post',
	    parameters:{ songid: sid, cid: cid, i: i },
	    onSuccess: function(transport)
	    	{
	    	$('competition_song_'+sid+i).update(transport.responseText);
	    	}
		});
	}
	
function RevokeCompetition(sid, cid, i)
	{
	new Ajax.Request('competition/competitionmanager.php?task=revokecompetition',
		{
	    method:'post',
	    parameters: { songid: sid, cid: cid, i: i },
	    onSuccess: function(transport)
	    	{
	    	$('competition_song_'+sid+i).update(transport.responseText);
	    	}
		});
	}
//model jelendkezes
function ApplyToCompetitionModel(mid, cid, i)
{
new Ajax.Request('competition/competition_model.php?task=applycompetition',
	{
    method:'post',
    parameters:{ mid: mid, cid: cid, i: i },
    onSuccess: function(transport)
    	{
    	$('competition_model_'+mid+i).update(transport.responseText);
    	}
	});
}
function RevokeCompetitionModel(mid, cid, i)
{
new Ajax.Request('competition/competition_model.php?task=revokecompetition',
	{
    method:'post',
    parameters: { mid: mid, cid: cid, i: i },
    onSuccess: function(transport)
    	{
    	$('competition_model_'+mid+i).update(transport.responseText);
    	}
	});
}

// Get song Score
function GetSongScore(song_id){
		new Ajax.Request('?site=karaokes&action=ratesetsong',{
			    method:'post',
			    parameters: {songid: song_id}
		  		});
}
//commendatory
function SendThisSongAj(data){  
	new Ajax.Request('?task=sendcommendatory',{  
	 	method:'post',   
	 	parameters: data,
	 	onSuccess: function(transport){alert(transport.responseText);}
	 	
	 	}  
	);
}

function NoMyCompositionsAj(text,kf,song){
		new Ajax.Updater('no_my_composittions', '?site=karaokes&action=nomycomp',
				{
			    method:'post',
			    parameters: {txt: text, kf: kf, song: song}
		  		});
}

function UploadOwnCompositions(song){
	new Ajax.Updater('upload_own_compositions', '?site=karaokes&task=uploadowncomositions',
			{
		    method:'post',
		    parameters: {song: song}
	  		});
}
var jar = new CookieJar({ expires:(30 * 24 * 60 * 60 * 1000), path: '/' });
function CookieJarTable(type,subtask) {
	if (!type && jar.get('tab_cookie_type') == null) type = 'all';
	if (!subtask && jar.get('tab_cookie_subtask') == null) subtask = 'weektop';

	if (type) jar.put('tab_cookie_type', type);
	if (subtask) jar.put('tab_cookie_subtask', subtask);

	tab_cookie_type = jar.get('tab_cookie_type');
	tab_cookie_subtask = jar.get('tab_cookie_subtask');

	TabsButtons(tab_cookie_type, tab_cookie_subtask);
	
	new Ajax.Updater('songs_preview_ajax_subtask','?site=karaokes&task=songspreviewhome',{
	 	method:'get',
	 	parameters: { 'type': tab_cookie_type, 'subtask': tab_cookie_subtask, 'home': true},
		onCreate: function(){ $('ajax_wait').show();},
		onSuccess:  function(){ $('ajax_wait').hide();}
	    });
}
function TabsButtons(type,subtask,top){
	top = !top? '' : top;

	$('tab_all'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/all_gomb.png) no-repeat center';
	$('tab_composition'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/composition_gomb.png) no-repeat center';
	$('tab_song'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/song_gomb.png) no-repeat center';
	$('tab_dance'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/dance_gomb.png) no-repeat center';
//	$('tab_comedy'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/comedy_gomb.png) no-repeat center';
	$('tab_X-treme'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/comedy_gomb.png) no-repeat center';

	$('tab_'+type+top).style.background = 'url(http://91.120.21.217/images/webdesign1/'+type+'_bg_fent.png) no-repeat center';

	$('sub_tabs_l'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/'+type+'_bg_bal.png) no-repeat center';
	$('sub_tabs_c'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/'+type+'_bg_kozep.png) repeat-x';
	$('sub_tabs_r'+top).style.background = 'url(http://91.120.21.217/images/webdesign1/'+type+'_bg_jobb.png) no-repeat center';
	
	$('sub_tabs_video'+top).style.background = '';
	$('sub_tabs_last'+top).style.background = '';
	$('sub_tabs_watch'+top).style.background = '';
	$('sub_tabs_weektop'+top).style.background = '';
	$('sub_tabs_monthtop'+top).style.background = '';
	
	$('sub_tabs_'+subtask+top).style.background = 'url(http://91.120.21.217/images/webdesign1/'+type+'_bg_aktiv.png) no-repeat center';
	
}

function GephazEfekt() {
//	$('tabla_id').style.top = (parseInt($('tabla_id').style.top) -2)+'px';
//	if(Math.abs(parseInt($('tabla_id').style.top)) > parseInt($('tabla_id').style.height)) $('tabla_id').style.top = 0+'px';
//	setTimeout( "GephazEfekt ()", 200)
}	

function SongCategoryDisplay(value) {
	$('category_composition').style.display = 'none';
	$('category_song_rel').style.display = 'none';
	$('category_dance').style.display = 'none';
//	$('category_comedy').style.display = 'none';
	$('category_X-treme').style.display = 'none';
	
	$('category_'+value).style.display = 'block';
	if(value == 'song_rel'){$('artist_'+value).style.display = '';}
	else {$('artist_song_rel').style.display = 'none';}
} 

/* smájlik beillesztése	*/
function popUp(url, w, h){
	if(bWin){
		bWin.close();
	}
	var bWin = null;
	var ww = w*1+20;
	var hh = h*1+20;
	bWin = window.open(
		url,
		"ZoomImgWin", 
		"titlebar=yes, toolbar=no, menubar=no, status=yes, directories=no, resizable=yes, scrollbars=yes, top=20, left=20, width=" + ww + ", height=" + hh
	);
	while(bWin==null);
	bWin.focus();
	bWin.moveTo(20, 20);
	bWin.resizeTo(ww+15, hh+50);
}

function addText(textToAdd,fieldName){ 
	/*var fieldName = 'comment';*/ 
	$(fieldName).value += textToAdd;
	$(fieldName).focus();  
}
/* 	*/
function UserProductionOrderBy(uid,order) {
	if (order) jar.put('user_productions_o_b', order);
    document.location='?site=previewsongs&subtask=user&limit=all&uid='+uid+'&order='+order;

}
function DokumentLocation(site) {
    document.location= site;
}
function PlayerDownTabsHide(showid) {
	$('embedtext').hide();
	$('whosfavorite').hide();
	$('othersingers').hide();
	$('send_this_song').hide();
	$('song_productions').hide();
	$('popularly').hide();
	if(showid)$(showid).show();
}

function UpdateOtherSingersP(originalRequest)
{
	$('song_productions').update(originalRequest.responseText);
	// Load of other singers should trigger a pageview in GA
	pageTracker._trackPageview("/song_productions");
}
function LoadOtherSingersP(data,uid,refid)
{
	var id = 'refid';
	//if(refid){id = refid;}alert(id);
		var aj = new Ajax.Request('?site=karaokes&task=othersingers&uid='+uid+'&refid='+refid,{
		 	method:'post',
		 	parameters: data ,
		 	onComplete: UpdateOtherSingersP
		 	}
			);
}
function LoadOtherSingersPO(data,uid,refid){
	new Ajax.Updater('popularly', '?site=karaokes&task=othersingers&uid='+uid+'&refid='+refid,
			{
		    method:'post',
		    parameters: data
	  		});
}


function PoscardSongDisplay(showid) {
	for (var i = 1; i <= 11; i++){//alert('pcs_'+i);
		$('pcs_'+i).hide();
	}
	for (var i = 21; i <= 36; i++){//alert('pcs_'+i);
		$('pcs_'+i).hide();
	}
	if(showid)$('pcs_'+showid).show();
}

/*	Találatok egy oldalon	*/
var jar = new CookieJar({ expires:(30 * 24 * 60 * 60 * 1000), path: '/' });
function CookieJarPage(type,num) {
	if (type) jar.put(type, num);
	window.location.reload();
}

//	elmenti a jelentést
function ForumsReportToModeratorAj(text,mid){
	new Ajax.Updater('forums_report_' + mid, '?site=forum&action=mreport&mid=' + mid,
			{
		    method:'post',
		    parameters: {text: text, mid: mid}
	  		});
}
//	a jelentést elfogadja a moderátor
function ForumsReportToModeratorOk(mid){
	new Ajax.Updater('forums_report_ok_' + mid, '?site=forum&action=mreportok&mid=' + mid,
			{
		    method:'post',
		    parameters: {mid: mid}
	  		});
}
//	a privát topik felhasználó list
function ForumUsersList(fid){
	new Ajax.Updater('forum_private_list_user_' + fid, '?site=forum&action=privatetopicuserlisr',{
	 	method:'post',
	 	parameters: {fid: fid} ,
		onCreate: function(){ $('ajax_wait').show();},
		onComplete: function(transport){ $('ajax_wait').hide();}
	 	}
		);
	}
//	a privát topik felhasználó listába az elfogadás / elutasítás
function ForumUserAcceptance(fid, uid, status){
	new Ajax.Updater('forum_privat_status_' + uid, '?site=forum&action=forumuseracceptance',{
	 	method:'post',
	 	parameters: {fid: fid, uid: uid, status: status} ,
		onCreate: function(){ $('ajax_wait').show();},
		onComplete: function(transport){ $('ajax_wait').hide();}
	 	}
		);
	ForumUsersList(fid);
	}
//	a privát topikba felhasználó jelentkezik
function AddUserPrivateTopic(fid){
	new Ajax.Updater('forum_privat_adduser', '?site=forum&action=adduserprivtopic',{
	 	method:'post',
	 	parameters: {fid: fid} ,
		onCreate: function(){ $('ajax_wait').show();},
		onComplete: function(transport){ $('ajax_wait').hide();}
	 	}
		);
	}