function CheckBrowser() {
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5") >-1&&this.dom)?1:0;
	this.ie4=(document.all&&!this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver,10) >=5)?1:0;
	this.ns4=(document.layers&&!this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this;
}
var bw=new CheckBrowser();
var innerWidth;
var innerHeight;
function makeflagrefererObject() {
	if(!bw){
			bw=new CheckBrowser();
	}
	this.x=0;
	this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth;
	this.y=0;
	this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight;
	this.x50=this.x2/2;
	this.y50=this.y2/2;
	this.x10=(this.x2*10)/100;
	this.y10=(this.y2*10)/100;
	this.x15=(this.x2*15)/100;
	this.y15=(this.y2*15)/100;
	return this;
}
function MM_reloadflagreferer(init){
	if(init===true){
		with(navigator){
			if((appName=="Netscape")&&(parseInt(appVersion,10)==4)){
				document.MM_pgW=innerWidth;
				document.MM_pgH=innerHeight;
				onresize=MM_reloadflagreferer
			}
		}
	} else {
		if(innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH){
			location.reload();
		}
	}
}
var rp = new MM_reloadflagreferer(true);
function window_open(flagreferer_name,width,height){
	var w=window.open(flagreferer_name,"flagreferer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",left=50,top=50");
}
function oww(n,w,h,u){
	var sh=(bw.ie4 || bw.ie5)?screen.height:window.innerHeight;
	var sw=(bw.ie4 || bw.ie5)?screen.width:window.innerWidth;
	var x=(bw.ie4 || bw.ie5)?0:window.screenX;
	x+=((sw/2)-(w/2));
	var y=(bw.ie4 || bw.ie5)?0:window.screenY;
	y+=((sh/2)-(h/2));
	if(!x&&!y){
		x=150;
		y=150;
	}
	w=window.open(u,n,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+",screenX="+x+",screenY="+y+",left="+x+",top="+y);
	w.focus();
}
function flagreferer_findObj(n,d){
	var p,i,x;
	if(!d){
		d=document;
	}
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all){
		x=d.all[n];
	}
	for(i=0; !x&&i<d.forms.length; i++){
		x=d.forms[i][n];
	}
	for(i=0; !x&&d.layers&&i<d.layers.length; i++){
		x = flagreferer_findObj(n,d.layers[i].document);
	}
	return x;
}
function target_parent(URL){
	var pw;
	if(window.opener != null){
		pw=window.opener.top;
		pw.location=URL;
		window.close();
		if(window.opener.opener != null){
			pw=window.opener.opener.top;
			pw.location=URL;
			window.opener.close();
			window.close();
		} else {
			pw=window.top;
			pw.location=URL;	
		}
	} else {
		pw=window.top;
		pw.location=URL;		
	}
}
function add_to_mailing_list() {
	var email_address;
	var from_where;
	if(document.mailform){
		email_address=document.mailform.email.value;
		if(document.mailform.from_where){
			from_where=document.mailform.from_where.value;
		}
	}
	if(window.mailform){
		email_address=window.mailform.email.value;
		if(window.mailform.from_where){
			from_where=window.mailform.from_where.value;
		}
	}
	var this_window="/scripts/php/add_to_mailing_list.php?email_address="+email_address+"&from_where="+from_where;
	var myWin=open(this_window,"test","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=300,height=200,left=150,top=150");
}
function openwin(withURL,w,h,noscrollbars){var scrollbars;
	if(noscrollbars=="TRUE"){
		scrollbars="no";
	} else{
		scrollbars="yes";
	}
	var myWin=open(withURL,"newwindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrollbars+",resizable=yes,width="+w+",height="+h+",left=150,top=150");
}
function wn(withURL){
	oww("chooseGalleryWindow",500,250,withURL);
}
function zm(qs){
	oww('zoomWindow', 780, 580, '/scripts/zoom/zoom.pl?'+qs);
}

function redirect(newdb){
	if(!window.location || !newdb){
		return false;
	}
	// frompage and flagreferer are hard-coded into the calling html page as global variables
	var tmp = '/scripts/404_handlers/flags_redirect.php?newdb='+newdb+'_easyart&frompage='+frompage+'&flagreferer='+escape(flagreferer);
	window.location = tmp;
}

