
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// bomb test
var sPop = null;
var postSubmited = false;
document.write("<style type='text/css'id='defaultPopStyle'> .cPopText { font-family: Tahoma, Verdana; background-color: #FFFFFF; border: 1px #000000 solid; font-size: 12px; padding-right: 20px; padding-left: 20px; height: 20px; padding-top: 20px; padding-bottom: 20px; visibility: hidden; filter: Alpha(Opacity=255)}</style><div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");

function showPopupText() {
	var o=event.srcElement;
	MouseX=event.x;
	MouseY=event.y;
	if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
        if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
	if(o.pop!=sPop) {
		sPop=o.pop;
		if(sPop==null || sPop=="") {
			popLayer.style.visibility="hidden";	
		} else {
			if(o.dyclass!=null) popStyle=o.dyclass 
			else popStyle="cPopText";
			popLayer.style.visibility="visible";
           	popLayer.className=popStyle;
        	popLayer.innerHTML=sPop.replace(/<(.*)>/g,"&lt;&gt;").replace(/\n/g,"<br>");;
			popWidth=popLayer.clientWidth;
			popHeight=popLayer.clientHeight;
			if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
				else popLeftAdjust=0;
			if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
				else popTopAdjust=0;
			popLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
			popLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
		}
	}
}

// DELFILE YES/NO
function j_mode_linkyn(b_text,l_text,yn_sum){
 n=false;
 for(i=0;i!=yn_sum;i++)
 {
  if(confirm(b_text)==false)
  {
	n=true;
	break;  
  }
 }
 if(n==false)
 {
	 location=l_text;
 }
}

//觸發事件底圖跟換程式
function act_bgcolor(st,scolor) {
st.style.backgroundColor = scolor
}

//網頁轉向副程式
function redirect(URLStr) { location = URLStr }


document.onmouseover=showPopupText;

