/**
*	David Lu@2008-10-7
*	Javascripts for photobook
*/
function checkUser(nickId){
	var id = gi(nickId).value;
	if(!id.match(/^[a-z]\w{2,15}$/i)){
		alert("请输入合法的用户名！");
		gi(nickId).focus();
		return false;
	}
	var u="./log.php?nick=" + id;
	send_request(u,checkUserR);
	return false;
}
function checkUserR(){
	if(http_request.responseText != "No"){
		alert("此用户名已经被使用，请选择其他用户名！");
	}else{
		alert("您可以使用这个用户名！");
	}
}
function copyTxt(txt){
	if(copyToClipboard(txt))
		alert('成功复制到剪切板！');
	else
		alert('复制失败，请重试！');
}
function redirect(u)
{
	window.location.href = u;
	//window.location.replace(u);
}
function showChecked(o,divId)
{
	if(o.checked)
		gi(divId).style.display = "";
	else
		gi(divId).style.display = "none";
}
function as(fid)
{
	var s = gi(fid).src;
	document.frames[fid].location.href = s;
	document.frames[fid].scrollBy(0,800);
}
function subMenu(o){
	if(o == 'none'){
		gi('subMenu').innerHTML = '';
		return;
	}
	var smxy = getCord(o);
	var smxy1 = getCord(gi('subMenu'));
	var smw = gi('subMenu').offsetWidth;
	var oid = o.href.match(/id=(\d+)/i);
	var smcodes = eval('sub'+oid[1]).replace('<div></div>','');
	var cLen = smcodes.split('</div><div>');
	var divw = cLen.length * 88;
	var mleft = smxy[0]-smxy1[0];
	if(divw+mleft > smw){
		mleft -= (divw+mleft-smw+50);
	}
	gi('subMenu').innerHTML = '<div style="background:none;margin-left:'+mleft+'px;">'+smcodes+'</div>';
}
function moveLeft(){
	gi('slide').scrollLeft -= 3;
}
function moveRight(){
	gi('slide').scrollLeft += 3;
}
function movePic(num){
	var i = 0;
	if(num < 0){
		itv = setInterval("moveLeft()",10);
	}
	else if(num == 0){
		clearInterval(itv);
	}
	else{
		itv = setInterval("moveRight()",10);
	}
}
function movePics(){
}
