var tmpheight = 120;
var tmpwidth = 380;
var timer = 'fail';
var max = 45;
function locklength(e)
{
	if (e.keyCode){
		k =e.keyCode;
	}else if (e){
		k = e.which;
	}
	
	var desc = $('#bk_input_text').val();
	
	if(k == 8 || k == 46){
		var langd = desc.length-1;
	}else if(k>39){
		var langd = desc.length+1;
	}else{
		var langd = desc.length;
	}

	var kvar = max - langd;
	
	if(k == 8 || k == 46){
		return true;
	}else if(kvar < 0){
		return false;
	}else{
		return true;
	}
}

function copytext(ob)
{
	var desc = $('#bk_input_text').val()
	.replace(/"/g,"&quot;")
    .replace(/</g,"&lt;")
    .replace(/>/g,"&gt;");
	
	var kvar = max - desc.length;
	if(kvar < 0){
		$('#charcountertag').css({'color' : '#ff0000'});
	}else{
		$('#charcountertag').css({'color' : '#999'});
	}
	$('#charcounter').html(kvar);
	$('#bl_spot_text').html(desc);
}



function widgetenter(e,ob)
{
	if(catchEnter(e))
	{
		se = $(ob).val();
		widgetsearch(se,'/ajax/search/spotlight/');
	}
	return true;
}

function spotlightselect(spotlight)
{
	var name = $('#spot' + spotlight + ' > div.info > h2 > a').html();
	name = name.replace(/&amp;/g,"&");
	var url = $('#spot' + spotlight + ' > div.info > span').html();
	var src = $('#spot' + spotlight + ' > div.image > a > img').attr('src');
	$('#bl_spot_img').attr('src',src);
	$('#bl_spot_img').attr('alt',name);
	$('#bl_spot_name').html(name);
	$('#bl_spot_link').attr('title',url);
	$('#bl_spot_link').attr('href',url);
	$('input.search').val(name);
	$('#blog_id').val(spotlight);
	tb_remove();
	return false;
}

function change_page(){
	$.post('/ajax/newspotlight/status/',{spotid: spotid},changepageback,'');
}
function changepageback(content){
	if(content >= 1)
	{
		window.clearInterval(timer);
		$('#step1').hide();
		$('#step2').hide();
		$('#step3').show();
	}
}

function catchenter(e,ob)
{
	if(catchEnter(e)){
		return searchblogname(ob);
	}
}
