var overhelplayer = false;
var isHelp = false;
var overpopuplayer = false;
var popup_dropdown = false;
var isMenu = false;
var last_popupuser = 0;
var this_delayed_popup = 0;
var Texts = new Array();
var ThingsToRemember = new Array();

Path=location.pathname.split('/');
page=Path[Path.length-1];

document.onmousedown = function (e){
  if( isMenu == true ) {
    if( overpopuplayer == false && popup_dropdown == false ){
      isMenu = false ;
      document.getElementById('popuplayer').style.display = 'none' ;
      //new Effect.Fade('popuplayer', { queue: 'end' });
      return true ;
    }
  }
  if( isHelp == true ) {
    if( overhelplayer == false ){
      isHelp = false ;
      document.getElementById('helpbox').style.display = 'none' ;
      //new Effect.Fade('helpbox', { queue: 'end' });
      return true ;
    }
  }
  return true;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (oldonload && typeof window.onload != 'function') {
        window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func;
		}
	}
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: John G. Wang | http://www.csua.berkeley.edu/~jgwang/ */

var capsError = 'MERK:\n\nCaps Lock er slått på.\nPassordet kan bli feilstavet.';

//this will make the script run a function and pass it a parameter saying if Caps Lock is engaged
//function format NOT compatible with v1 - it will now be run even if Caps Lock is not enabled
function capsError( capsEngaged ) {
	if( capsEngaged ) {
		//do something to warn the user that caps lock is engaged
	} else {
		//remove any warnings that caps lock is engaged
	}
}
function capsDetect( e ) {
	if( !e ) { e = window.event; } if( !e ) { MWJ_say_Caps( false ); return; }
	//what (case sensitive in good browsers) key was pressed
	var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
	//was the shift key was pressed
	var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //bitWise AND
	//if upper case, check if shift is not pressed. if lower case, check if shift is pressed
	MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ) );
}
function MWJ_say_Caps( oC ) {
	if( typeof( capsError ) == 'string' ) 
    { 
	   if( oC ) 
       { 
	       alert( capsError );
           capsError = false;
       } 
    } else
    { 
        capsError( oC ); 
    }
}

function hide_pl(){
	overpopuplayer = false;
	popup_dropdown = false;
 	isMenu = false;
 	//new Effect.Fade('popuplayer');
	document.getElementById('popuplayer').style.display = 'none' ;
}

function get_help(obj,unique){
	context = obj.id;
	url = (unique)?'task=get_help&context='+context+'&page='+location.pathname:'task=get_help&context='+context;
	//url = 'task=get_help&context='+context+'&page='+location.pathname;
	isHelp = true;
	overhelplayer = true;
	coors = findPos(obj,0,23);
	var x = document.getElementById('helpbox');
	x.style.top = coors[1];
	x.style.left = coors[0];
	if (Cache[url])	{
		x.innerHTML = (Cache[url]);
	} else {
		get_content('helpbox',url)
	}
	new Effect.Appear('helpbox',{ duration: 0.2 });
}

function toggle_visibility(id)
{
	id=$(id);
//	alert(concatObject(id));
    if (id.style.display == "none"){
		new Effect.Appear(id,{duration:0.2});
		if (id.id == 'adv_search') {
			document.toggle.src=root+'Bilder/Minibilder/Trekant_ned.png';
			document.toggle.title='Klikk for å skjule avansert søk';
		}
		log('toggle_visibility_' + id.id);
    } else {
		new Effect.Fade(id,{duration:0.2});
		if (id.id == 'adv_search'){
			document.toggle.src=root+'Bilder/Minibilder/Trekant_hoyre.png';
			document.toggle.title='Klikk for å vise avansert søk';
			document.search.where.value='all';
			document.search.order.value='id';
			document.search.d0.checked = false;
			document.search.d1.checked = true;
		}
	}
}


function getIT(it)
{
    it = $(it);
    return (it);
}

function cache_content(url,refresh){
	if (enable_cache && !refresh && Cache[url])
		return Cache[url];
	else {
		request = new Ajax.Request(
			ajax_server,
			{
				method: 'get',
				parameters: url,
				onComplete: function (transport){
					Cache[url] = transport.responseText;
					if (document.progress)
						document.progress.src=root+'Bilder/spacer.gif';
				}
			}
		)
	}
}

function get_content(div_id,url){
	if (enable_cache && Cache[url]){
		document.getElementById(div_id).innerHTML = Cache[url];
		return;
	}
	request = new Ajax.Updater(
		div_id,
		ajax_server,
		{
			method: 'get',
			parameters: url,
			onComplete: function (transport){
				if(enable_cache)
					Cache[url] = transport.responseText;
				if (document.progress)
					document.progress.src=root+'Bilder/spacer.gif';
			}
		}
	)
}

function submitform(elem){
	while (elem.parentNode && elem.parentNode.tagName != "FORM"){
		elem = elem.parentNode;
	}
	var oForm = elem.parentNode;
	oForm.submit();
}

function show_user_files(context){
	var url = 'task=show_user_files&context='+context;
	enable_cache = false;
	get_content('user_files',url);
	enable_cache = true;
}

function change_field(obj){
	lines = obj.value.split("\n");
	var value = lines[0];
	for (i = 1; i < lines.length; i++){
		value += '_lb_'+lines[i];
	}
	value = encodeURIComponent(value);
	var url = 'task=change_field&context='+obj.name+'&value='+value;
	get_content(obj.name,url);
}

function vote(image,vote){
	var url = 'task=vote&image='+image+'&vote='+vote;
	get_content('eggs',url);
}

function bg(obj,color){
	if (color){
		ThingsToRemember['init_bg'] = obj.style.background;
		obj.style.background=color;
	} else {
		obj.style.background = ThingsToRemember['init_bg'];
	}
}

function set_class(obj,name){
	alert(obj.style.background);
}

function search(search,forum_list,topic){
	if (search.length >= 3){
		if (document.progress)
			document.progress.src='http://www.nofoa.no/Bilder/Minibilder/Laster_fil_anim.gif';
		parts = search.split("+");
		var search = parts[0];
		for (i = 1; i < parts.length; i++){
			search += '_pluss_'+parts[i];
		}
		search = encodeURIComponent(search);
		var url = 'task=search&page='+page+'&search='+search+((forum_list)?'&forum_list='+forum_list:'')+((topic)?'&topic='+topic:'');
		enable_cache = false;
		get_content('search_results',url);
		enable_cache = true;
	}
}

function concatObject(obj) {
	str='';
	for(prop in obj)
	{
		str+=prop + " value :"+ obj[prop]+"\n";
	}
	return(str);
}

function expand(group,expand){
	if (document.progress)
		document.progress.src='http://www.nofoa.no/Bilder/Minibilder/Laster_fil_anim.gif';
	var url = 'task=expand&group='+group+'&expand='+expand;
	enable_cache = false;
	get_content(group,url);
	enable_cache = true;
}

function prepare_cache(file,size,context,style){
	style = (style)?style:'';
	var url = 'task=prepare_cache&file='+file+'&size='+size+'&context='+context+'&style='+style;
	get_content(size,url);
}

function bookmark(context,status){
	Parts = context.split('-');
	if (page=='Min_side.php'){
		if (Parts[3] > 0)
			tag = Parts[0]+'-'+Parts[1]+'_'+Parts[3];
		else
			tag = Parts[0]+'-'+Parts[1];
		var url = 'task=bookmark&context='+context+'&page='+page;
		document.getElementById('popuplayer').style.display = 'none' ;
		overpopuplayer == false;
		isMenu = false ;
	} else {
		if (status > 0){
			document.getElementById('bm_'+context).style.background = 'url(http://nofoa.no/Bilder/Minibilder/Bokmerkeflipp.png) top left no-repeat';
			isMenu = true;
			overpopuplayer = true;
		} else {
			document.getElementById('bm_'+context).style.background = 'url(http://nofoa.no/Bilder/spacer.gif) top left no-repeat';
			document.getElementById('popuplayer').style.display = 'none' ;
			overpopuplayer == false;
			isMenu = false ;
		}
		var url = 'task=bookmark&context='+context;
		enable_cache = false;
		get_content('popuplayer',url);
		enable_cache = true;
	}
}

function store_text(obj){
	context=obj.name;
	lines = obj.value.split("\n");
	var text = lines[0];
	for (i = 1; i < lines.length; i++){
		text += '_lb_'+lines[i];
	}
	text = encodeURIComponent(text);
	if (page=='Min_side.php'){
		Parts = context.split('-');
		if (Parts[3] > 0)
			tag = Parts[0]+'-'+Parts[1]+'_'+Parts[3];
		else
			tag = Parts[0]+'-'+Parts[1];
		var url = 'task=bookmark&context='+context+'&text='+text+'&page='+page;
		get_content(tag,url);
	} else {
		var url = 'task=bookmark&context='+context+'&text='+text;
		put_content(url);
	}
}

function show_utm(obj,utm){
	isMenu = true;
	overpopuplayer = true;
	coors = findPos(obj,-9,-20);
	var x = document.getElementById('popuplayer');
	x.style.top = coors[1];
	x.style.left = coors[0];
	x.innerHTML = '<div class="popuplayer" style="width:160px" onclick="copy_field.select()"><a onclick="new Effect.Fade(\'popuplayer\',{ duration: 0.2 });return false;" href="#"><img src="/Bilder/Minibilder/kryss_svak.gif" border="0" align="right" style="margin:0"></a>&nbsp;UTM-koordinater:<input id="copy_field" style="width:100%; background:white; border:1px solid grey; padding:2px; margin:2px 0 0 0; font-size: 9px" value="'+utm+'"></div>';
	new Effect.Appear('popuplayer',{ duration: 0.2 });
}

function preload_popup(obj,context){
	obj.src = root + 'Bilder/Minibilder/Menyknapp_over.png';
	url = 'task=show_popup&context='+context+'&page='+page;
	cache_content(url);
}

function show_popup(obj,context,timeout){
	obj=getIT(obj)
	isMenu = true;
	overpopuplayer = true;
	url = 'task=show_popup&context='+context+'&page='+page;
	if (obj.id == 'login_link')
		coors = findPos(obj,0,-40);
	else
		coors = findPos(obj);
	var x = document.getElementById('popuplayer');
	x.style.top = coors[1];
	x.style.left = coors[0];
	if (Cache[url])	{
		x.innerHTML = (Cache[url]);
		Cache[url] = '';
	} else {
		x.innerHTML = '<div class="popuplayer" style="padding:3px">Vent...</div>';
		if (!timeout) timeout = 5;
		var myInterval = window.setInterval(function () {
			if (Cache[url]){
				x.innerHTML = (Cache[url]);
				Cache[url] = '';
				window.setTimeout(function () {
					clearInterval(myInterval);
				},0);
				return
			}
		},100);
		window.setTimeout(function () {
			clearInterval(myInterval);
		},timeout*1000);
	}
	new Effect.Appear('popuplayer',{ duration: 0.2 });
}

function findPos(obj,lcorr,tcorr){
	curleft = curtop = 0;
	lcorr = (lcorr)?lcorr:0;
	tcorr = (tcorr)?tcorr:0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
    if (curleft+lcorr > 0)
        curleft+=lcorr;
    else 
        curleft=5
        
    if (curtop+tcorr > 0)
	   curtop+=tcorr;
    else 
        curtop=5
	curleft+='px';
	curtop+='px';
	return [curleft,curtop];
}

function show_day(day){
	var url = 'task=show_day&day='+day;
	get_content('day',url);
}

function show_calendar(month){
	var url = 'task=show_calendar&month='+month+'&page='+page;
	get_content('calendar',url);
}

function edit_bird(bird_id,lines){
	var url = 'task=edit_bird&bird_id='+bird_id+'&lines='+lines;
	get_content('edit_bird',url);
}

function choose_observations(){
	if (document.search.selection.value == 'member'){
		alert ('Du må være innlogget medlem for å bruke denne funksjonen');
	} else {
		document.search.submit()
	}
}

function keep_alive(start,remain,step,call_function){
	if (remain <= step){
		remain = start + step;
		Now = new Date();
		h = Now.getHours();
		m = Now.getMinutes();
		if (h < 10){
			h = '0' + h;
		}
		if (m < 10){
			m = '0' + m;
		}
		time = h+'.'+m;
		if (confirm(time+': Du har vært inaktiv i '+start+' minutter. Trykk OK innen '+ step +' minutter for å fortsette å være innlogget.')){
			Confirmed = new Date();
			delay = (Confirmed - Now)/60000;
			if (delay <= step){
				if (call_function)
					var url = 'task=keep_alive&start='+start+'&remain='+remain+'&step='+step+'&call_function='+call_function;
				else
					var url = 'task=keep_alive&start='+start+'&remain='+remain+'&step='+step;
			} else if (page == 'Kikkhullet.php')
				cache_content('task=logout&page='+page);
			else
				this.location.href = root + '?logout=forced';

		} else if (page == 'Kikkhullet.php')
            cache_content('task=logout&page=' + page);
		else
			this.location.href = root + '?logout=yes_please';

	} else {
		if (call_function)
			var url = 'task=keep_alive&start='+start+'&remain='+remain+'&step='+step+'&call_function='+call_function;
		else
			var url = 'task=keep_alive&start='+start+'&remain='+remain+'&step='+step;
	}
    if (url)
	   get_content('keep_alive',url);
}

function change_bird(bird_id,field,value){
	var url = 'task=change_bird&bird_id='+bird_id+'&field=' + field + '&value='+value;
	container = 'cf_'+bird_id;
	get_content(container,url);
}

function approve_bird(report_id,bird_id,value){
	var url = 'task=approve_bird&report_id='+report_id+'&bird_id='+bird_id+'&value='+value;
	enable_cache = false;
	put_content(url);
	enable_cache = true;
}

function log(value){
	var url = 'task=log_this_event&value='+value;
	put_content(url);
}

function change_userpass(id){
	var url = 'task=change_userpass&id=' + id;
	get_content('new_password',url);
}

function get_news(id){
	var div_id = 'news_'+id;
	var url = 'task=get_news&id=' + id;
	get_content(div_id,url);
}

function close_news(id){
	open_news_link = '<a href="javascript:get_news('+id+')" href="#a_'+id+'"><span class="navn">Les mer (lest) &gt;&gt;</span></a>';
	var div_id = 'news_'+id;
	document.getElementById(div_id).innerHTML = open_news_link;
}

function get_story(id,image_context){
	var div_id = 'story_'+id;
	url = (image_context)?'task=get_story&id=' + id + '&context=' + image_context + '&page=' + page : 'task=get_story&id=' + id + '&page=' + page ;
	get_content(div_id,url);
}

function close_story(id,image_context,has_text){
	if (image_context){
		if (has_text){
			open_story_link = '<a href="javascript:get_story('+id+",'"+image_context+"'"+')" href="#a_'+id+'"><span class="navn">Klikk her for turreferat med bilder (lest) &gt;&gt;</span></a>';
		} else {
			open_story_link = '<a href="javascript:get_story('+id+",'"+image_context+"'"+')" href="#a_'+id+'"><span class="navn">Klikk her for turbilder (sett) &gt;&gt;</span></a>';
		}
	} else {
		open_story_link = '<a href="javascript:get_story('+id+')" href="#a_'+id+'"><span class="navn">Klikk her for turreferat (lest) &gt;&gt;</span></a>';
	}
	var div_id = 'story_'+id;
	document.getElementById(div_id).innerHTML = open_story_link;
}

function refresh_names(letter){
	if (letter.name == 'firstname') firstname = letter.value;
	if (letter.name == 'lastname') lastname = letter.value;
	get_content('listedNames','task=get_names&firstname=' + firstname +'&lastname=' + lastname);
}

function project_approve(checkbox,project_id,observation_id){
	checkbox = getIT(checkbox);
	approve = checkbox.value;
	var url = 'task=project_approve&project_id='+project_id+'&observation_id='+observation_id+'&approve='+approve;
	get_content('obs_'+observation_id,url);
}

function session_put(id){
	id = getIT(id);
	set = (id.checked)? 1:0;
	var url = 'task=session_put&arr='+id.name+'&value='+id.value+'&set='+set;
	put_content(url);
}

function put_content(url){
	cache_content(url,true);
}

function up(obj,y,id){
	isMenu = true;
	var url = 'task=user_popup&id=' + id ;
	var x = document.getElementById('the_table');
	if (id != last_popupuser){
		last_popupuser = id;
		y.style.display = 'none';
		y.innerHTML = '';
	}
	coorsY = findPos(obj,0,0);
	coorsX = findPos(x,-135,0);
	y.style.top = coorsY[1];
	y.style.left = coorsX[0];
	if (enable_cache && Cache[url]){
		document.getElementById('popuplayer').innerHTML = Cache[url];
		new Effect.Appear('popuplayer',{ duration: 0.6 });
	} else {
		request = new Ajax.Updater(
			'popuplayer',
			ajax_server,
			{
				method: 'get',
				parameters: url,
				onComplete: function (transport){
					if(enable_cache)
						Cache[url] = transport.responseText;
					document.getElementById('popuplayer').innerHTML = transport.responseText;
					new Effect.Appear('popuplayer',{ duration: 0.6 });
				}
			}
		)
	}
}

function user_popup(obj,id) {
	var y = document.getElementById('popuplayer');
	if (id > 0){
		this_delayed_popup = up.delay(0.5,obj,y,id)
	} else {
		isMenu = false;
		overpopuplayer = false;
		y.style.display = 'none';
		y.innerHTML = '';
	}
}

function get_user_info( id,line_count ) {
	var url = 'task=user_popup&id=' + id +'&line_count=' + line_count;
	if (id == 0){
		document.getElementById( 'focused_user' ).innerHTML = '';
	} else {
		get_content('focused_user',url);
	}
}

function checkAll(checkname, value) {
  for (i = 0; i < checkname.elements.length; i++)
  checkname[i].checked = value.checked? true:false
}

function Count_words(){
	var content_w=document.Min_side_endre.presentation.value;
	content_w=content_w.split(" ");
	wordsleft=maxwords-content_w.length;
	document.Min_side_endre.wordcount.value=wordsleft;
	if (wordsleft<0) {
		document.Min_side_endre.presentation.className='yellowbg';
		if (!alerted_words) alert('Du har brukt opp din kvote av ord!');
		alerted_words=true;
	} else document.Min_side_endre.presentation.className='navn';
}

var maxlines=5;
var alerted_lines=false;

function Count_lines(){
	var content_l=document.Min_side_endre.specialities.value;
	content_l=content_l.split("\n");
	linesleft=maxlines-content_l.length;
	if (linesleft<0) {
		document.Min_side_endre.specialities.className='yellowbg';
		if (!alerted_lines) alert('Du kan skrive maks 5 linjer!');
		alerted_lines=true;
	} else document.Min_side_endre.specialities.className='navn';
}

function clear_empty_year1() {
	if (document.Min_side_endre.year_bw_start.value == '0000'){
		document.Min_side_endre.year_bw_start.value = ''
	}
}

function clear_empty_year2() {
	if (document.Min_side_endre.year_member.value == '0000'){
		document.Min_side_endre.year_member.value = ''
	}
}

function clear_empty_year3() {
	if (document.Min_side_endre.date_birth_year.value == '0000'){
		document.Min_side_endre.date_birth_year.value = ''
	}
}

function uploaded() {
<!--	location.reload(true); -->
	opener.reload();
	self.close();
}

function removeText(field) {
	field.value = '';
}

function reg_project_data(pid,ref){
	var	win_location;
	var	win_top, win_left;
	var	win_width;
	var	win_height;

	unique_name='project_'+pid;

	win_width = 320;
	win_height = 500;

	win_size = find_size();

	win_location = root+'Sider/Rapporteringer/Prosjektparametre.php?pid=' + pid + '&ref=' + ref;

	win_top	 = 20;
	win_left = win_size[0]	- win_width	- 20;
	P_Win	= window.open(
		win_location,
		unique_name,
		'width='+win_width+',height='+win_height+',top='+win_top+',left='+win_left
	);
	P_Win.focus();
}

function open_gps_win(id){
	var	win_location;
	var	win_top, win_left;
	var	win_width;
	var	win_height;

	unique_name='gps_'+id;

	win_width = 260;
	win_height = 210;

	win_size = find_size();

	win_location = root+'Sider/Rapporteringer/GPS.php?id=' + id;

	win_top	 = 20;
	win_left = win_size[0]	- win_width	- 20;
	GPS_Win	= window.open(
		win_location,
		unique_name,
		'width='+win_width+',height='+win_height+',top='+win_top+',left='+win_left
	);
	GPS_Win.focus();
}

function open_ul_win(type,name){
	var	win_location;
	var	win_top, win_left;
	var	ul_win_width;
	var	ul_win_height;

	win_size = find_size();

	unique_name='upload_'+type+'_'+name;

	ul_win_width = 390;

	if (type == 'portraits'){
		ul_win_height =	250;
	} else if (name == 'tur'){
		ul_win_height =	440;
	} else {
		ul_win_height =	650;
	}

	win_location = root+'Upload/Brukerfiler.php?type=' + type + '&id=' + name;

	win_top	 = 20;
	win_left = win_size[0]	 - ul_win_width	 - 20;
	Ul_Win	= window.open(
		win_location,
		unique_name,
		'width='+ul_win_width+',height='+ul_win_height+',top='+win_top+',left='+win_left+',scrollbars=1'
	);
	Ul_Win.focus();
}

function show_image(image,context,style,size){
	var	win_location;
	var	win_top = 0;
	var win_left = 5;
	var	HelpWin;
	var	win_top	 = 5;
	var	win_width = 570;
	var win_height = 710;
	style = (style) ? style : '';
	size = (size) ? size : 'standard';
	//win_size = find_size();
	max_height = screen.height-25;
//	if (image.indexOf('tur') > 0){
//		win_left = win_size[0] - win_width - 20;
//	} else {
//		win_left = 60;
//	}

	win_location = root+'Bilder/Vis_bilde.php?image=' + image + '&size=' + size + '&max_height=' + max_height + '&context=' + context+ '&style=' + style;

	Img_win	= window.open(
		win_location,
		size,
		'scrollbars=yes, width='+win_width+',height='+win_height+',top='+win_top+',left='+win_left
	);

	Img_win.focus();
}

function open_registration_win(id){

	var	win_location;
	var	win_top, win_left;
	var	HelpWin;

	unique_name='zyx';

	var	reg_win_width = 500;
	var	reg_win_height = 180;

	win_size = find_size();

	win_location = root+'Sider/Medlemmer/Brukerregistrering.php?id=' + id;

	win_top	 = win_size[1] - reg_win_height - 20;
	win_left = win_size[0]	 - reg_win_width - 20;
	Reg_Win	= window.open(
		win_location,
		unique_name,
		'width='+reg_win_width+',height='+reg_win_height+',top='+win_top+',left='+win_left
	);
	Reg_Win.focus();
}

function find_size(){
	var screen_width = 630, screen_height = 460;
//	if (parseInt(navigator.appVersion)>3) {
//		if (navigator.appName=="Netscape") {
//			screen_width = window.innerWidth;
//			screen_height = window.innerHeight;
//		 }
//	 	if (navigator.appName.indexOf("Microsoft")!=-1) {
//			screen_width = document.body.offsetWidth;
//			screen_height = document.body.offsetHeight;
//		}
//	}
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    screen_width = window.innerWidth;
	    screen_height = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    screen_width = document.documentElement.clientWidth;
	    screen_height = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    screen_width = document.body.clientWidth;
	    screen_height = document.body.clientHeight;
	  }
	return [screen_width,screen_height];
}


function pageHeight()
{
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
//function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}










