var flag = true;
var playList = new Array();
var curSong = 0;
var isplay;
var lang = get_cookie("language");

var root = "/";


var cUrl;
var trylisten = false;
var t;
var currentSong = '';
var curSetting = new Array();
var focusString = false;
var confirmBlip = false;
if (lang == 'en') {
	var blip = 'Post';
	var preview = 'Preview';
	var noresult = 'No results';
	var sresult = 'Search results';
	var listening = 'is playing';
	var closeForm = '[Close]';
	var introSearch = 'Search for a song and share with others';
	var introEmbed = '<p>Create a new gadget HTML/Javascript in your Blogger and paste the code below. <a href="http://blog.ibox.fm/en/entry/10-08-2009/insert-ibox-music-box-your-blogspot-blogger" target="_blank"> See help</a></p>';
        var introBlogerEmbed = '<p>Create a new gadget HTML/Javascript in your Blogger and paste the code below. <a href="http://blog.ibox.fm/en/entry/10-08-2009/insert-ibox-music-box-your-blogspot-blogger" target="_blank"> See help</a></p>';
        var helpTitle = 'Feedback'; 
} else {
	var blip = 'Phát';
	var preview = 'Nghe thử';
	var noresult = 'Không tìm thấy bài hát phù hợp';
	var sresult = 'Danh sách bài hát tìm thấy';
	var listening = 'Đang nghe';
	var closeForm = '[Đóng]';
	var introSearch = 'Hãy chọn một bài hát và chia sẻ với mọi người';
        var introEmbed = '<p>Bạn mở một gadget mới dạng HTML/Javascript trên Blogger và chép đoạn mã sau đây vào. <a href="http://blog.ibox.fm/entry/08-07-2009/th%C3%AAm-h%E1%BB%99p-nh%E1%BA%A1c-v%C3%A0o-blog-yahoo-360plus" target="_blank">Xem hướng dẫn chi tiết</a></p>';
        var introBlogerEmbed = '<p>Bạn mở một gadget mới dạng HTML/Javascript trên Blogger và chép đoạn mã sau đây vào. <a href="http://blog.ibox.fm/entry/10-05-2009/c%C3%A0i-%C4%91%E1%BA%B7t-h%E1%BB%99p-ibox-c%E1%BB%A7a-b%E1%BA%A1n-v%C3%A0o-blogger" target="_blank">Xem hướng dẫn chi tiết</a></p>';
        var helpTitle = 'Trợ giúp';
}

var tabs = ['nav_timeline_public','nav_timeline_personal','nav_timeline_profile','nav_timeline_reply','nav_timeline_favorites','nav_timeline_props','nav_timeline_comment'];
var tabPages = ['public?aj=1','/all?aj=1','?aj=1','/replies?aj=1','/favorites?aj=1','/props?aj=1','/comment?aj=1'];
//$config['categories'] = array('all'=>'Tất cả','pop'=>'Pop','rock'=>'Rock','party'=>'Party','jazz'=>'Jazz','nhactrinh'=>'Nhạc Trịnh');
var tags = ['all','pop','rock','party','jazz','khongloi'];
var data;
var timeplay = 0;
var errUrl = null;
var errTitle = null;
var errArtist = null;
var pageTo;
var autoplay = false;
var tryListenFlag = true;
/*
 * Validate Register
 */




function showPageByAjax(po,page) {
	var pathURL = root;
	
	if(tabs[po] != 'nav_timeline_public') {
		pathURL += $('#pageUser').html() + tabPages[po];
	} else {
		pathURL += tabPages[po];
	}
	
	if(page != null) {
		pathURL += '&page=' + page;
	}
	
	removeTabCurrent(po);
	var html = $.ajax({
		   type: "POST",
		   url: pathURL,
		   async: false
		 }).responseText;
		 return html; 
}
function removeTabCurrent(po) {
	
	$('#' + tabs[po]).addClass('current');
	for(i = 0; i < tabs.length; i++) {
		if(i != po) {
			$('#' + tabs[i]).removeClass('current');
		}
	}
	
}
function tryListen(control) {
	if ($(control).html() == preview) {
		$('a.media').html(preview);
		tryListenFlag = true;
		$(control).html(listening);
	} else {
		$(control).html(preview);
		tryListenFlag = false;
		niftyplayer('player').stop();
	}
	
}

function toggleAll(element) 
{
var form = document.forms.openinviter, z = 0;
for(z=0; z<form.length;z++)
	{
	if(form[z].type == 'checkbox')
		form[z].checked = element.checked;
   	}
}


function blipRegisterAndLogin() {
	$('#bliploginForm').show();
	$("#blipRegisterForm").hide();
	$('#blipLogin').click(function(){
		$('#bliploginForm').show();
		$("#blipRegisterForm").hide();
	});
	$('#blipRegister').click(function(){
		$('#bliploginForm').hide();
		$("#blipRegisterForm").show();
	});
	var loginBlip = { beforeSubmit: function() { 
						   			return true;
						   		},
						   success: function(msg) {
						   			if (msg=='ready') {
						   				//tb_remove();
						   				
						   				if ($('#notice_data-text').val() != '') {
						   					$('#form_notice').submit();	
						   				} else {
						   					 location.reload(true);
						   				}
						   			} else {
						   				alert(msg);	
						   			}
						   				
								}
						   };
	$("#form_loginblip").ajaxForm(loginBlip);
	var registerBlip = { beforeSubmit: function() { 
						   			return true;
						   		},
						   success: function(msg) {
						   			if (msg=='successful') {
						   				//tb_remove();
						   				
						   				if ($('#notice_data-text').val() != '') {
						   					
						   					$('#form_notice').submit();	
						   				} else {
						   					location.reload(true);
						   				}
						   			} else {
						   				alert(msg);	
						   			}
						   				
								}
						   };
	$("#form_registerblip").ajaxForm(registerBlip);
}
function blipWindow(sartist,sName,url){
		$('#blipbox').show();
		$('#notice_data-text').val('');
		$('#notice_text-count').text('140');
		$('#searchResults').hide();
		$("#statusResults").hide();
		$('#searchbox').hide();
		$('#s_artist').val(sartist);
		$('#s_title').val(sName);
		$('#s_url').val(url);
		$('#frm-title').html(sName);
		$('#frm-artist').html(sartist);	
		randomText();
}
function bookmark(url,title) {
	window.open('http://www.addthis.com/bookmark.php?wt=nw&pub=Blip.fm&url='+url+'&title='+title+'', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=yes,status=no,screenX=200,screenY=100,left=200,top=100'); return false;
}

function setFavFooter(id) {
	var status = 'disfavor-' + id;
	if($('#'+status).html() == null) {
		var status = 'favor-' + id;
	}
	$('#fav_footer').val(status);
	
	//get nickname
	
	var classAuthor = $('#notice-' + id).children();
	var spanNickname = $(classAuthor).children();
	var tempNickname = $(spanNickname).find('span');
	var nickname = $('li[id=notice-' + id  + '] span[class=nickname fn]').html();//$(tempNickname).text();
	$('#nickname_footer').val(nickname);
}
function playSingle(pos){
	//alert(niftyplayer('player'));	
	niftyplayer('player').stop();

	
	curSong = pos;
	currentSong = $('ul.notices li:eq('+pos+')').attr('id');
	//alert(currentSong);
	if (currentSong == null) {
		currentSong = $('ul.notices li:eq(0)').attr('id');
	}
	
	$.cookie('pagePlayList',$('body').attr('id'));
	$.cookie('cookieCurrentSong',currentSong);
	//set cookie page current
	
	var pageNext = $('#pageNext').val();
	pageCurr = pageNext - 1;
	$.cookie('cookieCurrentPage',pageCurr);
	
	if(currentSong) {
		var temp = currentSong.split('-');
		setFavFooter(temp[1]);
	}
	
	if(playList[pos]) {
		url = playList[pos][2];
		sName = playList[pos][1];
		sArtist = playList[pos][0];
		
		playMp3(url,sName,sArtist);
	}
}
function playSong(){
		idCurrent = null;
		if($.cookie('cookieCurrentSong') != null) {
			temp = $.cookie('cookieCurrentSong').split('-');
			idCurrent = temp[1];
		}
		if(niftyplayer('player').getPlayingState() == 'stopped') {
			flag = true;
			if(curSong == -1) curSong = 0;
			playSingle(curSong);
		} else {
			niftyplayer('player').play();
		}
		if(idCurrent != null) {
			$('#song-' + temp[1]).html('Stop....');
		}
		$('#playControl').html('Pause')
}
function pauseSong(){
	idCurrent = null;
	if($.cookie('cookieCurrentSong') != null) {
		temp = $.cookie('cookieCurrentSong').split('-');
		idCurrent = temp[1];
	}
	niftyplayer('player').pause();
	if(playList[curSong]) {
		$('#'+playList[curSong][3]).html('play');
	}
	if(idCurrent != null) {
		$('#song-' + temp[1]).html('play');
	}
	$('#playControl').html('Play');
	$("#statusLoading").html('&nbsp;&nbsp;');
}
function prev(){
	$('a.play').html('Play');
	if (curSetting['play_type']==0) {
		if (curSong == 0) {
			curSong = playList.length-1;
		} else {
			curSong = curSong - 1;
		}
	} else {
		if (curSong == playList.length-1) {
			curSong = 0;
		} else {
			curSong = curSong + 1;
		}
	}
	playSingle(curSong);
}
function getStatusPlayer(action,cSong) {
	$('div.control-panel-wrapper').show();	
	if(curSetting['play_type']==0) {
		if(cSong == '') {
			curSong = 0;
		} else {
			curSong = cSong;
		}
	} else{
		if(cSong == '') {
			curSong = playList.length - 1;
		} else {
			curSong = cSong;
		}
	}
	if (action == 'playblip') {
		flag = true;
		if(($('body').attr('id')=='public')&&($('#notices_primary .notices li[class*=sticky]').html())){
			playSingle(1);
		} else {
			playSingle(0);
		}
	}
	$('a.download').unbind('click');
	$('a.download').click(
		function() {
			if($('#usCurrent').val() == null) {
					var url = "http://ibox.fm/main/login?type=blip&height=170&width=320";
					var t = '<a id="blipLogin" href="#">Đăng nhập</a>&nbsp;|&nbsp;<a id="blipRegister" href="#">Đăng ký</a>';//null;//this.title || this.name || null;
					tb_show(t,url,"Blipping");
					return false;
			} else {
				var url = "http://ibox.fm/?action=download&nid="+$(this).attr('id')+"&height=150&width=350";
				var t = 'Download';//null;//this.title || this.name || null;
				tb_show(t,url,"Download");
				return false;
			}
		}
		
	);
	$('#notices_primary ul li').unbind('click');
	$('#notices_primary ul li').click(
		function(event) {
			 if (($(event.target).attr('href') == null)&&($(event.target).parent().attr('href') == null))  {
      			if ($('a.play',this).text()=='play') {
	      			curSong = $(this).parent().children().index($(this));
					playSingle(curSong);
				 } else  {
				 	updatePageOnStop();
					niftyplayer('player').stop();
					$("#statusLoading").html('&nbsp;&nbsp;');
				 }
      		  }
			//	
		}
	);
	
	$('a.play').unbind('click');
	$('a.play').click(
		function() {
			//alert(playList[1]);
			if ($(this).html() == 'play'){
				$('a.play').html('play');
				$(this).html('Stop....');
				$('#playControl').html('Pause');
				curSong = $(this).parent().parent().parent().parent().parent().parent().children().index($(this).parent().parent().parent().parent().parent());
				//flag = true;
				playSingle(curSong);
				
			} else {
				//flag = false;
				updatePageOnStop();
				niftyplayer('player').stop();
				$("#statusLoading").html('&nbsp;&nbsp;');
			}	
		}
		
		
	);
	
}
function next(){
	$('a.play').html('Play');
	if (curSetting['play_type']==0) {
		if (curSong == playList.length-1) {
			curSong = 0;
		} else {
			curSong = curSong + 1;
		}	
	} else {
		
		if (curSong == 0) {
			curSong = playList.length-1;
		} else {
			curSong = curSong - 1;
		}	
	}
	
	playSingle(curSong);
	if(niftyplayer('player').getPlayingState() == 'playing') {
		$('#playControl').html('Pause');
	} else {
		$('#playControl').html('Play');
	}
}
function listentry() {
	$('.user-control').css('visibility','hidden');
	trylisten = true;
}

function calClickPlay() {
		$.ajax({
				   type: "POST",
				   url: root + 'index.php?action=click&type=play',
				   async: false
				 });
				 //alert('sdf');
}
	
function playMp3(url,sName,sArtist) {
		//case this song error
		
		calClickPlay();
		if (tryListenFlag) {
			if($.cookie('cookieCurrentSong') != null) {
				id = $.cookie('cookieCurrentSong').split('-');
				
				classid = '#song-' + id[1];
				if($(classid).parent().attr('class') == 'errorSong') {
					$(classid).parent().removeAttr('class');
				}
				
			}
			
			$('li.notice').removeClass('playing');
			//alert($.cookie('cookieCurrentSong'));

			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			
			errUrl = url;
			errArtist = sArtist;
			errTitle = sName;
			//alert(niftyplayer('player'));
			niftyplayer('player').stop();
			
			$("#statusLoading").html('&nbsp;&nbsp;');
			//if (flag) {
				focusSong();
				if($('#usCurrent').val() != "" && trylisten == false ) {
					$('.user-control').css('visibility','visible');
					
					$('#curArtist').val(sArtist);
					$('#curName').val(sName);
					$('#curUrl').val(url);
					if($('#usCurrent').val() == $('#nickname_footer').val() ) {
						$('#props').hide();
					} else {
						var classProp = $('li[id=' + $.cookie('cookieCurrentSong') + '] dl[class=notice_props] a').attr('class');
						var titleProp = $('li[id=' + $.cookie('cookieCurrentSong') + '] dl[class=notice_props] a').attr('title');
						$('#props').attr('title',titleProp);
						$('#props').attr('class',classProp);
						$('#props').show();
						
					}
				} else {
					trylisten = false;
				}
				//$('#frm-title').html(sName);
				//$('#frm-artist').html(sArtist);
				$('div.control-panel-wrapper').show();
				
				//check is url of chacha
				if(url.substring(0,14) == 'http://xalo.vn') {
					id = url.replace('http://xalo.vn/','');
					 var newURL = $.ajax({
				   		type: "POST",
				   		url: root +  'index.php?action=parseurl&sid='+id,
				   		async: false
				 	}).responseText;
				 	url = newURL.replace('urlsong=','');
				}
				if(url.substring(0,16) == 'http://chacha.vn') {
					temp = url.split('id=');
					temp2 = temp[1].split('&');
					id = temp2[0];
					var newURL = $.ajax({
				   		type: "POST",
				   		url: root +  'index.php?action=parseurl&id='+id,
				   		async: false
				 	}).responseText;
				 	url = newURL;
			 	}
			 	if(url.substring(0,28) == 'http://www.nhaccuatui.com/M/') {
					id = url.replace(/http:\/\/www.nhaccuatui.com\/M\//, "");
					var newURL = $.ajax({
				   		type: "POST",
				   		url:  root +  'index.php?action=parseurl&id='+id,
				   		async: false
				 	}).responseText;
				 	url = newURL;
			 	}
			 	if(url.substring(0,21) == 'http://xalo.vn/http://') {
					url = url.replace('http://xalo.vn/','');
				}
			 	isplay = false;
			 	//niftyplayer('player').reset();
				niftyplayer('player').loadAndPlay(url);
				cUrl = url;
				//alert(url);
				niftyplayer('player').registerEvent('onSongOver', 'statusPlayer("onSongOver")');
				niftyplayer('player').registerEvent('onBufferingStarted', 'setPlay()');
				niftyplayer('player').registerEvent('onBufferingComplete', 'setPlay()');
				niftyplayer('player').registerEvent('onPlay', 'setPlay()');
				niftyplayer('player').registerEvent('onBufferingStarted', 'loadingStatus("loading")');
				niftyplayer('player').registerEvent('onBufferingComplete', 'loadingStatus("complete")');
				niftyplayer('player').registerEvent('onError', 'errorplay()');
				$('#playState').html(niftyplayer('player').getPlayingState()+' : '+ sArtist + ' - ' + sName);
				if(t) {
					clearTimeout(t);
				}
				t = setTimeout("errorplay();",60000);
				
		}
			//create cookie
		/*} else {
			niftyplayer('player').stop();
			updatePageOnStop();
		}*/
		
}
function setPlay() {
	isplay = true;
}
function errorplay() {
	if(isplay == false ) {
		//set state error
		niftyplayer('player').stop();
		if(timeplay == 0) {
			//playMp3(errUrl,errTitle,errArtist);
			niftyplayer('player').play();
			timeplay++;
		} else {
			if($.cookie('cookieCurrentSong') != null) {
				id = $.cookie('cookieCurrentSong').split('-');
				classid = '#song-' + id[1];
				$(classid).parent().addClass('errorSong');
			} else {
				$('a[onclick*='+cUrl+']').addClass('errorSong');
			}
			pauseSong();
		}
	}
}
function loadingStatus(statusPlayer){
	//alert('abc');
	if (statusPlayer == "loading") {
		$("#statusLoading").html('<img src="'+root+'theme/itfs/images/spinner-dark.gif"/>');	
	} else {
		$("#statusLoading").html('&nbsp;&nbsp;');
	}
	
}
function updatePageOnStop() {
	$('#playControl').html('Play');
	$('.user-control').html('');
	$('#playState').html('');
	$('.notices li').removeClass('focus');
	$('a.play').html('play');
}
function setSongError() {
	//next();
}
function isExistsSong() {
	if(currentSong != '') {
		return $('#'+currentSong).parent().children().index($('#'+currentSong));
	}
	return -1;
}
function clearStyle() {
	$('.notices li').removeClass('focus');
	$('a.play').html('play');
}
function focusSong () {
	$('a.play').html('play');
	index = isExistsSong();
	if (index != -1) {
		tmpcurrentSong =  currentSong.split('-');
		$('#song-'+ tmpcurrentSong[1]).html('Stop....');
		
		curSong = index;	
	}	
}
function statusPlayer(event) {
	switch (event){
		case 'onSongOver':
				$('#playState').html(niftyplayer('player').getPlayingState());
				$('a.play').html('play');
				$('a.media').html(preview);
				$('#playControl').html('Play');
				$('.user-control').css('visibility','hidden');
				if(curSetting['auto_scroll']==0) {
					next();
				} 
				break;		
	}
}
function closeSearchForm() {
	$("#statusResults").hide();	
	$('#searchResults').hide();	
	$('#searchbox').show();
	$('#form_mp3').show();
}

function sortPlayList(classOdd,classEven) {
	var strList = $('#sortable').sortable('serialize');
	var temp;
	var id;
	
	lists = strList.split('&');//alert(lists);
	playList.length = 0;
	for(i = 0; i< lists.length; i++) {
		temp = lists[i].split('=');
		id = temp[1];
		title = $('li[id=notice-' + temp[1]  + '] span[class=ct-title]');
		artist = $('li[id=notice-' + temp[1] + '] span[class=ct-artist]');
		url = $('li[id=notice-' + temp[1] + '] input[class=ct-url]');
		playList.push(new Array(artist.text(),title.text(),url.val()));			
	}
	
	var list = $('#sortable').children();
	for( i = 0; i < list.length; i++ ) {
		if(i % 2 != 0) {
			$(list[i]).removeClass();
			$(list[i]).attr('class',classOdd);
		} else {
			$(list[i]).removeClass();
			$(list[i]).attr('class',classEven);
		}
	}
}

function drag() {
	$(function() {
		if($('body').attr('id') == 'showfavorites') {
			var classOdd;
			var classEven;
			var list = $('#sortable').children();
			classOdd = $(list[1]).attr('class').replace(/ui-sortable-placeholder/,' ');
			classOdd = classOdd.replace(/over/,' ');
			classEven = $(list[2]).attr('class').replace(/ui-sortable-placeholder/,' ');
			classEven = classEven.replace(/over/,' ');
					
			$("#sortable").sortable({
				cursor: "move",
				start: function(event, ui) {
					
				},
				update: function(event, ui) {
					curSong = 0;
					sortPlayList(classOdd,classEven);
				}
				
			});
			$("#sortable").disableSelection();
		}
	});
}


function clearReblip() {
	$('#notice_in-reply-to').val(null);
}
if ($.browser.version == '6.0') {
		$(window).scroll(function() {
			$('.control-panel-wrapper').css({'top' : $(this).scrollTop() + document.documentElement.clientHeight - 43 + "px", 'width': document.documentElement.clientWidth + 'px'})
			$('.control-panel-wrapper').css({'bottom' : '43px'})
		});
}
function autoPlayTrigger() {
	playSingle(0);
}
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
$(document).ready(function(){
	swfobject.embedSWF(root+"niftyplayer.swf?file=01.mp3&amp;as=0", "player", "165", "18", "9.0.0");
	
	
	//alert(swfobject);
	//DOB
	$("input#dob").datepicker({ dateFormat: "dd/mm/yy", showOn: "button", buttonImage: root + "theme/ibox/images/datepicker.png", buttonImageOnly: true });
	
	 var tabContainers = $('div#entity_topdj > div');
		$('div#entity_topdj ul.tabs a').click(function () {
			tabContainers.hide().filter(this.hash).show();
			$('div#entity_topdj ul.tabs li').removeClass('selected');
			$(this).parent().parent().addClass('selected');
			return false;
		}).filter(':second').click();
	
	
	if(autoplay){
		setTimeout('autoPlayTrigger();',2000);
	}
	$('#introduce').click(
		function () {
			window.open(root+'doc/help?type=intro','Hướng dẫn sử dụng','width=550,height=320,resizable=no')
		}
	);
	
	
	var tmpkey;
	$('form input[name=songName]').focus(function() {
		tmpkey = $(this).val();
		if (tmpkey == introSearch) $(this).val('');
	});
	$('form input[name=songName]').blur(function() {
			if ($(this).val() == '') $(this).val(tmpkey);
		});
	
	if ($.browser.version == '6.0') {
		$('.control-panel-wrapper').css({'top' : $(this).scrollTop() + document.documentElement.clientHeight - 43 + "px", 'width': document.documentElement.clientWidth + 'px'});
		$('#notifyContent').css({'bottom' : '43px'});
	}
	$('#notify').click(onClick);
    $('#closebutton').click(function(){ $('#notifyContent').hide(); });
	$('#logo, .pagination, .control-panel-wrapper').supersleight();
	
	$('#toolbar ul li:last-child, #site_nav_local_views ul li:last-child').addClass('last');
		$('#site_nav_local_views ul li:first-child').addClass('first');
		$('#right .block p:last-child, #right #loginbox p:last-child').addClass('last');
		$('.notices li.notice:even').addClass('alter');
	$.cookie('cookieCurrentSong',null);
	drag();
	
		
	//catch event when click tag
	//var tags = ['all','vpop','pop','rock','jazz'];
	if($('#tagall')) {
		$('#tagall').addClass('current');
	}
	for(i = 0; i < tags.length; i++) {
		clickTag(tags[i]);
	}
	function clickTag(tag) {
		$('#tag' + tag).click(function() {
				//1. tag, 2. page
				
				for(i = 0; i < tags.length; i++) {
					$('#tag' + tags[i]).removeClass('current');
				}			
				
				$('#tag' + tag).addClass('current');
				$('#notice_tag_current').val(tag);
				
				
				if(tag != 'all') {
					$('select[id=notice_tag] option[value=' + tag + ']').attr('selected',true);
				} else {
					$('select[id=notice_tag] option[value="-1"]').attr('selected',true);
				}
				//alert ('abc');
				callTag(tag,null);
				$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
				
				return false;
		});
	}
	//next
	nextPage();
	prevPage();
	//check element is in array?
	function isInArray(e,arr) {
		for(i = 0; i < arr.length; i++) {
			if(arr[i] == e) {
				return true;
			}
		}
		return false;
	}
	function nextPage() {
		$('.nav_next').click(function() {
				var pageNext;
				pageNext = $('#pageNext').val();
				pageNext -= 0;
				pageTo = pageNext;
				
				var bodyId = $('body').attr('id');
				if(isInArray(bodyId,tags) && bodyId != 'all') {
					callTag(bodyId,pageNext);
					return false;
				}
				
				if($('#tag').html()) {
					callTag($('#tagcurrent').val(),pageNext);
					return false;
				}
				
				if($('#all').html()) {
					callPersonal(pageNext);
					return false;
				}
				if($('#showstream').html()) {
					callProfile(pageNext);
					return false;
				}
				if($('#replies').html()) {
					callReply(pageNext);
					return false;
				}
				
				if($('#showfavorites').html()) {
					callFavor(pageNext);
					return false;
				}
				
				if($('#public').html()) {
					callPublic(pageNext);
					return false;
				}
		});
		$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
	}
	
	function prevPage() {
		$('.nav_prev').click(function() {
				pageNext = $('#pageNext').val();
				pageNext -= 0;
				pagePrev = pageNext -2;
				pageTo = pagePrev;
				
				var bodyId = $('body').attr('id');
				if(isInArray(bodyId,tags) && bodyId != 'all') {
					callTag(bodyId,pagePrev);
					return false;
				}
				
				if($('#tag').html()) {
					callTag($('#tagcurrent').val(),pagePrev);
					return false;
				}
				
				if($('#all').html()) {
					callPersonal(pagePrev);
					return false;
				}
				if($('#showstream').html()) {
					callProfile(pagePrev);
					return false;
				}
				if($('#replies').html()) {
					callReply(pagePrev);
					return false;
				}
				if($('#showfavorites').html()) {
					callFavor(pagePrev);
					return false;
				}
				if($('#public').html()) {
					callPublic(pagePrev);
					return false;
				}
		});
		$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
	}
	
	$('#nav_timeline_public').click(function() {
			callPublic(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	$('#tagall').click(function() {
			callPublic(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	
	$('#nav_timeline_personal').click(function() {
			callPersonal(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	
	$('#nav_timeline_profile').click(function() {
			callProfile(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	
	$('#nav_timeline_reply').click(function() {
			callReply(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	
	$('#nav_timeline_favorites').click(function() {
			callFavor(null);
			$('li[id=' + $.cookie('cookieCurrentSong') + ']').addClass('playing');
			return false;
		}
	);
	
	function callTag(tag,page) {
		
		var pathURL = root + "tag/" + tag;
		if(page != null) {
			pathURL += "&page=" + page;
		}
		pathURL += "&aj=1";
		if(tag != 'all') {
			data = $.ajax({ type: "POST",url: pathURL,async: false}).responseText;
		}
		playList.length = 0;
		
		if(data != "" && $.cookie('pagePlayList') != 'public') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
		} else {
			if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
		}
		$('#content_inner').html(data);
		
		focusSong();	
		
		$('body').attr('id',tag);
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Box cá nhân của ' + $('#pageUser').html() + ' - ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	function callPublic(page) {
			var data;
			data = showPageByAjax(0,page);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'public') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
				
				
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
			}
			
			$('#content_inner').html(data);
			$('#toolbar ul li:last-child, #site_nav_local_views ul li:last-child').addClass('last');
		$('#site_nav_local_views ul li:first-child').addClass('first');
			focusSong();
			
			$('body').attr('id','public');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			
			//$('title').html('Box chung – ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	
	
	
	function callPersonal(page) {
			data = showPageByAjax(1,page);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'all') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
			}
			
			$('#content_inner').html(data);
			focusSong();
			
			$('body').attr('id','all');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Box cá nhân của ' + $('#pageUser').html() + ' - ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	
	function callProfile(page) {
		data = showPageByAjax(2,page);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'showstream') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
			}
			
			$('#content_inner').html(data);
			focusSong();
			$('body').attr('id','showstream');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Hồ sơ của ' + $('#pageUser').html() + ' - ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	
	
	function callReply(page) {
		data = showPageByAjax(3,page);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'replies') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
			}
			
			$('#content_inner').html(data);
			focusSong();
			$('body').attr('id','replies');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Bài hát được tặng của ' + $('#pageUser').html() + ' - ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	
	
	function callFavor(page) {
			data = showPageByAjax(4,page);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'showfavorites') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
			}
			$('#content_inner').html(data);
			focusSong();
			$('body').attr('id','showfavorites');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Playlist của ' + $('#pageUser').html() + ' - ibox.fm');
			nextPage();
			prevPage();
			return false;
	}
	$('#nav_timeline_props').click(function() {
			data = showPageByAjax(5,null);
			playList.length = 0;
			if(data != "" && $.cookie('pagePlayList') != 'showprops') {
				if(niftyplayer('player').getPlayingState() == 'playing') {
					curSong = -1;
				}
			} else {
				if($.cookie('cookieCurrentSong') != null) {
					if(pageTo == $.cookie('cookieCurrentPage') ) {
						curSongId = "#" + $.cookie('cookieCurrentSong');
						curSong = $(curSongId).parent().children().index($(curSongId));
					} else {
						curSong = -1;
						playList.length = 0;
					}
				} else {
					playList.length = 0;
				}
				
			}
			$('#content_inner').html(data);
			focusSong();
			$('body').attr('id','showprops');
			NoticeHover();
			NoticeReply();
			Props();
			NoticeGift();
			$("form.form_favor").ajaxForm(favoptions);
			$("form.form_disfavor").ajaxForm(disoptions);
			$("form.form_favor").each(addAjaxHidden);
			$("form.form_disfavor").each(addAjaxHidden);
			getStatusPlayer('',curSong);
			drag();
			//$('title').html('Bài hát được yêu thích của ' + $('#pageUser').html() + ' - ibox.fm');
			return false;
		}
	);
	
	$('#nav_timeline_comment').click(function() {
			data = showPageByAjax(6,null);
			$('#content_inner').html(data);
			$('body').attr('id','showcomment');
			return false;
		}
	);
	
	//end click tabs
	
	$('#searchResults').hide();
	$('.user-control').css('visibility','hidden');
	
	
	$('#props').click(
		function() {
			//bookmark(root + 'notice/'+playList[curSong][3],playList[curSong][1]);
			var nickname = $('#nickname_footer').val();
			var pageUser = $('#pageUser').html();
			var tempId = $('#fav_footer').val();
			tempId = tempId.split('-');
			id = tempId[1];
			$.ajax({
						   type: "POST",
						   url: root + nickname+"/addprops",
						   data: 'id=' + id + '&pageUser=' + pageUser,
						   success: function(msg){
						   	if(msg != '') {
						   		if(msg == 'error') {
						   			//alert('Ban khong the tang props cho chinh ban');
						   		} else {
							   		var temp = msg.split(":");
							   		$('#showprops').html(temp[0]);
							   		$('#props_receive').html(temp[1]);
							   		//alert('Ban da tang ' + nickname.html() + ' 1 props');
							   		$('#yougivprops').html(nickname);
							   		$('.control-panel-wrapper2').slideDown("slow",function() { 
							   			setTimeout("hideAlert();",2000);
							   		});							   		
							   		send_to_props('props',nickname,id);
						   		}
						   	} else {
						   		//alert('Ban khong the tang ' + nickname + ' 1 props');
						   	}
						   	
						   	//alert(msg);
						   }
						 });
		}
	);
	$('#reblip').click(
		function() {
			if($.cookie('cookieCurrentSong') != null) {
				$('li[id=' + $.cookie('cookieCurrentSong') + '] div[class=notice-options] dl[class=notice_reply]').click();
			}
		}
	);
	
	
	
	$('#playControl').click(
		function() {
			if ($(this).html()=='Pause') {
				pauseSong();
			} else {
				playSong();	
			} 
			
		}
	);
	
	var Mp3Search = { beforeSubmit: function() { 
						   			var songName = $('#songName').val();
						   			songName = songName.replace(/ /,'');
						   			if(songName == ''){
						   				alert('Mời bạn nhập tên bài hát cần tìm');
						   				$('#songName').focus();
						   				return false;
						   			} else {
						   				if(songName.length >= 3) {
						   					$("#indicator").html('<img src="'+root+'theme/ibox/images/indicator.gif"/>');
						   					return true;	
						   				} else {
						   					alert('Tên bài hát cần tìm phải có ít nhất 3 ký tự');
							   				$('#songName').focus();
							   				return false;	
						   				}
						   				
						   			}
						   		},
						   success: function(xml) {
						   		//	alert(xml);
						   		result = mp3SearchResult(xml);
						   			$("#statusResults").show();
						   			if (result == '<table></table>'){
										result = noresult;
										$("#statusResults").html(result);
										$('#searchResults').hide();
									} else {
										
							   			$("#statusResults").html('<div style="float:left">'+sresult+'</div><div style="float:right"><a href="javascript:closeSearchForm();" title="'+closeForm+'" id="close_search_form">'+closeForm+'</a></div>');
							   			$("#searchResults").html(result);
							   			$('#searchResults').show('slow');
									}
						   			$("#indicator").html('');	
								}
						   };
	$("#form_mp3").ajaxForm(Mp3Search);
	
	function mp3SearchResult(xmlMp3) {
		var result = "<table>";
		
		$(xmlMp3).find("mp3").each(function() {
			  var marker = $(this);
			  var id = marker.find('id').text();
			  var title = marker.find('name').text();
			  var artist = marker.find('artist').text();
			  if (isNaN(id)) {
				var url = id;
			  } else {
				var url = "http://xalo.vn/"+id;
			 }
			 //var url = id;
			  if(marker.find('artist').text()!='') {
				result += '<tr><td><a class="blipControl" href="javascript:void(0);" onclick="javascript:clearReblip();blipWindow(\'' + artist + '\',\'' + title + '\',\'' + url + '\');" >'+blip+'</a></td><td>' + title + '-' + artist+ '</td><td><a class="media" href="javascript:void(0);" onclick="javascript: tryListen(this);listentry();playMp3(\''+url+'\',\''+title+'\',\''+artist+'\'); clearStyle();" >'+preview+'</a></td></tr>';				  
			  } else {
				result += '<tr><td><a class="blipControl" href="javascript:void(0);" onclick="javascript:clearReblip();blipWindow(\'' + artist + '\',\'' + title + '\',\'' + url + '\');" >'+blip+'</a></td><td>' + title + '</td><td><a class="media" href="javascript:void(0);" onclick="javascript: tryListen(this);listentry();playMp3(\''+url+'\',\''+title+'\',\''+artist+'\'); clearStyle();" >'+preview+'</a></td></tr>';	
			  }
			});
			result += '</table>';
			return result;
	}
	getStatusPlayer('','');
	getNewNotice();
	
	$('#form_register #nickname').change(
		function (){
			//alert($(this).val());
			if (($(this).val().length < 4) || ($(this).val().length > 24)) {
				$('#nicknamespan').text('Tên dài từ 4 - 24 ký tự.');	
				$('#nicknamespan').addClass('error');		
				$('#nicknamesam').text('');		
				return;
			}
			var result = $.ajax({
					   type: "POST",
					   url: root + 'main/register?type=validate&usn='+$(this).val(),
					   async: false
					 }).responseText;
			if (result == 'valid') {
				$('#nicknamespan').html('<img src="'+root+'theme/ibox/images/register-ticked.jpg" alt = "Hợp lệ" />');
				$('#nicknamesam').text($(this).val());			
			} else if (result == 'invalid') {
				$('#nicknamespan').text('Tên đã có người sử dụng.');	
				$('#nicknamespan').addClass('error');		
				$('#nicknamesam').text('');		
			} 
			 
		}
	);
	$('#form_register #password').change(
		function (){
			if ($(this).val().length < 6){
				$('#passwordspan').text('Mật khẩu dài từ 6 ký tự trở lên.');
				$('#passwordspan').addClass('error');
				return;
			} else {
				$('#passwordspan').html('<img src="'+root+'theme/ibox/images/register-ticked.jpg" alt = "Hợp lệ" />');
				//$('#passwordspan')
			}
		}
	);
	$('#form_register #confirm').change(
		function (){
			if ($(this).val().length < 6){
				$('#confirmspan').text('Mật khẩu dài từ 6 ký tự trở lên.');
				$('#confirmspan').addClass('error');
				return;
			} else {
				$('#confirmspan').html('<img src="'+root+'theme/ibox/images/register-ticked.jpg" alt = "Hợp lệ" />');
			}
			if ($(this).val() != $('#password').val()) {
				$('#confirmspan').text('Mật khẩu xác nhận chưa đúng');
				$('#confirmspan').addClass('error');
			} else {
				$('#confirmspan').html('<img src="'+root+'theme/ibox/images/register-ticked.jpg" alt = "Hợp lệ" />');
				//$('#confirmspan').text('');	
			}	
		}
	);
	$('#form_register #email').change(
		function (){
			var result = $.ajax({
					   type: "POST",
					   url: root + 'main/register?type=validate&usn=&email='+$(this).val(),
					   async: false
					 }).responseText;
					 
			if (result == 'valid') {
				$('#emailspan').html('<img src="'+root+'theme/ibox/images/register-ticked.jpg" alt = "Hợp lệ" />');
			} else if (result == 'invalid') {
				$('#emailspan').text('Email đã có người sử dụng.');	
				$('#emailspan').addClass('error');		
			} 
		}
	);
	$('#help').click(
		function () {
			var url = root + "quickhelp/guide?TB_iframe=true&height=290&width=680";
							var t = helpTitle;
							tb_show(t,url,helpTitle);
							return false;			
		}
	);
	
	$('#btnEmbed').click(function(){
		
		if (!$('#pageUser').text()) {
			alert('Xin mời bạn đăng nhập trước khi sử dụng chức năng này');
			return;
		}
		if (isNaN($('#wBox').val())) {
			alert('Chiều rộng hộp nhạc phải là giá trị kiểu số');
			$('#wBox').focus();
			return;
		}
		if (isNaN($('#hBox').val())) {
			alert('Chiều cao hộp nhạc phải là giá trị kiểu số');
			$('#hBox').focus();
			return;
		}
		if ($('#replies').attr('checked')) {
			$('#codeEmbed').html(introBlogerEmbed + '<textarea readonly="readonly" cols="62" rows="3"><iframe name="iframe1" width="'+$('#wBox').val()+'" height="'+ $('#hBox').val() +'" src="http://ibox.fm/main/embed?type=playlistembed&dj='+$('#pageUser').text()+'&limit='+$('#countBlip').val()+'&replies=1&theme='+$("input[name='embedtheme']:checked").val()+'" frameborder="no" scrolling="auto"></iframe></textarea>');
			$('#preview').html('<iframe name="iframe1" width="'+$('#wBox').val()+'" height="'+ $('#hBox').val() +'" src="http://ibox.fm/main/embed?type=playlistembed&dj='+$('#pageUser').text()+'&limit='+$('#countBlip').val()+'&replies=1&theme='+$("input[name='embedtheme']:checked").val()+'" frameborder="no" scrolling="auto"></iframe>');
		} else  {
			$('#codeEmbed').html(introBlogerEmbed + '<textarea readonly="readonly" cols="62" rows="3"><iframe name="iframe1" width="'+$('#wBox').val()+'" height="'+ $('#hBox').val() +'" src="http://ibox.fm/main/embed?type=playlistembed&dj='+$('#pageUser').text()+'&limit='+$('#countBlip').val()+'&replies=0&theme='+$("input[name='embedtheme']:checked").val()+'" frameborder="no" scrolling="auto"></iframe></textarea>');
			$('#preview').html('<iframe name="iframe1" width="'+$('#wBox').val()+'" height="'+ $('#hBox').val() +'" src="http://ibox.fm/main/embed?type=playlistembed&dj='+$('#pageUser').text()+'&limit='+$('#countBlip').val()+'&replies=0&theme='+$("input[name='embedtheme']:checked").val()+'" frameborder="no" scrolling="auto"></iframe>');			
		}
		
	});
	
	$('#btnEmbedYahooPlus').click(function(){
		if (!$('#pageUser').text()) {
			alert('Xin mời bạn đăng nhập trước khi sử dụng chức năng này');
			return;
		}
		
		
		
		switch($("input[name='embedtheme']:checked").val())
		{
		case 'theme1':
			headcolor ='0xF86729';
			endcolor ='0xEDB83D';
			break;
		case 'theme2':
			headcolor ='0xB31A1A';
			endcolor ='0xF86729';
		  break;
		case 'theme3':
			headcolor ='0xEDB83D';
			endcolor ='0xF8E6CB';
		  break;
		case 'theme4':
			headcolor ='0x3F7128';
			endcolor ='0x1AB394';
		  break;
		case 'theme5':
			headcolor ='0x143F7C';
			endcolor ='0x8248D9';
		  break;
		case 'theme6':
			headcolor ='0x184381';
			endcolor ='0x45AFDC';
		  break;
		 case 'theme7':
			headcolor ='0x5E7B2F';
			endcolor ='0xC5BA5C';
		  break;
		case 'theme8':
			headcolor ='0x4F3C39';
			endcolor ='0xCCBBBB';
		  break;
		case 'theme9':
			headcolor ='0x1F3D58';
			endcolor ='0x45DCDC';
		  break;
		default:
			headcolor ='0x184381';
			endcolor ='0x45AFDC';
		}
		if($('#typeBox').val() == 'Trung bình') {
			var height = 350;
			var width = 290;
			var flash = 'embed-small.swf';
		}
		// if($('#typeBox').val() == 'Lớn') {
			// var height = 350;
			// var width = 420;
			// var flash = 'embed-medium.swf';
		// }
		if($('#typeBox').val() == 'Lớn') {
			var height = 500;
			var width = 424;
			var flash = 'embed-large.swf';
		}
		var plembed=0;
		if ($('#playlist').attr('checked')) {
			plembed = 1;
		} else {
			plembed = 0;
		}
		if ($('#replies').attr('checked')) {
			$('#codeEmbed').html(introEmbed + '<textarea readonly="readonly" cols="62" rows="5"><object height="'+ height +'" width="'+ width +'" type="application/x-shockwave-flash" data="http://ibox.fm/'+flash+'" id="embedbox" style="visibility: visible;"><param name="flashvars" value="djname='+$('#pageUser').text()+'&amp;limit='+$('#countBlip').val()+'&amp;showPlaylist='+plembed+'&amp;autostart=false&amp;replies=1&amp;textcolor=12792834&amp;itemcolor=16777215&amp;headercolor='+headcolor+'&amp;endcolor='+endcolor+'"/></object></textarea>');
			$('#preview').html('<object height="'+ height +'" width="'+width+'" type="application/x-shockwave-flash" data="http://ibox.fm/'+flash+'" id="embedbox" style="visibility: visible;"><param name="flashvars" value="djname='+$('#pageUser').text()+'&amp;limit='+$('#countBlip').val()+'&amp;showPlaylist='+plembed+'&amp;autostart=false&amp;replies=1&amp;textcolor=12792834&amp;itemcolor=16777215&amp;headercolor='+headcolor+'&amp;endcolor='+endcolor+'"/></object>');
		} else  {
			$('#codeEmbed').html(introEmbed + '<textarea readonly="readonly" cols="62" rows="5"><object height="'+ height +'" width="'+ width +'" type="application/x-shockwave-flash" data="http://ibox.fm/'+flash+'" id="embedbox" style="visibility: visible;"><param name="flashvars" value="djname='+$('#pageUser').text()+'&amp;limit='+$('#countBlip').val()+'&amp;showPlaylist='+plembed+'&amp;autostart=false&amp;replies=0&amp;textcolor=12792834&amp;itemcolor=16777215&amp;headercolor='+headcolor+'&amp;endcolor='+endcolor+'"/></object></textarea>');
			$('#preview').html('<object height="'+ height +'" width="'+width+'" type="application/x-shockwave-flash" data="http://ibox.fm/'+flash+'" id="embedbox" style="visibility: visible;"><param name="flashvars" value="djname='+$('#pageUser').text()+'&amp;limit='+$('#countBlip').val()+'&amp;showPlaylist='+plembed+'&amp;autostart=false&amp;replies=0&amp;textcolor=12792834&amp;itemcolor=16777215&amp;headercolor='+headcolor+'&amp;endcolor='+endcolor+'"/></object>');			
		}
		
	});
	
	/*$('a.download').unbind('click');
	$('a.download').click(
		function() {
			var url = "http://ibox.fm/?action=download&nid="+$(this).attr('id')+"&height=150&width=350";
			var t = 'Download';//null;//this.title || this.name || null;
			tb_show(t,url,"Download");
			return false;
		}
		
		
	);*/
});
