Japan has been subject to sudden invasions of new ideas followed by long periods of minimal contact with the outside world. Over time the Japanese developed the ability to absorb, imitate, and finally assimilate those elements of foreign culture that complemented their aesthetic preferences. The earliest complex art in Japan was produced in the 7th and 8th centuries in connection with Buddhism. In the 9th century, as the Japanese began to turn away from China and develop indigenous forms of expression, the secular arts became increasingly important; until the late 15th century, both religious and secular arts flourished. After the Ōnin War (1467–1477), Japan entered a period of political, social, and economic disruption that lasted for over a century. In the state that emerged under the leadership of the Tokugawa shogunate, organized religion played a much less important role in people's lives, and the arts that survived were primarily secular.