function valert_test(){
	//valert("content","title","yesno",0,"alert('1')^sender.close();alert('2')","label1","label2","label3");
	alerT("content","title",900,"label1","label2","alert('1')","alert('2')",1,0);
}
function valert(con,til,act,dgb,fnc,lbl_0,lbl_1,lbl_2){
	if(til){til=til.trim();}
	if(!til){til=sys_v;}
	var wid=0;
	var b1=lbl_0;
	var b2=lbl_1;
	var f1=false;
	var f2=false;
	if(act=='yesno' || act=='yesino'){
		var f=fnc.split('^');
		f1=f[0];f2=false;
		if(f.length>1){f2=f[1];}
	}	
	alerT(con,til,wid,b1,b2,f1,f2);
} 
function valert_fnc(sender,fnc){
	eval(fnc);
}
function alerT(con,til,wid,b1,b2,f1,f2,c1,c2){ 
	//if(!con){fire_event(ge('btn_valerT_cancel'),'click');return;}
	if(!con){var btn=ge('btn_valerT_cancel');if(!btn){btn=ge('btn_valerT_ok');}fire_event(btn,'click');return;}
	if(!b1){b1='Yes';}
	if(!til){til=sys_v;}
	if(!wid){wid=300;}
	if(!c1){c1='sender.close();'}else{c1="";}
	if(!c2){c2='sender.close();'}else{c2="";}
	if(!f1){
		f1={value:true,text:b1,onclick:alerT_close};
	}else{
		f1=c1+f1;
		f1={value:f1,text:b1,onclick:valert_fnc};
	}
	if(b2){
		if(!f2){
			f2={value:false,text:b2,onclick:alerT_close};
		}else{
			f2=c2+f2;
			f2={value:f2,text:b2,onclick:valert_fnc};
		}
	}
	var v=new valerT({
		skin:'valert', 
		width:wid,
		ok:f1,
		cancel:f2
	});
	v.show(til,con);	
	var top;
	var top_adj=25;
	v=v.html.alertWindow;
	v.style.display='block';
	top=(self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 - v.offsetHeight / 2;
	v.style.left=(self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 - v.offsetWidth / 2 + 'px';	
	v.style.top=(top-top_adj)+'px';
}	
function alerT_close(sender){sender.close();}
function alerT_drag(){var e = arguments[0] || window.event;drag_select(e,'win_valert');}
	
//Copyright (c) 2008 Lewis Linn White Jr.
//Author: Lewis Linn White Jr.

function valerT(settings){
	var that, modalWindow, iframe, alertWindow, titleBar, title, ricon, licon, contentArea, buttonArea, okButton, cancelButton, defaultCallback, okCallback, cancelCallback;

	//create version of ourself for use in closures
	that = this;
	
	//Create our settings
	this.settings = settings;
	
	//Create a namespae object to hold our html elements
	this.html = {};
	
	//ie6 test.  what a crappy browser
	this.isIE6 = (document.all && window.external && (typeof document.documentElement.style.maxHeight === 'undefined')) ? true : false;	
	
	// use the Default skin if none was provided
	this.settings.skin = this.settings.skin ? this.settings.skin : 'valerT';
	
	// Set up a default for OK setting
	if (!this.settings.ok) {
		defaultCallback = function ()	{	that.close();};
		this.settings.ok = {text: 'Ok', value: true, onclick: defaultCallback};
	}
	
	//Create our modal background
	modalWindow = document.createElement('div');
	modalWindow.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight : document.documentElement.scrollHeight) + 'px';
	modalWindow.style.width = document.documentElement.scrollWidth + 'px';
	if (!this.isIE6)	{
		modalWindow.style.background = 'url(valert/tp2.png)';  //transparent png with low opacity.  Provides a similar effect as opacy/filter settings, but without the memory leaks
	}
	modalWindow.style.position = 'absolute';
	modalWindow.style.left = '0px';
	modalWindow.style.top = '0px';
	modalWindow.style.zIndex = 998;
	modalWindow.style.visibility = 'hidden';
	document.body.appendChild(modalWindow);
	this.html.modalWindow = modalWindow;
	
	//shoehorn a iframe to cover our select elemtns for ie6.  what a crappy browser....
	if (this.isIE6)	{
		iframe = document.createElement('iframe');
		iframe.style.position = 'absolute';
		iframe.style.visibility = 'hidden';
		iframe.style.zIndex = 997;
		iframe.frameBorder = 0;
		iframe.style.position = 'absolute';
		document.body.appendChild(iframe);
		this.html.iframe = iframe;
		
		//also, need to add an alpha image loader for ie6 transparency affect.  again, style.filter has a huge memory leak
		modalWindow.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/tp2.png', sizingMethod='scale', enabled=true)";
	}
	
	//Create our alert window
	alertWindow = document.createElement('div');
	alertWindow.className = this.settings.skin + '_alertWindow';
	alertWindow.style.position = this.isIE6 ? 'absolute' : 'fixed';
	alertWindow.style.zIndex = 999;
	alertWindow.id = "win_valert";
	if (this.settings.width)	{
		alertWindow.style.width = this.settings.width + 'px';
	}
	document.body.appendChild(alertWindow);
	alertWindow.style.visibility = 'hidden';
	this.html.alertWindow = alertWindow;
	
	//Create out title bar
	titleBar = document.createElement('div');
	titleBar.className = this.settings.skin + '_titleBar';
	titleBar.onmousedown=alerT_drag;
	alertWindow.appendChild(titleBar);
	this.html.titleBar = titleBar;
	
	//Create our right Icon
	ricon = document.createElement('div');
	ricon.className = this.settings.skin + '_titleBarRightIcon';
	ricon.style.cssFloat = 'right';
	ricon.style.styleFloat = 'right';
	titleBar.appendChild(ricon);
	this.html.ricon = ricon;
	
	//Create our Left Icon
	licon = document.createElement('div');
	licon.className = this.settings.skin + '_titleBarLeftIcon';
	licon.style.cssFloat = 'left';
	licon.style.styleFloat = 'left';
	titleBar.appendChild(licon);
	this.html.licon = licon;
	
	//Create our span that goes in our title
	title = document.createElement('span');
	title.innerHTML = this.settings.title;
	titleBar.appendChild(title);
	this.html.title = title;
	
	//Create our main content area
	contentArea = document.createElement('div');
	contentArea.className = this.settings.skin + '_contentArea';
	contentArea.innerHTML = this.settings.text;
	if (this.settings.height){
		contentArea.style.height = this.settings.height + 'px';
	}
	alertWindow.appendChild(contentArea);
	this.html.contentArea = contentArea;
	
	//Create out button area
	buttonArea = document.createElement('div');
	buttonArea.className = this.settings.skin + '_buttonArea';
	alertWindow.appendChild(buttonArea);
	this.html.buttonArea = buttonArea;
	
	//Draw an OK button
	okButton = document.createElement('input');
	okButton.type = 'button';
	okButton.id = 'btn_valerT_ok';
	okButton.className = this.settings.skin + '_okButton';
	okButton.value = this.settings.ok.text;
	okCallback = function (){	that.settings.ok.onclick(that, that.settings.ok.value);};
	okButton.onclick = okCallback;
	buttonArea.appendChild(okButton);
	this.html.okButton = okButton;
	
	//Draw a cancel button, if present
	if (this.settings.cancel)	{
		cancelButton = document.createElement('input');
		cancelButton.type = 'button';
		cancelButton.id = 'btn_valerT_cancel';
		cancelButton.className = this.settings.skin + '_cancelButton';
		cancelButton.value = this.settings.cancel.text || 'Cancel';
		cancelCallback = function ()
		{
			that.settings.cancel.onclick(that, that.settings.cancel.value);
		};
		cancelButton.onclick = cancelCallback;
		buttonArea.appendChild(cancelButton);
		this.html.cancelButton = cancelButton;
	}
	
	//Center our alert box on the screen
	this.center();

}

valerT.prototype.show = function (titleText, contentText){
	if (contentText)	{
		this.html.title.innerHTML = titleText;
		this.html.contentArea.innerHTML = contentText;
	}
	if (titleText && !contentText)	{
		this.html.contentArea.innerHTML = titleText;
	}
	
	this.html.modalWindow.style.visibility = 'visible';
	this.html.alertWindow.style.visibility = 'visible';
	if (this.html.iframe)	{
		this.html.iframe.style.height = this.html.alertWindow.offsetHeight;
		this.html.iframe.style.width = this.html.alertWindow.offsetWidth;
		this.html.iframe.style.visibility = 'visible';
	}
	if (this.html.cancelButton)	{
		this.html.cancelButton.focus();
	}	else	{
		this.html.okButton.focus();
	}	
};
valerT.prototype.hide = function (){
	this.html.modalWindow.style.visibility = 'hidden';
	this.html.alertWindow.style.visibility = 'hidden';
	if (this.html.iframe)	{
		this.html.iframe.style.visibility = 'hidden';
	}
};
valerT.prototype.close = function (){
	var obj, prop;	
	//make sure our DOM objects are deleted and our onclick statements are nulled
	for (obj in this.html)	{
		if (this.html[obj].parentNode)		{
			if (this.html[obj].onclick)			{
				this.html[obj].onclick = null;
			}
			this.html[obj].parentNode.removeChild(this.html[obj]);
			delete this.html[obj];
		}
	}		
	//remove object properties
	for (prop in this)	{
		if (this[prop])		{
			this[prop] = null;
			delete this[prop];
		}
	}
};
valerT.prototype.center = function (){
	var alertWindow, scrollT, scrollL, iframe,top;
	var top_adj=25;
	alertWindow = this.html.alertWindow;
	var $valerT=alertWindow;
	if (alertWindow.style.position === 'absolute')	{
		scrollT = window.pageYOffset || document.documentElement.scrollTop;
		scrollL = window.pageXOffset || document.documentElement.scrollLeft;
		top=(self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 + scrollT - alertWindow.offsetHeight / 2;
		top=top-top_adj;
		alertWindow.style.left = (self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 + scrollL - alertWindow.offsetWidth / 2 + 'px';
		alertWindow.style.top = top + 'px';
		if (this.html.iframe)		{
			this.html.iframe.style.left = alertWindow.style.left;
			this.html.iframe.style.top = alertWindow.style.top;
		}
	}	else	{
		//alertWindow.style.display='block';
		//top=(self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 - alertWindow.offsetHeight / 2;
		//top=top-top_adj;
		//alertWindow.style.left = (self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 - alertWindow.offsetWidth / 2 + 'px';
		//alertWindow.style.top = top + 'px';
	}
};
