Insert Header continued

Dear All,
There are two paragraph styles used in INDD document and if first para of any page is not “Heading” then it should copy content the last “Heading” used in the previous page and add text “cont…” should get inserted as first paragraph with applied style “Heading” on page which is not having.

A small piece of code I am trying. Please let me know if some one can help me.


tell application "Adobe InDesign CS4"
	set myDoc to document 1
	tell myDoc
		set thePageCount to get page count
		display dialog "Tota pages are: " & thePageCount
		repeat with i from 1 to thePageCount by 1
			tell page i
				tell text frame 1
					set firstParaSyle to get the name of applied paragraph style of paragraph 1 of text column 1
					--if firstParaSyle = "P1" then
					display dialog firstParaSyle
					--else
					--	display dialog "P2"
					--end if
				end tell
			end tell
		end repeat
	end tell
end tell

Regards,
Poo