﻿function chkLogin()
{
  //document.write(GetCookie("MemID"));
  if (GetCookie("MemID") == null) {  
        // 未登入導向登入頁
        location.href="/login.aspx?page="+location.href;
  }  
}
function ShowLoginHelloWord()
{
    //document.write("good");
    //if(document.cookie.indexOf('UserName=')>0){
  if (GetCookie("MemID") != null) {  
    if (GetCookie("UserName") != null) {
        if (location.href.indexOf('/explorers/explore/')>=0)
        {
            hellomsg = '<FONT class="word_10" color="#d7cec5">親愛的 <FONT color="#ffffff">' + unescape(GetCookie("UserName")) + '</FONT> 您好，歡迎光臨格蘭菲迪官方網站</FONT> <a href="/logout.aspx?page=/index.htm"><FONT class="word_10" color="#d7cec5"><b>登出<b></FONT></a>' ;
        }
        else
        {
            hellomsg = '<FONT class="word_10" color="#d7cec5">親愛的 <FONT color="#ffffff">' + unescape(GetCookie("UserName")) + '</FONT> 您好，歡迎光臨格蘭菲迪官方網站</FONT> <a href="/logout.aspx?page='+location.href+'"><FONT class="word_10" color="#d7cec5"><b>登出<b></FONT></a>' ;    
        }
		
		document.write(hellomsg);
	}
  }	
}

function ShowLoginPenal(){
  if (GetCookie("MemID") != null) { 
	if (GetCookie("UserName") != null){
		document.write('<a href="Platform.aspx"><img src="images/newmenu_litterbu02.jpg" width="74" height="20" border="0" /></a>');
	}else{
		document.write('<a href="login.aspx"><img src="images/menu_s_01.jpg" width="74" height="20" border="0" /></a>');
	}
  }	
}

function ShowMenu07(){
		document.write('<a href="/blog/main.htm" target="_top"><img src="images/menu_07.jpg" width="112" height="36" border="0" /></a>');
}

	function delItem(){
		objListItems = document.getElementsByName("listItem");
		if( objListItems.length != 0 ){
			flag = false;
			for( i = 0 ; i < objListItems.length ; i++ ){
				if(objListItems[i].checked){
					flag = true;
					break;
				}
			}
			if( flag ){
				if( confirm("確定要刪除勾選的資料？") ){
					webForm.editMethod.value = "delete";
					webForm.submit();
				}
			}else{
				alert( "請勾選要刪除的項目！" );
			}
		}
	}
	function chgActive( para ){
		webForm.editMethod.value = "chgActive";
		webForm.para.value = para;
		webForm.submit();
	}
	function chgVisible( para ){
		webForm.editMethod.value = "chgVisible";
		webForm.para.value = para;
		webForm.submit();
	}
	function chgOrder( para, ord ){
		webForm.editMethod.value = "chgOrder";
		webForm.para.value = para;
		webForm.ord.value = ord;
		webForm.submit();
	}
	FillText = null;
	function UploadFile( objText, upFolder, maxSize, upType ){
		FillText = objText;
		OpenCenterWin( "include/upload.aspx?upFolder="+upFolder+"&maxSize="+maxSize+"&upType="+upType, 350, 200, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
	}
	function UploadFileActMember( objText, upFolder, maxSize, upType ){
		FillText = objText;
		OpenCenterWin( "../include/uploadactmember.aspx?upFolder="+upFolder+"&maxSize="+maxSize+"&upType="+upType, 350, 200, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
	}
	function PickDate( objText ){
		FillText = objText;
		OpenCenterWin( "../include/datepicker.aspx?evtDate="+objText.value, 240, 280, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
	}
	function OpenCenterWin( TargetURL, OpenWidth, OpenHeight, Features ){
		LeftPos = ( screen.availWidth - OpenWidth ) / 2;
		TopPos = ( screen.availHeight - OpenHeight ) / 2;
		if( Features != "" ) Features += ",";
		Features += "width=" + OpenWidth + ",height=" + OpenHeight + ",left=" + LeftPos + ",top=" + TopPos;
		window.open( TargetURL, null, Features );
	}
	


// for cookie use	
function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) 
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break; 
}
return null;
}
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function setLastlastVisitCookie ()
{
var rightNow = new Date();
var expdate = new Date();
expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
SetCookie ("lastVisit", rightNow.getTime(), expdate, "/");
}
function ResetCookie()
{
SetCookie("lastVisit", 0, null, "/");
}

function DeleteCookie( name, path, domain ) {
if ( GetCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
	
	
