function getObj(oName)	{
	return findObj(oName,null,document);
}

function findObj( oName, oFrame, oDoc ) {
	if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else { oDoc = window.document; } }
	if( oDoc[oName] ) { return oDoc[oName]; } if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }
	if( oDoc.getElementById && oDoc.getElementById(oName) ) { return oDoc.getElementById(oName); }
	for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
	for( var x = 0; x < oDoc.anchors.length; x++ ) { if( oDoc.anchors[x].name == oName ) { return oDoc.anchors[x]; } }
	for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
		var theOb = findObj( oName, null, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
	if( !oFrame && window[oName] ) { return window[oName]; } if( oFrame && oFrame[oName] ) { return oFrame[oName]; }
	for( var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++ ) {
		var theOb = findObj( oName, oFrame.frames[x], oFrame.frames[x].document ); if( theOb ) { return theOb; } }
	return null;
}

function getAbsLeft(obj)	{
	if (obj==null) return 0;
	return obj.style.left+getAbsLeft(obj.parent);
}

/*function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}*/

function showObject(name)	{
	obj=get('xml');
	alert(obj.style);
}


function refreshImage(image)	{
	document.images[image+'_img'].src="/Images/"+getObj(image).value+".jpg";
	
}


function openWindow(ref)	{
	window.open(ref,'','toolbar=no,bar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=600,height=500,top=100,left=200');
}

function updateImageFromPopUp(field,value)	{
	image=findObj(field,null,window.opener.document);
	image.value=value;
	findObj(field+'_img',null,window.opener.document).src="/Images/"+findObj(field,null,window.opener.document).value+".jpg";
	window.close();
}

function updateAndSubmit()	{
	//alert("OK1");
	updateRTEs();
	//updateRTE('Content');
	//alert(document.RTEDemo.Content.value);
	//alert("OK2");
	return true;
}

function showHideAnswers() {
	s=document.StepItemForm.Type.value;
	if(s!="Text")	{
		document.all.Answers.style.display="";
	} else {
		document.all.Answers.style.display="none";
	}
}

function showDemo()	{
	window.open('/demo/','','toolbar=no,bar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=500,top=10,left=10');
}

function toggleMenu()	{
	rm=getObj('rightMenu');
	rmb=getObj('rightMenuButton');
	if(rm.style.display=='inline')	{
		rm.style.display='none';
		rmb.style.visibility='visible';
	} else {
		rm.style.display='inline';
		rm.style.position="absolute";
		rmb.style.visibility='hidden';
		
	}
}

function toggle_addcat(id,depth)	{
	btn=getObj('NEW'+id);
	row=getObj('ROW'+id);
	if(btn.innerHTML=="Cancel")	{
		row.style.display='none';
		btn.innerHTML='New';	
	}else{	
		row.style.display='inline';
		btn.innerHTML="Cancel";
	}
}

function printCert()	{
	d=getObj("GiftCert");
	nw=window.open('','','toolbar=no,bar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=600,height=500,top=100,left=200');
	nw.document.write(d.innerHTML);
	nw.print();
	nw.close();
}

function printSchedule()	{
	d=getObj("Schedule");
	nw=window.open('','','toolbar=yes,bar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=500,top=100,left=200');
//	nw.document.write('<body onLoad="alert(\'ok\');">');
	nw.document.write('<style type="text/css" media="all">@import "/styles.css";</style><style type="text/css" media="all">@import "/style.css";</style>');
	nw.document.write(d.innerHTML);
//	nw.document.write('</body>');	
	nw.print();
	nw.close();
}

var old="";
function highlightRow(o)	{
	old=o.style.backgroundColor;
	o.style.backgroundColor='rgb(200,0,0)';
}
function unHighlightRow(o)	{
	o.style.backgroundColor=old;
}

function showRTE(field)	{
	o=getObj("div_"+field);
	value=o.innerHTML;
	writeRichText(field,value , 400, 150, true, false);
}

