// okman.cn JavaScript Document
//屏蔽js错误 
function ResumeError() { 
return true; 
} 
window.onerror = ResumeError; 

//Flash时钟
function flashclock()
{document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0\" width=\"77\" height=\"77\">");
document.writeln("        <param name=\"movie\" value=\"\/images\/clock.swf\" \/>");
document.writeln("		<param name=\"wmode\" value=\"transparent\">");
document.writeln("        <param name=\"quality\" value=\"high\" \/>");
document.writeln("        <embed src=\"\/images\/clock.swf\" quality=\"high\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" type=\"application\/x-shockwave-flash\" width=\"77\" height=\"77\"><\/embed>");
document.writeln("      <\/object>")
	}

//天气
function weather()
{document.writeln("<iframe src=\"http:\/\/www.tianqi123.com\/small_page\/chengshi_1.html?c0=red&c1=yellow&bg=101113&w=188&h=20&text=yes\" width=190 height=21 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no align=center id=url><\/iframe>")
}

//QQ
function myqq()
{document.writeln("<a href=\"http:\/\/wpa.qq.com\/msgrd?v=1&uin=16456787&site=www.okman.cn&menu=yes\"target=\"_blank\" title=\"通过QQ联系我\" ><img border=\"0\" height=\"16\" src=\"http:\/\/wpa.qq.com\/pa?p=1:16456787:4\" alt=\"QQ\">16456787<\/a>")}

//音乐播放器
//use allowtransparency ,it is not xhtml1.0 standard!
function myplayer()
{document.writeln("<iframe name=\"content\" frameborder=\"0\" width=\"1001\" height=\"45\" src=\"player\/exobud.htm\" scrolling=\"no\" allowtransparency=\"true\"><\/iframe>")}

//首页图片展示 flash photo 523x232
//修改okgg目录下的523x232.xml文件内容即可
function myphoto()
{
document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,29,0\" width=\"523\" height=\"232\">");
document.writeln("	<param name=\"movie\" value=\"\/okgg\/bcastr3.swf\">");
document.writeln("	<param name=\"quality\" value=\"high\">");
document.writeln("	<param name=\"wmode\" value=\"transparent\">");
document.writeln("	<param name=\"FlashVars\" value=\"bcastr_xml_url=\/okgg\/idx_523x232.xml&IsShowBtn=1\">");
document.writeln("	<embed src=\"\/okgg\/bcastr3.swf\" FlashVars=\"bcastr_xml_url=\/okgg\/idx_523x232.xml&IsShowBtn=1\" quality=\"high\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" type=\"application\/x-shockwave-flash\" width=\"523\" height=\"232\"><\/embed>");
document.writeln("<\/object>")
}

//符合W3C的滚动JS --------------------------------------
//用法：
//<div class="ccMarquee">
// <a href="/" title="">这里是滚动的</a>
//</div>
function getElementsByClass(searchClass,tagName) {
 var classElements = new Array();
 if ( tagName == null )
  tagName = '*';
 var els = document.getElementsByTagName(tagName);
 var elsLen = els.length;
 var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
 for (i = 0, j = 0; i < elsLen; i++) {
  if ( pattern.test(els[i].className) ) {
   classElements[j] = els[i];
   j++;
  }
 }
 return classElements;
}
 
function ccMarquee(className){
 var a=getElementsByClass(className);
 for (i = 0; i < a.length; i++) {
  a[i].innerHTML="<marquee>"+ a[i].innerHTML+"</marquee>";
 }
}window.onload = function () {
 ccMarquee("ccMarquee");
}
//----------------------END ----------------------------

//表单全选与取消的函数
//用法：每个select 命名
//		每个选项加上 onclick="Item(this, 'mmAll')" 
//      全选，修改后边的item <input type=checkbox name=mmAll onclick="All(this, 'p_id')">
function All(e, itemName)
{
  var aa = document.getElementsByName(itemName);
  for (var i=0; i<aa.length; i++)
   aa[i].checked = e.checked; //得到那个总控的复选框的选中状态
}
function Item(e, allName)
{
  var all = document.getElementsByName(allName)[0];
  if(!e.checked) all.checked = false;
  else
  {
    var aa = document.getElementsByName(e.name);
    for (var i=0; i<aa.length; i++)
     if(!aa[i].checked) return;
    all.checked = true;
  }
}
//----------------------------------------------------------------

// 复制文本框内容，使用办法:
// <a href="javascript:copyIt('textarea')" onmouseover="window.status='';return true;">复制</a>
//<![CDATA[
	function copyIt(id) {
		var o = document.getElementById(id);
		if (document.all) {
			o.select();
			window.clipboardData.clearData();
			window.clipboardData.setData("text",o.value);
			alert('已经复制到剪贴板, 您可以直接利用CTRL+V帖到需要的地方去');
		} else {
			alert('请利用ctrl+c 手动拷贝');
			o.select();
		}
	}
//]]>
//----------------------------------------------------------------

//跳转列表菜单
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//缩小图片
//用法：<img src="1.jpg" onLoad="ImgSize(this,300)">
function ImgSize(id,w)
{
if(id.width>w)
{
id.width=w;
}
}
//单个图片,由图片唯一ID区分
//w3c 不能通过img的onload属性，因此在此文件执行函数检测图片唯一ID进行缩小
//width>300 website....
function loadImgs300()
{
var imgs = document.getElementById("img300");
  var max_width = 300;
  var w = imgs.width;
  var h = imgs.height;
  if (w > max_width)
  {
    imgs.width = max_width;
    imgs.height = h*max_width/w;
  }
}
//width>470 ,blog...
function loadImgs470()
{
var imgs = document.getElementById("img470");
  var max_width = 470;
  var w = imgs.width;
  var h = imgs.height;
  if (w > max_width)
  {
    imgs.width = max_width;
    imgs.height = h*max_width/w;
  }
}
//当前页所有该尺寸图片
function loadImgsall()
{
  var imgs = document.images;
  var max_width = 500;
  for (var i=0; i<imgs.length; i++)
  {
    var w = imgs[i].width;
    var h = imgs[i].height;
    if (w > max_width)
    {
      imgs[i].width = max_width;
      imgs[i].height = h*max_width/w;
    }
  }
}
//进行检查
window.onload = loadImgs300;
window.onload = loadImgs470;
//----------------------- email login form -------------------------
function gook() {

	if (f1.usernameshow.value == "")
	{
		alert("用户名不可为空");
		f1.usernameshow.focus();
		return ;
	}
	if (f1.pwshow.value == "")
	{
		alert("密码不可为空");
		f1.pwshow.focus();
		return ;
	}

//	f1.saveUser.value = showsaveUser.checked;
	f1.username.value = f1.usernameshow.value;

	f1.SecEx.value = f1.showSecEx.checked;
	f1.pwhidden.value = encode(f1.pwshow.value, parseInt(f1.picnum.value));

	f1.submit();
}
//加密字符串
function encode(datastr, bassnum) {
	var tempstr;
	var tchar;
	var newdata = "";

	for (var i = 0; i < datastr.length; i++)
	{
		tchar = 65535 + bassnum - datastr.charCodeAt(i);
		tchar = tchar.toString();

		while(tchar.length < 5)
		{
			tchar = "0" + tchar;
		}
		newdata = newdata + tchar;
	}
	return newdata;
}
//-->