/*
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// see what browser
var is_gecko = (agt.indexOf('gecko') != -1);
var is_konq  = (agt.indexOf('konqueror') != -1);
var is_ie    = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_opera = (agt.indexOf("opera") != -1);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && !is_gecko);


var last_highlighted="";
var last_highlighted_color="";
var highlight_color="#AACCAA"

//alert(is_major + ":" + is_minor + " -- " + agt);

//if (is_konq) 	alert ("Konqueror detected");
//if (is_gecko) alert ("Gecko detected");
//if (is_ie) 		alert ("Internet Explorer detected");
//if (is_nav)		alert ("Navigator detected");

var use_DOM = false;
var use_IE = false;
var use_NAV = false;

if ( is_gecko || is_konq || is_opera || (is_nav && is_major >= 6)) {
	use_DOM = true;
} else if (is_ie && is_major >= 4) {
	use_IE = true;
} else if (is_nav) {
	use_NAV = true;
} else {
	// we don't know this browser,
	// so we assume it is DOM compliant
	use_DOM = true;
}

*/

/*
function setSlaveDivHeight() {
	

	var myheight; 
	myheight = 	getInnerHeight(window) -165;
//	myheight = 	getInnerHeight(window);

	//if (use_DOM) document.getElementById("my_slave_div").style.height = myheight;
	//else if (use_NAV) document.layers["my_slave_div"].height = myheight;
	//else if (use_IE) document.all["my_slave_div"].style.height = myheight;
	//document.getElementById("my_slave_div").style.height = myheight;

}
*/


/*

var pics = new Array();
my_img = new Image(); 

function register_pic(id, on_src, off_src) {
	my_img = new Image(); 

	my_img.src = off_src;
	pics[id + "_off"] = my_img;

	my_img = new Image(); 
	my_img.src = on_src; 
	pics[id + "_on"] = my_img;

	//off(id);
}

function register_button(button_id, img_id, pic_id) {

	var button = document.getElementById(button_id);

	//alert(button_id + " " + img_id);
	if (button) { 
		button.onmouseover=function(){on_id(img_id,pic_id)};
		button.onmouseout =function(){off_id(img_id,pic_id)};
	}
	
}
function register_buttons(tag, button_exp, img_id, pic_id) {
	for(m=0;m<document.getElementsByTagName(tag).length;m++){
		bid = (document.getElementsByTagName(tag)[m].id);
		if (bid.match(button_exp) ) {
			//alert(bid.match(button_exp)[1]);
			button_id = img_id + bid.match(button_exp)[1];
			//alert(button_id);
			register_button(bid, button_id, pic_id);
		}
	}
}


function on_id(id,pic) {

	pic_src = pics[pic+"_on"].src;

	if (use_DOM && document.getElementById(id)) document.getElementById(id).src = pic_src;
	//if (use_DOM && document.getElementById(pic)) document.getElementById(pic).src = pic_src;
	else if (use_IE) document.all[id].src = pic_src;	

	return true;
	
}

function on(pic) {
	on_id(pic,pic)
}

function off_id(id,pic) {
	pic_src = pics[pic+"_off"].src
	//alert(id);
	if (use_DOM) document.getElementById(id).src = pic_src;
	//if (use_DOM && document.getElementById(pic)) document.getElementById(pic).src = pic_src;
	else if (use_IE) document.all[id].src = pic_src;	
	return true;
}
function off(pic) {
	off_id(pic,pic)
}

function swapPic(pictoswap, swappedpic) {
	var pictoswap_src;
	pictoswap_src = pics[pictoswap].src;
	if (use_DOM) document.getElementById(swappedpic).src = pictoswap_src;
	else if (use_IE) document.all[swappedpic].src = pictoswap_src;	
	return true;
}

function register_pic_light(id, src) {
	my_img = new Image(); 
	my_img.src = src;
	pics[id] = my_img;
}
*/



/*********************************************************/
/* show popups (divs)*/
/*
function show_popup(id)
{
	if (use_DOM) document.getElementById(id).style.visibility = "visible";
	else if (use_NAV) document.layers[id].visibility = "show";
	else if (use_IE) document.all[id].style.visibility = "visible";
}
*/

/* hide popups (divs)*/
/*
function hide_popup(id)
{
	if (use_DOM) document.getElementById(id).style.visibility = "hidden"
	else if (use_NAV) document.layers[id].visibility = "hide"
	else if (use_IE) document.all[id].style.visibility ="hidden"
}
*/

/* toggle visibility (divs) DOM */
/*
function toggle_popup(id, x_offset) {
	e = document.getElementById(id);
	if ( e.style.visibility == "visible" ) {
		e.style.visibility = "hidden"; 
		
		var num = e.childNodes.length;
		var i;
		for (i=0; i<num; ++i) {
			if (e.childNodes[i].nodeName.toUpperCase() == "DIV") {
				//alert(e.childNodes[i].nodeName);
				e.childNodes[i].style.visibility = '';
			}
		}
		
	} else {
		e.style.left = x-x_offset;
		e.style.top = y;
		e.style.visibility = "visible"; 
	}
}
*/

/*
function set_class(className, obj) {
	if (use_IE) obj.className = className;
}
*/


function openWindow(href, name, width, height) {
	window.open(href, name, "width=" + width + ", height=" + height + ",toolbar=no,scrollbars=yes,resizable=yes"); 
}



/******************* Window Dimensions **************************************/
// Window properties  v1.1
// documentation: http://www.dithered.com/javascript/window_properties/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


/*
function getInnerWidth(win) {
  var winWidth;
  if (win.innerWidth) {
    winWidth = win.innerWidth;
  }
  else if (win.document.documentElement && win.document.documentElement.clientWidth) {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (document.body) {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}

function getInnerHeight(win) {
  var winHeight;
  if (win.innerHeight) {
    winHeight = win.innerHeight;
  }
  else if (win.document.documentElement && win.document.documentElement.clientHeight) {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (win.document.body) {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}
*/
/*
function getScrollTop(win) {
   var scrollTop = 0;
   if (win.pageYOffset) {
	   scrollTop = win.pageYOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollTop) {
	   scrollTop = win.document.body.scrollTop;
   }
   else if (win.document.body) {
      scrollTop = win.document.body.scrollTop;
   }
   return scrollTop;
}
*/

/*
function getScrollLeft(win) {
   var scrollLeft = 0;
   if (win.pageXOffset) {
	   scrollLeft = win.pageXOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollLeft) {
	   scrollLeft = win.document.body.scrollLeft;
   }
   else if (win.document.body) {
      scrollLeft = win.document.body.scrollLeft;
   }
   return scrollLeft;
}
*/

/*
function reloader(secs) {
	window.setTimeout("reload_window()", secs*1000);
}

function reload_window() {
	window.location.reload();
}
*/



// current mouse position
/*
var x, y;
if (window.Event) {
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = getXY;

function getXY(e) {
  x = (window.Event) ? e.pageX : event.clientX;
  y = (window.Event) ? e.pageY : event.clientY;
}
*/

function toggleVisibility(id,praefix) {
	elem = document.getElementById(id);
	if (elem.style.visibility == 'visible' || elem.style.visibility == '') {
		elem.className = praefix+'hidden';
		elem.style.visibility='hidden';
	} else {
		elem.className = praefix+'visible';
		elem.style.visibility='visible';
	}
}
function toggleVisibility2(id,praefix,visible) {
	elem = document.getElementById(id);
	if (visible) {
		elem.className = praefix+'visible';
		elem.style.visibility='visible';
	} else {
		elem.className = praefix+'hidden';
		elem.style.visibility='hidden';
	}
}

function _null() {
	return;
}

// find the position of an object in the page
// http://www.quirksmode.org/js/findpos.html
function findPosX(obj)
{
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (obj.x)
                curleft += obj.x;
        return curleft;
}

function findPosY(obj)
{
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop;
}


// --------------------------------------------------------------
// simple AJAX functionality
// --------------------------------------------------------------


// --------------------------------------------------------------
// helper
// --------------------------------------------------------------
function $I(id) {
	return document.getElementById(id);
}



// --------------------------------------------------------------
// actual AJAX Classes
// --------------------------------------------------------------
// USEAGE: ajax.getback(url, function(txt,req) { updater.respone = req; updater.update(txt,divid);  });
function UPDATER() {
	this.update = function(txt,id) {
	 document.getElementById(id).innerHTML = txt;
	}
}

function AJAX() {


	// -----------------------------------------------------------
	// helper functions
	// -----------------------------------------------------------
	this.callBack = function() {
		if(req.readyState == 4) {
			if(req.status == 200 || req.status == 302 || req.status == 304 ) {
				if (req.responseXML) {
					handler(req.responseXML, req, true);
				} else {
					handler(req.responseText, req, false);
				}
			} else {
				alert('An error has occurred: ' + req.statusText);
			}
		}
	}

	// -----------------------------------------------------------
	//	get answer codes
	// -----------------------------------------------------------
	this.getStatus = function(xml) {
		retstatus = xml.getElementsByTagName('statusText');
		retstatus = retstatus[0];
		// working for mozilla
		//return (status.firstChild.nodeValue);
		//return(status.firstChild);
		return(retstatus.firstChild.nodeValue);
	}

	// -----------------------------------------------------------
	// default handler
	// -----------------------------------------------------------
	this.default_handler = function(txt,req,is_xml) {
		if (is_xml) {
			// get the status
			alert(ajax.getStatus(txt));
		} else {
			// get the status
			alert(txt);
		}
	}




	// -----------------------------------------------------------
	// get a html request object
	// -----------------------------------------------------------
	this.getXMLHttpRequestObject = function(mime) {

		http_request = false;

		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			 http_request = new XMLHttpRequest();
			 if (http_request.overrideMimeType && mime && mime != "") {
					// set type accordingly to anticipated content type
					//http_request.overrideMimeType('text/xml');
					http_request.overrideMimeType(mime);
			 }
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
		if (!http_request) {
			 alert('Cannot create XMLHTTP instance');
			 return false;
		}
		return http_request;
	}

	// GET REQUEST
	var req;

	this.get = function(url, handler) {
		req = this.getXMLHttpRequestObject();
		if (req) {
			req.onreadystatechange = this.callBack;
			req.open('GET', url, true);
			req.send(null);
		}
	}

	this.post = function(url, handler, parameters) {
		req = this.getXMLHttpRequestObject();

		if (req) {
			req.open('POST', url, true);
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			req.setRequestHeader("Content-length", parameters.length);
			req.setRequestHeader("Connection", "close");
			req.onreadystatechange =  this.callBack;
			req.send(parameters);

		}
	}

	this.exportUrlVarsFromId = function(ids) {
		urlVars = "";
		for(i=0;i<ids.length;i++) {
			urlVars.append(encodeURI( ids[i] + "=" + encodeURI( $I(ids[i]).value )));
		}
		return urlVars;
	}
	this.exportUrlVar = function(id,value) {
		return (id + "=" + encodeURI(value));
	}

}

