/******************************
 Goto the URL link.
******************************/
function myGotoURL(strURL)
{
    location.replace(strURL);
    return;
}

/******************************
 Confirm to the URL link.
******************************/
function myConfirmURL(strMsg, strURL)
{
    flag = confirm(strMsg);
    if(flag == true) {
        location.replace(strURL);
    }
    return;
}

/******************************
 Window Open.
******************************/
function windows_open(thisurl,thisframe,thiswidth,thisheight,thisfeture){
    var screen_width  = window.screen.width;
    var screen_height = window.screen.height
    var win_left;
    var win_top;

    win_left = (screen_width - thiswidth)/2;
    win_top  = (screen_height - thisheight)/2 - 30;

    window.open(thisurl, thisframe, "toolbar=no,width="+thiswidth+",height="+thisheight+",top="+win_top+",left="+win_left+" "+thisfeture);
}


/******************************
 Pop Window link.
******************************/
function PopWin(File,WinWidth,WinHeight,scroll){
    NwWin=window.open(File,"","scrollbars="+scroll+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable="+scroll+",width=1,height=1");
    NwWin.moveTo((window.screen.availWidth-WinWidth)/2,(window.screen.availHeight-WinHeight)/2); 
    NwWin.resizeTo(WinWidth,WinHeight); 
}

function windows_open(thisurl,thisframe,thiswidth,thisheight,thisfeture){
var screen_width  = window.screen.width;
var screen_height = window.screen.height
var win_left;
var win_top;

  win_left = (screen_width - thiswidth)/2;
  win_top  = (screen_height - thisheight)/2 - 30;

  window.open(thisurl, thisframe, "toolbar=no,width="+thiswidth+",height="+thisheight+",top="+win_top+",left="+win_left+" "+thisfeture);
}

/******************************
 Get radio value
*******************************/
function myGetRadioValue(theForm, theName) {
    var thisRadio = eval(theForm +'.'+ theName);
    if (thisRadio.value != undefined) {
        //若只有一個選項.  
        if (thisRadio.checked) {
          return thisRadio.value;
        }
    }else{
        //若有兩個以上的選項.      
        for (var i=0; i < thisRadio.length; i++) {   
            if (thisRadio[i].checked) {
                return thisRadio[i].value;
                break;
            }
        }
    }
}

/******************************
 Cookies functions.
*******************************/
function addCookie(name,value,expireHours){
      var cookieString=name+"="+escape(value);
      if(expireHours>0){
             var date=new Date();
             date.setTime(date.getTime+expireHours*3600*1000);
             cookieString=cookieString+"; expire="+date.toGMTString();
      }
      document.cookie=cookieString;
}

function getCookie(name){
      var strCookie=document.cookie;
      var arrCookie=strCookie.split("; ");
      for(var i=0;i<arrCookie.length;i++){
            var arr=arrCookie[i].split("=");
            if(arr[0]==name)return arr[1];
      }
      return "";
}

function deleteCookie(name){
       var date=new Date();
       date.setTime(date.getTime()-10000);
       document.cookie=name+"=v; expire="+date.toGMTString();
}


/******************************
 Get radio value
*******************************/
function mySendMe() {
    var thisForm = eval('document.SendMeForm');
    if(confirm('您確定要寄出嗎？')) {
        thisForm.action='/SendMe.php';
        thisForm.submit();
    }
    return true;
}
