var type;
function button_over(eButton)
	{
		eButton.style.backgroundColor =	"LightSlateGray";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
	}
function button_out(eButton)
	{
		eButton.style.backgroundColor =	"threedface";
		eButton.style.borderColor =	"threedface";
	}
function button_down(eButton)
	{
		eButton.style.backgroundColor =	"#8494B5";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
	}
function button_up(eButton)
	{
		eButton.style.backgroundColor =	"#B5BDD6";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
		eButton	= null;	
	}
var	isHTMLMode=false
function document.onreadystatechange()
	{
		NewsBody_rich.document.designMode="On";		
	}
function cmdExec(cmd,opt) 
	{
		if (isHTMLMode)
		{
			alert("Formatting happens only in Normal mode");
			return;
		}
		NewsBody_rich.focus();
		NewsBody_rich.document.execCommand(cmd,"",opt);
		NewsBody_rich.focus();
	} // end cmdExec

function ChangeImage (ImageName,FileName) {
document[ImageName].src = FileName;
}

var intHCount = 0;
var intNCount = 0;

function setMode(Nbut, Hbut) 
	{
		var	sTmp;
		isHTMLMode = Hbut;
		isNormalMode = Nbut;

		if(Hbut == 1)
		{
			intHCount++;
			intNCount = 0;
		}

		if(Nbut == 1)
		{
			intNCount++;
			intHCount = 0;
		}	

		if (isHTMLMode && intHCount == 1)
		{
			sTmp=NewsBody_rich.document.body.innerHTML;NewsBody_rich.document.body.innerText=sTmp;
			ChangeImage ('HTMLbut','images/HTML_on.jpg');
			ChangeImage ('Normalbut','images/Normal_off.jpg'); return true;
		}
		if(isNormalMode && intNCount == 1)
		{
			sTmp=NewsBody_rich.document.body.innerText;NewsBody_rich.document.body.innerHTML=sTmp;
			ChangeImage ('HTMLbut','images/HTML_off.jpg');
			ChangeImage ('Normalbut','images/Normal_on.jpg'); return true;
		}
		NewsBody_rich.focus();
	} // end setMode
	
function createLink()
	{
		if (isHTMLMode){alert("Please uncheck 'Edit	HTML'");return;}
		cmdExec("CreateLink");
	} // end createLink
	
function foreColor()
	{
		var	arr	= showModalDialog("ColorPalette.htm","","font-family:Verdana;	font-size:12; dialogWidth:18;	dialogHeight:18" );
		if (arr	!= null) cmdExec("ForeColor",arr);	
	} // end foreColor

function setImage()	
{ 
	var	imgSrc = " ";
	var	flag = 0;	
	while(imgSrc ==	" ")
	{
		var aa;
		var bb;
		aa=showModalDialog("pickImage.aspx","","font-family:Verdana;	font-size:12; dialogWidth:40;	dialogHeight:18" );
		
		imgSrc = GetFileName(aa);
		if (imgSrc == "	") alert("Please enter the required	URL");
		if(imgSrc != "")
		{
			cmdExec('insertimage', imgSrc);	
		}
	} // end while
} // end setImage

function GetFileName(filePath)
	{
	try
	{
		var len=filePath.length;
		var fileName;
		var index=1;
		var c=filePath.substring(len-index,len);
		while(c!='\\')
		{
			fileName=filePath.substring(len-index,len);
			index=index+1;
			c=filePath.substring(len-index,len-(index-1));
		}
		fileName="images/" + fileName;
		return fileName;
		}
		
		catch(err)
		{
		 return "";
		}
	}
			
function ShowCM(t,headerText)
	{
	NewsBody_rich.document.designMode='On';
	if (divContent.style.display=="block")
		{
			divContent.style.display="none";
		}
	else
		{
			divContent.style.display="block";
		}
	type=t;
	spnHeader.innerText=headerText;
	if(document.getElementById(type).value != '')
		{
		NewsBody_rich.document.body.innerHTML=document.getElementById(type).value;
		}
	}
function fillTxt(k)
		{
		var State = new Object()
		var aa;
		
		document.getElementById("hdnmsg").innerText=NewsBody_rich.document.body.innerHTML; 
		}
	
function ClearIFrame()
	{
	NewsBody_rich.document.body.innerHTML ='';
	divContent.style.display="none";
	}
function DisableSave(bool)
	{
		document.Form1.btnSaveHead.style.display="none";
		if(bool=='show')
		{	
			if(document.Form1.btnSaveHead.style.display=="none")
			{
				document.Form1.btnSaveHead.style.display="block";
			}
			else
			{
				document.Form1.btnSaveHead.style.display="none";
			}
		}
	}
		function Toggle(node1)
		{
			var node=document.getElementById(node1.id);
			// Unfold the branch if it isn't visible
			if (node.nextSibling.style.display == 'none')
			{
				node.childNodes.item(0).src = "Images\\minus.gif";
				node.nextSibling.style.display = '';
			}
			// Collapse the branch if it IS visible
			else
			{
				// Change the image (if there is an image)
				if (node.childNodes.length > 0)
				{
					if (node.childNodes.item(0).tagName == "IMG")
					{
						node.childNodes.item(0).src = "Images\\plus.gif";
					}
				}
				node.nextSibling.style.display = 'none';
			}
		}
		function setup()
		{
			var my=document.getElementById("main");
			my.nextSibling.style.display = 'none';
			
		}
		function evtmouseover(node)
		{
			var obj=document.getElementById(node.id);
			obj.style.cursor="hand";
			obj.style.color="#ffffff";
		}
		function evtmouseout(node)
		{
			var obj=document.getElementById(node.id);
			obj.style.cursor="auto";
			obj.style.color="#000000";
		}
		function evtclick(obj)
		{
			document.location=obj;
		}
		function relod()
		{
			var obj=document.getElementById("NewsBody_rich");
			obj.document.location.reload();
		}
