function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url, ""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}
function makeArray() {
	for (i = 0; i < makeArray.arguments.length; i++)
		this[i+1] = makeArray.arguments[i];
}
function makeDate()
{
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var months = new makeArray('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var m = date.getMonth() + 1;
var month = months[m];
var yy = date.getYear();
var y = (yy > 2000) ? yy - 2000 : yy;
if (y < 10)
 	year = '0' + y;
else
	year = y;
var h = date.getHours();
if (h > 12)
	h = h - 12;
var hh = (h < 10) ? '0' + h : h;
var mi = date.getMinutes();
var mm = (mi < 10) ? '0' + mi : mi;
var s = date.getSeconds();
var ss = (s < 10) ? '0' + s : s;
var dt = month + "-" + day + "-" + year + " " + h + ":" + mm + ":" + ss;
return dt;
}
function fnSet(){
	oHomePage.setHomePage("http://www.myfavoritegames.com");
}

function Cookie(document, name, mins, path, domain, secure) {
this.$document = document;
this.$name = name;
if (mins)
 this.$exp = new Date((new Date()).getTime() + mins*60000);
else
 this.$exp = null;
if (path)
 this.$path = path;
else
 this.$path = null;
if (domain)
 this.$domain = domain;
else
 this.$domain = null;
if (secure)
 this.$secure = secure;
else
 this.$secure = false;
}

Cookie.prototype.store = function() {
var cookieval = "";
for (var prop in this) {
 if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function'))
  continue;
 if (cookieval != "")
  cookieval += '&';
 cookieval += prop + ':' + escape(this[prop]);
}
var cookie = this.$name + '=' + cookieval;
if (this.$exp)
 cookie += '; expire=' + this.$exp.toGMTString();
if (this.$path)
 cookie += '; path=' + this.$path;
if (this.$domain)
 cookie += '; domain=' + this.$domain;
if (this.$secure)
 cookie += '; secure';
this.$document.cookie = cookie;
}

Cookie.prototype.load = function() {
var allcookies = this.$document.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++) {
 var b = a[i].split(':');
 this[b[0]] = unescape(b[1]);
}
return true;
}

Cookie.prototype.remove = function() {
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';
this.$document.cookie = cookie;
}

function setParam(param, value) {
 var ck = new Cookie(document, "gallery", 259200);
 ck.load();
 var onth = ck.nth;
 ck[param] = value + "";
 ck.store();
 var url;
 if ((param == "sort") || (param == "nth")) {
  var ag = getArgs();
  url = "images.aspx";
  if (ag.f) {
   url += "?f=" + ag.f;
  } else if (ag.v) {
   url += "?v=" + ag.v;
  }
 } else
  url = window.location;
 window.location = url;
}
function getArgs() {
 var args = new Object();
 var query = location.search;
 if (query.length > 1) {
  query = query.substring(1);
  var pairs = query.split("&");
  for (var i = 0; i < pairs.length; i++) {
   var pos = pairs[i].indexOf('=');
   if (pos != -1) {
    var ky = pairs[i].substring(0, pos);
    var vl = pairs[i].substring(pos+1);
    args[ky] = unescape(vl);
   }
  }
 }
 return args;
}

var st1;
var st2;
var st3;
var st4;
var st5;
var setup = false;
var stwid = 16;
var cvt = 0;
var isIE = false;
var msg = new Array("", "Hate it", "Don't like it", "Just OK", "Like it", "Love it");
var voteProxy;

var vsav;
function RateOut(ev, overImg) {
if (!ev)
 ev = window.event;
if (vsav != null) {
 overImg.src = vsav;
 vsav = null;
}
cvt = 0;
window.status = "";
}
function RateMove(ev, overImg) {
var xpos = 0;
if (!ev)
 ev = window.event;
if (setup) {
 if (vsav == null)
  vsav = overImg.src;
 if (isIE)
  xpos = ev.offsetX;
 else {
  var Element = ev.target; 
  while (Element.offsetParent) { 
   xpos += Element.offsetLeft; 
   Element = Element.offsetParent; 
  }
  xpos = ev.pageX - xpos;
 }
 var snum = xpos / stwid;
 if (snum <= 1) { setImg(overImg, st1, 1); }
 else if (snum <= 2) { setImg(overImg, st2, 2); }
 else if (snum <= 3) { setImg(overImg, st3, 3); }
 else if (snum <= 4) { setImg(overImg, st4, 4); }
 else { setImg(overImg, st5, 5); }
 window.status = msg[cvt];
}
}
function setImg(overImg, url, nn) {
 if (overImg.src != url.src) {
  overImg.src = url.src;
  cvt = nn;
 }
}
function RateVote(overImg, entryid) {
 if (setup && (cvt != 0)) {
  vsav = null;
  voteProxy = new TwelveTitans.IVote();
  voteProxy.vote(entryid, cvt, OnSuccess, OnFailure, overImg);
 }
}
function OnSuccess(result, overImg) {
 var pnt = overImg.parentNode;
 var kids = pnt.childNodes;
 var vt = document.getElementById("votetotal");
 if (isIE) {
  kids[3].innerText = result.Votes;
  kids[6].innerText = result.Rank;
  if (vt != null)
   vt.innerText = result.VoteTotal;
 } else {
  kids[3].textContent = result.Votes;
  kids[6].textContent = result.Rank;
  if (vt != null)
   vt.textContent = result.VoteTotal;
 }
}
function OnFailure(result, overImg) {
 alert("Error voting: " + result);
}
function CutFolder(eid) {
 var adminProxy = new TwelveTitans.Admin();
 adminProxy.CutFolder(eid, OnCutSuccess, OnCutError, 'cutFol');
}
function OnCutSuccess(nc, el) {
 var fs = document.getElementById(el);
 if (fs != null) {
  fs.innerText = nc;
 }
}
function OnCutError(er) {
 alert("Error: " + er.get_message());
}
function clearCutBuffer() {
 var adminProxy = new TwelveTitans.Admin();
 adminProxy.ClearCutBuffer(OnClearSuccess, OnCutError);
}
function OnClearSuccess() {
 OnCutSuccess('0', 'cutFol');
 OnCutSuccess('0', 'cutEnt');
}
function Paste(eid) {
 var adminProxy = new TwelveTitans.Admin();
 adminProxy.Paste(eid, OnPasteSuccess, OnCutError);
}
function OnPasteSuccess(val) {
 if (val != 'ok')
  alert(val);
 else
  history.go(0);
}
function DeleteFolder(eid, nm) {
 if (confirm("Really delete " + nm + " and all images and subfolders it contains?")) {
  var adminProxy = new TwelveTitans.Admin();
  adminProxy.DeleteFolder(eid, OnPasteSuccess, OnCutError);
 }
}
function Scan(eid) {
 var adminProxy = new TwelveTitans.Admin();
 adminProxy.Scan(eid, OnScanSuccess, OnCutError);
}
function OnScanSuccess(val) {
 if (val != 'ok')
  alert(val);
 else
  alert("Scan successfully started");
}
