﻿//设置Cookie
function setcookie(name, value) {
var value = escape(value);
var namestring = "_350009_" + name + "=" + value; //给cookie变量增加前缀
var extime = new Date();
extime.setTime(extime.getTime() + 600 * 24 * 60 * 60 * 1000);
var expiryString = ";expires=" + extime.toGMTString();
var pathString = ";path=/";
var setvalue = namestring + expiryString;
document.cookie = setvalue;
}

//读取Cookie
function getcookie(name) {
var cookiefounded = false;
var start = 0;
var end = 0;
var cookiestring = document.cookie;
var i = 0;
name = "_350009_" + name; //增加前缀
while (i <= cookiestring.length) {
start = i;
end = start + name.length;
if (cookiestring.substring(start, end) == name) {
cookiefounded = true;
break;
}
i++;
}
if (cookiefounded) {
start = end + 1;
end = cookiestring.indexOf(";", start);
if (end < start) {
end = cookiestring.length;
}
var getvalue = cookiestring.substring(start, end);
return unescape(getvalue);
}
return "";
}

// CTRL+ENTER 快速提交UBBFORM表单
function ctlent(obj) {
if( (event.ctrlKey && window.event.keyCode == 13) || (event.altKey && window.event.keyCode == 83)) {
this.document.submit();
}
}

// RunCode 运行文本框中的HTML代码
function runcode(code)  {
cod=document.all(code)
var code=cod.value;
if (code!=""){
var newwin=window.open('','','');  
newwin.opener = null
newwin.document.write(code); 
newwin.document.close();
}
}

// 跳转菜单
function JumpMenu(targ,selObj,restore){
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

// 显示开关
function SwitchDiv(objID)
{
if (document.getElementById(objID).style.display == "none") {
document.getElementById(objID).style.display = "inline-block";
}else{
document.getElementById(objID).style.display = "none";
}
}

// 打开菜单
function showlayer(objID)
{document.getElementById(objID).style.display = "block";}

// 关闭菜单
function hidelayer(objID)
{document.getElementById(objID).style.display = "none";}

// 弹出模式窗口
function popwin(PopUrl,PopW,PopH){
var returnValue=showModalDialog(PopUrl+"&Rand="+Math.random(), window, "dialogWidth:"+PopW+"px; dialogHeight:"+PopH+"px; resizable:no; help:no; status:no; scroll:yes;");
	// 判断返回参数 刷新页面 或 跳转链接
	if (returnValue=="RefreshThisPage"){
	  window.location.reload();
	  }	else if(returnValue != null) {
		  window.location.href=returnValue;
		  }
}

function OpenUrl(url) 
{       
    var a=document.createElement("a");   
    a.href=url;   
    document.body.appendChild(a);   
    a.click();
}


// 自动缩小图像
var flag=false; 
function resizeimage(ImgD){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width>640){ 
ImgD.width=640; 
ImgD.height=(image.height*640)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 			
}  
} 
} 
