
///////////////////////////////
//define top level class
function opclass() { }
opclass.prototype.construct = function() {};
opclass.extend = function(def) {
	var classDef = function() {
		if (arguments[0] !== opclass) { this.construct.apply(this, arguments); }
	};
	
	var proto = new this(opclass);
	var superClass = this.prototype;
	
	for (var n in def) {
		var item = def[n];                        
		if (item instanceof Function) item.$ = superClass;
		proto[n] = item;
	}

	classDef.prototype = proto;
	
	//Give this new class the same static extend method    
	classDef.extend = this.extend;        
	return classDef;
};

//
////////////////////////////////////




/////////////////////////////////////
// opcmf base class
var opbase = opclass.extend({

	mod_url: opcmf_mod_url,
	root_url: opcmf_root_url,
	template_url: opcmf_template_url,
	session_info: opcmf_session_info,
	serveraddress: opcmf_serveraddress,
	lang: opcmf_lang,
	page_category: opcmf_page_category,
	page_title: opcmf_page_title,
	vscript: opform_vscript,		
	modal: opcmf_modal,
	self: opcmf_self,
	self_url: opcmf_self_url,
	dragobjid: '',
	dragobjzindex: '',
	floatobjid: '',
	floatobjzindex: '',
	
	


	
construct: function() {
		//BaseClass constructor code goes here

		//this.lang = opcmf_lang;


		
	},



ShowInfoBar: function (bShow){

		document.cookie = "showinfobar=" + (bShow ? "Y" : "N") + "; expires=Thu, 31 Dec 2035 23:59:59 GMT; path=/;";

		ctlInfoBar = document.getElementById("infobar");
		
		if(ctlInfoBar){
			if(bShow){
				$("#infobar").slideDown();
			}else{
				$("#infobar").slideUp();
			}
		}
	},
	
scrollto: function (target_id,speed){

		if(target_id == '') return;

		if(!document.getElementById(target_id)) return;

		var currentypos = getScrollY();

		targetdiv = document.getElementById(target_id);

		var desty = targetdiv.offsetTop;

		var thisNode = targetdiv;

		while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) {

			thisNode = thisNode.offsetParent;
			desty += thisNode.offsetTop;

		}

		// bring you to just above
		desty -= 12;

		if(desty < currentypos){
			for ( I=currentypos; I > desty; I-= speed ){
				parent.scroll(1,I);
			}
		}else{

			for ( I=currentypos; I < desty; I+= speed ){
				parent.scroll(1,I);
			}
		}
	},




	
dragStart: function (event, id) {

		var el;
		var x, y;
		
		if(this.dragobjid != "" && this.dragobjzindex != "") $("#" + this.dragobjid).css('zIndex',this.dragobjzindex);
				
		
		this.dragobjzindex = $("#" + id).css('zIndex');
		this.dragobjid = id;
		
		
		

		// If an element id was given, find it. Otherwise use the element being
		// clicked on.

		if (id)
		dragObj.elNode = document.getElementById(id);
		else {
			if (browser.isIE)
			dragObj.elNode = window.event.srcElement;
			if (browser.isNS)
			dragObj.elNode = event.target;

			// If this is a text node, use its parent element.

			if (dragObj.elNode.nodeType == 3)
			dragObj.elNode = dragObj.elNode.parentNode;
		}

		// Get cursor position with respect to the page.

		if (browser.isIE) {
			x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
		}
		if (browser.isNS) {
			x = event.clientX + window.scrollX;
			y = event.clientY + window.scrollY;
		}

		// Save starting positions of cursor and element.

		dragObj.cursorStartX = x;
		dragObj.cursorStartY = y;
		dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
		dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

		if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
		if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

		// Update element's z-index.
		//dragObj.elNode.style.zIndex = ++dragObj.zIndex;
		
		// finally, brint this thing to the front
		$("#" + id).bringtofront();
		

		// Capture mousemove and mouseup events on the page.

		if (browser.isIE) {
			document.attachEvent("onmousemove", dragGo);
			document.attachEvent("onmouseup",   dragStop);
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (browser.isNS) {
			document.addEventListener("mousemove", dragGo,   true);
			document.addEventListener("mouseup",   dragStop, true);
			event.preventDefault();
		}
		

	},
	
	
dragGo: function (event) {

		var x, y;

		// Get cursor position with respect to the page.

		if (browser.isIE) {
			x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
		}
		if (browser.isNS) {
			x = event.clientX + window.scrollX;
			y = event.clientY + window.scrollY;
		}

		// Move drag element by the same amount the cursor has moved.

		dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
		dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

		if (browser.isIE) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (browser.isNS)
		event.preventDefault();
	},
	
dragStop: function (event) {

		// Stop capturing mousemove and mouseup events.

		if (browser.isIE) {
			document.detachEvent("onmousemove", dragGo);
			document.detachEvent("onmouseup",   dragStop);
		}
		if (browser.isNS) {
			document.removeEventListener("mousemove", dragGo,   true);
			document.removeEventListener("mouseup",   dragStop, true);
		}
		
		//$("#" + this.dragobjid).css('zIndex',this.dragobjzindex);
		        
				
	},
	
	
	
	
fadein: function(obj_id,speed) {

		if(speed > 5) speed = "fast";
		else speed = "slow";
		$("#" + obj_id).fadeIn(speed);


	},



fadeout: function(obj_id,speed) {


		if(speed > 5) speed = "fast";
		else speed = "slow";
		$("#" + obj_id).fadeOut(speed);

	},

findPos: function(obj) {

		obj = document.getElementById(obj);

		if(obj) {

			var curleft = curtop = 0;

			if (obj.offsetParent) {

				curleft = obj.offsetLeft
				curtop = obj.offsetTop
				
				while (obj = obj.offsetParent) {
					curleft += obj.offsetLeft
					curtop += obj.offsetTop

				}
			}	

			return [curleft,curtop];

		}
	},

	

repositiondiv: function(anchor,tleft,ttop,divname) {

		var targetdiv = document.getElementById(divname);

		var coors = this.findPos(anchor);

		var newx = (( coors[0]*1) + (tleft*1)  );
		var newy = (( coors[1]*1) + (ttop*1)  );

		var x = document.getElementById(divname);
		x.style.left = newx + 'px';
		x.style.top = newy + 'px';
		
		this.fadein(targetdiv.id,'5');
		

		return;

	},


setOpacity: function(obj_id, value) {

		if (navigator.vendor == "KDE") {
			document.getElementById(obj_id).style.KHTMLOpacity = value;
		} else if (navigator.appName == "Netscape") {
			document.getElementById(obj_id).style.MozOpacity = value;
		} else if (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1) {

			newval = value * 100;
			document.getElementById(obj_id).style.filter = "alpha(opacity=" + newval + ");";

			document.getElementById(obj_id).style.opacity = value;

		} else {
			document.getElementById(obj_id).style.opacity = value;
		}
		
		return;

	},
	
displaytooldiv: function (tleft, ttop, divname){

	var targetdiv = document.getElementById(divname);

	
	if(tleft > 10000 && ttop > 10000){
		
		var adjustedleft = (tleft - 10000);
		var adjustedtop = (ttop - 10000);
		
		document.getElementById(divname).style.left = adjustedleft + 'px';
		document.getElementById(divname).style.top = adjustedtop + 'px';
		
	}else{
		
		document.getElementById(divname).style.left = (xMousePos + tleft) + 'px';
		document.getElementById(divname).style.top = (yMousePos + ttop)  + 'px';
		
	}

	
	targetdiv.style.visibility = 'visible';
	targetdiv.style.display = 'none';

	//opcmf.fadein(targetdiv.id,'5')
	
	$("#" + targetdiv.id).fadeIn();
		

	return;

},



togglevisibility: function(obj_id) {

		var obj = document.getElementById(obj_id);

		if(obj) {

			if(obj.style.display == '') {
				obj.style.display='none';
			}else{
				obj.style.display='';
			}
		}
		
	},

show: function(obj_id) {

		$("#" + obj_id).show();
		
	},

hide: function(obj_id) {

		$("#" + obj_id).hide();

	},
	


getDimensions: function(element_id) {
		
		element = document.getElementById(element_id);
		
		// All *Width and *Height properties give 0 on elements with display none,
		// so enable the element temporarily
		
		var els = element.style;
		var originalVisibility = els.visibility;
		var originalPosition = els.position;
		var originalDisplay = els.display;
		
		els.visibility = 'hidden';
		els.position = 'absolute';
		els.display = '';
		
		var originalWidth = element.clientWidth;
		var originalHeight = element.clientHeight;
		
		
		els.display = originalDisplay;
		els.position = originalPosition;
		els.visibility = originalVisibility;
		
		
		return {width: originalWidth, height: originalHeight};
		
	},
	


centerobj: function(obj_id,offsetx,offsety) {
		$("#" + obj_id).centerInClient();
		
	},
	
	
openfloatwindow: function(obj_id,windowurl) {

	$("#" + obj_id).load(windowurl, function(){
	
	
		$("#" + obj_id).centerInClient();
	
		$("#" + obj_id).bringtofront();
		
		$("#" + obj_id).fadeIn();
	

   
  	});
					
	
},

/**
* Mostly obsolete buyt used in cases where jquery datepicker just won't damn well work eh!!!
*/
popupcalendar: function (obj, returnfunc,layername){

	var date = obj.value;

	var currentdate = $('#' + obj.id).val();
	
	var args = "";
	
	args += "&layername=" + layername;
	args += "&obj_id=" + obj.id;
	args += "&date=" + currentdate;	
			
	var url = '?sv=&cma=common:Remote:PopupCalendar&returnfunc=' + returnfunc + args;
			
	$('#' + layername).load(url,function(){

		
		$('#' + layername).maxZIndex(); //bringtofront();
					
		opcmf.displaytooldiv(10, 10, layername);

		
	
	});


},




floatwindow: function(obj_id) {

	$("#" + obj_id).centerInClient();
	
	//this.floatobjzindex = $("#" + obj_id).css('zIndex');
	//this.floatobjid = obj_id;
		
	$("#" + obj_id).bringtofront();
	
	$("#" + obj_id).bind("dblclick", function(e){
	
		$("#" + obj_id).maxZIndex();
		//$("#" + obj_id).bringtofront();
		
   });
					
	
},

closefloatwindow: function(obj_id) {

	$("#" + obj_id).fadeOut("fast",  function(){
			
			
		//if(this.floatobjid != "" && this.floatobjzindex != ""){
		
		//	$("#" + this.floatobjid).css('zIndex',this.floatobjzindex);
				
		//}
			

	});
		
	$("#" + obj_id).unbind("click");
					
	
},

addEventCode: function (eventname,code){

		if (window.attachEvent) { 

			eventname = "on" + eventname;
			eval("window.attachEvent(\"" + eventname + "\", " + code + " );"); 

		} else { 

			window.addEventListener(eventname,eval(code), false);
			
			
		}
	},
	
		
	
qform_highlight_color: '',
opfldname: '',





ajaxexec: function (url,prm,req_callback,async){

	var jp = new jsPHP('runjs()');

	if(req_callback != '') jp.setCallBack(req_callback);

	jp.cmd(url,prm,async);

}



	

});


var opcmf = new opbase();


var modalWindow = {  

     parent:"body",  
     windowId:null,  
     content:null,  
     width:null,  
     height:null,  
    close:function()  
     {  
         $(".modal-window").remove();  
         $(".modal-overlay").remove();  
     },  
     open:function()  
     {  
         var modal = "";  
         modal += "<div class=\"modal-overlay\"></div>";  
         modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";  
         modal += this.content;  
         modal += "</div>";      
   
        $(this.parent).append(modal);  
   
         $(".modal-window").append("<a class=\"close-window\"></a>");  
         $(".close-window").click(function(){modalWindow.close();});  
         $(".modal-overlay").click(function(){modalWindow.close();});  
     }  
 }; 


var browser = new Browser();
var dragObj = new Object();
dragObj.zIndex = 0;


// used for form validation 
var checkfields = Array();
var checkfieldnum = 0;

DOMC=false;
IE=(document.all);
if (!IE) { DOMC=(document.getElementById); }


////////////////////////////////////////
// Used to consolidate onload requests
// by more than a single module
// Example: onloadfuncs[onloadfuncs.length] = " alert('therer you go'); ";
// This is now obsolete. Start using opcmf.addEventCode()

var onloadfuncs = new Array();

window.onload=function(){

	for(i=0; i < onloadfuncs.length; i++){

		eval(onloadfuncs[i]);

	}
}

//
////////////////////////////////////


// Global variables
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen



function isdefined ( variable){

	return (typeof(window[variable]) == "undefined")?  false: true;

}


/////////////////////////////////////////////////////////////////////////////
// this is an ie6 hack and can be removed when IE6 finally dies .. bye bye ie6 you pig!
function swapfancybackground(obj,state){

	if(state == 'on'){ 
		
		$('#' + obj.id).removeClass('fancybutton').addClass('fancybutton_hover');
		
		
	}else { 
		
		$('#' + obj.id).removeClass('fancybutton_hover').addClass('fancybutton');
		
		
	}
	

}////////////





///////////////////////////////////////
// ** function is deprecated and should be replaced by  opcmf.repositiondiv(anchor,tleft,ttop,divname)
function displaytooldiv(tleft, ttop, divname){

	opcmf.displaytooldiv(tleft, ttop, divname)
	

}




//////////////////////////////
// state = visible, hidden
/////////////////////////////
function togglelayer(divname,state){
	
	if (document.layers) {

		var oLayer;
		oLayer = document.layers[divname].document;
		oLayer.style.visibility = state;

	}else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {

		document.getElementById(divname).style.visibility = state;

	}else if (document.all){

		document.all[divname].style.visibility = state;

	}


}



function Browser() {

	var ua, s, i;

	this.isIE    = false;
	this.isNS    = false;
	this.version = null;

	ua = navigator.userAgent;

	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}

	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}

	// Treat any other "Gecko" browser as NS 6.1.

	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}




function dragStart(event, id) {
	opcmf.dragStart(event, id);
}

function dragGo(event) {
	opcmf.dragGo(event);
}

function dragStop(event) {
	opcmf.dragStop(event);
}

function ShowInfoBar(bShow){
	opcmf.ShowInfoBar(bShow);
}



function getScrollX() {

	var scrOfX = 0;

	if( typeof( window.pageXOffset ) == 'number' ) {

		//Netscape compliant
		scrOfX = window.pageXOffset;

	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {

		//DOM compliant
		scrOfX = document.body.scrollLeft;

	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {

		//IE6 standards compliant mode
		scrOfX = document.documentElement.scrollLeft;

	}

	return scrOfX;

}


function getScrollY() {

	var scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {

		//Netscape compliant
		scrOfY = window.pageYOffset;

	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {

		//DOM compliant
		scrOfY = document.body.scrollTop;

	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {

		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;

	}

	return scrOfY;

}


function scrollto(target_id,speed){

	opcmf.scrollto(target_id,speed);

}




function popupwindow(target, twidth, theight){
	var tposx= (screen.width- twidth)/2
	var tposy= (screen.height - theight)/2
	var newWin1=window.open(target,"View","toolbar=no,width="+ twidth+",height="+ theight+ ",directories=no,status=no,scrollbars=yes,resizable=yes, menubar=no")
	newWin1.moveTo(tposx,tposy);
	newWin1.focus()
}

function backToTop(){
	for (I=250;I>0;I=I-5){
		parent.scroll(1,I) }
	parent.scroll(1,0);
}

function addtofav(urlAddress,pageName) { 

	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName) 
	} else { 
		alert("Sorry! Your browser doesn't support this function."); 
	}
}

function setfieldvalue(formname,fieldname,fieldvalue){

	if(formname == ''){
		obj = document.getElementById(fieldname);
		if(obj) obj.value = fieldvalue;
	}else{
		eval("document.forms['" + formname + "']." + fieldname + ".value='" + fieldvalue + "'");
	}
}


function setfieldcolor(formname, fieldname, color){

	if(formname == ''){
		obj = document.getElementById(fieldname);
		if(obj) obj.style.background = color;
	}else{
		eval("document.forms['" + formname + "']." + fieldname + ".style.background='"+color+"'");
	}
	

}






function rowOver(name, nColor) {
	if (!nColor) nColor = "#ECECD9";
	var nameObj = (document.getElementById) ? document.getElementById(name) : eval("document.all['" + name + "']");
	if (nameObj != null) nameObj.style.background=nColor;
}


function rowOut(name, nColor) {
	var trObj = (document.getElementById) ? document.getElementById(name) : eval("document.all['" + name + "']");
	var nameObj = (document.getElementById) ? document.getElementById(name) : eval("document.all['" + name + "']");
	if (trObj == null || trObj.style.display=="none") nameObj.style.background=nColor;
}



///////////////////////////////////////
// just so we don't get an error for 
// calling a non existing function

var qform_highlight_color = '';


/////////////////////////
// this is legacy
function divhighlight(opfldname){

	opform.divhighlight(opfldname);
	
}


function goback() {

	history.go(-1);
}



//
///////////////////////
function opencolorpicker(formname,fieldname){

	jsphp_shtml('dToolWindow','Admin:Manager:Remote','func=ColorPicker&formname=' + escape(formname) + '&fieldname=' + fieldname,'  opencolorpicker_callback()  ');

}

function opcmf_colorpicker(field_id){

	jsphp_shtml('dToolWindow','Admin:Manager:Remote','func=ColorPicker&fieldname=' + field_id,'  opencolorpicker_callback();  ');

}


function opencolorpicker_callback(){

	displaytooldiv(-100,10,'dToolWindow');

}




//////////////////////////////////
// COOKIES


function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	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(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}



function setintrocookie(page,state){

	if(state == false || state == ''){ eraseCookie('intropage'); }
	else{ createCookie('intropage',page,'365'); }

}

//  COOKIES
//////////////////////////////


function opcmf_setOpacity(obj_id, value){

	opcmf.setOpacity(obj_id, value);

}


//  END FadeFX
/////////////////////////////////////////////

function showgreypopup(title,url,height,width){

	GB_show(title,url,height,width);

}






/////////////////////
// IMLT functions

function ajaxUnescape( str ){

	if(!str) return "";
	// payload has slashes escaped with whacks
	return str.replace( /\\\//g, "/" );
}


//
/////////////////////

//public AJAX functions
function jsphp_gcontent(url,prm,req_callback){

	var jp = new jsPHP('void(0)');
	if(req_callback != '') jp.setCallBack(req_callback);
	jp.cmd(url,prm,false);
	return jp.getdata();
}

function jsphp_svalue(id,url,prm,req_callback,async){

	var jp = new jsPHP('changevalue("'+id+'")');
	if(req_callback != '') jp.setCallBack(req_callback);
	jp.cmd(url,prm);
}

function jsphp_shtml(id,url,prm,req_callback, async){


	var jp = new jsPHP('changehtml("'+id+'")');

	if(req_callback != '') jp.setCallBack(req_callback);

	jp.cmd(url,prm,async);

}


function jsphp_exec(url,prm,req_callback,async){

	var jp = new jsPHP('runjs()');

	if(req_callback != '') jp.setCallBack(req_callback);

	jp.cmd(url,prm,async);

}




function hidediv(obj_id) {

	$("#" + obj_id).hide();

}
	

//ajax-handler class
function jsPHP(efunc){

	var req;

	var data = null;
	var exefunction = efunc;

	////////////////////////////////
	// opcmf add-on for callbacks
	var callback = null;
	this.setCallBack = setCallBack;
	//
	////////////////////////////////

	this.cmd = cmd;
	this.getdata = getdata;

	// if Mozilla, Safari etc
	if (window.XMLHttpRequest) 
	req = new XMLHttpRequest()
	// if IE
	else if (window.ActiveXObject){ 

		try {
			req = new ActiveXObject("Msxml2.XMLHTTP")
		} 

		catch (e){

			try{ req = new ActiveXObject("Microsoft.XMLHTTP") }catch (e){}
		}

	}else{
		
		alert('This Browser do not support AJAX-Technology!');
		return ;

	}


	//handle status
	req.onreadystatechange = reqreadystatechange;



	function setCallBack(req_callback){

		if(req_callback != "") {
			callback = ajaxUnescape(req_callback);
		}

	}

	function reqreadystatechange() {

		if (req.readyState != 4) return;

		if (req.status == 200) {
			data = req.responseText;
			_showstatus(false);
			try {
				eval(exefunction);
			}catch (e){
				alert('ERROR executing result!');
			}

			////////////////////////////////
			// opcmf add-on for callbacks
			if(callback) try {
				eval(callback);
			}catch (e){
				alert('ERROR executing callback ' + callback + '!');
			}
			//
			////////////////////////////////


		}else{
			alert('ERROR loading data :-(');
		}
	}


	function cmd(url,prm,async){
		if(!prm) prm='';
		if(async!=false && async!=true) async=true;
		
		_doajax(url,prm,async);
	}

	function getdata(){
		return data;
	}

	function changevalue(id){
		document.getElementById(String(id)).value = data;
	}

	function changehtml(id){
		document.getElementById(String(id)).innerHTML = data;
	}

	function runjs(){
		eval(data);
	}

	function _showstatus(on){
		if(on){
			window.defaultStatus = 'Loading...';
			showstatus();
		}else{
			window.defaultStatus = '';
			closestatus();
		}
		
		return true;
	}

	function _doajax(url,prm,async) {
		
		data = null;
		
		if(!url || url==''){
			alert('Requestfile is not set!');
			return;
		}else{ url = 'phpinc='+url ;}
		
		if(prm!='') url += '&' + prm;
		
		_showstatus(true);


		req.open('POST', ajax_requesthandler , async);

		req.setRequestHeader("Method", "POST " + ajax_requesthandler + " HTTP/1.1");


		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		req.send(url);

	}
	//statusbar functions
	//---------------------------------------------------------------------
	var verticalpos="frombottom" //enter "fromtop" or "frombottom"
	var startX =30;var startY=30;

	function _createstatusbar(){
		//statusbar div
		var uiStatus = document.createElement("div");
		uiStatus.setAttribute("style","visibility:hidden;position:absolute;width:400px;left:0px;top:0px;font:normal 9px Tahoma;background:#ffffca;padding:4px;color:#330000;border:1px #999 solid;z-index:100;");
		uiStatus.setAttribute("id","uiStatus");
		
		var statusText = document.createTextNode("Loading...");
		uiStatus.appendChild(statusText);
		
		window.document.documentElement.appendChild(uiStatus);
		
		
	}

	function iecompattest(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	function closestatus(){
		document.getElementById("uiStatus").style.visibility="hidden"
	}

	function showstatus(){
		if(!document.getElementById("uiStatus")) _createstatusbar();
		
		barheight=document.getElementById("uiStatus").offsetHeight
		var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
		var d = document;
		function ml(id){
			var el=d.getElementById(id);
			el.style.visibility="visible"
			if(d.layers)el.style=el;
			el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
			el.x = startX;
			if (verticalpos=="fromtop")
			el.y = startY;
			else{
				el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
				el.y -= startY;
			}
			return el;
		}
		window.stayTopLeft=function(){
			if (verticalpos=="fromtop"){
				var pY = ns ? pageYOffset : iecompattest().scrollTop;
				ftlObj.y += (pY + startY - ftlObj.y)/8;
			}
			else{
				var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
				ftlObj.y += (pY - startY - ftlObj.y)/8;
			}
			ftlObj.sP(ftlObj.x, ftlObj.y);
			setTimeout("stayTopLeft()", 10);
		}
		ftlObj = ml("uiStatus");
		stayTopLeft();
	}


}




// this is to get a function return from an ajax call
function jsphp_getval(url){

	var strURL= url;

	// if Mozilla, Safari etc
	if (window.XMLHttpRequest) 
	req = new XMLHttpRequest()
	// if IE
	else if (window.ActiveXObject){ 

		try {
			req = new ActiveXObject("Msxml2.XMLHTTP")
		} 

		catch (e){

			try{ req = new ActiveXObject("Microsoft.XMLHTTP") }catch (e){}
		}

	}else{
		
		alert('This Browser do not support AJAX-Technology!');
		return ;

	}
	
	
	if (req)
	{
		req.onreadystatechange = function()
		{
			if (req.readyState == 4)
			{
				return req.responseText;
			}
		}

		req.open('GET', strURL, true);
		req.send(null);
		
		alert(req.responseText);
		
		return req.responseText;
		
	}
}



// probably obsolete. if mask is set to 100%, no need to use this thing here really!

// don't know how in the heck this works, but it does make the mask readjust to 100% on window resize

( function( $ ){ 

	$.fn.wresize = function( f ){ 
		
		version = '1.1'; 
		wresize = {fired: false, width: 0}; 
		

		function resizeOnce(){ 
			if ( $.browser.msie ){ 
				if ( ! wresize.fired ){ 
					wresize.fired = true; 
				} 
				else  
				{ 
					var version = parseInt( $.browser.version, 10 ); 
					wresize.fired = false; 
					if ( version < 7 ) 
					{ 
						return false; 
					} 
					else if ( version == 7 ) 
					{ 
						//a vertical resize is fired once, an horizontal resize twice 
						var width = $( window ).width(); 
						if ( width != wresize.width ) 
						{ 
							wresize.width = width; 
							return false; 
						} 
					} 
				} 
			} 

			return true; 
		} 

		function handleWResize( e )  
		{ 
			if ( resizeOnce() ) 
			{ 
				return f.apply(this, [e]); 
			} 
		} 

		this.each( function()  
		{ 
			if ( this == window ) 
			{ 
				$( this ).resize( handleWResize ); 
			} 
			else 
			{ 
				$( this ).resize( f ); 
			} 
		} ); 

		return this; 
	}; 

} ) ( $ );




/////////////////////////////////
// example of usage
// $('#exportxls_div').centerInClient({completeHandler: function(){  alert('hi');   } );

$.fn.centerInClient = function(options) {
	
	var opt = { forceAbsolute: false,
	container: window,    // selector of element to center in
	completeHandler: null
	};
	
	$.extend(opt, options);

	return this.each(function(i) {
		var el = $(this);
		var jWin = $(opt.container);
		var isWin = opt.container == window;

		// force to the top of document to ENSURE that 
		// document absolute positioning is available
		if (opt.forceAbsolute) {
			if (isWin)
			el.remove().appendTo("body");
			else
			el.remove().appendTo(jWin.get(0));
		}

		// have to make absolute
		el.css("position", "absolute");

		// height is off a bit so fudge it
		var heightFudge = isWin ? 2.0 : 1.8;

		var x = (isWin ? jWin.width() : jWin.outerWidth()) / 2 - el.outerWidth() / 2;
		var y = (isWin ? jWin.height() : jWin.outerHeight()) / heightFudge - el.outerHeight() / 2;

		var finalx = x + jWin.scrollLeft();
		var finaly= y + jWin.scrollTop();
		
		// this just makes sure the thing isnt off the screen
		if(finalx < 0) finalx = 0;
		if(finaly < 0) finaly = 0;
		
		el.css("left", finalx);
		el.css("top", finaly);
		
		//alert(finalx + ' ' + finaly);

		// if specified make callback and pass element
		if (opt.completeHandler)
		opt.completeHandler(this);
		
	});
}

// seems better than bringtofront
$.maxZIndex = $.fn.maxZIndex = function(opt) {
    // <summary>
    // Returns the max zOrder in the document (no parameter)
    // Sets max zOrder by passing a non-zero number
    // which gets added to the highest zOrder.
    // </summary>    
    // <param name="opt" type="object">
    // inc: increment value, 
    // group: selector for zIndex elements to find max for
    // </param>
    // <returns type="jQuery" />
    var def = { inc: 10, group: "*" };
    $.extend(def, opt);
    var zmax = 0;
    $(def.group).each(function() {
        var cur = parseInt($(this).css('z-index'));
        zmax = cur > zmax ? cur : zmax;
    });
    if (!this.jquery)
        return zmax;
				
    return this.each(function() {
        zmax += def.inc;
		
		//alert(zmax);
			
        $(this).css("z-index", zmax);
    });
}

// similar to the maxZIndex function above
$.fn.bringtofront = function() {

	var divs = getabsolutedivs();  
	var max_index = 0;  
	var cur_index;  
	var el = $(this);
	var divid = $(this).attr('id');
	var obj = document.getElementById(divid); 
	 
  
     // Compute the maximal z-index of  
     // other absolute-positioned divs  
     for (i = 0; i < divs.length; i++){
	 
		var item = divs[i]; 
		
		if (item == obj || item.style.zIndex == '')  
			continue;  
   
		cur_index = parseInt(item.style.zIndex);  
        
		if (max_index < cur_index){
			max_index = cur_index;  
		}  
	}
   
	// have to make absolute
	el.css("position", "absolute");
	// now brint it ahead
	el.css("zIndex", max_index + 1);
	

	

	function getabsolutedivs(){  
	
		var arr = new Array();  
		var all_divs = document.body.getElementsByTagName("DIV");  
		var j = 0;  
   
		for (i = 0; i < all_divs.length; i++)  
		if (all_divs.item(i).style.position=='absolute')  
		{  
			arr[j] = all_divs.item(i);  
			j++;  
		}  
		return arr;  
	}
}



