﻿var imgwidth=700;
function $(id){return document.getElementById(id);}
function show(o){document.getElementById(o).style.display="block";}
function hide(o){document.getElementById(o).style.display="none";}
function geturl(url,id){
var http=false;
$(id).innerHTML='<span class="loading">&nbsp;&nbsp;</span>';
if(window.XMLHttpRequest){http=new XMLHttpRequest();if(http.overrideMimeType){http.overrideMimeType('text/plain');}}else if(window.ActiveXObject){try{http=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http){alert('Cannot send an XMLHTTP request');return false;}
http.onreadystatechange=function(){if(http.readyState==4){$(id).innerHTML=http.responseText;}}
http.open("get", url, true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.send(null);
}
function imgsize(){
	var img=document.getElementById("content").getElementsByTagName("img");
	for(var i=0; i<img.length;i++){
		if(img[i].width>imgwidth){img[i].width=imgwidth;img[i].style.width=imgwidth;img[i].title="View";img[i].style.cursor="pointer";img[i].border=0;img[i].onclick=function(e){window.open(this.src);}}
	}
}

function clearInput(obj,objValue){
	if(obj.value==objValue){
		obj.value="";
	}
		obj.style.color="#000";
}
function initInput(obj,objValue){
	if(obj.value==""){
		obj.value=objValue;
	}
		obj.style.color="#999";
}

// --- 设置cookie
function setCookie(sName,sValue,expireHours) {
	var cookieString = sName + "=" + escape(sValue);
	//;判断是否设置过期时间
	if (expireHours>0) {
		 var date = new Date();
		 date.setTime(date.getTime + expireHours * 3600 * 1000);
		 cookieString = cookieString + "; expire=" + date.toGMTString();
	}
	document.cookie = cookieString;
}
//--- 获取cookie
function getCookie(sName) {
  var aCookie = document.cookie.split("; ");
  for (var j=0; j < aCookie.length; j++){
	var aCrumb = aCookie[j].split("=");
	if (escape(sName) == aCrumb[0])
	  return unescape(aCrumb[1]);
  }
  return null;
}


function SetCookie(_Name, _Value, _Time)
{
	var Now = new Date();
	var Exp = new Date(Now.valueOf()+_Time*1000);
	document.cookie = _Name+'='+escape(_Value)+'; path=/; expires='+Exp.toGMTString()+';';
}

function GetCookie(_Name)
{
	var Res = eval('/'+_Name+'=([^;]+)/').exec(document.cookie);
	return Res == null ? false : unescape(Res[1]);
}


function recordMrg(obj)
{
    var _name=obj.parentElement.parentElement.id;
    setCookie(_name,obj.id,2);
}

window.onload = function() {
    var aCookie = document.cookie.split("; ");
    if (aCookie == null) {return;}
    for (var j = 0; j < aCookie.length; j++) {
        var aCrumb = aCookie[j].split("="); 
        if (document.getElementById(aCrumb[0]) == null) { return; }
        var liobj = document.getElementById(aCrumb[0]).getElementsByTagName("li");
        for (var i = 0; i < liobj.length; i++) {
            if (liobj[i].id == aCrumb[1]) {
                liobj[i].className = "on";
            } else {
                liobj[i].className = "";
            }
        }
    }
}