//<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

function getFileExtension(filePath) 
{
	fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length));
	return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
}

function turnit(ss)
{
	if (ss.style.display=="none")
	{
    	ss.style.display="";
  	}
  	else
  	{
    	ss.style.display="none";
  	}
}


function addBookmark(title, url) 
{
    if (window.sidebar) 
    { 
        window.sidebar.addPanel(title, url, ""); 
    } 
    else if (document.all) 
    {
        window.external.AddFavorite(url, title);
    } 
    else if(window.opera && window.print) 
    {
        return true;
    }
}

function changeBoard_BBS(thisBoard, SubID)
{
	if(thisBoard.options[thisBoard.selectedIndex].value != "-1")
	{
    	window.location.href="List.aspx?SubID=" + SubID + "&SortTopic=" + thisBoard.options[thisBoard.selectedIndex].value;
	}
}

var transshow = false;
function showAndHide(obj,types)
{
    var Layer = $("#" + obj)[0];
	var LayerType = (typeof(types) == 'undefined') ? '' : types;
	if (LayerType == '')
	{
		LayerType = (transshow) ? 'none' : 'block';
	}
	else
	{
		LayerType = (LayerType != 'hide') ? 'block' : 'none';
	}
	Layer.style.display = LayerType;
	transshow = (LayerType != 'none');
	
    var o = $("#icon").position();
    $("#menuul").css({'top':o.top + 20,'left':o.left});
}
function hideTrans()
{
    if ($("#menuul") != null)
    {
	    $("#menuul")[0].style.display = 'none';
	    transshow = false;
	}
}

function switchicon(iconid, obj) 
{
    $("#c_Emotion").val(iconid);
    $("#icon_img").attr("src",obj.src);
    hideTrans();
}

function AddContent(Filename, extensions)
{
    var sFile = $("#" + Filename).val();

    if (sFile == "" || extensions.toUpperCase().indexOf(getFileExtension(sFile).toUpperCase()) == -1)
	{
	    alert("这种文件类型不允许上传，请选择别的文件并重新上传");
		return false;
	}
    
	var sourceEditor = document.getElementById("sourceEditor");
	if (sourceEditor.style.display == "")
	{
	    sourceEditor.value = sourceEditor.value + "[upfile]" + Filename + "[/upfile]";
	}
	else
	{
	    var f = window.frames["HtmlEditor"];
	    var body = f.document.getElementsByTagName("BODY")[0];
	    body.innerHTML = body.innerHTML + "[upfile]" + Filename + "[/upfile]";
	}
}

function copyToClipboard(url) 
{ 
    if (document.all)
    {
	    window.clipboardData.setData("text", url); 
	    alert('您现在可在MSN/QQ上粘贴发送');
	}
	else
	{
        alert("使用此功能请使用IE浏览器");
        return;
	}
} 

function CheckUserModiForm()
{
    var sFile = $("#c_HeadPic").val();

    if (sFile == "" || extensions.toUpperCase().indexOf(getFileExtension(sFile).toUpperCase()) == -1)
	{
	    alert("这种文件类型不允许上传，请选择别的文件并重新上传");
		return false;
	}

    return true;
}

function ShowBigPic(place, src)
{
    if (place == 1 || place == 2)
    { 
        $("#BigPic" + place).attr("src", src);
    }
}

function clearFileInput(file)
{ 
    var form = document.createElement('form'); 
    document.body.appendChild(form); 
    var pos = file.nextSibling; 
    form.appendChild(file); 
    form.reset(); 
    pos.parentNode.insertBefore(file, pos); 
    document.body.removeChild(form); 
} 

function Searchmouseout()
{
	if ($("#Content").val() == "")
	{
		$("#Content").css("color", "#ccc");
		$("#Content").val("请输入关键字");
	}
}

function Searchmouseover()
{
	if ($("#Content").val() == "请输入关键字")
	{
		$("#Content").css("color", "#000");
		$("#Content").val("");
	}
}

function ShowVote(selected)
{
    var valradio = $(":radio:checked").val(); 
    if (valradio == "0")
    {
        $("#VotePlace").css("display", "none");
    }
    else
	{
		$("#VotePlace").css("display", "");
	}
}

function checkOK()
{
	var bReturn = false;
	
	for (var i=0; i<BBS_Vote.elements.length; i++)
    {
		if (BBS_Vote.elements[i].checked)
		{
			bReturn = true;
		}
	}
	
	if (bReturn)
	{
		BBS_Vote.submit();
	}
	else 
	{
		alert('您尚未选择！');
		BBS_Vote.reset();
	}
}

function showimage()
{
    var nValue = document.frmpost.c_HeadPicSys.options[document.frmpost.c_HeadPicSys.selectedIndex].value;
    if (nValue == "0")
    {
        if ($("#c_HeadPicUP").val() != "")
        {
            $("#UserHead").attr("src", $("#c_HeadPicUP").val());
        }
    }
    else
    {
        $("#UserHead").attr("src", "images/head/" + nValue + ".jpg");
        CurSelect = nValue;
    }
}