//複製連結
function $(id) {
	return document.getElementById(id);
}
function copy(text){
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
if(is_ie) {
clipboardData.setData('Text', text);
alert('複製成功，在你需要位置上，按鍵盤上 Ctrl + V 就可貼上。');
} else if(prompt('請按鍵盤上 Ctrl+C 複製到剪貼簿上', text)) {
alert('複製成功，在你需要位置上，按鍵盤上 Ctrl + V 就可貼上。');
}
}

function screentable(prefix, setstyle) {
	prefix = prefix == '' ? 'screentable' : prefix;
	setstyle = setstyle == '' ? "1px solid #F00" : setstyle;		
	$(prefix+screen.width+"x"+screen.height).style.border=setstyle;
		
	return $(prefix+screen.width+"x"+screen.height);
}




 // 存放被開啟視窗的參照
 function openWindow(url, id, w,h,center) {
 
 args = 'width='+w+', height='+h;
 
 if(center){
 
 	args += ", left="+(window.screen.width-w)/2+",top="+(window.screen.height-h)/2;
 
 }	
   
  var win = window.open(url,id, args);
  win.focus();
 }


 // 存放被開啟視窗的參照
 function openPhotoWindow(url, id, w,h,center) {
 
  var win = window.open(url);
  win.focus();
 }





document.getCookie = function(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
      return decodeURIComponent(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

document.setCookie = function(sName, sValue, sExpires)
{
  var sCookie = sName + "=" + encodeURIComponent(sValue);
  if (sExpires != null)
  {
    sCookie += "; expires=" + sExpires;
  }

  document.cookie = sCookie;
}

document.removeCookie = function(sName,sValue)
{
  document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}