
/* WFX : JavaScript Document */

// -----------------------------------------------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  
	if(!d) d=document; 
	if ((p=n.indexOf("?"))>0 && parent.frames.length) 
	{ d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); }
	
  if (!(x=d[n]) && d.all) x=d.all[n]; 
	  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		
  for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
// -----------------------------------------------------------
function ToggleVisible(id)
{ 
	var el, img;
	
	el = MM_findObj(id);
	img = MM_findObj("img" + id);
	
  if (el && el.style.display == "none") 
	{ 
	  el.style.display="";
		if (img) img.src="templates/wfx/images/i_folder_open.gif"; 
	}
	else 
	{ 
	  el.style.display="none";
		if (img) img.src="templates/wfx/images/i_folder.gif"; 
	}
}
// -----------------------------------------------------------
/*
function ChangeFolderState(basename, id, img_dir, cookies_name)
{ 
	var el = MM_findObj(basename + id);
	var img = MM_findObj("img_" + basename + id);
	
  if (el && el.style.display == "none") 
	{ 
	  // открываем папку
		el.style.display = "";
		if (img) img.src = img_dir + "i_folder_open.gif"; 
		
		var date = new Date();
		date.setTime(date.getTime()+(365*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		
		document.cookie = cookies_name + id + "=1" + expires + "; path=/";
	}
	else 
	{ 
		// закрываем папку
	  el.style.display = "none";
		if (img) img.src = img_dir + "i_folder.gif"; 
		
		var date = new Date();
		date.setTime(date.getTime() - 1000);
		var expires = "; expires="+date.toGMTString();
		
		document.cookie = cookies_name + id + "=" + expires + "; path=/";
	}
}
*/
// -----------------------------------------------------------
function ConfirmOperation(operationURL, operation_message)
{
  if (confirm(operation_message + ". \n\nПодтверждаете ?")) 
	    window.location.href=operationURL;
  else alert ('Операция отменена');
}
// -----------------------------------------------------------
function ConfirmPostOperation(form_obj, operation_message)
{
  if (confirm(operation_message + ". \n\nПодтверждаете ?")) 
	    form_obj.submit();
  else alert ('Операция отменена');
}
// -----------------------------------------------------------
/*
function HighLight_ON(object_id)
{
  var el = document.all[object_id];
	el.style.backgroundColor = "#F6F6F6";
} 
// -----------------------------------------------------------
function HighLight_OFF(object_id)
{
  var el = document.all[object_id];
	el.style.backgroundColor = "#FFFFFF";
} 
*/
// -----------------------------------------------------------
function ButtonClick(object_id, action, disable)
{
	var el = MM_findObj(object_id);
	
	if ( disable ) el.onclick = '';
	
	eval(action.replace(/`/g, "'"));
}
// -----------------------------------------------------------
// 
//                    LIST FUNCTIONS
//
// -----------------------------------------------------------
function RowToggle( object_id )
{
	var obj = MM_findObj(object_id);
	var checkbox = MM_findObj('select_ids_' + object_id);
	var new_class_name = '';
	
	switch (obj.className)
	{
		case 'row_light': { new_class_name = 'row_light_selected'; break; }
		case 'row_dark':  { new_class_name = 'row_dark_selected';  break; }
		case 'row_light_selected': { new_class_name = 'row_light'; break; }
		case 'row_dark_selected':  { new_class_name = 'row_dark';  break; }
	}
	
	obj.className = new_class_name;
	checkbox.checked = !checkbox.checked;
}
// -----------------------------------------------------------
function RowMark( object_id, mark_selected )
{
	var obj = MM_findObj(object_id);
	var checkbox = MM_findObj('select_ids_' + object_id);
	
	if ( mark_selected != checkbox.checked ) RowToggle( object_id );
}
// -----------------------------------------------------------
var popUpWin=0;
function popUpWindow(URLStr, WinName, left, top, width, height)
{
  // alert('ok');
	popUpWin = open(URLStr, WinName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.focus();
	location.self;
} 
// -----------------------------------------------------------
function SelectItemImage( obj_id, image )
{
	document.all[ obj_id ].src=image;
}

// -----------------------------------------------------------  

