function getEditorValue(instanceName)
{	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance(instanceName);
  
	// Get the editor contents as XHTML.
	return oEditor.GetXHTML(true);  // "true" means you want it formatted.
}

function setEditorValue(instanceName, text)
{	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance(instanceName);
 	// Set the editor contents.
	oEditor.SetHTML(text);
}  	

//////////////////////
function getObjby(name)
{   if (document.getElementById)
	{	return document.getElementById(name);
	}else if (document.all)
	{	return document.all[name];
	}else if (document.layers)
	{	return document.layers[name];
	}
}

function SetRecordTextBoxNew(UcControl,FieldName,setdefault)
{
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	if(Field!=null)
	//Field.setAttribute('value',setdefault);
	Field.value=setdefault;
}
function SetRecordCheckBoxNew(UcControl,FieldName,_Default)
{
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	//if(Field!=null)
	//Field.setAttribute('checked',(_Default==1)?true : false );
	if(Field!=null)
		{
			//Field.setAttribute('checked',value_default);
			if (_Default==1)
			{
				Field.checked=true;
			}
			else
			{
				Field.checked=false;
			}
	   }
}

function SetFocus(UcControl,FieldName)
{
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	if(Field!=null)
	Field.focus();
}
function SetRecordFCK(UcControl,FieldName,RowObject,AttbName)
{ 
	var Obj=UcControl+'_'+FieldName;
	var text=RowObject.getAttribute(AttbName);
	var Field=getObjby(Obj);
	if(Field!=null)
		{
		 setEditorValue(Obj, text);
	    }
	
}

function SetRecordFCKNew(UcControl,FieldName,_default)
{ 
	var Obj=UcControl+'_'+FieldName;
	var text=_default;
	var Field=getObjby(Obj);
	if(Field!=null)
		{
		 setEditorValue(Obj, text);
	    }
	
}

function SetRecordLabel(UcControl,FieldName,RowObject,AttbName)
{     
	var Obj=UcControl+'_'+FieldName;
	var Field=getObj(Obj);
	if(Field!=null)
	{	
		//Field.setAttribute('value', RowObject.getAttribute(AttbName));
		Field.innerHTML=RowObject.getAttribute(AttbName);		
	}		
}
function SetRecordTextBox(UcControl,FieldName,RowObject,AttbName)
{     
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	if(Field!=null)
	{	
		//Field.setAttribute('value', RowObject.getAttribute(AttbName));
		Field.value=RowObject.getAttribute(AttbName);		
	}		
}
function SetRecordComboBox(UcControl,FieldName,RowObject,AttbName)
{  //mainForm.cboFunction.value=what.parent_id;
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
		if(Field!=null)
			{
				try{	
				     Field.value=RowObject.getAttribute(AttbName);
					}
				catch(err)
					{
					Field.setAttribute('value', RowObject.getAttribute(AttbName));
					}
			
				
			}
			
}
function SetRecordCheckBox(UcControl,FieldName,RowObject,AttbName)
{
	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);		
	if(Field!=null)
	{
		if (RowObject.getAttribute(AttbName)==1)
		{
			
			//Field.setAttribute('checked','checked');	
			Field.checked=true;
			//alert(Field.checked);		
		}
		else
		{
			//Field.removeAttribute('checked');
			//Field.setAttribute('checked',false);	
			Field.checked=false;
		}
	}
	//Field.setAttribute('checked',(RowObject.getAttribute(AttbName)==1)?true : false );
}

function SetRecordRadio(UcControl,FieldName,RowObject,AttbName,value_default)
{	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	if(Field!=null)
		{if(RowObject.getAttribute(AttbName)==value_default)
			{
			//Field.setAttribute('checked','checked');
			Field.checked=true;
			}
		else
			//Field.removeAttribute('checked');
			Field.checked=false;
	 }
	
}

function SetRecordRadioNew(UcControl,FieldName,value_default)
{	var Obj=UcControl+'_'+FieldName;
	var Field=getObjby(Obj);
	if(Field!=null)
		{
			//Field.setAttribute('checked',value_default);
			if (value_default==1)
			{
				Field.checked=true;
			}
			else
			{
				Field.checked=false;
			}
	   }
	
}

/*****************admin CSS**////////////////////////////
var ActiveCell = null
	
function active(what)
{	if (ActiveCell == what)
		return
	if (ActiveCell != null)
		ActiveCell.className = 'cell_normal'
	ActiveCell = what
	ActiveCell.className = 	'cell_active'	
}
	
function highlight(what)
{	if (ActiveCell != what)
		what.className = 'cell_over'
}
	
function lowlight(what)
{	if (ActiveCell != what)
		what.className = 'cell_normal'
}

var ActiveRec = null
	
function active_item(what)
{	if (ActiveRec == what)
		return
	if (ActiveRec != null)
		ActiveRec.className = 'cell_normal'
	ActiveRec = what
	ActiveRec.className =  'cell_active'	
}
	
function highlight_item(what)
{	if (ActiveRec != what)
		what.className = 'cell_over'
}
	
function lowlight_item(what)
{	if (ActiveRec != what)
		what.className = 'cell_normal'
}

function resetchosen()
{	if (ActiveRec != null)
	{	ActiveRec.className = 'cell_normal'
		ActiveRec = null
	}
}
