// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function addToFavoriate(title, url)
{
  if (window.sidebar)
  {
    window.sidebar.addPanel(title, url, '');
  }
  else if (window.external)
  {
    window.external.AddFavorite(url, title);
  }
  else
  {
    alert('sorry, can not add to bookmark.');
  }
}

function copy(inElement)
{
  alert('已经成功复制以下内容到剪贴板，你可以通过Ctrl+V粘贴到QQ/MSN/论坛签名档：\n\n'+inElement.innerHTML);
  if (inElement.createTextRange)
  {
    var range = inElement.createTextRange();
    if(range)
    {
      range.execCommand('Copy');
    }
  }
  else
  {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier))
    {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="/flashs/clipboard.swf" flashvars="clipboard='+inElement.value+'" width="0" height="0" type="application/x-shockwave-flash"/>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}

function fullscreen()
{
  obj = $('videoObject');
  if (navigator.appName.indexOf("Microsoft") != -1)
  {     
    obj.width = document.documentElement.clientWidth + 'px'; 
    obj.height = (document.documentElement.clientHeight - 24) + 'px'; 
  }     
  else  
  {     
    obj.width = (document.documentElement.clientWidth - 20) + 'px'; 
    obj.height = (document.documentElement.clientHeight - 24) + 'px'; 
  }
}

var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};

function load_flash(url, width, height)
{
  document.write('<embed src="' + url + '" wmode="transparent" allowscriptaccess="always" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" />');
}
