function get_current_url()
{
	 url = SWFAddress.getValue();
	url_length = url.length;
	if (url[url_length - 1] == '/')
	{
		url = url.substring(0, url_length - 1);
	}
	else
		url = url + '/';

	return url;
}

function updateFormLang(name, id)
{
	var liste = document.getElementsByName(name);
	for (i=0; i<liste.length; i++)
		liste[i].style.display = "none";
	$("#"+id).show();
}

function addInputForm()
{
	nb_autres_artistes = document.getElementById('nb_autres_artistes').value;
	$("#otherArtists").append("<input id='EventArtisteSecondaire" + nb_autres_artistes + "' class='ac_input' type='text' value = '' name='artiste_secondaire" + nb_autres_artistes + "' /><br/>");
	autocompleteArtistOfArticle('EventArtisteSecondaire' + nb_autres_artistes);
	document.getElementById('nb_autres_artistes').value ++;
}

function updateDiv(div, url, loader) {
	var loader = loader || false;

	if (loader == false) {
		$('#' + div).load(url);
	} else {
		$('#' + loader).show();
		$('#' + div).load(url, function() {
			$('#' + loader).hide();
		});
	}
	return false;
}

function swapOnglet(menu_id, onglet_id) {
	var onglets = $("#" + menu_id).children();
	for (i = 0; i < onglets.length; i++) {
		$('#' + onglets[i].id).removeClass('ongletsSelected');
	}
	$("#" + onglet_id).addClass('ongletsSelected');
}

function swapOngletWithClass(classe, onglet_id) {
	$('.'+classe).removeClass('ongletsSelected');
	$("#" + onglet_id).addClass('ongletsSelected');
}

function swapDomain(id,module) {
    var module = module||'admin';
    
	updateDiv('submenu', '/'+module+'/' + id + '/submenu');
}

function display(domain, fonction,module) {
    var module = module||'admin';
	SWFAddress.setValue('/'+module+'/' + domain + '/' + fonction);
}

function confirmAlert(text, color, t_fadein, t_fadeout) {
	$('#confirmAlert').html(text);
	$('#confirmAlert').css( {
		'background-color' :color
	});
	if (t_fadein == undefined)
		t_fadein = 1000;
	if (t_fadeout == undefined)
		t_fadeout = 3000;
	$('#confirmAlert').fadeIn(t_fadein);
	$('#confirmAlert').fadeOut(t_fadeout);
}

function search(form) {
	var name = form.children("[name=query]");
	var module = form.children("[name=module]").attr("value");
	updateDiv("mainContent", "/admin/" + module + "/search/name/"
			+ encodeURI(name.attr("value")) + "/");
}

function destroyElement(container_id, element_id) {
	var elements = $("#" + container_id).children();
	for (i = 0; i < elements.length; i++) {
		if (elements[i].id == element_id) {
			$("#" + elements[i].id).remove();
		}
	}
}

jQuery.create = function() {
	if (arguments.length == 0)
		return [];
	var args = arguments[0] || {}, elem = null, elements = null;
	var siblings = null;

	// In case someone passes in a null object,
	// assume that they want an empty string.
	if (args == null)
		args = "";
	if (args.constructor == String) {
		if (arguments.length > 1) {
			var attributes = arguments[1];
			if (attributes.constructor == String) {
				elem = document.createTextNode(args);
				elements = [];
				elements.push(elem);
				siblings = jQuery.create.apply(null, Array.prototype.slice
						.call(arguments, 1));
				elements = elements.concat(siblings);
				return elements;

			} else {
				elem = document.createElement(args);

				// Set element attributes.
				var attributes = arguments[1];
				for ( var attr in attributes)
					jQuery(elem).attr(attr, attributes[attr]);

				// Add children of this element.
				var children = arguments[2];
				children = jQuery.create.apply(null, children);
				jQuery(elem).append(children);

				// If there are more siblings, render those too.
				if (arguments.length > 3) {
					siblings = jQuery.create.apply(null, Array.prototype.slice
							.call(arguments, 3));
					return [ elem ].concat(siblings);
				}
				return elem;
			}
		} else
			return document.createTextNode(args);
	} else {
		elements = [];
		elements.push(args);
		siblings = jQuery.create.apply(null, (Array.prototype.slice.call(
				arguments, 1)));
		elements = elements.concat(siblings);
		return elements;
	}
};

function addNewElement(container_id, element_type, new_id, new_class, content,
		onclick, closable) {

	if (closable == undefined)
		closable = true;
	if (onclick == undefined)
		onclick = "";
	var elements = $('#' + container_id).children();
	var len = elements.length + 1;
	var name = new_id + "[]";
	new_id = new_id + len;

	var divcontent = $.create("div", {
		"class" :"blockLeft"
	}, [ content ]);
	var o = $.create(element_type, {
		"id" :new_id,
		"class" :new_class
	}, [ divcontent ]);
	var hidden = $.create("input", {
		"type" :"hidden",
		"value" :content,
		"name" :name
	}, []);

	if (closable) {
		var x = $.create(element_type, {
			"id" :"suppr" + new_id,
			"class" :"suppr",
			"onclick" :"destroyElement('" + container_id + "','" + new_id
					+ "')"
		}, [ "x" ]);
		$(o).append(x);
	}
	$('#' + container_id).append($(o));
	$('#' + container_id).append($(hidden));
	$('#' + new_id).effect("pulsate", {
		times :2
	}, 300);
}

function addNewPhoto(container_id, element_type, new_id, new_class, content,
		onclick, closable) {

	if (closable == undefined)
		closable = true;
	if (onclick == undefined)
		onclick = "";
	var elements = $('#' + container_id).children();
	var len = elements.length + 1;
	var name = new_id + "[]";
	new_id = new_id + len;

	var divcontent = $.create("img", {
		"class" :"blockLeft",
		"src" :content,
		"width" :35,
		"height" :35
	}, []);
	var o = $.create(element_type, {
		"id" :new_id,
		"class" :new_class
	}, [ divcontent ]);
	var hidden = $.create("input", {
		"type" :"hidden",
		"value" :content,
		"name" :name
	}, []);

	if (closable) {
		var x = $.create(element_type, {
			"id" :"suppr" + new_id,
			"class" :"suppr",
			"onclick" :"destroyElement('" + container_id + "','" + new_id
					+ "')"
		}, [ "x" ]);
		$(o).append(x);
	}
	$('#' + container_id).append($(o));
	$('#' + container_id).append($(hidden));
	$('#' + new_id).effect("pulsate", {
		times :2
	}, 300);
}

function addOnglet(container_id, content) {
	var newOnglet = $.create("a", {
		"id" :content,
		"class" :"blockLeft",
		"onclick" :"swapOnglet('editadvancedonglets',this.id);"
	}, [ content ]);
	$("#" + container_id).append(newOnglet);
}

function autocomplete(id, data) {
	$("#" + id).autocomplete(data);
}

function displayEditArticle(id) {

	var url = '/admin/articles/edit/id/' + id;
	window.open(url, 'Article', 'menubar=no, status=no, scrollbars=yes, width=1200, height=850');
}

function displayEditSources(id, toControl) {
	var toControl = toControl || false;
	
	$("#sourceDetails").html('');
	$("#sourceDetails").show('fast');
	if (toControl == false) {
		updateDiv("sourceDetails", "/admin/sources/edit/id/" + id);
	} else {
		updateDiv("sourceDetails", "/admin/sources/edit/id/" + id + "/tocontrol/true");
	}
}

function addLayer(id,layer_id,opacity) {
	if ($("#"+id).length) {
		var vid = $("#"+id);
		var pos = vid.position();
		if ($("#"+layer_id).length == 0) // If layer doesn't exist, we create it
		{
			vid.before("<div id='"+layer_id+"'></div>");
		}
		var layer = $("#"+layer_id);
		layer.height(vid.height());
		layer.width(vid.width());
		layer.css('top', pos.top);
		layer.css('left', pos.left);
		layer.css('opacity', opacity);
	}
}


/******* Quizz ******/
 function updateQuizzDiv(div,url)
 {             
    $('#loader').show();
    $('#'+div).load(url, function() {
      $('#loader').hide();
       addLayer("quizzVideo","quizzLayer",0.95);
       $("#quizzLayer").html("<div class='quizzLayerText bold'>Blindtest Quizz</div>");
    });
}
/****Fin Quizz***/

function displayPreview(size, info, autoplay) {

	var urlpreview = '/preview/complete/ide/' + info.id;
	// var urlArticle = '/articles/index/id/'+id;

	var urlArticle = info.url;

	if (autoplay != undefined && autoplay == true) {
		urlpreview = urlpreview + '/autoplay/yes/charts/yes';
	}

	updateDiv('embed', urlpreview);
	SWFAddress.setValue(urlArticle);
	window.scrollTo(0, 0);
    $('#megabanner').attr("src","/ad/smart?id=mb&r=7"+"&_="+Math.round(Math.random()*1000));
    $('#PubPave1').attr("src","/ad/smart?id=p&r=7&level=index"+"&_="+Math.round(Math.random()*1000));

	PlCounter.kill();

	return false;
}

function updatePreview(size, id, autoplay, charts) {
	var urlpreview = '/preview/complete/ide/' + id;
	var charts = charts || false;
	
	if (charts) {
		urlpreview = urlpreview + '/charts/yes/';
	}
	if (autoplay) {
		urlpreview = urlpreview + '/autoplay/yes/';
	}
	updateDiv('embed', urlpreview);
	window.scrollTo(0, 0);
	$('#megabanner').attr("src","/ad/smart?id=mb&r=7"+"&_="+Math.round(Math.random()*1000));
	$('#PubPave1').attr("src","/ad/smart?id=p&r=7&level=index"+"&_="+Math.round(Math.random()*1000));
	
	// Clean Smartclip if exists
	try {
		wrapAdRoll.clean() ;
	} catch(e) {} ;
	
	
	//MAJ cookie notification
	if (getCookie('notif') == '' || isNaN(getCookie('notif')) || getCookie('notif') == null) {
		setCookie('notif','0');
	}		
		var val_notif = getCookie('notif');
		Notification.run(val_notif);   

	PlCounter.kill();

	return false;
}

/*
 * function displayHighlight(size, id){
 * 
 * if($('#homeVideo').length > 0){ var targetdiv = 'homeVideo'; var action =
 * 'withtitle'; }else{ var targetdiv = 'embed'; size = 'bigPreview'; var action =
 * 'withtitle'; } var urlpreview = '/preview/'+action+'/preview/'+size
 * +'/id/'+id+'/autoplay/yes/'; updateDiv(targetdiv,urlpreview);
 * window.scrollTo(0,0); PlCounter.kill(); return false; }
 */

function displayChannel(flatname) {
	SWFAddress.setValue('/' + flatname + '/');
	window.scrollTo(0, 0);
	$("#viewall").hide('fast');
	return false;
}

function ucfirst(str) {
	str += '';
	var f = str.charAt(0).toUpperCase();
	return f + str.substr(1);
}

function goHome() {
	swapNav( {
		'id' :'index',
		'rel' :'/index'
	});
	return false;
}

function swapArtistContent(section, id) {
	updateDiv('artistContent', '/artist/' + section + '/id/' + id);
	return false;
}

function intOnly(event) {
	var keyCode = null;
	// var autorised = '0123456789';
	// autorised.indexOf(String.fromCharCode(keyCode)) >= 0

	// Authorized FF :
	// 8 => backspace
	// 0 => horizontal tab
	// 0 => <--
	// 0 => -->
	// 0 => del
	// 48 to 57 => 0 to 9
	if (event.which) {
		keyCode = event.which;

		if (keyCode == 8 || keyCode == 0 || (keyCode >= 48 && keyCode <= 57)) {
			return true;
		}

	}
	// Authorized IE :
	// 48 to 57 => 0 to 9
	else {
		keyCode = event.keyCode;

		if (keyCode >= 48 && keyCode <= 57) {
			return true;
		}
	}

	return false;
}

function swapWorldTop(country) {
	updateDiv('topByCountry', '/topworld/index/country/' + country);
}

// temporaire
function swapWorldTop2(country) {
	updateDiv('topByCountry2', '/topworld/index/country/' + country);
}

function swapUtil(id) {
	$("#comment").removeClass("utilSelected");
	$("#send").removeClass("utilSelected");
	$("#" + id).addClass("utilSelected");
}
function pulsate(id) {
	$('#' + id).effect("pulsate", {
		times :3
	}, 300);
}

function swapTop(obj) {
	updateDiv('topTitle', '/charts/title/top/' + obj.id);
	updateDiv('tops', obj.rel);
}

/** ********************************FONCTIONS TELECOMMANDE******************** */
function addlike(id, article) {
	process = function(data) {
		if (data === true || data.good != undefined) {
			pulsate(id);
			if (data.good != undefined) {
				confirmAlert(data.good, "#060");
			}
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		$('#loadingTelecommande').hide();
	};

	$('#loadingTelecommande').show();
	$.post("/command/love", {
		id :article,
		rating :1
	}, process, "json");

}
function adddontlike(id, article) {
	process = function(data) {
		if (data === true || data.good != undefined) {
			pulsate(id);
			if (data.good != undefined) {
				confirmAlert(data.good, "#060");
			}
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		$('#loadingTelecommande').hide();
	};
	$('#loadingTelecommande').show();
	$.post("/command/love", {
		id :article,
		rating :-1
	}, process, "json");
}
function addtofavorite(id, article, broadcast) {
	var broadcast = broadcast || false;

	process = function(data) {
		if (data.confirm) {
		    confirmAlert(data.confirm,"#060");
			if (broadcast == true) {
				$('#' + id).fadeOut(400, function() {
					$('#removefavorite').fadeIn(400);
				});
				/*PLUS UTILE if (typeof (document.getElementById(id + '_' + article)) != 'undefined') {
					$('#' + id + '_' + article).fadeOut(400, function() {
						$('#removefavorite_' + article).fadeIn(400);
					});
				}*/
			} else {
				/*PLUS UTILE $('#' + id).fadeOut(400, function() {
					$('#removefavorite_' + article).fadeIn(400);
				});*/
				if ($('#broadcastfavorite').html() == article) {
					$('#addfavorite').fadeOut(400, function() {
						$('#removefavorite').fadeIn(400);
					});
				}
			}
		} else {
			var text = "";
			if (data.errorFavorite) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errorDuplicate) {
					text = data.errorDuplicate;
				} else if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		$('#loadingTelecommande').hide();
	};
	$('#loadingTelecommande').show();
	$.post("/command/favorite", {
		id :article
	}, process, "json");
}
function removetofavorite(id, article, broadcast, topic, user) {
	var broadcast = broadcast || false;
	var topic = topic || false;
	var user = user || false;

	process = function(data) {
		if (data.deleted) {
			confirmAlert(data.deleted,"#060");
			if (broadcast == true) {
				$('#' + id).fadeOut(400, function() {
					$('#addfavorite').fadeIn(400);
				});
				if (typeof (document.getElementById(id + '_' + article)) != 'undefined') {
					$('#' + id + '_' + article).fadeOut(400, function() {
						$('#addfavorite_' + article).fadeIn(400);
					});
				}
			} else {
				// On est dans son profil
				if (user != false) {
					// Rafraîchir la liste des favoris
					updateDiv('userContent', '/users/favoris/page/' + topic
							+ '/id/' + user);
				} else {
					$('#' + id).fadeOut(400, function() {
						$('#addfavorite_' + article).fadeIn(400)
					});
				}
				if ($('#broadcastfavorite').html() == article) {
					$('#removefavorite').fadeOut(400, function() {
						$('#addfavorite').fadeIn(400);
					});
				}
			}
		} else {
			var text = "";
			if (data.errorFavorite) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		$('#loadingTelecommande').hide();
	};
	$('#loadingTelecommande').show();
	$.post("/command/favorite", {
		id :article,
		'remove' :'true'
	}, process, "json");
}
function sendToFriend(form) {
	alert('undefined function');
}

function deleteComment(form, what, redirect){

	process = function(data)
	{
		if (data.success)
		{
		    var text = data.success;
            if(text == undefined) text = "OK";
			if (what == "article") {
				swapOnglet('articlesTabs', "artistcomments");
				swapArticleTab("artistcomments", form[0].articles_id.value);
			}
			if (what == "artist") {
				swapOnglet('artistTabs', "artistcomments");
				swapArtistContent("artistcomments", form[0].artists_id.value);
			}
			if (what == "user") {
				updateDiv('displayCommentUser',
						'/users/comments/id/' + form[0].users_id.value);
			}
			 confirmAlert(text, "#060");
		}
		else if (data.error)
		{
			var text = data.error;
			confirmAlert(text, "red");
		}
	}
$.post("/command/deletecomment/", form.serialize(), process, "json");
//$.get("/command/deletecomment/type/"+form[0].parent_id.value, '', process, "json");
}

function postComment(form, what, redirect) {

	// var what = what || "article";
	if (what == undefined) {
		what = "article";
	}

	process = function(data) {
		//if (data === true) {
		if (data.success || data === true) {
            var text = data.success;
            if(text == undefined) text = "OK";
			if (what == "article") {
				swapOnglet('articlesTabs', "artistcomments");
				swapArticleTab("artistcomments", form[0].articles_id.value);
			}
			if (what == "artist") {
				//swapOnglet('artistTabs', "artistcomments");
				//swapArtistContent("artistcomments", form[0].artists_id.value);
				updateDiv('mainContent', '/artist/artistcomments/id/'+form[0].artists_id.value);
			}
			if (what == "user") {
				updateDiv('displayCommentUser',
						'/users/comments/id/' + form[0].users_id.value);
			}
			form[0].utilMessage.value = '';
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		form[0].utilMessage.disabled = false;
		$('#loadingTelecommande').hide();
		updateDiv('homeComments', '/index/homecomments/');

		if (redirect != undefined) {
			//SWFAddress.setValue(redirect);
		}
        confirmAlert(text, "#060");
	}
    
	if (form[0].utilMessage.disabled != 'disabled') {
		
		//if ($(form).attr('name') == 'share') {
			if ($('#emailaddress').css('display') == 'block') {
				sendVideoToFriend();
			} else {
				$('#loadingTelecommande').show();
				$.post("/command/" + what + "comment", form.serialize(), process,
					   "json");
			}
		//}

		form[0].utilMessage.disabled = 'disabled';
	}
}

function createArticleAnomaly(form, message) {	
	process = function(data) {		
        if (data === true) {
            confirmAlert(message, '#060');
            //$('#anomaly').hide('fast');
			 $('.dialogBox').dialog('close');
            
            // Si la source a été suspendu
            if ($('#suspendsource').attr('checked')) {
            	updatePreview('bigPreview', $('#articleid').val(), true);
            }
        } else {
        	var text = '';
             
        	if (data.error) {
				text = data.error;
				//$('#anomaly').hide('fast');
				 $('.dialogBox').dialog('close');
			} else {
            	text = 'ERROR !';
            }
             
            confirmAlert(text, '#f00');
        }
    };

    $.post('/command/anomaly',
    	form.serialize(), 
    	process,
    	'json'
    ); 	
}

/** *********** PLAYLIST ***************************************** */
function addtoplaylists(id) {
	Playlist.add(id);
	/*
	 * $("#myPlaylists").show("fast");
	 * updateDiv("myPlaylists","/playlist/myplaylists/article/"+id);
	 */
}

function searchplaylist(form) {
	process = function(data) {
	    if(data != false){
    	    Playlist.load(data,0);
    	    url = '/playlist/artist-playlist,'+data.id;
    	    $('#playlistsPanel').empty();
    	    updateDiv('julioplaylist',url);
	    }else{
	        confirmAlert("error", '#f00');
	    }
	};

	$.post("/playlist/search", 
	{'query' : form.query.value},
	process,
	"json");
	return false;
}
/** *********** PLAYLIST ***************************************** */

function saveUserTitle(userID) {
	$.ajax( {
		type :'GET',
		url :'/users/title/id/' + userID + '/title/'
				+ encodeURIComponent($('#memberTitleText').val()),
		data :null
	});
}




/** ****************************CONTRIB 2.0************************* */
function voteContrib(source, vote, message, articleID) {
	process = function(data) {
		if (data.errors == undefined || data.errorLogin == undefined) {
			confirmAlert(message, "#060");
			updatePreview('bigPreview', articleID, true);
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
		$('#loadingTelecommande').hide();
	};
	$('#loadingTelecommande').show();
	$.post("/command/approvesource", {
		id :source,
		"vote" :vote
	}, process, "json");
}
/** ****************************CONTRIB 2.0************************* */

function ArtistSubmitContent() {
    if(setDialogBio()) {
    	$.ajax( {
    		url :'/users/isactiv',
    		type :'get',
    		dataType :"text",
    		success : function(data, status) {
    			if (data == 'false') {
    				showDialog('dialogLogin', 'Jukebo Login', 300);
    			} else {
    				ArtistSubmitContentForm();
    			}
    		}
    	});
	}
}

function ArtistLastContent() {
	if ($('#LastContent').html() != '') $('#artistBio').html($('#LastContent').html());
}

function ArtistCleanContent() {
	$('#content').val('');
  ArtistLastContent();
}

function ArtistSubmitContentForm() {
	if (dialogstate == true) {
		$('#FormSubmitContent_Div').dialog("close");
		dialogstate = false;
	} else {
		$('#FormSubmitContent_Div').dialog("open");
		dialogstate = true;
	}
	return true;
}

function ArtistSubmitPhotoContent() {

    if(setDialogPhoto()) {
    	$.ajax( {
    		url :'/users/isactiv',
    		type :'get',
    		dataType :"text",
    		success : function(data, status) {
    			if (data == 'false') {
    				showDialog('dialogLogin', 'Jukebo Login', 300);
    			} else {
    				ArtistSubmitPhotoForm();
    			}
    		}
    	});
	}
}

function ArtistSubmitPhotoForm() {
	if (dialogstate == true) {
    	$('#FormSubmitContent')[0].style.display='none';
		$('#uploadArtistPhoto')[0].style.display='block';
		$('#FormSubmitContent_Div').dialog("close");
		dialogstate = false;
	} else {
		$('#FormSubmitContent_Div').dialog("open");
		dialogstate = true;
	}
	return true;
}

function ArtistContentPreview() {
  if ($('#LastContent').html() == '') $('#LastContent').html($('#artistBio').html());
  $('#artistBio').html(editorHelper_getContent('content'));
}

function ArtistEditMenu(cas) {
	var defhtm = '';
	var htm = $('#editMenuOriginalBar').html();

	if (cas == 'new' || cas == 'def') {
		$('#editMenubar').html(defhtm);
	}
	if (cas == 'preview') {
		$('#editMenubar').html(htm);
		$('#editMenubar a:eq(0)').css('display', 'inline');
		$('#editMenubar a:eq(1)').css('display', 'none');
	}
}

function swapEditAdvanced(containerID, displayedDivID) {
	$('#' + containerID + ' div').hide();
	$("#" + displayedDivID).show();
}

/* fck Helper */
function editorHelper_getContent(fldname) {
  var msg = '';
  if ($('#'+fldname+'___Frame')) {
    msg = FCKeditorAPI.GetInstance(fldname).GetHTML();
  } else
    msg = $('#'+fldname).val();
  return msg;
}

function iLikeArtist(id, artist, type, refresh) {
	var type = type || 1;
	var refresh = refresh || false;

	process = function(data) {
		if (data.good != undefined) {
			if (refresh != false) {
				updateDiv('mainContent', refresh);
			} else {
				pulsate(id);
			}
			confirmAlert(data.good, "#060");
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
	};

	$.post('/artist/love', 
		   {id: artist, rating: 1, type: type}, 
		   process, 
		   'json');

}

function iDontLikeArtist(id, artist, type, refresh) {
	var type = type || 1;
	var refresh = refresh || false;

	process = function(data) {
		if (data.good != undefined) {
			if (refresh != false) {
				updateDiv('mainContent', refresh);
			} else {
				pulsate(id);
			}
			confirmAlert(data.good, "#060");
		} else {
			var text = "";
			if (data.errorLogin) {
				showDialog('dialogLogin', 'Jukebo Login', 300);
			} else {
				if (data.errors) {
					for (error in data.errors) {
						text += "" + data.errors[error] + "<br />";
					}
				} else {
					text = "ERROR !";
				}
				confirmAlert(text, "#f00");
			}
		}
	};

	$.post('/artist/love', 
		   {id: artist, rating: -1, type: type}, 
		   process, 
		   'json');
}

