// determin if the an button as been clicked or the table row detail view has been clicked
// by default it is false, when clicking an action item, set this variable to true first.
var action_button = false;



function isUndefined(a) {
	return typeof a == 'undefined';
} 
function empty(v){
	return (v == null || v == '' || v == 0 || isUndefined(v));
}


function checkClick(obj,colour) {
	if (obj.checked) {
		obj.parentNode.parentNode.style.backgroundColor=colour;
		obj.parentNode.parentNode.className="the"+colour;
	} else {
		obj.parentNode.parentNode.style.backgroundColor="#F8F8F8";
		obj.parentNode.parentNode.className="norm";
	}
}

function rollOver(obj1, color, checked_color) {


/*
	if ( obj1.className == 'norm'){

		// non checked normal rows
		if (obj1.style.backgroundColor=="") {
			//alert('blank');
			obj1.style.backgroundColor=color

		}else if (obj1.style.backgroundColor=color) {
			//alert('current color'+obj1.style.backgroundColor);
			obj1.style.backgroundColor='';

		}else {
			//alert('checked color');

		}

	}else{
		// checked rows

		// non checked normal rows
		if (obj1.style.backgroundColor=="") {
			//alert('blank');
			obj1.style.backgroundColor=color

		}else if (obj1.style.backgroundColor=color) {
			//alert('current color'+obj1.style.backgroundColor);
			obj1.style.backgroundColor=checked_color

		}else {
			//alert('checked color');

		}


	}
*/

}


function open_win( the_url,  the_x, the_y, win_name,
											the_scrollbars, 
											the_toolbar, 
											the_menubar,
											the_do_resize,
											the_addressbar,
											the_directories,
											the_statusbar,
											the_copy_history,

											the_position,
											popupwindow
											){ 



	//var the_url = "http://localhost"
	if(!popupwindow){
		the_url += '&popupwindow=1&_nonav=1';
	}

	//var the_x = 640;
	//var the_y = 480;
	
	//the_x -= 0;
	//the_y -= 0;
	var how_wide = screen.availWidth;
	var how_high = screen.availHeight;

	if(the_position == 'center'){
		top_pos = (how_high/2) -  (the_y/2);
		left_pos = how_wide - ((how_wide/2) + (the_x/2));
	}else{
		top_pos = (how_high/2) -  (the_y/2);
		left_pos = how_wide - (the_x+15);
	}
	//if(what_link != ""){the_url=what_link;}
	if(empty(the_toolbar)) the_toolbar = "no";
	if(empty(the_addressbar)) 	the_addressbar = "no";
	if(empty(the_directories)) the_directories = "no";
	if(empty(the_statusbar)) the_statusbar = "yes";
	if(empty(the_do_resize)) the_do_resize =  "yes";
	if(empty(the_copy_history)) the_copy_history = "no";

	if(empty(the_scrollbars)) the_scrollbars = "yes";
	if(empty(the_menubar)) the_menubar = "yes";

	var site;

	if (window.outerWidth ){
		var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
		//alert(win_name);

		} else {
		var option = "toolbar="+the_toolbar+",width="+the_x+",height="+the_y+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
//		site=open('', "DisplayWindow", option);
	}


	//alert(option);
	site = window.open(the_url, win_name, option);
	site.resizeTo(the_x,the_y);
	site.moveTo(left_pos,top_pos);

	var Opera = (navigator.userAgent.indexOf('Opera') != -1);
	if(Opera){
		site.resizeTo(the_x,the_y);
		site.moveTo(0,0);
	}


	if(site){
		site.focus();
		//return false;
	}

	return site;
}



function spawnMainWindow(url){
	
	if(screen.width > 800)
		x = 900;
	else
		x = screen.width;

	if(screen.height > 600)
		y = 650;
	else
		y = screen.height;
						
	var site = open_win(url+"?", x, y,"ProcessStationMainWindow", "yes", "no", "yes", "yes", "no", "no", "yes", "no", "center", "no");

			
}







/*
var querywindow = '';

function open_querywindow(url, w, h) {

    if (!querywindow.closed && querywindow.location) {
		querywindow.focus();
	} else {
		//querywindow=window.open(url, '','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=550,height=310');
		querywindow=window.open(url, '','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width='+w+',height='+h);
	}

	if (!querywindow.opener) {
		querywindow.opener = self;
	}

	if (window.focus) {
		querywindow.focus();
		querywindow.location.href = url;
	}

	return false;
}

function setOpenerURL(url){
	opener.location.href=url;
}
*/

/*
function rs(n,u,w,h,x) {
	args="width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=0";
	remote=window.open(u,n,args);
	if (remote != null) {
		if (remote.opener == null)
			remote.opener = self;
		}
	if (x == 1) { return remote; }
}
*/


function spawnWin(a){
	var the_x=a.x;
	var the_y=a.y;
	the_x -= 0;
	the_y -= 0;
	var how_wide = window.screen.availWidth;
	var how_high = window.screen.availHeight;
	top_pos = (how_high/2) -  (the_y/2);
	left_pos = how_wide - the_x;
	var w=window.open(a.url, a.window_name, 'width='+the_x+',height='+the_y+',top='+top_pos+', left='+left_pos+', menubar,scrollbars,resizable,status=1');
	w.resizeTo(the_x,the_y);
	w.focus();
	// so a href link won't open when it s lciked
	return false;
}



