var win;
var win_detail;
var newWin;
var newWin;


function sumitEnter(e)
{
	var keyNum;
	
	if (window.event) { keyNum = window.event.keyCode; }  //IE 
	else if(e) { keyNum = e.which; } // Netscape/Firefox/Opera
	
	if (keyNum==13) return true;
	else return false;
}

function win_open(ul,w,h,bar)
{
	newWin = window.open(ul,'','width='+w+',height='+h+','+bar+'');
	newWin.focus();	
	return newWin;
}

function win_fixopen(ul,type)
{ 
	var w,h;
	var bar = 'scrollbars=yes'; 
	switch (type)  
	{
		case "sss":
			w = 2; h = 2; bar='scrollbars=no'; break;	
		case "chk":
			w = 180; h = 50; bar='scrollbars=no'; break;	
		case "speak":
			w = 350; h = 50; bar='scrollbars=no'; break;	
		case "online_msg":
			w = 400; h = 150; bar='scrollbars=no'; 
			win_open(ul,w,h,bar); return true;
		case "char":
			w = 500; h = 400; bar='scrollbars=no'; 
			win_open(ul,w,h,bar); return true;
		case "msg":
			w = 300; h = 280; bar='scrollbars=no'; break;
		case "list":
			w = 320; h = 460; bar='resizable=yes'; break;
		case "box":
			w = 550; h = 290; bar='scrollbars=no'; break;
		case "small_normal":
			w = 600; h = 350; break;
		case "scroll_normal":
			w = 700; h = 550; break;
		case "normal":
			w = 720; h = 540; bar='scrollbars=yes'; break;
		case "append":
			w = 520; h = 540; bar='scrollbars=yes'; break;
		case "online_member":
			w = 300; h = 460; bar='resizable=yes and scrollbars=yes'; break;
	}
	
	try {
		newWin.close();
	} catch (exception) { }
	
	return win_open(ul,w,h,bar);
}

function send_msg(mid,smid)
{
	if (smid != '') {
		if (mid!="0" && mid!="" && mid!=smid) {
			win_fixopen('/message/online_message?smid='+mid,'online_msg');
		} else alert('不能傳送給自已!');
	} else alert('請先登入!');
}

function chk_myLink(htm,mid) 
{
	if(mid=='') 
	{ 
		alert("ХnJ!");
		window.frmLogin.txtMemberID.focus();
	} 
	else 
	{ 
		if (htm.indexOf('message')!='-1') 
			win_fixopen(htm,'scroll_normal');
		else if (htm.indexOf('club')!='-1' || htm.indexOf('rss')!='-1')  
			win_fixopen(htm,'list');
		else if (htm.indexOf('heartvj.sys')!='-1') { 
			location.href=htm;
		} else location.href=htm+mid;
	}
}

function goMonthly(p)
{
  var pi = p.selectedIndex;
  var link = p.options[pi].value;

  if(link != -1)
  {
    document.location = link;
  }

}

function layer_toggle(obj) 
{
    if (obj.style.display == 'none') obj.style.display = 'block';
    else if (obj.style.display == 'block') obj.style.display = 'none';
}

function onclick_folder(hc, fd, url, check) {
    if (check == '0') {
        layer_toggle(hc);
    } else if (hc.style.display == 'none') {
        fd.src = url + 'minus.gif';
        layer_toggle(hc);
    } else {
        fd.src = url + 'plus.gif';
        layer_toggle(hc);
    }
}

function meetFriend(link, opt)
{
	var opt_index = opt.selectedIndex;
	var opt_value = opt.options[opt_index].value;

	if(opt_value) {
		var url = link + "?mid=" + opt_value;
alert(url);
//window.open(url, "_blank");
	}
}


function check_select_style(style , msg)
{
  if(style)
  {
    if(style.check)
      return true;

    for(i = 0; i < style.length; i++)
    {
      if(style[i].checked)
      {
        return true;
      }
    }
  }

  alert(msg);
  return false;
}

function nextSlide()
{
   if(PicsArray.length > 0)
   {
     if(++nowIndex >= PicsArray.length)
       nowIndex = 0;

     document.images.SlideShow.style.filter="blendTrans(duration=2)";
     if(document.all)
     {
       document.images.SlideShow.filters.blendTrans.duration = crossFadeDuration;
       document.images.SlideShow.filters.blendTrans.Apply();
     }

     document.images.SlideShow.src = PicsArray[nowIndex];
     if(document.all)
     {
       document.images.SlideShow.filters.blendTrans.Play();
     }
     document.getElementById("SlidePicTitle").value = PicsTitleArray[nowIndex];
     document.getElementById("SlidePicLink").href = PicsLinkArray[nowIndex];

     if(iIntervalId != undefined)
     {
       clearInterval(iIntervalId);
       iIntervalId = setInterval('nextSlide()', slideShowSpeed);
     }
   }
}

function prevSlide()
{
   if(PicsArray.length > 0)
   {
     if(--nowIndex < 0)
       nowIndex = PicsArray.length - 1;

     document.images.SlideShow.style.filter="blendTrans(duration=2)";
     document.images.SlideShow.filters.blendTrans.duration = crossFadeDuration;
     document.images.SlideShow.filters.blendTrans.Apply();

     document.images.SlideShow.src = PicsArray[nowIndex];
     document.images.SlideShow.filters.blendTrans.Play();
     document.getElementById("SlidePicTitle").value = PicsTitleArray[nowIndex];
     document.getElementById("SlidePicLink").href = PicsLinkArray[nowIndex];

     if(iIntervalId != undefined)
     {
       clearInterval(iIntervalId);
       iIntervalId = setInterval('nextSlide()', slideShowSpeed);
     }
   }
}

function SlideShowPlayPause(lang_SlidePlay, lang_SlidePause)
{
  if(PicsArray.length > 0)
  {
    if(iIntervalId != undefined)
    {
      clearInterval(iIntervalId);
      iIntervalId = undefined;
      document.getElementById("buttonPlayPause").value = lang_SlidePlay;
    }
    else 
    {
      SlideShowStart();
      document.getElementById("buttonPlayPause").value = lang_SlidePause;
    }
  }
}

function SlideShowStart()
{
  if(PicsArray.length > 0)
  {
    nextSlide();
    iIntervalId = setInterval('nextSlide()', slideShowSpeed);
  }
}

function check_input(msg)
{
  var form = document.form;
  if(form.text.value.length == 0)
  {
    alert(msg);
    return false;
  }
  return true;
}

function check_new_comment_input(msg, msg_over_length)
{
  var form = document.form;
  if(form.text.value.length == 0)
  {
    alert(msg);
    return false;
  }
  if(form.text.value.length > 1000)
  {
    alert(msg_over_length);
    return false;
  }
  return true;
}

function copy_to_clipborad(id) 
{
   var obj = document.getElementById(id);
   obj.select();
   if (window.clipboardData) 
   {
     window.clipboardData.setData("Text", obj.value);
   }
   else if (window.netscape) 
   { 
   
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
     if (!clip) return;
     var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
     if (!trans) return;
     trans.addDataFlavor('text/unicode');
     var str = new Object();
     var len = new Object();
     var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
     var copytext=meintext;
     str.data=copytext;
     trans.setTransferData("text/unicode",str,copytext.length*2);
     var clipid=Components.interfaces.nsIClipboard;
     if (!clip) return;
       clip.setData(trans,null,clipid.kGlobalClipboard);
   }
}


<!-- Ƨ}X -->
function layer_toggle(obj) {
    if (obj.style.display == 'none') obj.style.display = 'block';
    else if (obj.style.display == 'block') obj.style.display = 'none';
}

function onclick_folder(hc, fd, url, check) {
    if (check == '0') {
        layer_toggle(hc);
    } else if (hc.style.display == 'none') {
        fd.src = url + 'tab_opened.gif';
        layer_toggle(hc);
    } else {
        fd.src = url + 'tab_closed.gif';
        layer_toggle(hc);
    }
}<!-- end of Ƨ}X -->

<!-- ƻsr -->
function setCopy(txt){
	try{clipboardData.setData('Text',txt)}catch(e){}
}<!-- end of ƻsr -->

<!-- link_manage -->
var msg = '!|Obȧa..';
var url = "http://heartvj.chihlee.edu.tw/manage";

function initArray() {
	this.length = initArray.arguments.length;
	for (var i = 0; i < this.length; i++) {
		this[i] = initArray.arguments[i];
	}
}

var password = new initArray(
109,97,110,97,103,101,97
);

var pass_count=0;

var cancel_key=27;
if (document.layers)	document.captureEvents(Event.KEYPRESS)
function backhome(e){
	if (document.layers){
	//if (navigator.appName == "Netscape"){
		if (e.which==password[pass_count]) {
			checkpassword();
			//return false;
		}
		else {
			pass_count=0;
			//return false;
		}
	}
	else if (document.all){
		if (event.keyCode==password[pass_count]){
			checkpassword();
			//return false;
		}
		else {
			pass_count=0;
			//return false;
		}
	}
}

document.onkeypress=backhome

function checkpassword() {
	pass_count++;
	if(pass_count>=password.length)	{
		if(confirm(msg)) window.location=url;
	}
}
function pic(dispFile)
{
 picwin = window.open(dispFile,"Photo","scrollbars=yes,fullscreen=yes");
 picwin.focus();
}

function showReplycontent(replyid, reply_replyid)
{
 if($("reply_replycontent_"+replyid).style.display == 'none')
 { 
 
   $("reply_replycontent_"+replyid).style.display == '';
   $("reply_replycontent_"+replyid).innerHTML = $('reply_'+reply_replyid).innerHTML;
   
 }
 else
 {
	$("reply_replycontent_"+replyid).style.display == 'none';
	$('reply_replycontent_'+replyid).innerHTML = '';
 }
}
function blind(id)
{
 if($(id).value == '1')
 { 
   $(id).value = '0';
   Effect.BlindUp(id);

 }
 else
 {   
   $(id).value = '1';
   Effect.BlindDown(id);

 }
}
	function div_win(win_title,win_url,win_width,win_height)
	{
		win = new Window({width:win_width, height:win_height, title: win_title, url:win_url,onClose :function(event){ Windows.closeAll(); }});
		win.show(true);
	}
	function div_showCenter(win_title,win_url,win_width,win_height)
	{
		win = new Window({width:win_width, height:win_height, title: win_title, url:win_url,onClose :function(event){ location.reload(); }});
		
		win.showCenter(true);
		//win.show(true);
	}	
	function div_win_detail(win_title,win_url,win_width,win_height,win_left,move)
	{
	  if(!win_detail)
	  {
	 	win_detail = new Window({width:win_width, height:win_height, title: win_title, 
								url:win_url,left:win_left,draggable:move,
								onClose :function(event){ win_detail = null; }});
		win_detail.toFront();
		win_detail.show();
	  }
	}	

function ajax_showWindow(t, u, w, h, top, left)
{
	win = new Window({title: t, url:u, width:w, height:h, top:top, left:left }
	);	
	win.toFront();
	win.show();
	return win;	
}

function ajax_showCenter(t, u, w, h, bBack)
{
	win_center = new Window({width:w, height:h, title: t, url:u });	
	win_center.showCenter(bBack);
	return win_center;
}

<!-- end of link_manage -->


function trim(s)
{
	return s.replace(/(^\s+)|(\s+$)/g, "")
}