function showmessage(msgtype,result){
	var msgclass;
	switch (msgtype)
	{
	case 0:
		msgclass="error"
		break
	case 1:
		msgclass="success"
		break
	default:
		msgclass="message"
	}
	var content = '<dl id="system-message"><dd class="'+msgclass+' message fade"><ul><li>'+result+'</li></ul></dd></dl>';
	$("#system-message").remove();
	$("#index_l_t").after(content);
	show_systemmessage();
}
function show_systemmessage(){
	msgwin(2000);
}
function msgwin(t) {
	
	var msgWinObj = document.getElementById('system-message');
	msgWinObj.style.display = '';
	msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
	msgWinObj.style.opacity = 0;
	var sTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	pbegin = sTop + (document.documentElement.clientHeight / 2);
	pend = sTop + (document.documentElement.clientHeight / 5);
	setTimeout(function () {showmsgwin(pbegin, pend, 0, t)}, 1);
	msgWinObj.style.left = ((document.documentElement.clientWidth - msgWinObj.clientWidth) / 2) + 'px';
	msgWinObj.style.top = pbegin + 'px';
}

function showmsgwin(b, e, a, t) {
	step = (b - e) / 100;
	var msgWinObj = document.getElementById('system-message');
	newp = (parseInt(msgWinObj.style.top) - step);
	//alert(newp);
	if(newp > e) {
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + a + ')';
		msgWinObj.style.opacity = a / 100;
		msgWinObj.style.top = newp + 'px';
		setTimeout(function () {showmsgwin(b, e, a += 10, t)}, 5);
	} else {
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		msgWinObj.style.opacity = 1;
		setTimeout('displayOpacity(\'system-message\', 100)', t);
	}
}

function displayOpacity(id, n) {
	var obj=document.getElementById(id);
	if(!obj) {
		return;
	}
	if(n >= 0) {
		n -= 10;
		obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';
		obj.style.opacity = n / 100;
		setTimeout('displayOpacity(\'' + id + '\',' + n + ')', 50);
	} else {
		obj.style.display = 'none';
		obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		obj.style.opacity = 1;
	}
}

function display(id) {
	var obj=document.getElementById(id);
	obj.style.display = obj.style.display == '' ? 'none' : '';
}


/**
 * @author zhucx
 * @date 2011-02-21
 * 验证码
 */

var i=0;
$('#captcha').live('click',function(){
		i++; 
		$(this).attr('src','index.php?option=com_captcha&id='+i);	
	}
);
$('#word').live('keyup',function(){		
	$('#a_word').val($('#word').val());

})

function checkAuthor(form){
	var word = $('#word').val();

	if(!trim(word)){
		$('#word').removeClass('validation-passed').addClass('validation-failed');
		$('label[for="word"]').remove();
		$('#captcha').after('<label for="word" class="validation-failed">验证码不能为空！</label>');
	}else{
		$.ajax({
			type: "post",
			url: "index.php?option=com_lifepayment&task=checkCaptcha",
			data: "word="+word+"&rand="+new Date().getMilliseconds(),
			success:function(data){
				if(data == 'true'){					
					getCardJson(form);
				}else{
					$('#word').removeClass('validation-passed').addClass('validation-failed');
					$('label[for="word"]').remove();
					$('#captcha').after('<label for="word" class="validation-failed">验证码错误，请重新输入！</label>');
					$('#word').val('');
					$('#word').focus();
				}
				
			}		
		});	
	}	
}
