/* cookie construct start */
function Cookie(document,name,hours,path,domain,secure) {
  // any VAR in "this" that does not start with a "$" will
  // be written into the cookie (read from also)
  this.$doc  = document
  this.$name = name
  if (hours)  this.$expiration=new Date((new Date()).getTime()+hours*3600000); else this.$expiration = null
  if (path)   this.$path   = path;                                             else this.$path       = null
  if (domain) this.$domain = domain;                                           else this.$domain     = null
  if (secure) this.$secure = true;                                             else this.$secure     = false
}

function CookieWrite() {
  var cookieval=""
  for(var prop in this) {
    if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function') || prop == '') continue
	if (cookieval != "") cookieval += '&'
	cookieval+=prop+":"+escape(this[prop])
  }
  var cookie=this.$name+"="+cookieval
  if (this.$expiration) cookie+='; expires=' + this.$expiration.toGMTString()
  if (this.$path)       cookie+='; path='    + this.$path
  if (this.$domain)     cookie+='; domain='  + this.$domain
  if (this.$secure)     cookie+='; secure'
  this.$doc.cookie=cookie
}

function CookieRead() {
  var allcookies=this.$doc.cookie
  if (allcookies=="") {
    return false
  }
  var start= allcookies.indexOf(this.$name+'=')
  if (start== -1) {
    return false
  }
  start += this.$name.length+1
  var end=allcookies.indexOf(';',start)
  if (end == -1) end=allcookies.length
  var cookieval = allcookies.substring(start,end)
  var a = cookieval.split('&')
  for (var i=0;i < a.length;i++) a[i]=a[i].split(':')
  for (var i=0;i < a.length;i++) this[a[i][0]]=unescape(a[i][1])
  return true
}

function CookieDelete() {
  var cookie = this.$name+'='
  if (this.$path)   cookie+='; path='+this.$path
  if (this.$domain) cookie+='; domain='+this.$domain
  cookie+='; expires=Fri, 02-Jan-1970 00:00:00 GMT'  // MAKE IT EXPIRE!
  this.$doc.cookie=cookie
}

new Cookie()
Cookie.prototype.write = CookieWrite
Cookie.prototype.del   = CookieDelete
Cookie.prototype.read  = CookieRead
/* cookie construct end */

function image_tip()
{
  var _obj=document.getElementById("tip");
  var myCookie=new Cookie(document,"image_tip_viewed",672);
  myCookie.read();
  var viewed=myCookie.viewed;
  if(viewed!=parseInt(viewed))viewed=0;
  var IMAGE_TIP=(!viewed)?1:0;
  if (IMAGE_TIP) {
    _obj.innerHTML="<div id='helpbox' style='display:none;' onclick='Effect.BlindUp(this, { duration: 0.5 });'><div id='helpicon'><img src='templates/lightwhite.v3/img/lightbulb_48.png'></div><div id='helptext'>Hold your cursor over an image to see a description. Click on the image to enter slideshow mode where clicking the left & right sides of the photo will take you to the previous or next image. Please see the <a href='index.php?x=about'>about</a> page for further help.</div><div id='X'><img src='templates/lightwhite.v3/img/close_20.gif' title='Click to close this tip.' alt='Click to close this tip.'></div></div>";
    Effect.BlindDown('helpbox');
    myCookie.viewed=IMAGE_TIP;
    myCookie.write();
  }
}

function browse_tip()
{
  var _obj=document.getElementById("tip");
  var myCookie=new Cookie(document,"browse_tip_viewed",672);
  myCookie.read();
  var viewed=myCookie.viewed;
  if(viewed!=parseInt(viewed))viewed=0;
  var BROWSE_TIP=(!viewed)?1:0;
  if (BROWSE_TIP) {
    _obj.innerHTML="<div id='helpbox' style='display:none;' onclick='Effect.BlindUp(this, { duration: 0.5 });'><div id='helpicon'><img src='templates/lightwhite.v3/img/lightbulb_48.png'></div><div id='helptext'>On this page you can select the type of image you would like to see. When a collection is selected you will then be browsing images only from that collection until you return to this page and change the selection.</div><div id='X'><img src='templates/lightwhite.v3/img/close_20.gif' title='Click to close this tip.' alt='Click to close this tip.'></div></div>";
    Effect.BlindDown('helpbox');
    myCookie.viewed=BROWSE_TIP;
    myCookie.write();
  }
}

function about_tip()
{
  var _obj=document.getElementById("tip");
  var myCookie=new Cookie(document,"about_tip_viewed",672);
  myCookie.read();
  var viewed=myCookie.viewed;
  if(viewed!=parseInt(viewed))viewed=0;
  var ABOUT_TIP=(!viewed)?1:0;
  if (ABOUT_TIP) {
    _obj.innerHTML="<div id='helpbox' style='display:none;' onclick='Effect.BlindUp(this, { duration: 0.5 });'><div id='helpicon'><img src='templates/lightwhite.v3/img/lightbulb_48.png'></div><div id='helptext'>Tip:<br/>Press F11 to make your browser full screen while using this site.<br/>Press F11 again to return to normal.</div><div id='X'><img src='templates/lightwhite.v3/img/close_20.gif' title='Click to close this tip.' alt='Click to close this tip.'></div></div>";
    Effect.BlindDown('helpbox');
    myCookie.viewed=ABOUT_TIP;
    myCookie.write();
  }
}

function links_tip()
{
  var _obj=document.getElementById("tip");
  var myCookie=new Cookie(document,"links_tip_viewed",672);
  myCookie.read();
  var viewed=myCookie.viewed;
  if(viewed!=parseInt(viewed)) viewed=0;
  var LINKS_TIP=(!viewed)?1:0;
  if (LINKS_TIP) {
    _obj.innerHTML="<div id='helpbox' style='display:none;' onclick='Effect.BlindUp(this, { duration: 0.5 });'><div id='helpicon'><a href='./index.php?x=rss'><img src='templates/lightwhite.v3/img/rss_48.png'></a></div><div id='helptext' style='margin-top:11px;'><a href='./index.php?x=rss'>Click here to subscribe to the Photoworx RSS feed</a>.<br/>Alteratively use <a href='http://www.addthis.com/feed.php?pub=worx&h1=http%3A%2F%2Fwww.worx.org.uk%2Fbeta%2Findex.php%3Fx%3Drss&t1=' title='Subscribe using any feed reader!' target='_blank'><img src='http://s7.addthis.com/static/btn/sm-plus.gif' width='13' height='13' border='0' alt='' /> AddThis</a> to subscribe using a web-based feed reader.</div><div id='X'><img src='templates/lightwhite.v3/img/close_20.gif' title='Click to close this tip.' alt='Click to close this tip.'></div></div>";
    Effect.BlindDown('helpbox');
    myCookie.viewed=LINKS_TIP;
    myCookie.write();
  }
}
