﻿//自动缩放代码///////////////////////////////
function ReImgSize(obj){
  for (i=0;i<document.images.length;i++)
   {
   if (document.all){
	if (document.images[i].width>500)
	 {
       document.images[i].width="500"
       document.images[i].outerHTML='<a href="'+document.images[i].src+'" target="_blank" title="在新窗口打开图片">'+document.images[i].outerHTML+'</a>'
  	 }
   }
  else{
	if (document.images[i].width>400) {
	  document.images[i].title="在新窗口打开图片"
	  document.images[i].style.cursor="pointer"
	  document.images[i].onclick=function(e){window.open(this.src)}
	}
  }
  }
 }

 function initJS(){
	ReImgSize() //自动缩放代码 
}

//缩放字体大小////////////////////////////
var status0='';
var curfontsize=10;
var curlineheight=18;
function fontZoomA(){
  if(curfontsize>8){
    document.getElementById('fontzoom').style.fontSize=(--curfontsize)+'pt';
	document.getElementById('fontzoom').style.lineHeight=(--curlineheight)+'pt';
  }
}
function fontZoomB(){
  if(curfontsize<64){
    document.getElementById('fontzoom').style.fontSize=(++curfontsize)+'pt';
	document.getElementById('fontzoom').style.lineHeight=(++curlineheight)+'pt';
  }
}

var Cookie = {
setCookie : function(name, value)
{
document.cookie = name + "=" + value + ";";
}
};
function getcookie(value)
{
  Cookie.setCookie("skincookie", value);
  window.location.reload();
}

function opensetTop(divid)
{
  var setTopdiv=document.getElementById(divid);
  var setToplink=document.getElementById('linksetTop'+divid);
  if(setTopdiv.style.display!="none")
  {
	  setTopdiv.style.display="none";
	  setToplink.style.background="url(images/opensetTop.gif) no-repeat";
  }else{
      setTopdiv.style.display="block";
	  setToplink.style.background="url(images/closesetTop.gif) no-repeat";
  }
}
//=========================================
//表单判断
//=========================================
function CheckForm(obj){
	if(document.form.userid.value=="")
	{
	alert("用户名不能为空");
	document.form.userid.focus();
	return false;
	}
	if(document.form.password.value=="")
	{
	alert("密码不能为空");
	document.form.password.focus();
	return false;
	}
	return true;
}
function checkUsername(obj){
var ajax=new AJAX();
//alert(document.getElementById("username").value);
ajax.get("checkusername.asp?username="+document.getElementById("username").value,function(obj){document.getElementById("usernameMsg").innerHTML=obj.responseText;});
}
function CheckForm1(obj){
	if(document.form1.content.value=="")
	{
	alert("评论内容不能为空");
	document.form1.content.focus();
	return false;
	}
	return true;
}

function cc(){
	if (document.all){
		var IframeID=frames["Dvbbs_Composition"];
	}
	else
	{
		var IframeID=document.getElementById("Dvbbs_Composition").contentWindow;
	}
	if(IframeID)
	{
		IframeID.document.body.innerHTML=document.all("content").value;
		document.all("content").value="";
	}
}

function openEditscript(url, width, height){
	var Win = window.open(url,"openEditscript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}

function Flash(Path,Width,Height){
	 var Temp,T=""
	 Temp='<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="FlashH" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="'+Width+'" height="'+Height+'">'
	 Temp+='<param name="movie" value="'+Path+'"/>'
	 Temp+='<param name="quality" value="High"/>'
	 Temp+='<param name="scale" value="ExactFit"/>'
	 Temp+=' <param name="wmode" value="transparent"/>';T='wmode="transparent"'
	 Temp+='<embed src="'+Path+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashH" width="'+Width+'" height="'+Height+'" quality="High"'+T+' scale="ExactFit"/>'
	 Temp+='</object>'
	 document.getElementById("Flash").innerHTML=Temp
}

//运行文本域代码
function runCode(codes)
{
	cod=document.all(codes);
	var code=cod.value;
	if (code!="")
	{
		var newwin=window.open('','','');  
		newwin.opener = null;
		newwin.document.write(code);  
		newwin.document.close();
	}
}
function runCode2(codes)
{
	return;
	var cod=document.getElementById(codes);
	if(cod!=null)
	{
		var winname=window.open("","test","");
		winname.document.open("text/html", "replace");
		winname.document.write(cod.value);
		winname.document.close();
	}
}
function copyCode(codes)
{
	cod=document.all(codes);
	cod.focus();
	cod.select();
	var clipeText = cod.createTextRange();
	clipeText.execCommand("Copy");
}

function saveCode(codes){
	var cod=document.getElementById(codes);
	if(cod!=null)
	{
		var winname=window.open('','test','top=10000');
		winname.document.open("text/html", "replace");
		winname.document.write(cod.value);
		winname.document.execCommand('saveas','','code.html');
		winname.close();
	}
}




function showUserPanel()
{

  try{
    var panel=document.getElementById("userPanel");
    if(panel){
      if(panel.style.display=='none'){
        panel.style.display='block';
      }else{
        panel.style.display='none';
      }
    }else{
		
      //document.location="login.asp";
    }
  }catch(e){}
}