
var _tk_arIFRAMES = document.getElementsByTagName("iframe");
var _tk_RteWindow = null;
var _tk_publishButtons = new Array();

//
for (var c=0; c<_tk_arIFRAMES.length; c++)
{
	if (_tk_arIFRAMES[c].className == "ms-rtelong")
	{
		var oContainer = _tk_arIFRAMES[c].parentNode;
		var oTable = oContainer.parentNode.children[1];

		var oTopRow = oTable.rows[0].cells[0].firstChild.rows[0];
		
		var newCell = oTopRow.insertCell();
		newCell.innerText = "1";
		newCell.style.fontFamily = "webdings";
		newCell.style.cursor = "hand";
		newCell.onclick =  function() { ViewByButton(this); } ;
		
        newCell.id = "viewBtn_" + c  ;
		oContainer.parentNode.id = "id_FloatRTE_" + c.toString();
		_tk_arIFRAMES[c].style.width = "600px";
	}
}

function findParentElement(obj , parentTag)
{
 var temp = obj.parentElement ;
 while( temp.tagName.toUpperCase() != parentTag.toUpperCase() )
 { 
    temp = temp.parentElement ;
    if( temp == null ){
        alert("parent ["+parentTag+"] not exist");
        return null ;
    }
 }
 return temp ;
}
 
 function ViewByButton( obj )
 { 
     var _tk_arIFRAMES = document.getElementsByTagName("iframe");
     
     var arr = obj.id.split("_");
     var index = parseInt(arr[1]); 

    for (var c=0; c<_tk_arIFRAMES.length; c++)
    {
        var iframe1 = _tk_arIFRAMES[c];
	    if (iframe1.className == "ms-rtelong")
	    {	
	        if( c == index )
	        {
	            var id = iframe1.id.replace("_iframe","");
    	        
	            ViewHTML( RTE_GetEditorDocument(id).body.innerHTML );
	            return ;
	        }
	    }    	
    }
  
  }
 
 
function ViewHTML( html )
{ 
    var param = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,copyhistory=yes,width=600px,height=680px,left=100px,top=100px' ;    

    var printWindow=window.open( "/_layouts/sjjw/resources/contentView.html" , "ViewWindow" , param ); //width=10,height=10,left=10000,top=10000
	var doc = 	printWindow.document ;
	 	
    
	var viewContentObj = doc.getElementById("viewContent");
	
	viewContentObj.innerHTML = html ;
	
	return;
	
	 
    printWindow.document.write("<html>");	 
   
    doc.write("<head>");	
    
    document.write("<meta HTTP-EQUIV='Content-Type' content='text/html; charset=utf-8' />");
    
    for ( i = 0; i < window.document.styleSheets.length; i++ )
    {
        if(window.document.styleSheets(i).href!="")
              doc.write ( "<link rel='stylesheet' href='"+ window.document.styleSheets(i).href + "'/>" );
    }    
 
    doc.write("</head>");	
    doc.write("<body>");	 
    
    doc.write( "Ô¤ÀÀ<hr size='1'/>" );       
     
    doc.write( html );      
  
  doc.write( "<br/><br/><input type='button' value='close' onclick='window.close();return false;'/>" );     
    
    doc.write("</body>");	
    
    doc.write("</html>");	 		
    doc.close();  
}