var editebleAlert = false;
var CarriageReturn 	= true; //inserts BR when enter key pressed, inserts P tag if false
var lastfocus = false; //inserts BR when enter key pressed, inserts P tag if false

function getEditArea()
{ 
   var objEditArea="";
   if(navigator.userAgent.indexOf("Netscape")!= -1 ){
       objEditArea = document.getElementById("editArea").contentWindow;
   }
   else if(navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1){
       objEditArea = document.getElementById("editArea").contentWindow;
   }
   else if(navigator.userAgent.indexOf("MSIE")!= -1){
      objEditArea = editArea;
   }
   return objEditArea;
}

function insertTableCheck()
{
  // isFocusPresent();

   var objEditArea="";
   if(navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1 || navigator.userAgent.indexOf("Netscape")!= -1)
   {
		
      insertTable_M();
   }
   else if(navigator.userAgent.indexOf("MSIE")!= -1)
   {
      insertTable_I();
   }
   return objEditArea;
}

     function isHTMLMode() 
     {
        if (HTMLMode) {
          // alert(TXT_Var48582);
           return true;
        }
        else {
           return true;
        }
     }

         var cmd_count =0;
         function cmdExec(cmd,opt) {   
         
            if (!isHTMLMode())
               return;
               
            var objEdit=getEditArea();
            var newNode;
            var sel;
            var range;
            
            if(isGECKO)
            {
             sel=objEdit.window.getSelection();
             range=sel.getRangeAt(0);
            }
          
            
            try 
            {                
               //  work around for bug id ff bugzilla - id 442186*/
               //alert(sel.focusNode==sel.anchorNode);
              // alert(cmd);
               if(isGECKO && !isWEBKIT && cmd!="insertorderedlist" && cmd!="insertunorderedlist")
               {
                  var cNode;
                  if( (cmd=="justifyleft"||cmd=="justifycenter"||cmd=="justifyright"||cmd=="indent"||cmd=="outdent"))
                  {
                    cNode = objEdit.document.createElement("DIV");
                  }
                  else 
                    cNode = objEdit.document.createElement("SPAN");     

                    try
                    {                    
                        range.surroundContents(cNode);                            
                        range.collapse(true);
                        //alert(range.collapsed);
                        newNode = objEdit.document.createElement("BR");
                        //alert(newNode);
                        range.insertNode(newNode);
                        
                        range.selectNodeContents(cNode);

                        if(cmd=="justifyleft")
                            cNode.style.textAlign="left";
                        else if( cmd=="justifycenter")
                            cNode.style.textAlign="center";
                        else if(cmd=="justifyright")
                            cNode.style.textAlign="right";
                        else
                          objEdit.document.execCommand(cmd, false, opt);           

                        //sel.collapse(cNode, 1);
                        sel.removeAllRanges();
                       var range = objEdit.document.createRange();
                        range.selectNodeContents(cNode);
                        sel.addRange(range);
                    }
                   catch(expobj)
                   {
                       //to handle NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR
                        objEdit.document.execCommand(cmd, false, opt);
                   } 

               }
               else
                  objEdit.document.execCommand(cmd, false, opt);
             
              //objEdit.focus();
            }
             catch (e) {
              // work around for bug id ff bugzilla - id 442186
              // alert('test');
               //range.collapse(true); 
               if(isGECKO && !isWEBKIT && e && e.result == 2147500037 )
               {
                 try {               
                  // alert(cmd);
                    var divNode = objEdit.document.createElement("DIV");
                    range.surroundContents(divNode);                            
                    range.collapse(true);
                    //alert(range.collapsed);
                    newNode = objEdit.document.createElement("BR");
                    //alert(newNode);
                    range.insertNode(newNode);
                    
                    range.selectNodeContents(divNode);

                    if(cmd=="justifyleft")
                        divNode.style.textAlign="left";
                    else if( cmd=="justifycenter")
                        divNode.style.textAlign="center";
                    else if(cmd=="justifyright")
                        divNode.style.textAlign="right";
                    else
                        objEdit.document.execCommand(cmd, false, opt);      
                        
                      
                    }
                  catch (e1) { 
                   //alert(e1.result);  
                  //alert(e1.toString());  
                  }
               
               } //end  work around for bug id ff bugzilla - id 442186
               else if(cmd == "cut" || cmd == "copy" || cmd =="paste")
               {
                  if(cmd_count==0 && cmd =="paste")
                  {}
                  else
                  {
                     alert("Use keyboard shortcuts for cut,copy and paste. For more information see help.")
                  }
               }
               else if(cmd == "Undo")
               {

               }
               else
               {                 
                  alert("This operation is not supported on your level of Mozilla.");
               }
            }
            //alert(objEdit.document.queryCommandValue () );
            if(newNode && isGECKO && !isWEBKIT)
            {              
              parent=newNode.parentNode;
              if(parent)
              parent.removeChild(newNode);
            }     

            cmd_count++;

         }
         
         function superScript()
         {
            if (!isHTMLMode())
               return;
            var objEditArea=getEditArea();
            objEditArea.focus();

             cmdExec("superscript",null);
         }


         function subScript()
         {
            if (!isHTMLMode())
               return;
            var objEditArea=getEditArea();
            objEditArea.focus();

          cmdExec("subscript",null);

         }
         
        function insertFile()
	    {
	             if (!isHTMLMode()) 
	                return;
	             var objEditArea=getEditArea();
	             objEditArea.focus();
	             var inner_window_width=650;
	             var inner_window_height=300;
	             var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
	             var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
	            // child_InsertImages = true;
	 
	           
	                InsertFiles = window.open('file_uploads.jsp', 'UploadFiles','top='+shell_window_top+',left='+shell_window_left+',width=680, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
	             
	            
         }


         function insertImage()
         {
		 	// isFocusPresent();
            
           if (!isHTMLMode())
               return;
            var objEditArea=getEditArea();
            
          try
          {
			if(isIE)
            setCursorFocus();
          }
          catch(e)
          {}          
		   
			var contentAreaNo = 1;
			var chkStatus = false;
			if(isIE)
			{
				if(startdivNode)
				{
					chkStatus = true;
				}
			}
			else
			{
				if(check_cursorlocation() && startdivNode)
				{
					chkStatus = true;
				}
			}
			
			if(chkStatus)
			{
				var contentAreaId = startdivNode.id;
				var noIndex = contentAreaId.indexOf("akcontEd_");
				if(noIndex != -1)
				{
					contentAreaNo = contentAreaId.substring(noIndex+"akcontEd_".length);
				}
				//alert(contentAreaId+" "+contentAreaNo);
			}
			
			if(!isDWT_DEPEND)
			{
				contentAreaNo = -1;
			}
			
		var called_from  = '';
		var z_index = 30;
		var scroll=false;
		if(l_str_goodie_flag == "0")
		 {
				called_from = 'shop_editor';
		 }
		var layer_width=700;
        var layer_height=480;
            var inner_window_width=650;
            var inner_window_height=300;
            var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
            var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
            child_InsertImages = true;
			if(isIE)
			{
				layer_sel_obj = editArea.document.selection.createRange();
			}
//alert(selected_obj+"edit");
            if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
            {
               seltext=objEditArea.getSelection();
               var range = seltext.getRangeAt(0);
               var pos = range.startOffset;
               var startNode = range.startContainer;
               var endNode = range.endContainer;
               var container = range.startContainer;
               var pos = range.startOffset;
               var img2 = container.childNodes[pos];
			   
			 var image_prop=new Array(); //Create new array to store image properties
			 var oIMG = container;
             
             if(!oIMG || isWEBKIT)
             oIMG=selected_obj;

			 var imgsource = oIMG.src;
			 if (!add_mode) {
			image_prop[0]=escape(oIMG.alt);
			if(selected_obj && selected_obj.getAttribute("width") == null)
			{
				image_prop[1]="";
			}
			else
			{
				image_prop[1]=oIMG.width;
			}
			if(selected_obj && selected_obj.getAttribute("height") == null)
			{
				image_prop[2]="";
			}
			else
			{
				image_prop[2]=oIMG.height;
			}
			
		
			image_prop[3]=oIMG.vspace;
			if(image_prop[3] == "-1")
			{
				image_prop[3] = "0";
			}
			image_prop[4]=oIMG.hspace;
			if(image_prop[4] == "-1")
			{
				image_prop[4] = "0";
			}
			image_prop[5]=oIMG.border;
			image_prop[6]=oIMG.align;
				try
				{

					var style_text = oIMG.style.MozOpacity;	
					if(style_text == "")
					{
						image_prop[7]=100;
					}
					else
					{
						var opct = parseFloat(style_text)*100;
						image_prop[7]=opct;
					}
				}
				catch(e)
				{
					image_prop[7]=100;
				}
			}
               if(selected_obj && selected_obj.nodeName == "IMG")
               {
                
                  if(wizard=="Blog")
                  {
						InsertImages = open_layer('/swiz/editor/edit_image.jsp?mode=1&imgsource='+imgsource+'&source='+oIMG.src+'&arrImgProp='+image_prop+'&win=modal&from='+called_from+'&ed_type='+l_str_editor+'&blog=y'+'&con_area_no='+contentAreaNo,'ImageProperties',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
						
                  }
                  else
				  {
						InsertImages = open_layer('/swiz/editor/edit_image.jsp?mode=1&imgsource='+imgsource+'&source='+selected_obj.src+'&win=modal&from='+called_from+'&arrImgProp='+image_prop+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'ImageProperties',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');

                  }
               }
               else
               {
                  if(wizard=="Blog")
                  {
                        //InsertImages = window.open('/blogwiz/editor/InsertImage.jsp', 'InsertImages','top='+shell_window_top+',left='+shell_window_left+',width=680, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
						InsertImages = open_layer('/blogwiz/editor/InsertImage.jsp?mode=1&imgsource='+imgsource+'&win=modal&from='+called_from+'&arrImgProp='+image_prop+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'InsertImages',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
                  }
                  else
                  {
                        //InsertImages = window.open('InsertImage.jsp', 'InsertImages','top='+shell_window_top+',left='+shell_window_left+',width=680, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
						InsertImages = open_layer('/swiz/editor/InsertImage.jsp?mode=1&imgsource='+imgsource+'&win=modal&from='+called_from+'&arrImgProp='+image_prop+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'InsertImages',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
                       
                  }
               }
            }
            else
            {
			
			var oIMG = objEditArea.document.selection.createRange();
			var add_mode = false;
            
			try
			{
				oIMG = oIMG.item(0);              

			}catch(e)
			{
             // alert(e.message);
            // alert(selected_obj.tagName);
                if(selected_obj && selected_obj.tagName=="IMG" )
                	oIMG=selected_obj;
                else    
				add_mode = true;
			}

			var image_prop=new Array(); //Create new array to store image properties

			 if (!add_mode) {
			
			image_prop[0]=escape(oIMG.alt);
			var oIMGTag = oIMG.outerHTML;
			oIMGTag = oIMGTag.toLowerCase();
			if(oIMGTag.indexOf("width") != -1)
			{
				image_prop[1]=oIMG.width;
			}
			else
			{
				image_prop[1]="";
			}
			if(oIMGTag.indexOf("height")  != -1)
			{
				image_prop[2]=oIMG.height;
			}
			else
			{
				image_prop[2]="";
			}
   			image_prop[3]=oIMG.vspace;
   			image_prop[4]=oIMG.hspace;
   			image_prop[5]=oIMG.border;
   			image_prop[6]=oIMG.align;
				try
				{
					var style_text = oIMG.style.filter;			
					var style_start = style_text.indexOf("opacity=");
					var style_end = style_text.indexOf(")");
					//alpha(opacity=100); 

					if(style_start != -1 && style_end != -1)
					{
					
						style_text = style_text.substring(style_start+8,style_end);
					}
		   			if(style_text == "")
					{
						image_prop[7]=100;
					}
					else
					{
						image_prop[7]=style_text;
					}
				}
				catch(e)
				{
					image_prop[7]=100;
				}
			}

               if(wizard=="Blog")
               {
                  if (!add_mode) {
                     //InsertImages = window.open('/blogwiz/editor/image_prop_adv.jsp', 'ImageProperties','top='+shell_window_top+',left='+shell_window_left+',width=480, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
					 InsertImages = open_layer('/swiz/editor/edit_image.jsp?mode=1&source='+oIMG.src+'&arrImgProp='+image_prop+'&win=modal&from='+called_from+'&ed_type='+l_str_editor+'&blog=y'+'&con_area_no='+contentAreaNo,'ImageProperties',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
					 
                  }
                  else
                  {
                     //InsertImages = window.open('/blogwiz/editor/InsertImage.jsp', 'InsertImages','top='+shell_window_top+',left='+shell_window_left+',width=680, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
					 InsertImages = open_layer('/blogwiz/editor/InsertImage.jsp?mode=1&win=modal&from='+called_from+'&arrImgProp='+image_prop+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'InsertImages',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
                     
                      InsertImages.callOnclose=setCursorFocus; 
                        //alert(InsertImages.callOnclose);                     
                  }
               }
               else
               {
                  if (!add_mode) {
                     //InsertImages = window.open('image_prop_adv.jsp', 'ImageProperties','top='+shell_window_top+',left='+shell_window_left+',width=480, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');

					 InsertImages = open_layer('/swiz/editor/edit_image.jsp?mode=1&source='+oIMG.src+'&arrImgProp='+image_prop+'&win=modal&from='+called_from+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'ImageProperties',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
                     
                      InsertImages.callOnclose=setCursorFocus; 
                       // alert(InsertImages.callOnclose);
                     
                  }
                  else
                  {
                     //InsertImages = window.open('InsertImage.jsp', 'InsertImages','top='+shell_window_top+',left='+shell_window_left+',width=680, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
					InsertImages = open_layer('/swiz/editor/InsertImage.jsp?mode=1&win=modal&from='+called_from+'&arrImgProp='+image_prop+'&ed_type='+l_str_editor+'&con_area_no='+contentAreaNo,'&nbsp;Edit Image',layer_width,layer_height,true,window.top,window.top,scroll,l_str_editor,z_index,'');
                    
                     InsertImages.callOnclose=setCursorFocus; 
                      //  alert(InsertImages.callOnclose);
                    
                  }
               }
            }
         }


         function cleanDoc() {
         
            if (!isHTMLMode())
               return;
               
            var objEditArea=getEditArea();
            var conf=confirm(TXT_Var48581);
            
            if(!conf)
            return false;
            
            //IE8 cusor focus retaining in pop up
				setCursorForIe8();
				
			if(isDWT_DEPEND &&conf)
            {
              
               if(check_cursorlocation() && startdivNode)
               {
                // alert(startdivNode);
                  startdivNode.innerHTML="&nbsp;";
               }
               return;
            }            
               
            objEditArea.focus();

              var s;                                 //new
              var objEditArea=getEditArea();
                s=objEditArea.document.body.innerHTML;                  //new
            if (s.length!=0) {                              //new
              // var conf=confirm(TXT_Var48581)

               if (conf)
               {
                  objEditArea.document.body.innerHTML = "&nbsp;";
                  //objEditArea.focus();
                  if(cssurl==""|| cssurl==null)
                  {
                     //alert("specify the css url name");
                  }
                  else
                  {
                     addstyle();
                  }
               }
               else
               { return;
               }
            }                                         //new
            else {
               objEditArea.document.body.innerHTML = "";          //new
               if(cssurl==""|| cssurl==null)
               {
                  //alert("specify the css url name");
               }
               else
               {
                  addstyle();
               }
            }                                         //new
            objEditArea.focus();
         }

          function insertSpecialSymbols() {
		 
		  var objEditArea=getEditArea();

		   	  
            if (!isHTMLMode())
               return;

               
               if(isDWT_DEPEND)
               {
                    if(!check_cursorlocation())
                    {
                       // alert(TXT_Var48692);
                        if(select_range && select_range.select)
                        {
                            select_range.select();
                            select_range.collapse(false);
                        }
                        else                        
                            setCursorFocus();
                    } 
               }
               else
                objEditArea.focus();

               var str;
               str=null;               //null initially
            var inner_window_width=250;
            var inner_window_height=300;
            var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
            var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
         child_SpecialSymbols = true;
        // InsertSymbols =   window.open('InsertSymbols.htm', 'InsertSymbols','top='+shell_window_top+',left='+shell_window_left+',width=600, height=200, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
		 var called_from  = '';
		var z_index = 30;
		var scroll=true;
		if(l_str_goodie_flag == "0")
		 {
				called_from = 'shop_editor';
		 }
		InsertSymbols = open_layer('/swiz/editor/InsertSymbols.jsp?win=modal&from='+called_from+'&ed_type='+l_str_editor,'InsertSymbols',600,200,true,window.top,window.top,scroll,l_str_editor,z_index,'');
          }


var command = "";
var link="";
         function foreColor() {
            if (!isHTMLMode())
               return;
               var objEditArea=getEditArea();               
               
           //IE8 cusor focus retaining in pop up
		   		setCursorForIe8();
               if(isDWT_DEPEND)
               {
                    if(!check_cursorlocation())
                    {
                        alert(TXT_Var48692);
                        setCursorFocus();
                        return false;
                    } 
               }
               else
                objEditArea.focus();
                if( isGECKO && lastfocus)
                {
                   alert(TXT_Var48692);
                   objEditArea.focus();
                   return false;
                }
                
                
            command = "forecolor";
            var inner_window_width=250;
            var inner_window_height=300;
            var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
            var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
            child_colors = true;
            //colors = window.open('selcolor.html', 'colors','top='+shell_window_top+',left='+shell_window_left+',width=240, height=190, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
			
		var called_from  = '';
		var z_index = 30;
		var scroll=false;
		if(isIE)
		{
			layer_sel_obj = editArea.document.selection.createRange();
		}
		if(l_str_goodie_flag == "0")
		 {
				called_from = 'shop_editor';
		 }
		colors = open_layer('/swiz/editor/color_palete.jsp?win=modal&from='+called_from+'&ed_type='+l_str_editor,'colors',350,310,true,window.top,window.top,scroll,l_str_editor,z_index,'');
		//colors = open_layer('/swiz/editor/selcolor.jsp?win=modal&from='+called_from+'&ed_type='+l_str_editor,'colors',240,190,true,window.top,window.top,scroll,l_str_editor,z_index,'');
         }

function backColor() {
            if (!isHTMLMode())
               return;
            command = "backcolor";
            var inner_window_width=250;
            var inner_window_height=300;
            var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
            var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
            child_colors = true;
            //colors = window.open('selcolor.html', 'colors','top='+shell_window_top+',left='+shell_window_left+',width=240, height=170, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
			var called_from  = '';
		var z_index = 30;
		var scroll=false;
		colors = open_layer('/swiz/editor/selcolor.jsp?win=modal&from='+called_from+'&ed_type='+l_str_editor,'colors',240,190,true,window.top,window.top,scroll,l_str_editor,z_index,'');
         }

function insertcolor_child(color)
{
   if (!isHTMLMode())
               return;
   var objEditArea=getEditArea();

   if(command=='backcolor')
   {
   if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
   {
     var sel=objEditArea.getSelection();
      var bgcolor= objEditArea.document.createElement("font");
      var style="BACKGROUND-COLOR: "+color;
      bgcolor.setAttribute("style", style);
      insertHTML(bgcolor, sel);
      cmdExec('foreColor',color);
   }
   else
   {
      objEditArea.document.execCommand(command, false,color);
   }
   }
   else
   {
	   if(isIE)
	   {
		sel = layer_sel_obj;
		sel.select();
		//editArea.focus();
		}

	  cmdExec('foreColor',color);
   }
   objEditArea.focus();
}

         function TableProperties() {
            if (!isHTMLMode())
               return;
            var arr=null;
            var args=new Array();

            var propTable = getCurrTable();
            if (propTable != null){
               args["edit"]=1;
               args["vTWidth"]=propTable.getAttribute("width",0);
               args["vTAlign"]=propTable.getAttribute("align",0);
               args["vTBrSize"]=propTable.getAttribute("border",0);
               args["vTBrClr"]=propTable.getAttribute("borderColor",0);
               args["vCellSp"]=propTable.getAttribute("cellSpacing",0);
               args["vCellPd"]=propTable.getAttribute("cellPadding",0);
               //args["vCellBgClr"]="";
               //args["vCellVerAlign"]="";
               arr=window.showModalDialog("TableProperties.jsp", args, "dialogWidth:30em; dialogHeight:20em" );
               if (arr !=null) {
                  //propTable.setAttribute("width",arr["vTWidth"]+"%",0);
                  propTable.setAttribute("width",arr["vTWidth"],0);
                  propTable.setAttribute("align",arr["vTAlign"],0);
                  propTable.setAttribute("border",arr["vTBrSize"],0);
                  propTable.setAttribute("borderColor",arr["vTBrClr"],0);
                  propTable.setAttribute("cellSpacing",arr["vCellSp"],0);
                  propTable.setAttribute("cellPadding",arr["vCellPd"],0);
               }

            }
         }
         function insertTable_I() {
               if (!isHTMLMode())
               return;
               var objEditArea=getEditArea();
			   
		//IE8 cusor focus retaining in pop up
				setCursorForIe8();
//alert('test');
               if(isDWT_DEPEND)
               {
                    if(!check_cursorlocation())
                    {
                        alert(TXT_Var48692);
                        setCursorFocus();
                        return false;
                    } 
               }
               else
                objEditArea.focus();
               
            if (editArea.document.selection.type!="None") {
               window.alert("Deselect Text/Object and Try Again");
               return;
            }
            if (editArea.document.selection.type=="None") {

            var htmLstr;
            var arr=null;
            var args=new Array();
            args["edit"]=null;
            args["vTRows"]=3;//rows1;  //Rows
            args["vTCols"]=2;//cols1;  //Columns
            args["vTWidth"]=100;//tblwidth;
            args["vTAlign"]="center";//tblalign;
            args["vTBrSize"]=1;//tblbrsize;
            args["vTBrClr"]="Red";//tblbrclr;
            args["vCellSp"]=0;//tblcellsp;
            args["vCellPd"]=0;//tblcellpd;
            args["vCellBgClr"]="";//cellbgclr;
            args["vCellVerAlign"]="Middle";//cellvertaln;

            //arr=window.showModalDialog("/swiz/editor/InsertTable.jsp", args, "dialogWidth:32em; dialogHeight:25em" );
			
			
		var called_from  = '';
		var z_index = 30;
		var scroll=false;
		arr = open_layer('/swiz/editor/InsertTable.jsp?win=modal&from='+called_from+'&ed_type='+l_str_editor,'InsertTable',500,310,true,window.top,window.top,scroll,l_str_editor,z_index,'');
		
            }
         }

		 function insertTableUi(evnt,arr)
		 {
         
         
         
            if (arr !=null) {

               rows1=arr["vTRows"];     //Rows
               cols1=arr["vTCols"];      //Cols
               tblwidth=arr["vTWidth"];   //Width
               tblalign=arr["vTAlign"];    //Tbl Align;
               tblbrsize=arr["vTBrSize"];   //Border Size
               tblbrclr=arr["vTBrClr"];      //Tbl Border Color
               tblcellsp=arr["vCellSp"];     //Cell Spacing
               tblcellpd=arr["vCellPd"];      //Cell Padding
               cellbgclr=arr["vCellBgClr"];    //Cell Bg Color
               cellvertaln=arr["vCellVerAlign"]; //Cell Vert.Align


               if ((rows1!=null) && (cols1!=null)) {
                  if(cellbgclr!="") {
                     htmLstr = "<TABLE class=table BGCOLOR=" +cellbgclr +" BORDER=" +tblbrsize +" BORDERCOLOR=" +tblbrclr +" WIDTH=" +tblwidth +"% ALIGN=" +tblalign+ " CELLPADDING="+tblcellpd +" CELLSPACING=" +tblcellsp +">"
                     cellbgclr=cellbgclr;
                  }
                  else {
                     htmLstr = "<TABLE class=table BORDER=" +tblbrsize +" BORDERCOLOR=" +tblbrclr +" WIDTH=" +tblwidth +"% ALIGN=" +tblalign+ " CELLPADDING="+tblcellpd +" CELLSPACING=" +tblcellsp +">"
                  }
                  for (row1 = 1; row1<=rows1; row1++) {
                     htmLstr += "<TR>"
                     for (col1 = 1; col1<=cols1; col1++) {
                        htmLstr += "<TD VALIGN=" +cellvertaln +" BGCOLOR=" +cellbgclr +">&nbsp;</TD>"
                     }
                     htmLstr += "</TR>"
                  }
                  htmLstr += "</TABLE>"

                  if (editArea.document.selection.type=="None") {
                     var sel=editArea.document.selection.createRange();
					 sel = layer_sel_obj;
                     
                    if(select_range && select_range!=''  &&  select_range.select)
                     sel = select_range;    
                     
                     sel.pasteHTML(htmLstr);
                     sel.select();
                     editArea.focus();
					 var styleMenu=document.getElementById("table_layer");       
					 hideLayer(evnt,styleMenu); 
                  }
               }
               else
			   {
				 editArea.focus();
			   }
            }
		 }

         function createLink() {
         
            if (!isHTMLMode())
               return;
               
            var objEditArea=getEditArea();
			
		//IE8 cusor focus retaining in pop up
			setCursorForIe8();
            
              if(isDWT_DEPEND)
               {
                    if(!check_cursorlocation())
                    {
                        alert(TXT_Var48692);
                        setCursorFocus();
                        return false;
                    } 
               }
              // else
               // objEditArea.focus();
				
            var new_win = '';
            var selected_link_url = '';
            var selected_link_id = '';
            var display_text = '';
			
			if(navigator.userAgent.indexOf("MSIE")!= -1)
            {
				//var selected_link = objEditArea.document.selection.createRange().parentElement();
				var selected_link = objEditArea.document.selection.createRange();
				if(objEditArea.document.selection.type != "Control")
				{
					selected_link = objEditArea.document.selection.createRange().parentElement();
				}
				
				if(selected_link.nodeName == "A")
				{
					selected_link_url = selected_link.href;
					selected_link_id = selected_link.id;
					new_win = selected_link.target;
                    
                    if(selected_obj && selected_obj.nodeName=="IMG")
                      display_text =  "";
                    else if(selected_obj.innerText)                    
                        display_text = escape(selected_obj.innerText);
                    else if(selected_link.innerHTML)
                        display_text = escape(selected_link.innerHTML);
				}
            }
            else if(navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1 || navigator.userAgent.indexOf("Netscape")!= -1)
            {
               	seltext=objEditArea.getSelection();
				var range = seltext.getRangeAt(0);
				var container = range.startContainer;
                
                if(selected_obj)
                 container=selected_obj;               
                
      
                if(selected_obj && selected_obj.nodeName != "A" && selected_obj.parentNode && selected_obj.parentNode.nodeName== "A") 
                    container=selected_obj.parentNode;

                 if(container.nodeName == "A")
				{
					selected_link_url = escape(container.href);
					selected_link_id = escape(container.id);
					new_win = container.target;
                    
                    if(selected_obj && selected_obj.nodeName=="IMG")
                      display_text =  "";
                    else if(selected_obj.text)                    
                        display_text = escape(selected_obj.text);
                    else
                        display_text = escape(container.innerHTML);
				}

            }

            command = "CreateLink";
            var inner_window_width=650;
            var inner_window_height=250;
            var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
            var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);
            child_link = true;
            //links = window.open('InsertLink.jsp', 'links','top='+shell_window_top+',left='+shell_window_left+',width=650, height=320, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
			
		var called_from  = '';
		var z_index = 30;
		var scroll=false;
		if(isIE)
		{
			layer_sel_obj = editArea.document.selection.createRange();
			if(display_text == "")
			{
				if(layer_sel_obj.text)
				display_text = layer_sel_obj.text;
			}
		}
		if(l_str_goodie_flag == "0")
		 {
				z_index = 35;
				called_from = 'shop_editor';
		 }
		 
		 selected_link_url = selected_link_url.replace(/%20/g,' ');
		 
		 
		colors = open_layer('/swiz/editor/InsertLink.jsp?link_url='+selected_link_url+'&link_id='+selected_link_id+'&display_text='+display_text+'&new_win='+new_win+'&win=modal&from='+called_from+'&ed_type='+l_str_editor,'&nbsp;Edit Link',700,300,true,window.top,window.top,scroll,l_str_editor,z_index,'');
		colors.callOnclose=setCursorFocus;
			
         }
function insertLinkText(win, insertNode)
  {
   text1 = objEdit.document.createTextNode(text);
   try
   {
   var objEdit=getEditArea();
    var html1 = document.createTextNode(objEdit.document.body.innerHTML);

    objEdit.document.body.innerHTML = "";

    objEdit.document.body.appendChild(html1);

    var html = objEdit.document.body.ownerDocument.createRange();
     html.selectNodeContents(objEdit.document.body);
     html = html.toString();
      var newtext1 = insertNode.substring( 0,1 );
   var newtext2 = insertNode.substring( 1,insertNode.length);
   var newtext3 = newtext1+"amp;"+newtext2;

   var myregExp_grt = new RegExp(newtext3,"g");
   html = html.replace(myregExp_grt,insertNode);

      objEdit.document.body.innerHTML = html.toString();
   }
   catch(e)
   {
      alert("Please Select The Edit Area & Insert Symbols");
   }
   };
function insertHTML(insertNode, seltext)
{
   var objEditArea=getEditArea();
   html = document.createTextNode(objEditArea.document.body.innerHTML);
   var sel ="";
   sel = window.frames[0].getSelection();
      var range = sel.getRangeAt(0);
      var inNode="";
   var frag ="";
   var container ="";
   if(sel=="")
   {
      var inNode = document.createTextNode(seltext);
      insertNode.appendChild(inNode);
   }
   else
   {
      frag = range.extractContents();
      insertNode.appendChild(frag);
   }
    var container = range.startContainer;
            if(container.nodeType==1 &&  insertNode.nodeType==1)
            {
         objEditArea.document.body.innerHTML = "";
         objEditArea.document.body.appendChild(html);
               setMode(false);
               return;
         }
      var pos = range.startOffset;
      range=document.createRange();
          var textNode = container;
          container = textNode.parentNode;
          var text = textNode.nodeValue;
          if(text==null)
          {
            text="";
          }
          var textBefore = text.substr(0,pos);
          var textAfter = text.substr(pos);
          var beforeNode = document.createTextNode(textBefore);
          var afterNode = document.createTextNode(textAfter);
          container.insertBefore(afterNode, textNode);
          container.insertBefore(insertNode, afterNode);
          container.insertBefore(beforeNode, insertNode);
          container.removeChild(textNode);
}
function setStyle(editor,htmlmode,name,value)
{

   var objEditArea=getEditArea();
   if( (cssurl=="" || cssurl==null )&& (!(isDWT_DEPEND)))
   {
      alert("Please specify the CSS url.");
      document.frmShowEditor.css1.selectedIndex=0;
      objEditArea.focus();
      return;
   }

   if (htmlmode || value=="Choose style")
   {
      document.frmShowEditor.css1.selectedIndex=0;
      objEditArea.focus();
      return;
   }
   if(navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1 || navigator.userAgent.indexOf("Netscape")!= -1)
   {
      //document.createStyleSheet();
      var sel = objEditArea.getSelection();
      var str=sel;
      var span = objEditArea.document.createElement("span");
      span.setAttribute("class",value);
      oRange=sel.getRangeAt(0);
      oRange.surroundContents(span);
      //insertHTML2(span, str);
   }
   else if(navigator.userAgent.indexOf("MSIE")!= -1)
   {
   if(!isDWT_DEPEND)
      objEditArea.document.createStyleSheet(cssurl) ;
      if (htmlmode) return;
      if (value != '') {

         doStyle(value);
      }
   }
   //alert(cssurl);
   //document.frmShowEditor.css1.selectedIndex=0;
   objEditArea.focus();
}


function addstyle()
{
   var objEditArea=getEditArea();
   
   var home_css = cssurl;
   try
   {
	//Taking the relating css path from absolute path
		var last_slash_ind = cssurl.lastIndexOf("/");
		var dot_ind = cssurl.lastIndexOf(".");
   
		if(last_slash_ind != -1 && dot_ind != -1)
		{
			home_css = cssurl.substring(last_slash_ind+1,dot_ind);
		}
	}
	catch(e)
	{
	}
    
   var l_obj = objEditArea.parent.document;
  // alert(l_obj);
   if(l_str_editor == "1")
   {
   //Setting the Home page editor1 css file in Request,(this variable is a hidden field in text_editor.jsp)
		if(l_obj.getElementById("hid_home_css1"))
		{
		l_obj.getElementById("hid_home_css1").value = home_css;
		}
   }
   else if(l_str_editor == "2")
   {
    //Setting the Home page editor2 css file in Request,(this variable is a hidden field in text_editor.jsp)
		if(l_obj.getElementById("hid_home_css2"))
		{
		l_obj.getElementById("hid_home_css2").value = home_css;
		}
   }

   if(!isDWT_DEPEND)
   {
       var mystyle = document.createElement('link');
       mystyle.setAttribute('type', 'text/css');
       mystyle.setAttribute('rel', 'stylesheet');
       mystyle.setAttribute('href', cssurl);
   }
   
   var link='';
   if(objEditArea.document.body)
   link=objEditArea.document.body.innerHTML;

   if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
   {

	  //alert("test");
      //objEditArea.addEventListener("keyup", rightclick, false);
	  objEditArea.addEventListener("keypress", rightclick, false);
     // objEditArea.addEventListener("mousedown", f1, false);
     // objEditArea.addEventListener("mouseup", f2, false);
	  objEditArea.addEventListener("click", rightclick, false);	  
	  // if()
       objEditArea.addEventListener("mouseover", hideStyleMenu, false);    
       if(window.top)
       window.top.addEventListener("click", lostFocus, false);    

      if(!isDWT_DEPEND && link.indexOf("<link")>=0)
      {
         mystyle.removeAttribute('href');
         mystyle.setAttribute('href', cssurl);
      }
      else if(!isDWT_DEPEND)
      {
         objEditArea.document.body.appendChild(mystyle);
      }
   }
   else
   {
	  //objEditArea.document.body.onload = duringLoad;
	  //document.body.onmouseover= rightclick1;
	  document.body.onmouseover= rightclick1;
      
     if(!isDWT_DEPEND)
      objEditArea.document.createStyleSheet(cssurl) ;
      
      var sel=editArea.document.selection.createRange();
   }
}

function lostFocus()
{

 lastfocus=true;
 //alert(lastfocus);
}


function rightclick1()
{
	var objEditArea=getEditArea();
	
		objEditArea.document.body.onkeydown = onKeyDown;
		//objEditArea.document.body.onkeypress = onKeyDown ;
		objEditArea.document.body.onclick= onKeyDown;
		// objEditArea.document.body.onmousedown= rightclick ;
		objEditArea.document.body.onmouseup= onKeyDown ;
		objEditArea.document.body.ondragstart=scriptDrag;
	
}

function scriptDrag()
{
var objEditArea=getEditArea();
	if(!check_cursorlocation())
   {
		//alert("Please select a editable area scriptDrag");
		hideEDLayer();
		
		if(isGECKO)
		{
			var ediv_object=objEditArea.document.getElementsByTagName('div');
	            if(ediv_object!=null && ediv_object!=undefined && ediv_object.length!=0)
	            {   
	                for(i=0;i<ediv_object.length;i++)
	                {
	                    var content_object_id = ediv_object[i].id;

	                    //If Id is for Editable div then check content for compliant
						//alert("content_object_id "+content_object_id);
	                   if(content_object_id.indexOf("mesg_area") == 0)
	                   {
							
							var selection = objEditArea.getSelection();
							var sel=objEditArea.getSelection();                           
							selection.selectAllChildren(ediv_object[i]);
							selection.collapse(ediv_object[i],1);							
							evt.returnValue = false;
							evt.cancel = true;
							evt.preventDefault();
							return false;
						}
					}
				}
			}
			else
			{
				
				objEditArea.document.selection.empty();
				//oWindow.event.returnValue = false; 
		        //oWindow.event.cancelBubble = true;
		        return false;
			}
			return false;
   }
}
// This method is called during thre click event, for insert goodie in the selected page
// This is written for Goodie page Type

function dstart(evt)
{
	//alert(evt);
}

function duringLoad()
{
	  setCursorFocus();
}

function setCursorFocus(view)
{
       
		var objEditArea=getEditArea();
		var sel;
		var oRange;
       //alert(isWEBKIT);
        if(!isDWT_DEPEND)
        {
    		if(isGECKO)
    		{
    			sel = objEditArea.getSelection()
    			//oRange = sel.getRangeAt(0);
    			oRange = document.createRange() ;
                lastfocus=false;
    		}
    		else
    		{
                try
                {
                sel=objEditArea.document.selection;
                var temp1=objEditArea.document.body.innerHTML;
    			oRange = sel.createRange() ;
    			oRange.moveStart('character',temp1.length+1) ;
    			oRange.select() ;
                }
                catch(exp){}
    		}
    		objEditArea.focus();
        }
        else
        {
             //alert('select editable region');
                var ediv_object=objEditArea.document.getElementsByTagName('div');
                
                if(isGECKO && ediv_object!=null && ediv_object!=undefined && ediv_object.length!=0)
                {   
                    for(i=0;i<ediv_object.length;i++)
                    {
                        var content_object_id = ediv_object[i].id;

                        //If Id is for Editable div then check content for compliant
                       if(content_object_id.indexOf( "akcontEd")!=-1)
                       {
                            //ediv_object[i].scrollIntoView(true); 
                            //alert(select_range);
                           
                            if(isWEBKIT)
                            {
                              //  alert("test");
                                ediv_object[i].focus();
                                var sel=objEditArea.getSelection();
                                var oRange=sel.getRangeAt(0);
                                var _parent=ediv_object[i].parentNode;
                                //select all nodes of editable div
                                sel.selectAllChildren(ediv_object[i]);
                                sel.collapse(ediv_object[i],0); 
                                if(view)
                                {
                                //ediv_object[i].scrollIntoView(true);                              
                                }
                                lastfocus=false;
                                break;
                               // 
                            }
                            else if(!select_range && select_range=='')
                            {                   
                                  
                                ediv_object[i].focus();
                                var selection = objEditArea.getSelection();
                                var sel=objEditArea.getSelection();   
                                
                                if(ediv_object[i].firstChild)                                  
                                    selection.selectAllChildren(ediv_object[i]);
                                    
                                if(ediv_object[i].firstChild && (!ediv_object[i].firstChild.textContent || ediv_object[i].firstChild.textContent=="") && ediv_object[i].firstChild.nextSibling)
                                    selection.collapse(ediv_object[i].firstChild.nextSibling,0);         
                                else if(ediv_object[i].firstChild)
                                   selection.collapse(ediv_object[i].firstChild,0);    
                                else
                                  selection.collapse(ediv_object[i],0);  
                                  lastfocus=false;
                                  
                                if(view)
                                {
                                //ediv_object[i].scrollIntoView(true);                                    
                                }    
                                break;
                                //obj_range = sel.getRangeAt(0);
                                //obj_range.setStart(ediv_object[i].firstChild,0);

                            }                                                 
                                                    
                            
                        } 
                    }    
                
               }
               else
               {
                     var set_focus=false;
                    // alert(select_range.text);
                     try
                     {                     
                       if(select_range && select_range.select)
                       {             
                                                 
                            if(select_range.text && select_range.text!="")
                            {
                             try
                             {                             
                              select_range.select();                                       
                              set_focus=true;
                             }
                             catch(e)
							 {
							  // alert(e.toString());
							 }                             
                            } 
							else if(!select_range.text) // if selection other than text
							{
							
							  try
                             {
                               // alert("select");                               
                              select_range.select();                                       
                              set_focus=true;
                             }
                             catch(e)
							 {
							   //alert(e.toString());
							 }         
							}
                       }    
                     }
                     catch(e)                       
                     {
                     }
                       
                        
                       if(!set_focus)
                       {
                            for(i=0;i<ediv_object.length;i++)
                            {
                                var content_object_id = ediv_object[i].id;

                                //If Id is for Editable div then check content for compliant

                               if(content_object_id.indexOf("akcontEd")!=-1)
                               {
                                  try
                                  {  
                                   ediv_object[i].focus();
                                  // ediv_object[i].click();
                                         /*if(view)
                                                                                                            {
                                                                                                            anchorPos = ediv_object[i].offsetTop
                                                                                                            window.scrollTo(0,anchorPos);
                                                                                                            } */
                                    
                                  }
                                  catch(e)
                                  {//alert(e.message);
                                  }
                                break;
                               }
                            }   
                       }
               }     
           }
           
		window.status="Done";
		window.parent.document.body.style.cursor='default';
		document.body.style.cursor='default';

}

function insert_goodie()
{
// Reading goodie parameters

	if(isIE)
	{
		layer_sel_obj = editArea.document.selection.createRange();
	}
			
	goodie_par1 = window.parent.document.getElementById("hid_goodie_par1").value;
	goodie_par2 = window.parent.document.getElementById("hid_goodie_par2").value;
	goodie_par3 = window.parent.document.getElementById("hid_goodie_par3").value;
	goodie_par4 = window.parent.document.getElementById("hid_goodie_par4").value;
	goodie_par5 = window.parent.document.getElementById("hid_goodie_par5").value;
	goodie_par6 = window.parent.document.getElementById("hid_goodie_par6").value;
	goodie_content = window.parent.document.getElementById("hid_goodie_content").value;
	
// This variable is for finding the first click, incrementing for each click

	click_count = eval(window.parent.document.getElementById("click_count").value);
	
// This is specific for Animated cursors to replace quotes
			  
	  if(goodie_par1.indexOf("AnimatedCursor") != -1)
	  {
			goodie_par2 = goodie_par2.replace(/\'/g,"\"");
	  }

// Goodie parameters validation
	
	if(goodie_par1 == null || goodie_par2 == null || goodie_par3 == null || goodie_par4 == null ||  goodie_par5 == null || goodie_par6 == null || goodie_par1 == "null" || goodie_par2 == "null" || goodie_par3 == "null" || goodie_par4 == "null" ||  goodie_par5 == "null" || goodie_par6 == "null" )
	{
	// for Page layout even goodie parameter null , we may call insert goodie
	// Since weonly paste the selected layout's content
		if(goodie_par1.indexOf("PageLayout") == -1)
		{
			click_count = click_count +1;
		}
	}

// Calling insert goodie functionality for the first click

	if(click_count == 0)
	{
		var objEditArea=getEditArea();
		if(goodie_par1.indexOf("PageLayout") != -1)
		{
		// for PageLay out goodie, clears the editor and paste the  selected layout's content			
			objEditArea.document.body.innerHTML = "";
			doOpen(goodie_content);
		}
        
		insertGoodies(goodie_par1,goodie_par2,goodie_par3,goodie_par4,goodie_par5,goodie_par6);
	// Alert message calling before goodie insertion in Goodie page type
		if(goodie_par1.indexOf("PageLayout") == -1 && goodie_par1.indexOf("AnimatedCursor") == -1)
		{
			goodie_final();
		}
		
	}
	click_count = click_count +1;
	window.parent.document.getElementById("click_count").value = click_count;
	
}
var key_count = 0;
var last_control = "";
function onKeyDown()
{

  var objEditArea=getEditArea();
  var oWindow = objEditArea.document.parentWindow;

    var e = objEditArea.event;	
    targ = e.srcElement; 
    evt = e;
    selected_obj="";
    
  //  alert(selected_obj);
  if(isDWT_DEPEND && isHeadImage(targ))
  {
  
    if(evt.type=='click')
     openTitle();
     
       if(oWindow && oWindow.event)
       {
       //alert(oWindow.event);
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
       //alert((targ.nodeName));
       else if(evt)
       {
            evt.returnValue = false;
            evt.cancel = true;
            evt.preventDefault();
       }
       return false;

  }
  
  if(isDWT_DEPEND && !check_selectObj(targ) && isUserImage(targ))
  {
     alert(TXT_Var48692);     
     setCursorFocus();     
    // hideStyleMenu(evt);
     
       if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
       //alert((targ.nodeName));
       else if(evt)
       {
            evt.returnValue = false;
            evt.cancel = true;
            evt.preventDefault();
       }
       
    hideEDLayer();
    return false;
  }
    
    //alert(check_selectObj(targ));
    if(!check_selectObj(targ))
    {
    
        alert(TXT_Var48692);
        setCursorFocus();
       if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       }
       
       hideEDLayer();
       return false;       
    }  
    
     if(isIE)
    {
       range=objEditArea.document.selection.createRange(); 
       select_range=range;       
    }  
    //alert();
    if(CarriageReturn && isIE && oWindow.event.type=="keydown")
    {
        if ( oWindow.event.ctrlKey || oWindow.event.altKey )
        {
            oWindow.event.returnValue = true;
            return;
        }
        if(oWindow.event.keyCode == 13  &&  oWindow.event.shiftKey)  // Shift+Enter Key
        {
            if ( objEditArea.document.queryCommandState( 'InsertOrderedList' ) || objEditArea.document.queryCommandState( 'InsertUnorderedList' ))
            {
                oWindow.event.returnValue = true ;
                return ;
            }
            var oRange = objEditArea.document.selection.createRange() ;
            oRange.pasteHTML("<P>;");
            oRange.moveStart('character',-1) ;
            oRange.select() ;
            objEditArea.document.selection.clear() ;
            oWindow.event.returnValue = false ;
        }
        else if (  oWindow.event.keyCode == 13 &&  !(oWindow.event.shiftKey) )  // Enter Key
        {
            if ( objEditArea.document.queryCommandState( 'InsertOrderedList' ) || objEditArea.document.queryCommandState( 'InsertUnorderedList' ))
            {
                oWindow.event.returnValue = true ;
                return ;
            }
            var oRange = objEditArea.document.selection.createRange() ;
            oRange.pasteHTML("<br>&nbsp;");
            oRange.moveStart('character',-1) ;
            oRange.select() ;
            objEditArea.document.selection.clear() ;
            oWindow.event.returnValue = false ;
        }           
        
     }   
    
	// During click call insert goodie
	var goodie_par = window.parent.document.getElementById("hid_goodie_par2");
	if(goodie_par != null && goodie_par != "null" && goodie_par != "")
	{
		var goodie_par_value = goodie_par.value;
		if(goodie_par_value != null && goodie_par_value != "null" && goodie_par_value != "")
		{
			if(isOneTimeGoodie != true && isOneTimeGoodie != "true")
			{
				insert_goodie();
			}
		}
	}   

//hide size layer
	var size_layer=document.getElementById("size_layer");   
    if(size_layer.style.display && size_layer.style.display=="block")
    {
        size_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }

//hide style layer	
	var style_layer=document.getElementById("style_layer");   
    if(style_layer.style.display && style_layer.style.display=="block")
    {
        style_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
	
//hide font layer	
	var font_layer=document.getElementById("font_layer");   
    if(font_layer.style.display && font_layer.style.display=="block")
    {
        font_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
//hide table layer	
	var table_layer=document.getElementById("table_layer");   
    if(table_layer.style.display && table_layer.style.display=="block")
    {
        table_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
	
	
    
   //displayMenuuuu(evt) ;
    
	var page_url="";
	//alert(targ.nodeName);
	 if(targ.nodeName=='IMG'|| targ.nodeName=='A')
	 { 
		if(isIE)
		{
			try
			{
				var r = objEditArea.document.body.createControlRange();
				r.add(targ);
				r.select();
			}
			catch(e)
			{
			}
		}
		DisplayEDLayer(targ,evt);
		evt.returnValue = false;
		evt.cancel = true;
        evt.cancelBubble = true;
		//evt.preventDefault();
		return false;
	 }   
	 else if(targ.parentNode.nodeName=='A')
	 {
		//alert(targ.parentNode.nodeName);
		DisplayEDLayer(targ.parentNode,evt);
		evt.returnValue = false;
		evt.cancel = true;
        evt.cancelBubble = true;
	//	evt.preventDefault();
		return false;
	 }
     else if(targ.parentNode && targ.parentNode.parentNode && targ.parentNode.parentNode.nodeName && targ.parentNode.parentNode.nodeName=='A')
	 {
		//alert(targ.parentNode.nodeName);
		DisplayEDLayer(targ.parentNode.parentNode,evt);
		evt.returnValue = false;
		evt.cancel = true;
        evt.cancelBubble = true;
		//evt.preventDefault();
		return false;
	 }
     else
       hideEDLayer();
     

   selValue();
}


var f11="";
var f12="";
var s11="";
var s12="";

function f1(evt)
{
var objEditArea=getEditArea();
	if(isGECKO) //Non-IE
	{
		targ=evt.target;
		if(targ.tagName=="img")
		{
	        //alert(targ.tagName);
			//targ.onresizestart=scriptDrag;
			//targ.onkeypress=scriptDrag;
		}
	}
    
// scriptDrag();
 
   try{
      var el = document.getElementById("select1");
      var str=objEditArea.document.queryCommandValue('fontname');

      var el1 = document.getElementById("FontSize");
      var str1=objEditArea.document.queryCommandValue('fontsize');

      f11=str;
      s11=str1;
   }
   catch(e){
   }
}

function f2()
{
   hideEDLayer();
   var objEditArea=getEditArea();
   var el = document.getElementById("select1");
   var str=objEditArea.document.queryCommandValue('fontname');
   var el1 = document.getElementById("FontSize");
   var str1=objEditArea.document.queryCommandValue('fontsize');
   f12=str;
   s12=str1;
   sel = window.frames[0].getSelection();
   if(sel!="")
   {
      if(f11!=str)
      {
         //el.selectedIndex = 0;
      }
      if(s11!=str1)
      {
         //el1.selectedIndex = 0;
      }
   }


   s11="";
   s12="";
   f11="";
   f12="";
}
function onMousePress()
{
   f1();
   f2();
}

function insertHTML2(insertNode, seltext)
{
   var objEditArea=getEditArea();
   html = document.createTextNode(objEditArea.document.body.innerHTML);
   var sel ="";
   sel = window.frames[0].getSelection();
   sel = window.frames[0].getSelection();
      var range = sel.getRangeAt(0);
   var frag ="";
   var container ="";
   if(sel=="")
   {
      var inNode = document.createTextNode(seltext);
      insertNode.appendChild(inNode);
   }
   else
   {
      frag = range.extractContents();
      remove();
      insertNode.appendChild(frag);
   }
    var container = range.startContainer;
    
            if(container.nodeType==1 &&  insertNode.nodeType==1)
            {
               objEditArea.document.execCommand('removeformat',false,'Normal');
                objEditArea.document.body.innerHTML = "";
                objEditArea.document.body.appendChild(html);
               setMode(false);
               objEditArea.document.execCommand('removeformat',false,'Normal');
               return;
            }
            
      var pos = range.startOffset;
      range=document.createRange();
          var textNode = container;
          container = textNode.parentNode;
          var text = textNode.nodeValue;
          if(text==null)
          {
            text="";
          }
          var textBefore = text.substr(0,pos);
          var textAfter = text.substr(pos);
          var beforeNode = document.createTextNode(textBefore);
          var afterNode = document.createTextNode(textAfter);
          container.insertBefore(afterNode, textNode);
          container.insertBefore(insertNode, afterNode);
          container.insertBefore(beforeNode, insertNode);
          container.removeChild(textNode);
}
function remove()
{
   var objEditArea=getEditArea();
   
   //objEditArea.document.designMode="on";
   //objEditArea.document.execCommand('removeformat',false,'Normal');
   
//IE8 cusor focus retaining in pop up
	setCursorForIe8();
	
	if(isDWT_DEPEND)
    {
        if(objEditArea.document.selection && objEditArea.document.selection.type !="None" && !check_cursorlocation())
        {
            alert(TXT_Var48692);
            setCursorFocus();
            return false;
        } 
    }
    else
    objEditArea.focus();
                
   cmdExec('removeformat','Normal');
    
   if(isIE) 
   {
       var oDoc = objEditArea.document;
       var oRange = oDoc.selection.createRange();
        oRange.select();
       
       var str_txt=oRange.text;
       var parentobj=oRange.parentElement();
     
       if(parentobj.innerText==str_txt)
       {
        parentobj.clearAttributes("class");
        parentobj.clearAttributes("style");        
       }
       
       var str=oRange.htmlText;
       //alert(removeStyle(str));
       oRange.pasteHTML(removeStyle(str));
   }
  // objEditArea.focus();
}

 function removeStyle(str)
   {
      // remove class value - sample values given as tags before each replacement
      //Single quoted attributes
      str = str.replace(/class\s*=\s*'[a-z0-9\s]*'/gi, "");
      //Double quoted attributes
      //var str = '<span cLass  =  "new1">span <span cLass  =  "new 2" >span tag2</span>tag</span>';
      str = str.replace(/class\s*=\s*"[a-z0-9\s]*"/gi, "");
      //With no quotes - last attribute
      //var str = '<span cLass  =  new1>span <span cLass  =  new2 >span tag2</span>tag</span>';
      str = str.replace(/class\s*=\s*[a-z0-9]*>+/gi, ">");
      //With no quotes - has next attribute
      str = str.replace(/class\s*=\s*[a-z0-9]*\s+/gi, "");
      str = str.replace(/class\s*=\s*(\\-)*(#)*[0-9]*[a-z]*[A-Z]*\s+/gi, "");

      // remove style value
        //Single quoted attributes
      str = str.replace(/style\s*=\s*'[a-z0-9-:;#\s]*'/gi, "");
      //alert(str);
      //Double quoted attributes
      str = str.replace(/style\s*=\s*"[a-z0-9-:;#\s]*"/gi, "");
      //alert(str);
      //With no quotes - last attribute
      str = str.replace(/style\s*=\s*[a-z0-9-:;#]*>+/gi, ">");
      //alert(str);
      //With no quotes - has next attribute
      str = str.replace(/style\s*=\s*[a-z0-9-:;#]*\s+/gi, "");
      
        str = str.replace(/\<strong\>/gi, "");
        str = str.replace(/\<\/strong\>/gi, "");
        str = str.replace(/\<span\>/gi, "");
        str = str.replace(/\<span \>/gi, "");
        str = str.replace(/\<\/span\>/gi, "");
        str = str.replace(/\<sub\>/gi, "");
        str = str.replace(/\<\/sub\>/gi, "");
        str = str.replace(/\<sup\>/gi, "");
        str = str.replace(/\<\/sup\>/gi, "");

     // alert(str);

     return str;
   }
function selValue()
{

   var objEditArea=getEditArea();
   var el = document.getElementById("select1");

   if(el==null || el=='undefined')
      return;
   var str=objEditArea.document.queryCommandValue('fontname');

   var el1 = document.getElementById("FontSize");
   if(el1==null || el1=='undefined')
         return;

   var str1=objEditArea.document.queryCommandValue('fontsize');

   var text="";
   if(str==null || str=="" && str1==null)
   {
      el.selectedIndex = 0;
      if(str1==null || str1=="")
      {
         el1.selectedIndex = 0;
      }
      return;
   }
   else if(str1==null || str1=="" && str==null)
   {
      el1.selectedIndex = 0;
      return;
   }

   for (var i = 0; i < el.length; i++)
   {
      if (((text || !el[i].value) && el[i].text.toLowerCase() == str.toLowerCase()) || ((!text || el[i].value) && (el[i].value).toLowerCase() == str.toLowerCase()))
      {
         el.selectedIndex = i;
      }
   }


   var text1="";
   for (var j = 0; j < el1.length; j++)
   {

      if (((text1 || !el1[j].value) && el1[j].text1 == str1) || ((!text1 || el1[j].value) && el1[j].value == str1))
      {
         el1.selectedIndex = j;
      }
   }
}
function unlink()
{
   var objEditArea=getEditArea();
  // objEditArea.focus();
   cmdExec('unlink','Normal');
   
  // objEditArea.document.execCommand('unlink',false,'Normal');
  if(isDWT_DEPEND)
  {
        var range='';
        
        if(isGECKO)
        {
            range=objEditArea.getSelection().getRangeAt(0);
            range.collapse(false);
			//setCursorFocus();
			  var sel=objEditArea.getSelection();
              sel.collapseToEnd();
			  sel.collapseToStart();
             // sel.removeRange(range);
              var newNode = document.createTextNode("");
              range.insertNode(newNode);
			  //setCursorFocus();
			 objEditArea.focus();
			//alert("test");
        }
        else
            range=objEditArea.document.selection.createRange();
        
        select_range=range;
        //alert(select_range.text.length);
        if(select_range && select_range.text && select_range.text!='')
        {
           select_range.collapse(true);
           
           if(select_range.moveStart)
           select_range.moveStart('character');
           //cmdExec('Unselect','Normal');
        }    
        //range.moveToElementText(select_obj);
        //objEditArea.document.selection.empty();
        
  }
  else
   objEditArea.focus();
}

function keydownhandler(e)
{
   alert("keydownhandler 1");
}

function setFont(fonttype)
{
   if(fonttype=="Font")
   {
      return;
   }
   cmdExec('fontname',fonttype);
}

function setSize(fontsize)
{
   if(fontsize=="Size")
   {
      return;
   }
   

   cmdExec('fontsize',fontsize);
}


function getText()
{
   var objEditArea=getEditArea();
   var seltext="";
   var str="";
   if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
   {
      seltext=objEditArea.getSelection();
      var range = seltext.getRangeAt(0);
      var container = range.startContainer;
      if(container.nodeType=="1")
         RangeType="Control";
   }
   else
   {
      var RangeType = objEditArea.document.selection.type;
      var selectedRange = objEditArea.document.selection.createRange();
      if(RangeType=="None")
      {
         seltext=" ";
      }
      else if(RangeType=="Control")
      {
         seltext="";
      }
      else
      {
         seltext=objEditArea.document.selection.createRange();
         seltext=seltext.htmlText;
      }
   }
   return seltext+"|"+RangeType;
}


function spell_check()
{
     if (!isHTMLMode())
      return;


        var inner_window_width=250;
        var inner_window_height=100;
        var shell_window_top=(window.screen.availHeight/2)-(inner_window_height/2);
        var shell_window_left=(window.screen.availWidth/2)-(inner_window_width/2);

        var objEditArea=getEditArea();
        var html = "";
        var myHTML="";

		if(isDWT_DEPEND) //If DWT present
		{
			var our_div=objEditArea.document.getElementsByTagName("DIV");
            
			for(var i=0;i<our_div.length;i++) //search each div tag
			{
				if(our_div[i].getAttribute && our_div[i].getAttribute("id") && our_div[i].getAttribute("id")!=null && (our_div[i].getAttribute("id")).indexOf("akcontEd")!=-1) //If editable div, get its content
				{
                    // every editable area content concatinate with word deleimeter
                    //if innerText property available
                    if(our_div[i].innerText)
                        myHTML=myHTML+" "+our_div[i].innerText;
    				else if(our_div[i].innerHTML) // else get from innerHTML
                        myHTML=myHTML+" "+our_div[i].innerHTML;
    				//alert(myHTML)
				}

			}
            //alert(html);
            html = myHTML;
		}
        else
        {
            if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
            {
                html = objEditArea.document.body.ownerDocument.createRange();
                html.selectNodeContents(objEditArea.document.body);
                html = html.toString();
            }
            else
            {
                html = objEditArea.document.body.innerText;
            }
        }
        
    var html1=html.toString();

    var l_obj = window.parent.document;
    if(spell_check_file==null || spell_check_file.length=="")
    {
       alert("Please specify the spell check file name.");
       return;
    }
    else
    {
       spell_check_file=l_obj.getElementById("spell_check_file").value;
    }

    var myExp =/\n/g;
	html1 = html1.replace(myExp," ");
    
      // alert(html1.toString());
if(html1.length>0)
{

   document.frmShowEditor.target="spell";
   document.frmShowEditor.method="POST";
   document.frmShowEditor.txa_content.value=html1.toString();
   //alert("1="+document.frmShowEditor.txa_content.value);
   //alert("4="+document.frmShowEditor.action);
   document.frmShowEditor.action=spell_check_file;
if(child_flag)
{
   //alert("2");
   window.open('progress.html', 'spell','top='+shell_window_top+',left='+shell_window_left+',width=370, height=250, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
   //window.open('about:blank','spell', 'top=0,left=0,directories=no,height=250,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=370');
   document.frmShowEditor.submit();
}
else
{
   //alert("3");
   window.open('progress.html', 'spell','top='+shell_window_top+',left='+shell_window_left+',width=370, height=250, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
   document.frmShowEditor.submit();
}
}
   child_flag =true;

}

function getTextContent()
{
   if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
   {
      var objEditArea = document.getElementById("editArea").contentWindow;
      var html = objEditArea.document.body.ownerDocument.createRange();
      html.selectNodeContents(objEditArea.document.body);
   }
   else
   {
      objEditArea = editArea;
      var html=objEditArea.document.body.innerText;
   }
   return html;
}


function save()
{
}

function saveAs()
{
   if(!child_saveas)
   {
      child_saveas=true;
      SaveAsWin = window.open('SaveAs.html','Save','top=100,left=300,width=500, height=400,status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=yes');
   }
   else
   {
      SaveAsWin.close();
      SaveAsWin = window.open('SaveAs.html','Save','top=100,left=300,width=500, height=400,status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=yes');
   }

}

function savecontent()
{
   var content=htmlContent();
   return content;
}

function openwin1() {
   objFile=prompt("Enter URL :","http://akmin.editletv2.com");
   if(objFile!=null)
      var openfile=window.open('samples/jsp/open.jsp?openurl='+objFile+'', 'open','top=300,left=400,width=300, height=30, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no, resizable=no');
      //test(objFile);
}

function doOpen1(content)
{
   var objEditArea=getEditArea();
   var doc = objEditArea.document;
   var preLoadedDoc  = "<BODY bgColor=white>" +content;
   doc.open();
   doc.write(preLoadedDoc);
   addstyle();
}
/*
function test(file)
{
   var objEditArea=getEditArea();
   file_name=file;
   var arrIFrame=document.getElementsByTagName("iframe");
   arrIFrame[0].src=file_name;
}*/

var clickedEditable = false;
function rightclick(evt)
{
var objEditArea=getEditArea();
var oWindow = objEditArea.document.parentWindow;
 
selected_obj="";

  // alert(selected_obj);
   var e = objEditArea.event;
	if(isGECKO) //Non-IE
	{
		targ=evt.target;
	}
	else //IE
	{
		targ = e.srcElement; 
		evt = e;
	}

  if(isDWT_DEPEND && isHeadImage(targ))
  {
  
       openTitle();
       if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
       //alert((targ.nodeName));
       else if(evt)
       {
            evt.returnValue = false;
            evt.cancel = true;
            evt.preventDefault();
       }
       return false;

  }    
  
  if(isDWT_DEPEND && !check_selectObj(targ) && isUserImage(targ))
  {
     alert(TXT_Var48692);     
     setCursorFocus();
      if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
       //alert((targ.nodeName));
       else if(evt)
       {
            evt.returnValue = false;
            evt.cancel = true;
            evt.preventDefault();
       }     
      hideEDLayer();
      return false;
  }
  
   
     // if(!check_selectObj(targ))
 // if( !check_cursorlocation()&&(evt.type=="click" && !check_selectObj(targ)))
    if(isDWT_DEPEND && (evt.type=="keypress" && !check_cursorlocation())||(evt.type=="click" && !check_selectObj(targ)))
    {
    
        alert(TXT_Var48692);
        setCursorFocus();
       if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
       //alert((targ.nodeName));
       if(evt)
       {
            evt.returnValue = false;
            evt.cancel = true;
            evt.preventDefault();
       }     
       hideEDLayer();
       return false;

    }
	// alert(check_cursorlocation()+" "+check_selectObj(targ));
   lastfocus=false;
   if (document.all)
   {
      if (oWindow.event.button==1)
      {
         //alert('left button.')
      }
      if (oWindow.event.button==2)
      {
         //alert('Right button.')
      }
      if (oWindow.event.button==3)
      {
         //alert('center button.')
      }
   }
   
// During click call insert goodie
	var goodie_par = objEditArea.parent.document.getElementById("hid_goodie_par2");
	if(goodie_par == null || goodie_par == "null" )
	{
       if(window.parent.document)
		goodie_par = window.parent.document.getElementById("hid_goodie_par2");
	}
	if(goodie_par != null && goodie_par != "null" && goodie_par != "")
	{
		var goodie_par_value = goodie_par.value;
		if(goodie_par_value != null && goodie_par_value != "null" && goodie_par_value != "")
		{
			if(isOneTimeGoodie != true && isOneTimeGoodie != "true")
			{
				insert_goodie();
			}
		}
	}   

//hide size layer
	var size_layer=document.getElementById("size_layer");   
    if(size_layer.style.display && size_layer.style.display=="block")
    {
        size_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }

//hide style layer	
	var style_layer=document.getElementById("style_layer");   
    if(style_layer.style.display && style_layer.style.display=="block")
    {
        style_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
	
//hide font layer	
	var font_layer=document.getElementById("font_layer");   
    if(font_layer.style.display && font_layer.style.display=="block")
    {
        font_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
//hide table layer	
	var table_layer=document.getElementById("table_layer");   
    if(table_layer.style.display && table_layer.style.display=="block")
    {
        table_layer.style.display="none";
        objEditArea.parent.document.onclick=null;    
        objEditArea.parent.parent.document.onclick=null; 
    }
	
    
   //displayMenuuuu(evt) ;
    
	var page_url="";
	//alert(targ.nodeName);
	 if(targ.nodeName=='IMG'|| targ.nodeName=='A')
	 { 
		if(isIE)
		{
			try
			{
				var r = objEditArea.document.body.createControlRange();
				r.add(targ);
				r.select();
			}
			catch(e)
			{
			}
		}
		DisplayEDLayer(targ,evt);
		evt.returnValue = false;
		evt.cancel = true;
		//evt.preventDefault();
		return false;
	 }   
	 else if(targ.parentNode.nodeName=='A')
	 {
		//alert(targ.parentNode.nodeName);
		DisplayEDLayer(targ.parentNode,evt);
		evt.returnValue = false;
		evt.cancel = true;
		evt.preventDefault();
		return false;
	 }	
     else if(targ.parentNode && targ.parentNode.parentNode && targ.parentNode.parentNode.nodeName && targ.parentNode.parentNode.nodeName=='A')
	 {
		//alert(targ.parentNode.nodeName);
		DisplayEDLayer(targ.parentNode.parentNode,evt);
		evt.returnValue = false;
		evt.cancel = true;
		evt.preventDefault();
		return false;
	 }
	 else
	 {
		hideEDLayer();
	 }   
}

function insertOrderedList()
{
   var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('insertorderedlist');
}

function copy()
{
   var objEditArea=getEditArea();
   if(isDWT_DEPEND && isIE)
   {
       setCursorFocus();
   }  
   cmdExec('copy');
}

function paste()
{
   var objEditArea=getEditArea();
   if(isIE && !check_cursorlocation())
   {
       setCursorFocus();
   }  
   cmdExec('paste');
}

function justifyleft()
{
   var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('justifyleft');
}

function justifyright()
{
   var objEditArea=getEditArea();
  if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('justifyright');
}

function justifycenter()
{
   var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('justifycenter');
}

function insertunorderedlist()
{
   var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('insertunorderedlist');
}


function indent()
{
    var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
    cmdExec('indent');
}

function outdent()
{
   var objEditArea=getEditArea();
   if(isIE)
   {
        if(select_range && select_range.select)
        {             
        //alert(select_range.text); 
            try
            {                             
                select_range.select();                                       
                set_focus=true;
            }
            catch(e){}                             
          
       }
       else
           setCursorFocus();   
   }
   cmdExec('outdent');
}

function InsertHorizontalRule()
{
   var objEditArea=getEditArea();
  // objEditArea.focus();
 
   if(isIE)
   { 
	   setCursorFocus();
       var oRange = objEditArea.document.selection.createRange();
       oRange.select();
       oRange.pasteHTML("<hr>");
       var oWindow = objEditArea;
      // alert(oWindow.event);
       if(oWindow && oWindow.event)
       {
        oWindow.event.returnValue = false; 
        oWindow.event.cancelBubble = true;
       } 
      // setCursorFocus();
   }
   else
   {
    cmdExec('InsertHorizontalRule');
   }
   
   
   return false;
}


function doOpen(content)
{
   var objEditArea=getEditArea();
   if(window.document.getElementById("Layout")!=null)
   {
      if(cssurl=="css/Choose" || cssurl=="" || document.frmShowEditor.Layout.value.indexOf("Choose")>=0)
      {
         cssurl="css/default.css";
         document.frmShowEditor.Layout.value="default";
      }
      setLayout(document.frmShowEditor.Layout.value);
   }
   objEditArea.focus();
   var doc = objEditArea.document;

   if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1)){
	 var preLoadedDoc  = "<BODY bgColor=white>" +content;
      doc.open();
      doc.write(preLoadedDoc);
      doc.close();
      setMode(true);
      setMode(false);
   }
   else
   {
      doc.body.innerHTML="";
      //doc.selection.createRange().pasteHTML(content) ;
      layer_sel_obj.pasteHTML(content) ;
   }
   objEditArea.focus();
}
function setLayout(layout)
{
   
   //alert("layout "+layout);
   var objEditArea=getEditArea();
   cssurl='http://'+document.domain+'/swiz/editor/css/'+layout+".css";
  // alert("objEditArea.focus 1");
   objEditArea.focus();
   
   if(!(isDWT_DEPEND))
   {
       window.parent.document.getElementById("cssurl").value=cssurl;
       if(window.document.getElementById("Layout")!=null)
       {
          window.parent.document.getElementById("css_file").value=document.frmShowEditor.Layout.value;
       }
   }

   addstyle();
   setMode(true);
   setMode(false);
}


function setMode(bMode)
{

  /*if(isDWT_DEPEND)
  {
   return false;
  }*/
  
   var objEditArea=getEditArea();
   HTMLMode = bMode;
   if(window.document.getElementById("Layout")!=null)
   {
     if(!(isDWT_DEPEND))
     {
      if(document.frmShowEditor.Layout.value=="Choose")
         document.frmShowEditor.Layout.value="default";
      cssurl='http://'+document.domain+'/swiz/editor/css/'+document.frmShowEditor.Layout.value+".css";
     } 
   }
   var bSource;
   if (HTMLMode)
   {
      if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
      {
          //alert(objEditArea.document.body); 
          
          if(objEditArea.document.body)
           temp=objEditArea.document.body.innerHTML;
          else
          {
            var body=objEditArea.document.getElementsByTagName("BODY");            
          
            if(body && body!=null &&  body[0] &&  body[0].innerHTML)
             temp=body[0].innerHTML;             
          }
          
          if(temp.indexOf('<link')>=0)
          {
               var outStr=temp.substring(temp.indexOf("<link",temp.indexOf("<link")), temp.indexOf(">",temp.indexOf("<link"))+1);
               temp = temp.replace(outStr,"");
               // to Uncomment script
               temp = remove_Scriptcmnt(temp);
          }
          //html = document.createTextNode(temp);
          //objEditArea.document.body.innerHTML = "";
          //objEditArea.document.body.appendChild(html);
          bSource = (trSource.style.display == "none") ;
          if(document.getElementById("txtSource"));
          (document.getElementById("txtSource")).value = temp ;
      }
      else
      {
         bSource = (trSource.style.display == "none") ;
         (document.getElementById("txtSource")).value = objEditArea.document.body.innerHTML ;
         temp=(document.getElementById("txtSource")).value ;
         objEditArea.document.body.innerText = "";
         objEditArea.document.body.innerText=temp;
         // to Uncomment script
         if(document.getElementById("txtSource"))
          (document.getElementById("txtSource")).value= remove_Scriptcmnt(temp);
      }
   }
   else
   {
      if((navigator && navigator.userAgent && navigator.userAgent.indexOf && navigator.userAgent.indexOf('Gecko') != -1) || (navigator.userAgent.indexOf("Netscape")!= -1))
      {
        var html =  (document.getElementById("txtSource")).value;
         //var html = objEditArea.document.body.ownerDocument.createRange();
         //html.selectNodeContents(objEditArea.document.body);         
          if(html.toString() == "" || html.toString() == "<br>")
          {
            html ="&nbsp;";
          }
         //to comment script tag 
         //alert(objEditArea.document.body.innerHTML);
         html = cmnt_script_tag(html.toString());
         if(!isDWT_DEPEND)
         html = html+'<link type="text/css" rel="stylesheet" href="'+cssurl+'">';
         objEditArea.document.body.innerHTML = html;
        }
        else
        {
         if((document.getElementById("txtSource")).value.indexOf("<LINK")==-1)
            var tempstr= (document.getElementById("txtSource")).value;//+ '<link type="text/css" rel="stylesheet" href="'+cssurl+'">' ;
         else
            var tempstr= (document.getElementById("txtSource")).value;         
         //to comment script tag 
         tempstr=cmnt_script_tag(tempstr);    
         //alert(tempstr);         
          if(objEditArea.document.body)
          objEditArea.document.body.innerHTML = tempstr;
          else
          {
            var body=objEditArea.document.getElementsByTagName("BODY");
            if(body &&  body!=null &&  body[0] &&  body[0].innerHTML)
            body[0].innerHTML=tempstr;
          }
         
         //alert(objEditArea.document.body.innerHTML);
        }

   }
   
   if(navigator.userAgent.indexOf("MSIE")!= -1)
   {
      trEditor.style.display = bSource ? "none" : "inline" ;
      trSource.style.display = bSource ? "inline" : "none" ;
   }
   else
   {
      trEditor.style.display = bSource ? "none" : "table-row";   
      trSource.style.display = bSource ? "table-row" :"none";
   }
   
   removeURL();
}

/* To comment script tags */
function cmnt_script_tag(l_str_content_buf)
{              
                     
               var int_start=0;
               var l_int_cmnt_start=0;
               var l_int_cmnt_end=0;
         
               while((int_start=l_str_content_buf.toLowerCase().indexOf("<"+"script",int_start))!=-1)
               {
                  
   					var l_str_editor_content = l_str_content_buf.toLowerCase();
                  
   					var l_int_end = l_str_editor_content.indexOf("</"+"script"+">",int_start);
                  
   					var l_str_script_tag = l_str_editor_content.substring(int_start,l_int_end+9);
   					var l_str_before_script = l_str_editor_content.substring(int_start-20,int_start);
   					
                  // skip already commented area
   				   l_int_cmnt_start=l_str_content_buf.indexOf("<"+"!--",l_int_cmnt_start);
                 
                  if(l_int_cmnt_start!=-1 && int_start>l_int_cmnt_start)
                  {
                   l_int_cmnt_end=l_str_content_buf.indexOf("--"+">",l_int_cmnt_start)+3;
                   if(l_int_cmnt_end!=-1)
                      int_start=l_int_cmnt_end;
                   else
                      int_start=l_str_content_buf.length-1;
                  } // if non - commented area
                  else
                  {
                    var l_int_scriptend=l_str_content_buf.toLowerCase().indexOf("</"+"script"+">",int_start);
                     
                     if(l_int_scriptend!=-1)
                     {
                        l_int_scriptend+=9;
                        
                        // split script content from real content
                        var l_str_script=l_str_content_buf.substring(int_start,l_int_scriptend);
                        
                        var tag_reg=new RegExp("<script","gi");
                        l_str_script=l_str_script.replace(tag_reg,"<akscrpt");
                        tag_reg=new RegExp("</script>","gi");
                        l_str_script=l_str_script.replace(tag_reg,"</akscrpt>");

                        
                        // find last comment-end in script content
                        var end_comnt=l_str_script.lastIndexOf("--"+">");                        
                        if(end_comnt!=-1)
                        {
                            end_comnt+=3;
                            // insert a comment start before script-end
                            l_str_script=insert(l_str_script,end_comnt,"<"+"!--akcmntBegin");
                        }
                        
                        //add comment at start and end of script content
                        l_str_script=insert(l_str_script,0,"<"+"!--akcmntBegin");
                        l_str_script=insert(l_str_script,l_str_script.length,"akcmntEnd--"+">");
                        
                        //replace commented script content in real content
                        l_str_content_buf=replace(l_str_content_buf,int_start,l_int_scriptend,l_str_script);
                        
                        int_start+=l_str_script.length;
                     }
                     else
                         int_start=l_str_content_buf.length-1;
                  }
                  
                  l_int_cmnt_start=int_start;
               }
               
               var temp_str=trim(l_str_content_buf)

               if(l_str_content_buf.indexOf("<"+"!--")==0)
                l_str_content_buf="&nbsp;"+l_str_content_buf;            
               
                  
       return l_str_content_buf;           
}

/* insert a string given index of string */
function insert(l_string,posIndex,rep_str)
{	
	l_string=l_string.substring(0,posIndex)+rep_str+l_string.substring(posIndex);	
  return l_string;	
}

/* replace a string using given index */
function replace(l_string,startIndex,endIndex,rep_str)
{		
	l_string=l_string.substring(0,startIndex)+rep_str+l_string.substring(endIndex);	
   
  return l_string;	
}


 //remove comment_tags in before script
function remove_Scriptcmnt(hid_out_content1)
{
   var start=0;
   var end=0;		

   while(hid_out_content1.indexOf("<!--akcmntBegin")!=-1)
   {
      hid_out_content1 = hid_out_content1.replace("<!--akcmntBegin","");
   }

   while(hid_out_content1.indexOf("akcmntEnd-->")!=-1)
   {
      hid_out_content1 = hid_out_content1.replace("akcmntEnd-->","");
   }
   
    var tag_reg=new RegExp("<akscrpt","gi");
    hid_out_content1=hid_out_content1.replace(tag_reg,"<script");
    tag_reg=new RegExp("</akscrpt>","gi");
    hid_out_content1=hid_out_content1.replace(tag_reg,"</script>");

   return hid_out_content1;
}


function init1()
{
   setMode(true);
   setMode(false);
}


function setRelativePath()
{
   var objEditArea=getEditArea();
   var src_domain="";
   if(location.port!="")
      src_domain=location.protocol+"//"+document.domain+":"+location.port;
   else
      src_domain=location.protocol+"//"+document.domain;

   var removeurl=new RegExp(src_domain,"g");
   var innerHtml=(document.getElementById("txtSource")).value;
   innerHtml=innerHtml.replace(removeurl,"");
   src_domain1=location.protocol+"//"+document.domain;
   removeurl1=new RegExp(src_domain1,"g");
   innerHtml=innerHtml.replace(removeurl1,"");
   objEditArea.document.body.innerHTML=innerHtml;
}

function removeURL()
{
   var objEditArea=getEditArea();
   var innerHtml=(document.getElementById("txtSource")).value;
  innerHtml=removeURLString(innerHtml);
   (document.getElementById("txtSource")).value=innerHtml
}

function removeURLString(innerHtml)
{
  if(location.port!="")
      src_domain=location.protocol+"//"+document.domain+":"+location.port+"/";
   else
      src_domain=location.protocol+"//"+document.domain+"/";

   var url=window.location.href;
   url=url.substring(0,url.lastIndexOf("/")+1)
   var removeurl=new RegExp(url,"g");
   innerHtml=innerHtml.replace(removeurl,"");
   removeurl=new RegExp(src_domain,"g");
   innerHtml=innerHtml.replace(removeurl,"/");
   removeurl=new RegExp("/swiz/goodies/PageLayout_action.jsp#","g");
   innerHtml=innerHtml.replace(removeurl,'#');
   removeurl=new RegExp("editor.html#","g");
   innerHtml=innerHtml.replace(removeurl,'#');
 return innerHtml;
}

// Alert message to be loaded  before goodie insertion in Goodie page type

function  goodie_initial()
{
	if(isOneTimeGoodie == true || isOneTimeGoodie == "true")
	{
	//If Animated cursor already present in the page, then no goodie insertion
	//Alert the user for edit the goodie
		alert(TXT_Var48670+" "+oneTimeGdyName+" "+TXT_Var48671);
		return false;
	}
	else
	{	
		alert(TXT_Var48622);
	}
}

// Alert message to be loaded  after goodie insertion in Goodie page type

function  goodie_final()
{
	alert(TXT_Var48623a);
}

//ffox_arr1 = ["à","è","ò","ù"];
//ffox_arr2 = ["&#224","&#232","&#242","&#249"];
// Trim function to trim the leading and trailing spaces.
function trim(l_str)
{
   var l_str_string = new String(l_str); // local variable to store the string
   var l_int_length = l_str_string . length; // local variable to store the length of string
   var l_str_temp = new String(''); // local variable to store the string
   var l_b_flag = true; // local variable to store the boolean value
   var STR_1_SPACE = ' ';  

   for(l_int_i = 0; l_int_i <= l_int_length - 1; ++l_int_i) // start of for loop to check for space from first
   {
      if (l_b_flag == true && l_str_string.charAt(l_int_i) == STR_1_SPACE) // checks for space
      {
         l_b_flag = true;
      } // end of check space if
      else
      {
         l_b_flag = false;
         l_str_temp = l_str_string.substring(l_int_i);
         break;
      } // end of check space else
      if (l_int_i == l_int_length - 1) // checks for length
      {
         return l_str_temp;
      } // end of length check if
   } // end of chack space from first for loop

   l_int_length = l_str_temp.length;
   l_b_flag = true;

   for(l_int_i = l_int_length - 1; l_int_i >= 0; l_int_i--) // start of for loop to check for space from the last
   {
      if (l_b_flag == true && l_str_temp.charAt(l_int_i) == STR_1_SPACE) // check for space
      {
         l_b_flag = true;
      } // end of check space if
      else
      {
         l_b_flag = false;
         l_str_string = l_str_temp.substring(0, l_int_i + 1);
         break;
      } // end of check space else
   } // end of chack space from last for loop
   return l_str_string;
} // end of trim function

var menu_targ;
var select_range;
var opened_menu;
/*
This method displays menu like a pull down irrespective of the resolution.
This finds top & left coordinates of the selected object & displays the menu at the position.
*/
function displayMenu(evnt,layer_name) 
{
	var x=0;
    var y=0;
    var objEditArea=getEditArea();
    
    if(isIE)
    {
       if(objEditArea.document.selection.type == "Text")
       {
        range=objEditArea.document.selection.createRange();
        select_range=range;
        //range.moveToElementText(select_obj);
        range.select();
       }
    }
 

    if(evnt==null)
        evnt=window.event;

    var targ;     
    if(isIE)
        targ=evnt.srcElement;
    else
        targ=evnt.target;
   	//ObjectNode assign select_obj
    
	var ObjectNode=targ;
	//Iterate until ObjectNode is body
	while(ObjectNode!=null)
    {
			//Set x as x+ObjectNode.offsetTop.
            //alert(ObjectNode.nodeName+" "+ObjectNode.offsetTop);
            if(!isNaN(ObjectNode.offsetTop))
                y=y+ObjectNode.offsetTop;            

            if(!isNaN(ObjectNode.offsetLeft))
                x=x+ObjectNode.offsetLeft;            
                
            if(ObjectNode.offsetParent)
                ObjectNode=ObjectNode.offsetParent;
            else
                ObjectNode=ObjectNode.parentNode;          
	}		//end Iterate until ObjectNode is HTML
    
    if(isGECKO)
    {
       if(targ.nodeName=='AREA' && targ.coords)
       {
        var str_coords=targ.coords;
        var arr_coords=str_coords.split(",");
            if(arr_coords.length>2)
            {
                y+=parseInt(arr_coords[1]);
                x+=parseInt(arr_coords[0]);
            }    
       } 
    }
   if(isGECKO)
   {
     if(targ.nodeName=='AREA' && targ.coords)
       {
        var str_coords=targ.coords;
        var arr_coords=str_coords.split(",");
            if(arr_coords.length>2)
            {
              y+=(parseInt(arr_coords[3])-parseInt(arr_coords[1]));
            }    
       } 
   }
   else
    y+=targ.offsetHeight;
     // get layer object
    var menu_layer=document.getElementById(layer_name);        
    //edit_del.innerHTML=str_tags;        
	if(isGECKO)
	{
		menu_layer.style.top=(y+25)+"px";
	}
	else
	{
		 menu_layer.style.top=y+"px";
	}
    
    menu_layer.style.left=x+"px";
    menu_targ=targ;
    //hideEDLayer();
    
    if(opened_menu)    
        hide(opened_menu);
        
    window.top.document.onclick=hideStyleMenu;    
    objEditArea.document.onmouseover=hideStyleMenu;    
   
    
    //if(isGECKO)
    objEditArea.parent.document.onclick=hideStyleMenu;  
        
    //show layer
    menu_layer.style.display="block";      

    opened_menu=menu_layer;
    hideEDLayer();
 }
 
//This method list all the supported fonts as a layer
function fontList(l_str_fontnames)
{
	//alert("inside 1"+l_str_fontnames);
	var fontnames=l_str_fontnames;

	var lastfont=fontnames.substring(fontnames.lastIndexOf(",")+1,fontnames.length);
	//alert("inside 1");
	document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\'Arial\');" ><a href="javascript:;" style="text-decoration: none;" ><FONT face=\'Arial\' size="2" color=\'black\'>'+TXT_Var48583+'</FONT></a></td></tr>');
	document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\'Times\');" ><a href="javascript:;" style="text-decoration: none;" ><FONT face=\'Times\' size="2" color=\'black\'>'+TXT_Var48584+'</FONT></a></td></tr>');
	document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\'Verdana\');" ><a href="javascript:;" style="text-decoration: none;" ><FONT face=\'Verdana\' size="2" color=\'black\'>'+TXT_Var48585+'</FONT></a></td></tr>');
	document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\'Helvetica\');" ><a href="javascript:;" style="text-decoration: none;" ><FONT face=\'Helvetica\' size="2" color=\'black\'>'+'Helvetica'+'</FONT></a></td></tr>');

	if(fontnames.length>0)
	{
    	while(fontnames.indexOf(",")>=0)
    	{
    		var str=fontnames;
    		var commaindex=fontnames.indexOf(",");
    		var font=fontnames.substring(0,commaindex);
    		fontnames=fontnames.substring(commaindex+1);
    		document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#999999\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\''+font+'\');" ><a href="javascript:;" style="text-decoration: none;" ><span class="editor_arial">'+font+'</span></a></td></tr>');

    	}
    document.write('<tr> <td width="89%" id="arial" align="left" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#999999\' " onMouseOut="this.style.background = \'\'" onMouseDown="setFont(\''+lastfont+'\');" ><a href="javascript:;" style="text-decoration: none;" ><span class="btext">'+lastfont+'</span></a></td></tr>');
	}
	//setFontName(font_name);
}

/* This method is called while clicking the Text style pull dowm to select styles to be applied.
All styles are displayed as a row & The no_of_styles_displayed is the row size of the styles displayed in the table.
*/ 
function displayStyleMenu(evnt)
{
	var no_of_styles_displayed = 4;	//No of styles displayed in a row for the table

	var str_table='<table width="350" border="0" cellspacing="0" cellpadding="0">';
	str_table+='<tr>';
	str_table+='<td bgcolor="#CCCCCC"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
	str_table+='<tr>';
	str_table+='<td align="center" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
	str_table+='<tr>';
     
	var style_index = 0;
	
	var cssval_class = new Array();
	cssval_class[0] = "heading1";
	cssval_class[1] = "heading2";
	cssval_class[2] = "textjustified";
	cssval_class[3] = "pageheader";
	cssval_class[4] = "boldtext";
	cssval_class[5] = "tableheader1";
	cssval_class[6] = "tablecolor";
	cssval_class[7] = "italictext";
	cssval_class[8] = "textbackground";
	cssval_class[9] = "tableheader2";
	cssval_class[10] = "tableheader3";
	cssval_class[11] = "graytext";
	cssval_class[12] = "smalltext";
	cssval_class[13] = "heading3";
	cssval_class[14] = "heading4";
	cssval_class[15] = "graytextbold";
	cssval_class[16] = "redtext";
	cssval_class[17] = "footertext";
	cssval_class[18] = "imagebackground";
	cssval_class[19] = "text";
	cssval_class[20] = "bulletsquare";
	cssval_class[21] = "bulletcircle";
	cssval_class[22] = "bulletnumeric";

	for(var style in cssval)
	{
		var class_name = cssval_class[style_index];
		style_index++;
		if((style_index - 1) % no_of_styles_displayed ==	0)
		{
			str_table+='<tr>';
		}
		
		
		//str_table+='<td align="center"><table   onMouseOver="this.style.background = \'#EFEFEF\' " onMouseOut="" width="100%" border="0" cellspacing="0" cellpadding="0" onmousedown="setLayerStyle(\'\',\'\',\''+cssval[style]+'\')">';
		str_table+='<td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0" onmousedown="setLayerStyle(\'\',\'\',\''+class_name+'\')">';
		str_table+='<tr>';
		str_table+='<td align="center" class="Heading"><table width="50" height="28" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">';
		str_table+='<tr>';
		str_table+='<td align="center" bgcolor="#FFFFFF"><a href="#" class="'+class_name+'">Aa</a></td>';
		str_table+='</tr>';
		str_table+='</table></td>';
		str_table+='</tr>';
		str_table+='<tr>';
		str_table+='<td height="15" align="center" valign="top"><a href="#" class="verbl">'+cssval[style]+'</a></td>';
		str_table+='</tr>';
		str_table+='</table></td>';

		if(style_index % no_of_styles_displayed ==	0)
		{
			str_table+='</tr>';
		}
     }
	  

	str_table+='</tr>';
	str_table+='</table></td>';
	str_table+='</tr>';
	str_table+='</table></td>';
	str_table+='</tr>';		  
		  

	var menu_layer=document.getElementById("style_layer");   
	menu_layer.innerHTML=str_table;
	displayMenu(evnt,"style_layer");
 }
 
 
/* This method is called while clicking the Table operations pull down to do table operations.
*/ 
function displayTableMenu(evnt)
{
	if(isIE)
	{
		layer_sel_obj = editArea.document.selection.createRange();
	}
	var str_table='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	str_table+='<tr>';
	str_table+='<td bgcolor="#CCCCCC"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
	str_table+='<tr>';
	str_table+='<td align="center" bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1">';
//Insert Table which calls insertTableCheck() in the onclick event,
	str_table+='<tr  onmousedown="insertTableCheck();hideStyleMenu();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"><img src="images/itable.gif" width="24" height="24"></td>';*/
	str_table+='<td align="left" class="ntext" >'+TXT_Var48443+'</td>';
	str_table+='</tr>';
	if(isIE)
	{
//Insert Row which calls insertRow() in the onclick event,

	str_table+='<tr onmousedown="insertRow();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td width="15%" align="center"><img src="images/table_irow.gif" width="20" height="19"></td>';*/
	str_table+='<td width="85%" align="left" class="ntext" >'+TXT_Var48444+'</td>';
	str_table+='</tr>';
//Insert Column which calls insertCol() in the onclick event

	str_table+='<tr onmousedown="insertCol();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center" class="BodyText"><img src="images/table_icolumn.gif" width="20" height="19"></td>';*/
	str_table+='<td class="ntext">'+TXT_Var48445+'</td>';
	str_table+='</tr>';
//Delete Row which calls DelRow() in the onclick event,

	str_table+='<tr onmousedown="DelRow();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center" ><img src="images/table_drow.gif" width="20" height="19"></td>';*/
	str_table+='<td class="ntext">'+TXT_Var48446+'</td>';
	str_table+='</tr>';
	
//Delete Column which calls DelCol() in the onclick event,
	str_table+='<tr onmousedown="DelCol();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"><img src="images/table_dcolumn.gif" width="20" height="19"></td>';*/
	str_table+='<td class="ntext">'+TXT_Var48447+'</td>';
	str_table+='</tr>';
//Merge Cells which calls ColMerge() in the onclick event,
	/*str_table+='<tr onmousedown="ColMerge();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	str_table+='<td align="center"  class="wm_link"><img src="images/table_mcell.gif" width="20" height="19"></td>';
	str_table+='<td  class="ntext">'+TXT_Var48448+'</td>';
	str_table+='</tr>';*/
//Split Cell which calls SplitCell() in the onclick event,
	/*str_table+='<tr onmousedown="SplitCell();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	str_table+='<td align="center"  class="wm_link"><img src="images/table_scell.gif" width="20" height="19"></td>';
	str_table+='<td  class="ntext">'+TXT_Var48449+'</td>';
	str_table+='</tr>';*/
	
//Change Column Width which calls cColWidth() in the onclick event,
	str_table+='<tr  onmousedown="cColWidth();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"  class="wm_link"><img src="images/table_rwidth.gif" width="20" height="24"></td>';*/
	str_table+='<td  class="ntext">'+TXT_Var48452+'</td>';
	str_table+='</tr>';
//Change Row Height which calls cRowHeight() in the onclick event,
	str_table+='<tr  onmousedown="cRowHeight();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"  class="wm_link"><img src="images/table_cheight.gif" width="23" height="22"></td>';*/
	str_table+='<td  class="ntext">'+TXT_Var48453+'</td>';
	str_table+='</tr>';
//Change Border Size which calls BorderSize() in the onclick event,
	str_table+='<tr  onmousedown="BorderSize();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"  class="wm_link"><img src="images/table_border.gif" width="23" height="20"></td>';*/
	str_table+='<td  class="ntext">'+TXT_Var48455+'</td>';
	str_table+='</tr>';
//Choose Cell Background Color which calls BGCellColor() in the onclick event 
	str_table+='<tr  onmousedown="BGCellColor();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"  class="wm_link"><img src="images/cellbgcolor.gif" width="24" height="24"></td>';*/
	str_table+='<td  class="ntext">'+TXT_Var48451+'</td>';
	str_table+='</tr>';
// Choose Cell Border Color which calls BorderColor() in the onclick event.
	str_table+='<tr  onmousedown="BorderColor();" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'">';
	/*str_table+='<td align="center"  class="wm_link"><img src="images/cellbordercolor.gif" width="24" height="24"></td>';*/
	str_table+='<td  class="ntext">'+TXT_Var48454+'</td>';
	str_table+='</tr>';

	}
	str_table+='</table></td>';
	str_table+='</tr>';
	str_table+='</table></td>';
	str_table+='</tr>';
	str_table+='</table>';
	var menu_layer=document.getElementById("table_layer");   
	menu_layer.innerHTML=str_table;
	displayMenu(evnt,"table_layer");
				

}

function displayHtmlMenu(evnt)
{
//alert(l_str_helppath);
  displayMenu(evnt,"html_layer");  

}
function displayLayoutMenu(evnt)
{
  displayMenu(evnt,"layout_layer");  
}

function displayFormatMenu(evnt)
{
 // alert(l_str_helppath);
  displayMenu(evnt,"format_layer");  

}

function displayInsertMenu(evnt)
{
  displayMenu(evnt,"insert_layer");  

}

/* This method is called while clicking the Table operations pull down to do table operations.
*/ 
function displaySizeMenu(evnt)
{
	var str_table='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	str_table+='<tr>';
	str_table+='<td bgcolor="#CCCCCC"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
	str_table+='<tr>';
	str_table+='<td align="center" bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1">';
	str_table+='<tr >';
	//<!--Small start-->
	str_table+='<td width="89%" align="left"  onmousedown="setSize(1)" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" ><a href="javascript:;"  class="small_size">'+TXT_Var48623+'</a></td>';
	//<!--Small end-->
	str_table+='</tr>';
	str_table+='<tr>';
	//<!--Normal start-->
	str_table+='<td align="left"  onmousedown="setSize(2)" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" ><a href="javascript:;" class="normal_size" >'+TXT_Var48624+'</a></td>';
	//<!--Normal end-->
	str_table+='</tr>';
	str_table+='<tr>';
	//<!--Large start-->
	str_table+='<td align="left"  onmousedown="setSize(4)" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'"  ><a href="javascript:;" class="large_size" >'+TXT_Var48625+'</a></td>';
	//<!--large end-->
	str_table+='</tr>';
	str_table+='<tr >';
	//<!--Huge start-->
	str_table+='<td align="left"  onmousedown="setSize(6)" onMouseOver="this.style.cursor=\'hand\';this.style.background = \'#CCCCCC\' " onMouseOut="this.style.background = \'\'" ><a href="javascript:;" class="huge_size" onclick="setSize(6)">'+TXT_Var48626+'</a></td>';
	//<!--Italic end-->
	str_table+='</tr>';
	str_table+='</table></td>';
	str_table+='</tr>';
	str_table+='</table></td>';
	str_table+='</tr>';
	str_table+='</table>';
	var menu_layer=document.getElementById("size_layer");   
	menu_layer.innerHTML=str_table;
	displayMenu(evnt,"size_layer");
}

/* This method is called while clicking the various supported Text style attribute displayed in the Text style layer pull down.
This applies the style to the selected text in the editor
*/ 
function setLayerStyle(htmlmode,name,value)
{  
  
	var objEditArea=getEditArea();
	
//IE8 cusor focus retaining in pop up
	setCursorForIe8();
	
	if( cssurl=="" || cssurl==null)
	{
		alert(TXT_Mobi4240);
		document.frmShowEditor.css1.selectedIndex=0;
		//alert("objEditArea.focus 2");
		//objEditArea.focus();
	return;
	}

	if (htmlmode || value=="Choose style")
	{
		document.frmShowEditor.css1.selectedIndex=0;
		//alert("objEditArea.focus 3");
		//objEditArea.focus();
		return;
	}
    
    if(isDWT_DEPEND)
    {
        if(!check_cursorlocation())
        {
            alert(TXT_Var48692);
            setCursorFocus();
        } 
    }
    else
    objEditArea.focus();
    //alert(cssurl);
	//nonIE
	if(isGECKO)
	{

		var sel = objEditArea.getSelection();

		if(sel!="")
		{
			var str=sel;
			var span = objEditArea.document.createElement("span");
			span.setAttribute("class",value);
			sel.getRangeAt(0).surroundContents(span);
		}
	}
	else if(isIE)
	{
// for IE
        if(!(isDWT_DEPEND))
		objEditArea.document.createStyleSheet(cssurl) ;

		if (htmlmode) return;

		if (value != '') 
		{
		//apply class for IE
			doStyle(value);
		}	
	}
	//alert("objEditArea.focus 4");
	objEditArea.focus();
}
// End setStyle code

/*
This method is called while clicking any where in the editor to close the already opened pull  down
layers such as font,size etc,If the pull domn is already displayed.
*/
function hideStyleMenu(evnt)
{ 
	var objEditArea=getEditArea();
	//select_range='';
    
	if(!evnt || evnt==null)
		evnt=window.event;

	if(!evnt || evnt==null) 
	{   
		var oWindow = objEditArea.document.parentWindow;    
        if(oWindow && oWindow.event)
		evnt=oWindow.event;       
	}    
    
	if(isGECKO) //Non-IE
	{
        if(evnt && evnt.target)
		targ=evnt.target;
	}
	else //IE
	{
        if(evnt && evnt.srcElement)
		targ = evnt.srcElement; 
	}
   // alert(targ.tagName);
    if(isDWT_DEPEND && !check_selectObj(targ) && isHeadImage(targ))    
   {
      //alert("test");
     window.top.document.body.style.cursor='hand';
        //targ.onmouseover="this.style.cursor='hand';";
        // alert( targ);
        //this.style.cursor='hand';
   }  
   else
     window.top.document.body.style.cursor='default';

	var SizeMenu=document.getElementById("size_layer");       
	hideLayer(evnt,SizeMenu);
	var styleMenu=document.getElementById("style_layer");       
	hideLayer(evnt,styleMenu);    
	var SizeMenu=document.getElementById("font_layer");       
	hideLayer(evnt,SizeMenu);
	var styleMenu=document.getElementById("table_layer");       
	hideLayer(evnt,styleMenu); 
	var styleMenu=document.getElementById("html_layer");       
	hideLayer(evnt,styleMenu); 
	var layoutMenu=document.getElementById("layout_layer");       
	hideLayer(evnt,layoutMenu); 
	var formatMenu=document.getElementById("format_layer");       
	hideLayer(evnt,formatMenu); 
	var layerMenu=document.getElementById("insert_layer");       
	hideLayer(evnt,layerMenu); 
	return;
}

/*
This method is called by hideStyleMenu to call a method to hide layer only when it is displayed
*/
function hideLayer(evnt,layer)
{
	var targ;     
    //alert(evnt.srcElement);
	if(isIE && evnt && evnt.srcElement)
		targ=evnt.srcElement;
	else if(evnt && evnt.target)
		targ=evnt.target;        

	if(targ && layer && targ!=menu_targ && layer.style.display && layer.style.display=="block")
	{
		hide(layer);
	}
}   

/*
This method is called by hideLayer to  hide layer displayed
*/ 
function hide(layer)
{
	var objEditArea=getEditArea();
	layer.style.display="none";
	objEditArea.parent.document.onclick=null;    
	window.top.document.onclick=null;   
	objEditArea.document.onmouseover=null; 
	opened_menu=null;        
}


function insertHyperLink(arr) // Called from insertGoodies() for Text Link Output goodies.
{
	var new_win = "";			// for href of anchor tag
	var hyper_link = "";			// for href of anchor tag
	var hyper_text = "";				// for display text
	var hyper_name = "";				// for goodie name
	var hyper_id = "0";				// for goodie id
	var objEditArea = getEditArea();
    

   
    if(select_range && select_range!=''  &&  select_range.select)
    {
        select_range.select();    
    }       
// Assign the value to source from vArr's Source;
	if(arr["Source"]!=""){
	hyper_link = arr["Source"];
	}

// Assign the value to seltext from vArr's Message;
	if(arr["Message"]!=""){
	hyper_text =arr["Message"];
	}

// Assign the value to seltext from vArr's Message;
	if(arr["NewWin"]!=""){
	new_win =arr["NewWin"];
	}
	
	
// Assign the value to hyper_id from vArr's id;
	if(arr["Id"]!=""){
	hyper_id=arr["Id"];
	}else{
	hyper_id="0";
	}
	var selNodeName = "";
	if(selected_obj)
	{
		selNodeName = selected_obj.nodeName;
	}
	var img_hyper_text = "";
	if(selNodeName == "IMG")
	{
		var src = "";
		if(selected_obj.src)
		src = selected_obj.src;
		
		var align = "";
		if(selected_obj.align)
		align = selected_obj.align;
		
		var border = "";
		if(selected_obj.border)
		border = selected_obj.border;
		
		var height = "";
		if(selected_obj.height)
		height = selected_obj.height;
		
		var hspace = "";
		if(selected_obj.hspace)
		hspace = selected_obj.hspace;
		
		
		var vspace = "";
		if(selected_obj.vspace)
		vspace = selected_obj.vspace;
		
		
		var width = "";
		if(selected_obj.width)
		width = selected_obj.width;
		
		//alert(selected_obj.style.cssText);
		var img_style = "";
		if(selected_obj && selected_obj.style)
		{
			if(selected_obj.style.cssText)
			{
				img_style = "\""+selected_obj.style.cssText+"\"";
			}
		}
		
		if(src != "")
		img_hyper_text = "<img src="+src;
		
		if(align != "")
		img_hyper_text += " align="+align;
		
		if(border != "")
		img_hyper_text += " border="+border;
		
		if(height != "")
		img_hyper_text += " height="+height;
	
		if(hspace != "")
		img_hyper_text += " hspace="+hspace;
		
		if(vspace != "")
		img_hyper_text += " vspace="+vspace;
		
		if(img_style != "")
		img_hyper_text += " style="+img_style;
		
		if(width != "")
		img_hyper_text += " width="+width+">";
		else
		img_hyper_text += ">";
		
	}
	if(isIE) //If IE
	{
	// Call delete operation to cut the selection if insert Text link goodie is called
		sel = layer_sel_obj;		// create selection object	
        if(select_range && select_range!=''  &&  select_range.select)
        sel = select_range;
              
            
       // alert(sel.innerHTML);
		var selected_link=sel;
		try
		{
			selected_link=sel.parentElement();					// get parant of selection
		}
		catch(e)
		{
		}
		var nodeName = selected_link.nodeName;					// get selected element
		if(nodeName == "A" || nodeName == "a")
		{
		// for Text link goodies Edit mode
			selected_link.href = hyper_link;
			selected_link.id = hyper_id;
			if(new_win == true)
			{
				selected_link.target = "blank";
			}
			else
			{
				selected_link.removeAttribute("target");
			}
			selected_link.innerHTML=hyper_text;
		}
		else
		{
		// for Text link goodies Add mode
	
		if(selNodeName == "IMG")
		{
			var parent_obj=selected_obj.parentNode;
			if(parent_obj && parent_obj.nodeName != "A" && parent_obj.nodeName != "a")
			{
				img_hyper_text = selected_obj.outerHTML;
			}
			else
			{
				parent_obj.href = hyper_link;
				parent_obj.id = hyper_id;
				if(new_win == true)
				{
					parent_obj.target = "blank";
				}
				else
				{
					parent_obj.removeAttribute("target");
				}
				parent_obj.innerHTML=img_hyper_text;
				return;
			}
			
			hyper_text = img_hyper_text;
		}
		hyper_link = hyper_link.replace(/ /g,'%20');
			try
			{
                if(select_range && select_range.htmlText && select_range.htmlText=="<BR>")
                  select_range.moveStart('character');
                else
                  select_range.select();                
				if(new_win == true)
				{
					sel.pasteHTML("<A HREF="+hyper_link+" id="+hyper_id+" target=\"blank\">"+hyper_text+"</A>");
				}
				else
				{
					sel.pasteHTML("<A HREF="+hyper_link+" id="+hyper_id+">"+hyper_text+"</A>");
				}
			}
			catch(e)
			{
				if(new_win == true)
				{
					selected_obj.outerHTML = "<A HREF="+hyper_link+" id="+hyper_id+" target=\"blank\">"+hyper_text+"</A>";
				}
				else
				{
					selected_obj.outerHTML = "<A HREF="+hyper_link+" id="+hyper_id+">"+hyper_text+"</A>";
				}
			}
		}

	}		
	else if(isGECKO) //If non-IE
	{
    
        /* When content is empty in FF  */
		if(objEditArea.document.body.innerHTML == "<br>" || objEditArea.document.body.innerHTML == "")
		{
			objEditArea.document.body.innerHTML = "&nbsp;";
		}		
		var selectedParent = objEditArea.window.getSelection().getRangeAt(0).startContainer.nodeName;
		if(selectedParent == "HTML" || selectedParent == "html")
		{
		//Not focusses in editable area
			objEditArea.document.body.innerHTML = "&nbsp;"+"<A HREF="+hyper_link+" id="+hyper_id+">"+hyper_text+"</A>";
			return false;
		}
    
		var parent_obj = "";
		if(selNodeName == "IMG")
		{
			parent_obj=selected_obj.parentNode;
			if(parent_obj.nodeName != "A" && parent_obj.nodeName != "a")
			{
				oldChild=parent_obj.removeChild(selected_obj);
			}
		}
		sel=objEditArea.getSelection();				// create selection object	
		var range = sel.getRangeAt(0);			
		var selected_link = range.startContainer;
		
		var nodeName = selected_link.nodeName;
		if(nodeName != "A" && nodeName != "a")
		{
			selected_link = selected_link.parentNode;
			nodeName = selected_link.nodeName;
			if(selNodeName != "IMG")
			{
				parent_obj = nodeName;
			}
		}
		
		if(nodeName == "A" || nodeName == "a" || parent_obj.nodeName == "A" || parent_obj.nodeName == "a")
		{
		// for Text link goodies Edit mode
			selected_link.setAttribute("href",hyper_link);
			selected_link.setAttribute("id",hyper_id);
			if(new_win == true)
			{
				selected_link.setAttribute("target","blank");
			}
			else
			{
				selected_link.removeAttribute("target");
			}
			if(parent_obj.nodeName == "A" || parent_obj.nodeName == "a")
			{
				selected_link.innerHTML=img_hyper_text;
			}
			else
			{
				selected_link.innerHTML=hyper_text;
			}

		}
		else
		{
		// for Text link goodies Add mode
			var href = objEditArea.document.createElement("a");
			href.setAttribute("href",hyper_link);
			href.setAttribute("id",hyper_id);
			
			if(new_win == true)
			{
				href.setAttribute("target","blank");
			}
			else
			{
				href.removeAttribute("target");
			}
 
            if(objEditArea.getSelection()=="")
            {                
                href.innerHTML=hyper_text;
				if(selNodeName == "IMG")
				{
					href.innerHTML=img_hyper_text;
				}				
                range.insertNode(href); 
            }
            else
            {
                range.surroundContents(href);
            }

		
		}
        
         if(select_range && select_range!='')
            select_range='';
	}
}

function mousedown(evt)
{
	var e=objEditArea.event;
	var targ=e.srcElement;

    
    //alert(targ.tagName)
	if(targ.tagName=="IMG" && targ.id=="akImgscript")
	{
        //alert(targ.tagName);
		targ.onresizestart=scriptDrag;
		targ.onkeypress=scriptDrag;
	}
	
	//To capture right click and paste
	var oWindow = objEditArea.document.parentWindow; 	
        
    if(oWindow.event.button==1)
    {
         
         if(targ.nodeName=='IMG')
         {
            DisplayEDLayer(targ,e);
            oWindow.event.returnValue = false; 
            oWindow.event.cancelBubble = true;
            return false;
         }   
         else if(targ.parentNode && targ.parentNode.nodeName=='A')
         {
            //alert(targ.parentNode.nodeName);
            DisplayEDLayer(targ.parentNode,e);
             oWindow.event.returnValue = false; 
             oWindow.event.cancelBubble = true;
             return false;
         }
         else if(targ.parentNode && targ.parentNode.parentNode && targ.parentNode.parentNode.nodeName=='A')
         {
            //alert(targ.parentNode.nodeName);
            DisplayEDLayer(targ.parentNode.parentNode,e);
            oWindow.event.returnValue = false; 
            oWindow.event.cancelBubble = true;
            return false;
         }
         else
         hideEDLayer();
         
               
    }
    else if (oWindow.event.button==2)
    {
		//var clipData = oWindow.clipboardData.getData("Text");
		alert(TXT_Mobi4247);
		oWindow.event.returnValue = false; 
		oWindow.event.cancelBubble = true;
		return false;		
    }
	else
	{
		// alert(oWindow.event.keyCode);
	}
}

 function editElement()
 {
    //Set selObject as selected_link.getAttribute() as "_gname"
     var gname=selected_obj.getAttribute("_gname");
	// setting edit mode goodie name & id
	 editGoodieName = gname;
	 editGoodieId = selected_obj.getAttribute("id");

		//If gname present
		if(gname)
          //call method to edit goodies
		  open_goodie();
		//Else If selected_link.nodeName is "A"	
		else if(selected_obj && selected_obj.nodeName=="A")
        //call method to edit link         
           createLink();				
		//Else If selected_link.nodeName is "IMG"	
		else if(selected_obj && selected_obj.nodeName=="IMG")
                insertImage();
                
        hideEDLayer();
    return false;
 }
 
 var selected_obj;
 //Begin DisplayEDLayer
 function DisplayEDLayer(select_obj,evnt)
 {
 
    inter=select_obj;
	var objEditArea=getEditArea();
    
    
    if(isIE)
    {
       range=objEditArea.document.selection.createRange(); 
       select_range=range;
       //alert(objEditArea.document.selection.type);
       if(select_obj.nodeName=="A")
       {        
        try
		{
		range.moveToElementText(select_obj);
        range.select();
		}
		catch(e)
		{
		}
       }

      //alert(select_range);
    }
 
    if(isGECKO)
    {
        var sel=objEditArea.getSelection();
        oRange=sel.getRangeAt(0);
        oRange.selectNodeContents(select_obj);
    }
    //Declare & Initialise a variable x as 0
    var x=0;
	//Declare & Initialise a variable y as 0
	var y=0;
    
     //var frms=document.getElementById("editArea").frames;
    //ObjectNode=document.getElementById("editArea");
    //alert(ObjectNode.offsetParent);

	//ObjectNode assign select_obj
	var ObjectNode=select_obj;
    var ifram=0;
	var body_count = 0;
	//Iterate until ObjectNode is body
	while(ObjectNode!=null)
    {
	if(ObjectNode.nodeName == "BODY" || ObjectNode.nodeName == "body" )
	{
		body_count++;
	}
			//Set x as x+ObjectNode.offsetTop.
            if(!isNaN(ObjectNode.offsetTop))
			y=y+ObjectNode.offsetTop;
            
			//Set y as y+ObjectNode.offsetLeft.
            if(!isNaN(ObjectNode.offsetLeft))
			x=x+ObjectNode.offsetLeft;
            
			//Set ObjectNode as ObjectNode.offsetParent.
                ObjectNode=ObjectNode.offsetParent;


            //if object null assume the it is a document
            if(ObjectNode==null )
            {
                    if(ifram==0)
                    {
                        // get editarea iframe object
                        ObjectNode=document.getElementById("editArea");
                        ifram++;
                    }
                    else if(ifram==1)
                    {
                        // get frame1 iframe object
                        ObjectNode=window.top.document.getElementById("frame1");  
                        ifram++;
                    }    
                    
                    if(ObjectNode!=null)
                        ObjectNode=ObjectNode.offsetParent;
            }  

			if(body_count == 2)
			{
				break;
			}
           
            
	}		//end Iterate until ObjectNode is HTML
	
     var cur_top=0;
     var objHeight=0;
    //add objects position from iframe
    //x=x+select_obj.offsetLeft;
    
    //add object height
    if(!isNaN(parseInt(select_obj.offsetHeight)))
    {
        y=y+select_obj.offsetHeight;
        objHeight=select_obj.offsetHeight;
    }    
    else if(!isNaN(parseInt(select_obj.style.height)))
    {
        y=y+select_obj.style.height;    
        objHeight=select_obj.style.offsetHeight;
    }    
    else if(select_obj.nodeName=="A")    
    {
        var child_node=select_obj.childNodes[select_obj.childNodes.length-1];
        
        if(parseInt(select_obj.style.fontSize))
        {
            y=y+parseInt(select_obj.style.fontSize);
            objHeight=select_obj.style.fontSize;
        }    
        else
        {
                objHeight=select_obj.style.fontSize;
                y=y+13;
        }           
    }
	
    
    
    //  get scrolled distance
    if(navigator.userAgent.indexOf("MSIE")!=-1)
    {
      cur_top=objEditArea.document.documentElement.scrollTop;
      
      if(cur_top==0)
        cur_top=objEditArea.document.body.scrollTop;      
    }  
    else
      cur_top=objEditArea.scrollY;
      
     //add hided object height from parent frame 
     cur_top+=layer_top_displ; 
     
     //x equals x -  (iframe object "edit_area" vertical scrolled distance)
     y-=cur_top; 
    // alert(y+"px,"+x+"px");
	
    var gname=select_obj.getAttribute("_gname");
    var goodie_id=select_obj.getAttribute("id");

    var str_tags='<table width="100%" border="0" cellspacing="0" cellpadding="1"><tr>';
    str_tags+='<td bgcolor="#000000"><TABLE width="160" border="0" cellpadding="1" cellspacing="2" bgcolor="#BBE2FF">';
        
		  //If _gname present
		if(gname)
        {        
         //If _gname present, then it is a Goodie

    		var hideEditLink = false;
    		var editGoodieName = gname.toLowerCase();
    		if( editGoodieName == 'google' || editGoodieName == 'langtrans' || editGoodieName == 'tafriend' || editGoodieName == 'mailinglist')
    		{
    		//for these type of goodies, only remove link is displayed
    		//Since, they dont need a edit mode
    			hideEditLink = true;
    		}
    		//display edit and remove link, in div element 'edit_del_layer'        
    		if(hideEditLink == false)
    		{
    		//Edit and Remove links display
    			str_tags='<table width="100%" border="0" cellspacing="0" cellpadding="1"><tr>';
    			str_tags+='<td bgcolor="#000000"><TABLE width="160" border="0" cellpadding="1" cellspacing="2" bgcolor="#BBE2FF">';
    			str_tags+='<TR>';
    			str_tags+='<TD width="93"><A href="javascript:;" class="verbl" onclick="editElement();">'+'Edit'+'</A></TD>';
    			str_tags+='<TD width="51"><a href="javascript:;" class="verbl" onclick="removeGoodies();">'+'Remove'+'</a></TD>';
    		}
    		else
    		{
    		//Only Remove link display
    			str_tags='<table width="67" border="0" cellspacing="0" cellpadding="1"><tr>';
    			str_tags+='<td bgcolor="#000000"><TABLE width="80" border="0" cellpadding="1" cellspacing="2" bgcolor="#BBE2FF">';
    			str_tags+='<TR>';

    			str_tags+='<TD width="64"><a href="javascript:;" class="verbl" onclick="removeGoodies();">'+'Remove'+'</a></TD>';
    		}
             
    		str_tags+='<TD width="16" valign="top"><a href="javascript:;" onClick="hideEDLayer();">';
    		str_tags+='<img src="images/cross.gif" width="12" height="13" border="0" class="tdbgcolor7"></a></TD></TR>';           
        }    
		//Else If selected_link.nodeName is "A"	
		else if(select_obj.nodeName=="A")
        {
            //url_ref assign selected_obj.href in div element 'edit_del_layer'
            //display Goto link to the url value of url_ref, target in new window, in div element 'edit_del_layer'
            var href_rul=select_obj.href;
            //if((href_rul.indexOf("http:")!=0 && href_rul.indexOf("https:")!=0) || href_rul.indexOf(window.top.document.form1.hid_adv_base_tag_rem.value)!=-1 || href_rul.indexOf(window.top.document.form1.hid_website_address.value)!=-1)
            if((href_rul.indexOf("http:")!=0 && href_rul.indexOf("https:")!=0) )
            {
                //href_rul=href_rul.replace(window.top.document.form1.hid_adv_base_tag_rem.value,"");
                //href_rul=href_rul.replace(window.top.document.form1.hid_website_address.value,"");
                if(href_rul.indexOf("/")!=-1)
                {
                    var href_arr=href_rul.split("/");

                    if(href_arr.length>0)
                    {
                        var href_text=href_arr[href_arr.length-1];                       
                        href_rul=href_text;
                    }
                }        
            }  

			var display_url = href_rul;
			var link_id = select_obj.id;
			
			try
			{
				if(link_id.charAt(0) == 'p')
				{
					var slash_index = href_rul.lastIndexOf("/");
					if(slash_index != -1)
					{
						display_url = href_rul.substring(slash_index+1);						
						href_rul = l_s_prepath+'?hid_page_id='+display_url;
					}
					else
					{
						href_rul = l_s_prepath+'?hid_page_id='+display_url;
					}
				}
				else if(link_id.charAt(0) == 'i')
				{
					display_url = href_rul = href_rul.replace("swiz/editor","websites/"+l_s_subdomain);
				}
				
			}
			catch(e)
			{
			}

			 display_url = display_url.replace(/%20/g,' ');
			 
/*Page Layout Goodie Link handling */
			 var pageLayoutLink = false;
			 if(display_url.indexOf("/swiz/editor/editor.html#") != -1)
			 {
				pageLayoutLink = true;
			 }
			 
			 
			 if(!pageLayoutLink)
			 {
			 str_tags+='<TR>'; 			
			 str_tags+='<TD colspan="2" class="ntext">'+'Go To link :'+'<a href="'+href_rul+'" target="_blank" class="verbl">'+display_url+'</a></TD>';        
             str_tags+='<TD width="16" valign="top"><a href="javascript:;" onClick="hideEDLayer();">';
             str_tags+='<img src="images/cross.gif" width="12" height="13" border="0" class="tdbgcolor7"></a></TD></TR>';
             //display change and remove link
             str_tags+='<TR> <TD width="93" align="center"><A href="javascript:;" onclick="editElement();" class="verbl">'+'Edit'+'</A></TD>';
             str_tags+='<TD width="51"><a href="javascript:;" onclick="unlink();hideEDLayer();" class="verbl">'+'Remove'+'</a></TD>';
             str_tags+='<TD width="16" valign="top">&nbsp;</TR>';       
			 }
			 else
			 {
	             //display change and remove link
	             str_tags+='<TR> <TD width="70" align="center"><A href="javascript:;" onclick="editElement();" class="verbl">'+'Edit'+'</A></TD>';
	             str_tags+='<TD width="51"><a href="javascript:;" onclick="unlink();hideEDLayer();" class="verbl">'+'Remove'+'</a></TD>';
				 str_tags+='<TD width="16" valign="top"><a href="javascript:;" onClick="hideEDLayer();">';
	             str_tags+='<img src="images/cross.gif" width="12" height="13" border="0" class="tdbgcolor7"></a></TD>';
	             str_tags+='</TR>';    
			 }
        }
		//Else If selected_link.nodeName is "IMG"	
		else if(select_obj.nodeName=="IMG")
        {
          //display edit image and remove link in div element 'edit_del_layer'  
          str_tags+='<TR><TD width="93"><A href="javascript:;" onclick="editElement();" class="verbl">'+'Edit'+'</A></TD>';
          str_tags+='<TD width="51"><a href="javascript:;" class="verbl" onClick="deleteElement();">'+'Remove'+'</a></TD>';
          str_tags+='<TD width="16" valign="top"><a href="javascript:;" onClick="hideEDLayer();">';
          str_tags+='<img src="images/cross.gif" width="12" height="13" border="0" class="tdbgcolor7"></a></TD></TR>';
        }  //end if        

        
        str_tags+='</TABLE></td></tr></table>';
   // alert();
    //alert("x "+(x));
  // alert("y "+(y+cur_top));    
    // get layer object
       // alert(cur_top);

   
    //alert(ObjectNode.offsetParent.offsetTop);
    
	y = (y+35);
    
        ObjectNode=window.top.document.getElementById("frame1");
        
       // alert(y);
    //alert(ObjectNode.offsetHeight+" "+(y));
    
    if(ObjectNode && ObjectNode.offsetHeight<(y))
    {
     // alert(objHeight+edit_del.offsetHeight);
      y=y-(objHeight+50);
    } 
    else if(y>585)
        y=y-(objHeight+60);
    
    var edit_del=document.getElementById("edit_del_layer");    
    edit_del.innerHTML=str_tags;        
	//alert("str_tags "+str_tags);
   edit_del.style.top=y+"px";
    //edit_del.style.top="260px";
    

  
	if(x > 850)
	{
		
		//alert("82 x "+x);
		//alert("82 x "+select_obj.offsetWidth);
		x-=(160-select_obj.offsetWidth);
	}
    edit_del.style.left=x+"px";
    //edit_del.style.left="820px";
  
	
	//alert("select_obj.width "+select_obj.width);
	//alert("select_obj.align "+select_obj.align);
    //show layer
    edit_del.style.display="block";
    hideStyleMenu(evnt);
    objEditArea.parent.document.onclick=hideEDLayer;    
    window.top.document.onmousedown=hideEDLayer;    
    selected_obj=select_obj;
    //alert(selected_obj);
 }
 //end DisplayEDLayer
 
 
 function hideEDLayer()
 {
 
  var objEditArea = getEditArea();
  var edit_del=document.getElementById("edit_del_layer");   
  //hide layer
    if(edit_del.style.display && edit_del.style.display=="block")
    {
        edit_del.style.display="none";
        objEditArea.parent.document.onclick=null; 
        if(objEditArea.parent && objEditArea.parent.parent && objEditArea.parent.parent.document && objEditArea.parent.parent.document.onclick)        
        objEditArea.parent.parent.document.onclick=null; 
    }
    
  return;
 }
 
 function editElement()
 {
    //Set selObject as selected_link.getAttribute() as "_gname"
     var gname;
     //alert(selected_obj);
      gname=selected_obj.getAttribute("_gname");
      
	// setting edit mode goodie name & id
	 editGoodieName = gname;
     if(selected_obj)
	 editGoodieId = selected_obj.getAttribute("id");

		//If gname present
		if(gname)
          //call method to edit goodies
		  open_goodie();
		//Else If selected_link.nodeName is "A"	
		else if(selected_obj && selected_obj.nodeName=="A")
        //call method to edit link         
           createLink();				
		//Else If selected_link.nodeName is "IMG"	
		else if(selected_obj && selected_obj.nodeName=="IMG")
                insertImage();
                
        hideEDLayer();
    return false;
 }
 
 var gd_parent;
 
 function deleteElement()
 {
    var objEditArea = getEditArea();
	if(selected_obj)
    {
        //action_history(DELETING); 
        
        //get parent node
        var parent_obj=selected_obj.parentNode;
        
        if(isGECKO)
        {
              try
              {              
                    var sel=objEditArea.getSelection();
                    var oRange=sel.getRangeAt(0);  
                    oRange.detach();
                    sel.selectAllChildren(parent_obj);
                    sel.collapse(parent_obj,1);                
                    globalvariable=parent_obj;    
              }
              catch(e)
              {}
        } 
		else
		{
			//sel.collapse(parent_obj,1);
		}
				
         
        //remove the object from dom
        
       if(parent_obj)
       {       
       oldChild=parent_obj.removeChild(selected_obj);    
       gd_parent=parent_obj;
       
        if(oldChild==selected_obj)
            hideEDLayer();
       }     
        selected_obj="";
    }
    
    return false;
 }
 
 var editGoodieName = '';		// for edit mode goodie name
var editGoodieId = '';			// for edit mode goodie id
function insertgoodie_link(arr) // Called from insertGoodies() for Text Link Output goodies.
{
	var goodie_link ="";			// for href of anchor tag
	var goodie_text="";				// for display text
	var goodie_name="";				// for goodie name
	var goodie_id="0";				// for goodie id
	var style_par ="FONT-SIZE: 11px; font-family: Arial, Helvetica, sans-serif;"+
				"color: #0000FF;text-decoration: underline;";	// for inserted goodie style
      
//add current content to undo history
	//action_history(OTHER);    

      
// Assign the value to source from vArr's Source;
	if(arr["Source"]!=""){
	goodie_link = arr["Source"];
	}

// Assign the value to seltext from vArr's Message;
	if(arr["Message"]!=""){
	goodie_text =arr["Message"];
	}

// Assign the value to goodie_name from vArr's goodie;
	if(arr["Goodie"]!=""){
	goodie_name=arr["Goodie"];
	}
	

// Assign the value to goodie_id from vArr's id;
	if(arr["Id"]!=""){
	goodie_id=arr["Id"];
	}else{
	goodie_id="0";
	}
	var selNodeName = "";
	try
	{
		selNodeName = selected_obj.nodeName;
	}
	catch(e)
	{
		selNodeName = "";
	}
	/*deleteElement();
	var objEditArea = getEditArea();
	objEditArea.focus();
	*/
	
	
	if(goodie_name == "Paypal")
	{
		goodie_name = "PaypalCheckout";
	}
	
	var objEditArea=getEditArea();
	if(isIE) //If IE
	{
	
		try
		{
    		if(selNodeName == "IMG")
    		{
    			var parNodeObj = selected_obj.parentNode;			
    			var r = objEditArea.document.body.createControlRange();
    			
    			r.add(selected_obj);
    			r.select();
    			oldChild=parNodeObj.removeChild(selected_obj);
    		}
		//setTimeout("timer(1500000)",1500000);

		}
		catch(e)
		{
			//alert("Ex "+e);
		}
	// Call delete operation to cut the selection if insert Text link goodie is called
		//cmdExec('delete');
		sel = objEditArea.document.selection.createRange();		// create selection object	
		if(selNodeName != "IMG")
		{
			sel = layer_sel_obj;
		}
		
		//var selected_link=sel.parentElement();					// get parant of selection
		var nodeName = "IMG";
		try
		{
			nodeName = sel.nodeName;					// get selected element
		}
		catch(e)
		{
			nodeName = "IMG";
		}
   
		if(nodeName == "A" || nodeName == "a")
		{
		// for Text link goodies Edit mode
			selected_link.href = goodie_link;
			selected_link.innerHTML=goodie_text;

		}
		else
		{
		// for Text link goodies Add mode

			if(goodie_name == null || goodie_name == '')
			{
				goodie_name = editGoodieName;
				goodie_id = editGoodieId;
			}

			sel.pasteHTML("<A HREF="+goodie_link+" id="+goodie_id+" _gname="+
						goodie_name+" name="+goodie_name+" style='"+style_par+"'>"+goodie_text+"</A>");
			
		}

	}		
	else if(isGECKO) //If non-IE
	{
		deleteElement();
		sel=objEditArea.getSelection();				// create selection object	
		var range = sel.getRangeAt(0);			
		var selected_link = range.startContainer;
		
		var nodeName = selected_link.nodeName;
		if(nodeName != "A" && nodeName != "a")
		{
			selected_link = selected_link.parentNode;
			nodeName = selected_link.nodeName;
		}
		
		if(nodeName == "A" || nodeName == "a")
		{
		// for Text link goodies Edit mode
			selected_link.setAttribute("href",goodie_link);
			selected_link.innerHTML=goodie_text;
		}
		else
		{
		// for Text link goodies Add mode
			var href = objEditArea.document.createElement("a");
			href.setAttribute("href",goodie_link);
			href.setAttribute("id",goodie_id);
			href.setAttribute("_gname",goodie_name);
			href.setAttribute("name",goodie_name);
			href.setAttribute("style",style_par);
			href.innerHTML=goodie_text;
			range.insertNode(href);   
		
		}
	}
}

function changeCellBgcolor(arr)
{
	var spTD = getCurrTDCell();		
	//alert(spTD);
	 if(spTD != null)
	 {		//.tagName
		  			
		var spTR = getCurrTRCell();
		currPos = spTD.cellIndex;
		var spTable = getCurrTableCell();	
		spTable.rows[spTR.rowIndex].cells[currPos].bgColor=arr;
		editArea.focus();	
	}
}

function getCurrTDCell()
{
   //alert(editArea.document.selection.type);
   if (editArea.document.selection.type == "Control") return null;
   var cTD = layer_sel_obj.parentElement();
   while ((cTD.tagName != "TD" && cTD.tagName != "BODY")){
	  cTD = cTD.parentElement;
   }
   if (cTD.tagName == "BODY")
	cTD = null;

   return cTD;
}

function getCurrTableCell()
{
   if (editArea.document.selection.type == "Control") return null;
   var sTable = layer_sel_obj.parentElement();
   while ((sTable.tagName != "TABLE" && sTable.tagName != "BODY")){
	  sTable = sTable.parentElement;
   }
   if (sTable.tagName == "BODY")
	sTable = null;

   return sTable;
}

function getCurrTRCell()
{
   if (editArea.document.selection.type == "Control") return null;
   var cTR = layer_sel_obj.parentElement();
   while ((cTR.tagName != "TR" && cTR.tagName != "BODY")){
	  cTR = cTR.parentElement;
   }
   if (cTR.tagName == "BODY")
	cTR = null;

   return cTR;
} 

function changeCellBordercolor(arr)
{
	setCursorForIe8();

	var spTD = getCurrTDCell();		
    	
	var spTable = getCurrTableCell();
	//alert(spTable);	
	if(spTD != null)
	{		//.tagName
		var spTR = getCurrTRCell();
		currPos = spTD.cellIndex;
		var spTable = getCurrTableCell();	
		spTable.borderColor=arr;	//Border color
		editArea.focus();	
	}	
}

var startdivNode=null;

function check_selectObj(inter)
{
    var startNode;
    var start_ok;
    
    if(!(isDWT_DEPEND))
     return true;
     
            for(var xx=inter;xx != null ;xx=xx.parentNode)
            //start with immediate parent node, loop up till it reaches the HTML tag, to find out whether the selection starts somewhere (deep) within an editable div
            {
              //alert(xx.nodeName+" "+xx.getAttribute("id"));

               if(xx && (xx.nodeName)=="DIV" && xx.getAttribute && xx.getAttribute("id")!=null && (xx.getAttribute("id").indexOf("akcontEd")!=-1)) //check whether start container is  an editable div. 
               {
                  startNode=xx;
                  startdivNode=startNode;
                  
                                   if(isIE && !startdivNode.style.width)
				  startdivNode.style.width=(startdivNode.offsetWidth-4)+"px";
                  
				 // alert(startdivNode.id);
                  start_ok=true; //return true;
                  break;
               }
               else
               {
                  if(xx.nodeName=="HTML")
                   {//check whether container is  HTML tag and hence the selection is not within an editable area

                     start_ok=false;
                     break;
                   }  
               }
                    
               
            }// end for		            
            
       return start_ok;
}

function isEditableDiv(xx)
{

return (xx && (xx.nodeName)=="DIV" && xx.getAttribute && xx.getAttribute("id")!=null && (xx.getAttribute("id").indexOf("akcontEd")!=-1));
}
/*
 For non-IE only.
 Checks whether the start and end positions of the selected text are within the same editable area.
 */
function check_cursorlocation()
{
   var objEditArea=getEditArea();
   //alert("call ");
   if(isGECKO) 
   //if non-IE
	{
      var start_ok=false;// To find start range is in editable
      var startNode=null;      
      
		if(objEditArea.window.getSelection() && objEditArea.window.getSelection().getRangeAt(0).startContainer.parentNode!=null)
      //check whether the sart container has a parent node
		{
         var inter=objEditArea.window.getSelection().getRangeAt(0).startContainer.parentNode;
         if((objEditArea.window.getSelection().getRangeAt(0).startContainer.nodeName=="DIV"))
         //check whether the sart container has a parent node
         {
            var attri=objEditArea.window.getSelection().getRangeAt(0).startContainer.getAttribute("id");
            if(attri && attri!=null && (attri.indexOf("akcontEd")!=-1))
            //check whether start container is  an editable div. 
            {
               // start_ok=true;
               startNode=objEditArea.window.getSelection().getRangeAt(0).startContainer;//store start node
               //startdivNode=startNode;
               start_ok=true; //return true;
            }   
         }
         
         if(!start_ok) //if already start is OK, should not loop through parent nodes
         {
            for(var xx=inter;xx != null ;xx=xx.parentNode)
            //start with immediate parent node, loop up till it reaches the HTML tag, to find out whether the selection starts somewhere (deep) within an editable div
            {
              //alert(xx.nodeName+" "+xx.getAttribute("id"));
               
               if((xx.nodeName)=="DIV" &&  xx.getAttribute("id")!=null && (xx.getAttribute("id").indexOf("akcontEd")!=-1)) //check whether start container is  an editable div. 
               {
                // alert(xx.nodeName+" 3 "+xx.getAttribute("id"));
                  startNode=xx;
                  start_ok=true; //return true;
                  startdivNode=startNode;
                  break;
               }
               else
               {
                  if(xx.nodeName=="HTML")
                   {//check whether container is  HTML tag and hence the selection is not within an editable area
                     start_ok=false;
                     //startdivNode=null;
                     return false;
                   }  
               }
            }// end for
         }//end -  start ok not true check
         
		}//end -  start range parent node check
      
      // if the range starts in editable area, verify whether ends in editable area
      if(start_ok)
      {
            if(objEditArea.window.getSelection().getRangeAt(0).endContainer.parentNode!=null)
      		{
            	  var inter=objEditArea.window.getSelection().getRangeAt(0).endContainer.parentNode;
                  //alert(inter);
                  if((objEditArea.window.getSelection().getRangeAt(0).endContainer.nodeName=="DIV") )  
                  //check whether container is  a div. 
                  {
                     var attri=objEditArea.window.getSelection().getRangeAt(0).endContainer.getAttribute("id");
                     if(attri!=null && (attri.indexOf("akcontEd")!=-1))
                     {
                       // alert("true-1");
                        // check is in same container
                        if(startNode==objEditArea.window.getSelection().getRangeAt(0).endContainer)
                          return true;                       
                     }   
                  }
            		for(var xx=inter;xx != null ;xx=xx.parentNode)
                  //start with immediate parent node, loop up till it reaches the HTML tag, to find out whether the selection ends somewhere (deep) within an editable div
            		{
             		 //alert(xx.nodeName)
                    // alert(xx.nodeName+" 2 "+xx.getAttribute("id"));
               		if((xx.nodeName)=="DIV" && xx.getAttribute("id")!=null &&  (xx.getAttribute("id").indexOf("akcontEd")!=-1))
               		{
                        //alert("true-2");
                        if(startNode==xx) // check is in same container
                        {                                                     
                           return true;
                           break;
                        }   
               		}
               		else
               		{
                        if(xx.nodeName=="HTML")
                        //check whether container is  HTML tag and hence the selection is not within an editable area
                        return false;
               		}
            		}
      		}// end parent node      
      }// end start ok      
	}//end non-IE if
	else //for IE
	{
        if(objEditArea.document.selection.type=="Control")
        //If selection is a control
        {
        return true;
        }

		if(objEditArea.document.selection.type=="None" || objEditArea.document.selection.type=="Text" )
      //If no selection or selection is text
		{

   		var inter=objEditArea.document.selection.createRange();
   		//alert(inter.htmlText);
   		inter=inter.parentElement();
		//alert(inter.text);
   		for(var xx=inter; xx != null ;xx=xx.parentNode)
         //start with immediate parent node, loop up till it reaches the HTML tag, to find out whether the selection is somewhere (deep) within an editable div
   		{
      		//alert(xx.nodeName)
      		if((xx.nodeName=="DIV") && (xx.getAttribute("id")!=null && xx.getAttribute("id").indexOf("akcontEd")!=-1) )
            //check whether container is  a editable div. 
      		{
                startdivNode=xx;
                if(isIE && !startdivNode.style.width)
                startdivNode.style.width=(startdivNode.offsetWidth-4)+"px";
         		return true;
         		break;
      		}
      		else
      		{
         		if(xx.nodeName=="HTML")
         		{
         		return false;
         		}
      		}
   		} // end - for

		}// end - selection text


	}// end-IE
}
// End check_cursorlocation code


function getXHTMLComp(content)
{
	var str="";
	try
	{
		var objEditArea=getEditArea();
		var reg1=/\&nbsp;/g;
		//(document.getElementById("txtSource")).value=objEditArea.document.body.innerHTML;
		//var innerHtml=(document.getElementById("txtSource")).value;
		var innerHtml=content;
		//var nonxhtml=(document.getElementById("txtSource")).value;
		innerHtml=innerHtml.replace(reg1,"");
		var temp_str_amp = /&/gi;  //for replacing &
		var temp_str_amph = "&amp;";  //for replacing &amp
		var temp_str_hypen = /©/gi;  //for replacing &
		innerHtml = innerHtml.replace( temp_str_amp, temp_str_amph); //replacing & with &amp;
		innerHtml = innerHtml.replace( temp_str_hypen, "" );
		//objEditArea.document.body.innerHTML=innerHtml;
		node=objEditArea.document.body;
		var sb = new StringBuffer;
		var childTag = node.childNodes;     // Tags Object
		var l = childTag.length;            // No of tags in the editor
		for (var i = 0; i < l; i++)
		{
			splitTag(childTag[i], sb);
		}
		str=sb.toString();
		//alert(str);
	}
	catch(e)
	{
		str=content;
	}
	return str;
}

function getffVersion()
{
 var str=navigator.userAgent;
 var version=10;
 
 if(str.toLowerCase().indexOf("firefox")!=-1 && str.indexOf("/"))
 {
   var pos=str.lastIndexOf("/")+1;
   version=str.substring(pos,str.indexOf(".",pos));  
 }
 
 try
 {
  version=parseInt(version);
 }
 catch(e) 
 {
  version=10;
 }
 
 return version;
}

function isUserImage(obj)
{
  var ret=false;
  var str_src="";
  var con_main_src="mi";
  var hp_main_src="mi";
  var hp_mt_src="mt";
  var hp_st_src="st";
  var hp_main_id="hp_mi"; 


    var obj_node=obj;
    while(obj_node!=null)
    {
     // alert(obj_node.nodeName);
        if(obj_node.nodeName=="IMG")
        {
            str_src=obj.src;  
            //alert(str_src);
        }
        else if(obj_node.nodeName=="TD"||obj_node.nodeName=="TABLE")
        {
            str_src=obj_node.getAttribute("background");           
        }  
        
        if(str_src && str_src!=null)
        {
            str_src=getImgName(str_src);  
            
            if( str_src.indexOf(con_main_src)==0 || str_src.indexOf(hp_main_src)==0 || str_src.indexOf(hp_main_id)==0|| str_src.indexOf(hp_mt_src)==0|| str_src.indexOf(hp_st_src)==0 )
            {
                ret=true;
                break;
            }
        }
     
     obj_node=obj_node.parentNode;
    
     if(!obj_node || obj_node==null || obj_node.nodeName=="HTML")
     break;
     
    }  
      
  return ret;
}

var l_o_ct_lay;
function isHeadImage(obj)
{
  //alert("test");
  var ret=false;
  var str_src="";
  var title_img="akhead_cont";
  var arrowimg="arrtitle";
  var editimg="imgtitle";
  var divobj="dvtitle";
  var id_obj=obj.id;
  //alert("id_obj>>"+id_obj+(arrowimg==arrowimg));
 
   if(id_obj==title_img||id_obj==arrowimg||id_obj==editimg||id_obj==divobj)
   {
      //alert("open layer and call objEditArea.setHeadImage(src)");
      //alert( window.top.document.getElementById("hid_ct_text_changed").value );
      //alert( window.top.document.getElementById("hid_ct_text").value );

      ret = true;
   }
      
  return ret;
}

function openTitle()
{
      var l_s_ct = window.top.document.getElementById("hid_ct_text").value;
     // alert(l_s_ct);
      var l_o_ct_lay = open_layer('/swiz/content_titles.jsp?h_ct'+l_s_ct,TXT_Var48693,580,120,true,window.top,window.top,scroll,l_str_editor,z_index,'');
      l_o_ct_lay.callOnclose=setCursorFocus;
}

function updateConTit(l_ct_txt, l_img_src)
{
  window.top.document.getElementById("hid_ct_text_changed").value='y';
  window.top.document.getElementById("hid_ct_text").value=l_ct_txt;
  window.top.document.getElementById("hid_ct_src").value=l_img_src;
  if(l_o_ct_lay)
  {
    l_o_ct_lay.close();
    l_o_ct_lay = null;
  }
  
  setHeadImage(l_img_src);

}

function setHeadImage(imgsrc)
{
  var objEditArea=getEditArea();
  obj_img=objEditArea.document.getElementById("akhead_cont");
  
  if(obj_img)
   obj_img.src=imgsrc;
   
 // return ret;
}


function getImgName(str_src)
{
  if( str_src.lastIndexOf("/")!=-1)
  {   
    str_src=str_src.substring(str_src.lastIndexOf("/")+1);  
  }
  return str_src;
}

var ed_length=0;

function getNoOfEditable()
{
 return ed_length;
}

function getBodyTitle()
{
 var objEditArea=getEditArea();
 return objEditArea.document.body.innerHTML;
}

function getEditableObjects()
{
               ed_length=0;
                var objEditArea=getEditArea();      
                var ediv_object=objEditArea.document.getElementsByTagName('div');
                var l_obj_divs=new Array();

                var j=0;
	            if(ediv_object!=null && ediv_object!=undefined && ediv_object.length!=0)
	            {   
                    
	                for(i=0;i<ediv_object.length;i++)
	                {
                      var content_object_id = ediv_object[i].id;

                      if(content_object_id && content_object_id!=null && content_object_id.indexOf("akcontEd") == 0)
                      {  
                        try
                        {
                         var str=ediv_object[i].innerHTML;
                         //str
                         str=removeURLString(str);
                         str=spec_char(str);
                         str=remove_Scriptcmnt(str);
                        // alert(content_object_id+" "+str);
                        l_obj_divs[content_object_id]=str;   
                        //alert(l_obj_divs[content_object_id]);
                        ed_length++;
                        }
                        catch(e)
                        {
                            alert(e.toString());
                        }
                        
                      }  
                    }
                }    
 //alert(l_obj_divs.length+" "+j);
  return l_obj_divs;
}

function setCursorForIe8()
{	
    if(isGECKO)
     return false;
     
	var userAgent = navigator.userAgent;	
	var objEditArea=getEditArea();      
    var ediv_object=objEditArea.document.documentMode;
				//alert(ediv_object);
	var range=objEditArea.document.selection.createRange();
		
	try
	{	
		if(ediv_object)
		{
			setCursorFocus();	
		}
	}
	catch(e)
	{}
}
