var returnvalue=0;

function bind(object, fnc) {
	if (typeof(fnc)=="string") fnc=object[fnc];
	var args=[];
	for (var i=2; i<arguments.length; ++i) {
		args.push(arguments[i]);
	}
	return function() {
		var args2=[];
		for (var i=0; i<arguments.length; i++) {
			args2.push(arguments[i]);
		}
		return fnc.apply(object, args.concat(args2));
	}
}

function popWin(anchor, width, height) {
	if (typeof(width)=="undefined") width=640;
	if (typeof(height)=="undefined") height=480;
	var d=window.open(anchor.href, "puppy", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height);
	d.focus();
	return false;
}

function popwin(anchor, height, width) {
	if (typeof(height) == "undefined") {
		height = 346;
	}
	if (typeof(width) == "undefined") {
		width = 489;
	}
	var d = window.open(anchor.href, "puppy", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height);
	d.focus();
	return false;
}

function popwinscroll(anchor, height, width) {
	if (typeof(height) == "undefined") {
		height = 346;
	}
	if (typeof(width) == "undefined") {
		width = 489;
	}
	var d = window.open(anchor.href, "puppy", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height);
	d.focus();
	return false;
}

function inArray(a, value) {
	var i;
	for (i=0; i<a.length; i++) {
		if (a[i]===value) return true;
	}
	return false;
}

function getAjax(url, callback) {
	var httpRequest=false;
	if (window.XMLHttpRequest) {
		httpRequest=new XMLHttpRequest();
		if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/html');
	} else if (window.ActiveXObject) {
		try {
			httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!httpRequest) return false;
	httpRequest.onreadystatechange=function() {
		if (httpRequest.readyState==4) {
			if (httpRequest.status==200) eval(callback);
		}
	}
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}

function updateFromCookie(id, cookie, defaultvalue) {
	value=unescape(readCookie(cookie)).replace("+", " ");
	if (value=='') value=defaultvalue;
	document.getElementById(id).innerHTML=value;
}

function readCookie(cookie) {
	var cookieEQ=cookie+"=";
	var ca=document.cookie.split(';');
	for (var i=0; i<ca.length; i++) {
		var c=ca[i];
		while (c.charAt(0)==' ') c=c.substring(1, c.length);
		if (c.indexOf(cookieEQ)==0) return c.substring(cookieEQ.length, c.length);
	}
	return "";
}

function setCookie(cookie, value, days) {
	var today=new Date();
	var expire=new Date();
	if (days==null || days==0) days=1;
	expire.setTime(today.getTime() + 3600000*24*days);
	document.cookie=cookie+"="+escape(value)+";expires="+expire.toGMTString();
}

